11<div x-data =" {
22 fp: null,
3- @if ($value && ! $attributes -> hasStartsWith (' wire:model' ) )
4- value: '{{ $value } } ',
5- @elseif ($attributes -> hasStartsWith (' wire:model' ) )
3+ @if ($hasWireModel () )
64 value: @entangle ($attributes -> wire (' model' ) ),
5+ @elseif ($hasXModel () )
6+ value: {{ $attributes -> first (' x-model' ) } } ,
77 @else
8- value: null,
8+ value: {{ $value ? " '{ $value }' " : ' null' } } ,
99 @endif
10+ updateValue(newValue) {
11+ this.value = newValue;
12+ $dispatch('input', newValue);
13+
14+ try {
15+ this.fp.setDate(newValue);
16+ } catch {}
17+
18+ @if ($hasXModel () )
19+ {{ $attributes -> first (' x-model' ) } } = newValue;
20+ @endif
21+ },
1022 }"
1123 x-init =" fp = flatpickr($refs.input, {
1224 defaultDate: value,
1325 onOpen: [
1426 function (selectedDates, dateStr, instance) {
1527 instance.setDate(value);
1628 },
29+ {{ $onOpen ?? ' ' } }
1730 ],
1831 {{ $jsonOptions () } }
1932 {{ $optionsSlot ?? ' ' } }
2033 })"
21- x-on:change =" value = $event.target.value; fp.setDate( value)"
34+ x-on:change =" updateValue( $event.target.value)"
2235 class =" {{ $getContainerClass () } }"
2336 {{ $extraAttributes } }
2437>
@@ -43,10 +56,14 @@ class="leading-addon cursor-pointer inline-flex items-center px-3 rounded-l-md b
4356 @if ($name ) name =" {{ $name } }" @endif
4457 @if ($id ) id =" {{ $id } }" @endif
4558 x-ref =" input"
46- x-bind:value =" value"
59+
60+ @unless ($hasXModel () )
61+ x-bind:value =" value"
62+ @endunless
63+
4764 placeholder =" {{ $placeholder } }"
4865
49- @if ($value && ! $attributes -> hasStartsWith ( ' wire:model ' ) ) value =" {{ $value } }" @endif
66+ @if ($value && ! $hasBoundModel ( ) ) value =" {{ $value } }" @endif
5067
5168 {!! $ariaDescribedBy () ! !}
5269 @if ($hasErrorsAndShow ($name ) )
@@ -59,7 +76,7 @@ class="leading-addon cursor-pointer inline-flex items-center px-3 rounded-l-md b
5976 <button x-show =" Boolean(value)"
6077 x-transition
6178 x-cloak
62- x-on:click =" value = null; fp.setDate(value )"
79+ x-on:click =" updateValue(null )"
6380 class =" form-input-clear h-6 w-6 group rounded-full p-1 hover:bg-blue-gray-200 focus:outline-blue-gray transition-colors"
6481 type =" button"
6582 >
0 commit comments