Skip to content

Commit 74b55a3

Browse files
authored
feat: add input debounce property (#538)
1 parent 4ddb7e6 commit 74b55a3

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

resources/views/inputs/checkbox.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'alpine' => false,
1313
'right' => false,
1414
'deferred' => false,
15+
'debounce' => null,
1516
])
1617

1718
@php
@@ -42,6 +43,10 @@
4243
class="focus-visible:ring-2 form-checkbox input-checkbox focus-visible:ring-theme-primary-500"
4344
@if ($deferred)
4445
wire:model.defer="{{ $model ?? $name }}"
46+
@elseif ($debounce === true)
47+
wire:model.debounce="{{ $model ?? $name }}"
48+
@elseif (is_string($debounce))
49+
wire:model.debounce.{{ $debounce }}="{{ $model ?? $name }}"
4550
@else
4651
wire:model="{{ $model ?? $name }}"
4752
@endif

resources/views/inputs/includes/input-field.blade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@
1010
'model' => null,
1111
'attributes' => $attributes,
1212
'deferred' => false,
13+
'debounce' => null,
1314
])
1415

1516
<input
1617
class="{{ $inputClass }} {{ $inputTypeClass }} @if ($errors) @error($name) {{ $errorClass }} @enderror @endif"
1718
@unless ($noModel)
1819
@if ($deferred)
1920
wire:model.defer="{{ $model ?? $name }}"
21+
@elseif ($debounce === true)
22+
wire:model.debounce="{{ $model ?? $name }}"
23+
@elseif (is_string($debounce))
24+
wire:model.debounce.{{ $debounce }}="{{ $model ?? $name }}"
2025
@else
2126
wire:model="{{ $model ?? $name }}"
2227
@endif
@@ -29,6 +34,8 @@ class="{{ $inputClass }} {{ $inputTypeClass }} @if ($errors) @error($name) {{ $e
2934
'model',
3035
'slot',
3136
'wire:model',
37+
'deferred',
38+
'debounce',
3239
])->merge([
3340
'type' => $type,
3441
'id' => $id ?? $name,

resources/views/inputs/input-with-icon.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'noModel' => $noModel ?? false,
2525
'model' => $model ?? $name,
2626
'deferred' => $deferred ?? false,
27+
'debounce' => $debounce ?? null,
2728
])
2829
</div>
2930

resources/views/inputs/input-with-prefix.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'noModel' => $noModel ?? false,
4343
'model' => $model ?? $name,
4444
'deferred' => $deferred ?? false,
45+
'debounce' => $debounce ?? null,
4546
'attributes' => $attributes->merge(['x-on:change' => 'isDirty = !! $event.target.value']),
4647
])
4748

resources/views/inputs/input-with-suffix.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'noModel' => $noModel ?? false,
3232
'model' => $model ?? $name,
3333
'deferred' => $deferred ?? false,
34+
'debounce' => $debounce ?? null,
3435
'attributes' => $attributes->merge(['x-on:change' => 'isDirty = !! $event.target.value']),
3536
])
3637

resources/views/inputs/input.blade.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
<div class="input-wrapper">
1818
@include('ark::inputs.includes.input-field', [
19-
'name' => $name,
20-
'errors' => $errors,
21-
'id' => $id ?? $name,
22-
'inputClass' => $inputClass ?? '',
23-
'noModel' => $noModel ?? false,
24-
'model' => $model ?? $name,
25-
'deferred' => $deferred ?? false,
19+
'name' => $name,
20+
'errors' => $errors,
21+
'id' => $id ?? $name,
22+
'inputClass' => $inputClass ?? '',
23+
'noModel' => $noModel ?? false,
24+
'model' => $model ?? $name,
25+
'deferred' => $deferred ?? false,
26+
'debounce' => $debounce ?? null,
2627
])
2728

2829
@error($name)

0 commit comments

Comments
 (0)