Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 0c1604d

Browse files
committed
Add hasStartsWith macro to ComponentAttributeBag
1 parent a5120ca commit 0c1604d

File tree

11 files changed

+27
-18
lines changed

11 files changed

+27
-18
lines changed

resources/views/components/choice/checkbox-or-radio.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@if ($id) id="{{ $id }}" @endif
66
type="{{ $type }}"
77
@if ($value) value="{{ $value }}" @endif
8-
@if ($checked && ! $attributes->whereStartsWith('wire:model')->first()) checked @endif
8+
@if ($checked && ! $attributes->hasStartsWith('wire:model')) checked @endif
99
{{ $extraAttributes }}
1010
/>
1111
</div>

resources/views/components/choice/switch-toggle.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div x-data="{
22
onValue: {{ json_encode($onValue) }},
33
offValue: {{ json_encode($offValue) }},
4-
@if ($attributes->whereStartsWith('wire:model')->first())
4+
@if ($attributes->hasStartsWith('wire:model'))
55
value: @entangle($attributes->wire('model')),
66
@else
77
value: {{ json_encode($value) }},
@@ -33,7 +33,7 @@ class="flex-grow switch-toggle-label form-label block text-sm font-medium leadin
3333
type="button"
3434
@if ($id) id="{{ $id }}" @endif
3535
@if ($label) aria-labelledby="{{ $labelId() }}" @endif
36-
{{ $attributes->except(['type', 'wire:model', 'wire:model.defer'])->merge(['class' => $buttonClass()]) }}
36+
{{ $attributes->except(['type', 'wire:model', 'wire:model.defer', 'wire:model.lazy'])->merge(['class' => $buttonClass()]) }}
3737
x-bind:class="{ 'pressed': isPressed }"
3838
@if ($disabled) disabled @endif
3939
>

resources/views/components/files/file-pond.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
$nextTick(function () {
5353
pond = FilePond.create($refs.input, {
5454
{{ $jsonOptions() }}
55-
@if ($attributes->whereStartsWith('wire:model')->first())
55+
@if ($attributes->hasStartsWith('wire:model'))
5656
server: {
5757
process: (fieldName, file, metadata, load, error, progress, abort, transfer, options) => {
5858
@this.upload('{{ $attributes->wire('model')->value() }}', file, load, error, progress);

resources/views/components/inputs/custom-select.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<div x-data="customSelect({
22
{{ $configToJson() }}
3-
@if ($hasWireModel = $attributes->whereStartsWith('wire:model')->first())
3+
@if ($attributes->hasStartsWith('wire:model'))
44
value: @entangle($attributes->wire('model')),
55
@else
66
value: {{ $selectedKeyToJS() }},
77
@endif
8-
@if ($hasWireFilter = $attributes->whereStartsWith('wire:filter')->first())
8+
@if ($attributes->hasStartsWith('wire:filter'))
99
wireFilter: '{{ $attributes->wire('filter')->value() }}',
1010
@endif
1111
})"
12-
x-init="init({{ $hasWireModel ? '$wire' : 'null' }}, $dispatch)"
12+
x-init="init({{ $attributes->hasStartsWith('wire:model') ? '$wire' : 'null' }}, $dispatch)"
1313
x-on:click.outside="close()"
1414
x-on:keydown.escape="close()"
1515
x-on:keydown.enter.stop.prevent="onEnter()"
@@ -31,7 +31,7 @@ class="custom-select__menu-container absolute w-full rounded-md bg-white shadow-
3131
<div class="custom-select__filter relative py-2 px-2 border-b border-blue-gray-200">
3232
<input x-ref="search"
3333
x-show="open"
34-
@if ($hasWireFilter)
34+
@if ($attributes->hasStartsWith('wire:filter'))
3535
wire:loading.class="busy"
3636
wire:target="{{ $attributes->wire('filter')->value() }}"
3737
@endif
@@ -41,7 +41,7 @@ class="custom-select__menu-container absolute w-full rounded-md bg-white shadow-
4141
class="custom-select__filter-input py-1 h-full w-full border-blue-gray-300 rounded-md bg-white focus:border-blue-gray-400 focus:ring-0 text-sm focus:outline-none"
4242
/>
4343

44-
@if ($hasWireFilter)
44+
@if ($attributes->hasStartsWith('wire:filter'))
4545
<span wire:loading.class.remove="hidden"
4646
class="absolute top-4 -mt-0.5 right-4 animate-spin hidden"
4747
>
@@ -77,7 +77,7 @@ class="custom-select__menu py-1 overflow-auto text-base leading-6 rounded-md sha
7777
@include('form-components::partials.leading-addons')
7878
@include('form-components::partials.custom-select-button')
7979

80-
@unless ($hasWireModel)
80+
@unless ($attributes->hasStartsWith('wire:model'))
8181
<input type="hidden" x-bind:value="JSON.stringify(value)" name="{{ $name }}">
8282
@endif
8383
</div>

resources/views/components/inputs/date-picker.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div x-data="{
22
fp: null,
3-
@if ($value && ! $attributes->whereStartsWith('wire:model')->first())
3+
@if ($value && ! $attributes->hasStartsWith('wire:model'))
44
value: '{{ $value }}',
5-
@elseif ($attributes->whereStartsWith('wire:model')->first())
5+
@elseif ($attributes->hasStartsWith('wire:model'))
66
value: @entangle($attributes->wire('model')),
77
@else
88
value: null,
@@ -46,7 +46,7 @@ class="leading-addon cursor-pointer inline-flex items-center px-3 rounded-l-md b
4646
x-bind:value="value"
4747
placeholder="{{ $placeholder }}"
4848

49-
@if ($value && ! $attributes->whereStartsWith('wire:model')->first()) value="{{ $value }}" @endif
49+
@if ($value && ! $attributes->hasStartsWith('wire:model')) value="{{ $value }}" @endif
5050

5151
@if ($hasErrorsAndShow($name))
5252
aria-invalid="true"

resources/views/components/inputs/input.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@if ($id) id="{{ $id }}" @endif
1010
type="{{ $type }}"
1111

12-
@if (! is_null($value) && ! $attributes->whereStartsWith('wire:model')->first()) value="{{ $value }}" @endif
12+
@if (! is_null($value) && ! $attributes->hasStartsWith('wire:model')) value="{{ $value }}" @endif
1313

1414
@if ($hasErrorsAndShow($name))
1515
aria-invalid="true"

resources/views/components/inputs/password.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class="{{ $containerClass() }}"
1818
type="password"
1919
@endif
2020

21-
@if ($value && ! $attributes->whereStartsWith('wire:model')->first()) value="{{ $value }}" @endif
21+
@if ($value && ! $attributes->hasStartsWith('wire:model')) value="{{ $value }}" @endif
2222

2323
@if ($hasErrorsAndShow($name))
2424
aria-invalid="true"

resources/views/components/inputs/textarea.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@endif
1414

1515
{!! $attributes->merge(['class' => $inputClass(), 'rows' => 3]) !!}
16-
>@if (! is_null($value) && ! $attributes->whereStartsWith('wire:model')->first()){!! $value !!}@elseif ($slot->isNotEmpty()){!! $slot !!}@endif</textarea>
16+
>@if (! is_null($value) && ! $attributes->hasStartsWith('wire:model')){!! $value !!}@elseif ($slot->isNotEmpty()){!! $slot !!}@endif</textarea>
1717

1818
@include('form-components::partials.trailing-addons')
1919
</div>

src/Components/Files/FilePond.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ public function jsonOptions(): string
7373
public function shouldWatch($attributes): bool
7474
{
7575
return $this->watchValue
76-
&& (bool) $attributes->whereStartsWith('wire:model')->first();
76+
&& $attributes->hasStartsWith('wire:model');
7777
}
7878
}

src/Components/Files/FileUpload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function canShowUploadProgress($attributes): bool
4747
return $this->canShowUploadProgress = false;
4848
}
4949

50-
if (! $attributes->whereStartsWith('wire:model')->first()) {
50+
if (! $attributes->hasStartsWith('wire:model')) {
5151
return $this->canShowUploadProgress = false;
5252
}
5353

0 commit comments

Comments
 (0)