-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
builder.blade.php
229 lines (205 loc) · 11.5 KB
/
builder.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<x-dynamic-component
:component="$getFieldWrapperView()"
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
>
@php
$containers = $getChildComponentContainers();
$isCollapsible = $isCollapsible();
$isItemCreationDisabled = $isItemCreationDisabled();
$isItemDeletionDisabled = $isItemDeletionDisabled();
$isItemMovementDisabled = $isItemMovementDisabled();
@endphp
@if ((count($containers) > 1) && $isCollapsible)
<div class="space-x-2 rtl:space-x-reverse" x-data="{}">
<x-forms::link
x-on:click="$dispatch('builder-collapse', '{{ $getStatePath() }}')"
tag="button"
size="sm"
>
{{ __('forms::components.builder.buttons.collapse_all.label') }}
</x-forms::link>
<x-forms::link
x-on:click="$dispatch('builder-expand', '{{ $getStatePath() }}')"
tag="button"
size="sm"
>
{{ __('forms::components.builder.buttons.expand_all.label') }}
</x-forms::link>
</div>
@endif
<div {{ $attributes->merge($getExtraAttributes())->class([
'space-y-6 rounded-xl filament-forms-builder-component',
'bg-gray-50 p-6' => $isInset(),
'dark:bg-gray-500/10' => $isInset() && config('forms.dark_mode'),
]) }}>
@if (count($containers))
<ul
class="space-y-12"
wire:sortable
wire:end.stop="dispatchFormEvent('builder::moveItems', '{{ $getStatePath() }}', $event.target.sortable.toArray())"
>
@php
$hasBlockLabels = $hasBlockLabels();
$hasBlockNumbers = $hasBlockNumbers();
@endphp
@foreach ($containers as $uuid => $item)
<li
x-data="{
isCreateButtonVisible: false,
isCollapsed: @js($isCollapsed()),
}"
x-on:builder-collapse.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = true)"
x-on:builder-expand.window="$event.detail === '{{ $getStatePath() }}' && (isCollapsed = false)"
x-on:click="isCreateButtonVisible = true"
x-on:mouseenter="isCreateButtonVisible = true"
x-on:click.away="isCreateButtonVisible = false"
x-on:mouseleave="isCreateButtonVisible = false"
wire:key="{{ $this->id }}.{{ $item->getStatePath() }}.item"
wire:sortable.item="{{ $uuid }}"
@class([
'bg-white border border-gray-300 shadow-sm rounded-xl relative',
'dark:bg-gray-800 dark:border-gray-600' => config('forms.dark_mode'),
])
>
@if ((! $isItemMovementDisabled) || $hasBlockLabels || (! $isItemDeletionDisabled) || $isCollapsible)
<header @class([
'flex items-center h-10 overflow-hidden border-b bg-gray-50 rounded-t-xl',
'dark:bg-gray-800 dark:border-gray-700' => config('forms.dark_mode'),
])>
@unless ($isItemMovementDisabled)
<button
wire:sortable.handle
wire:keydown.prevent.arrow-up="dispatchFormEvent('builder::moveItemUp', '{{ $getStatePath() }}', '{{ $uuid }}')"
wire:keydown.prevent.arrow-down="dispatchFormEvent('builder::moveItemDown', '{{ $getStatePath() }}', '{{ $uuid }}')"
type="button"
@class([
'flex items-center justify-center flex-none w-10 h-10 text-gray-400 border-r rtl:border-l rtl:border-r-0 transition hover:text-gray-300',
'dark:text-gray-400 dark:border-gray-700 dark:hover:text-gray-500' => config('forms.dark_mode'),
])
>
<span class="sr-only">
{{ __('forms::components.builder.buttons.move_item_down.label') }}
</span>
<x-heroicon-s-switch-vertical class="w-4 h-4"/>
</button>
@endunless
@if ($hasBlockLabels)
<p @class([
'flex-none px-4 text-xs font-medium text-gray-600 truncate',
'dark:text-gray-400' => config('forms.dark_mode'),
])>
@php
$block = $item->getParentComponent();
$block->labelState($item->getRawState());
@endphp
{{ $item->getParentComponent()->getLabel() }}
@php
$block->labelState(null);
@endphp
@if ($hasBlockNumbers)
<small class="font-mono">{{ $loop->iteration }}</small>
@endif
</p>
@endif
<div class="flex-1"></div>
<ul @class([
'flex divide-x rtl:divide-x-reverse',
'dark:divide-gray-700' => config('forms.dark_mode'),
])>
@unless ($isItemDeletionDisabled)
<li>
<button
wire:click="dispatchFormEvent('builder::deleteItem', '{{ $getStatePath() }}', '{{ $uuid }}')"
type="button"
@class([
'flex items-center justify-center flex-none w-10 h-10 text-danger-600 transition hover:text-danger-500',
'dark:text-danger-500 dark:hover:text-danger-400' => config('forms.dark_mode'),
])
>
<span class="sr-only">
{{ __('forms::components.builder.buttons.delete_item.label') }}
</span>
<x-heroicon-s-trash class="w-4 h-4"/>
</button>
</li>
@endunless
@if ($isCollapsible)
<li>
<button
x-on:click="isCollapsed = !isCollapsed"
type="button"
@class([
'flex items-center justify-center flex-none w-10 h-10 text-gray-400 transition hover:text-gray-300',
'dark:text-gray-400 dark:hover:text-gray-500' => config('forms.dark_mode'),
])
>
<x-heroicon-s-minus-sm class="w-4 h-4" x-show="! isCollapsed"/>
<span class="sr-only" x-show="! isCollapsed">
{{ __('forms::components.builder.buttons.collapse_item.label') }}
</span>
<x-heroicon-s-plus-sm class="w-4 h-4" x-show="isCollapsed" x-cloak/>
<span class="sr-only" x-show="isCollapsed" x-cloak>
{{ __('forms::components.builder.buttons.expand_item.label') }}
</span>
</button>
</li>
@endif
</ul>
</header>
@endif
<div class="p-6" x-show="! isCollapsed">
{{ $item }}
</div>
<div class="p-2 text-xs text-center text-gray-400" x-show="isCollapsed" x-cloak>
{{ __('forms::components.builder.collapsed') }}
</div>
@if ((! $loop->last) && (! $isItemCreationDisabled) && (! $isItemMovementDisabled))
<div
x-show="isCreateButtonVisible"
x-transition
class="absolute inset-x-0 bottom-0 z-10 flex items-center justify-center h-12 -mb-12"
>
<x-forms::dropdown>
<x-slot name="trigger">
<x-forms::icon-button
:label="$getCreateItemBetweenButtonLabel()"
icon="heroicon-o-plus"
/>
</x-slot>
<x-forms::builder.block-picker
:blocks="$getBlocks()"
:create-after-item="$uuid"
:state-path="$getStatePath()"
class="py-2"
/>
</x-forms::dropdown>
</div>
@endif
</li>
@endforeach
</ul>
@endif
@if (! $isItemCreationDisabled)
<div x-data class="relative flex justify-center">
<x-forms::button
size="sm"
x-on:click="$refs.panel.toggle"
type="button"
>
{{ $getCreateItemButtonLabel() }}
</x-forms::button>
<x-forms::builder.block-picker
:blocks="$getBlocks()"
:state-path="$getStatePath()"
/>
</div>
@endif
</div>
</x-dynamic-component>