diff --git a/resources/views/components/input.blade.php b/resources/views/components/input.blade.php index 440c912..ad1e622 100644 --- a/resources/views/components/input.blade.php +++ b/resources/views/components/input.blade.php @@ -19,6 +19,7 @@ @unless($field->disabled) required) required @endif + @if($field->maskOptions) x-ref="imaskref" x-init="$nextTick(() => IMask($refs.imaskref, {{$field->maskOptions}} ))" @endif {{ $attributes->except([...array_keys($attr), 'x-data', 'required', 'disabled'])->merge($attr)->merge(['class' => $errors->has($field->key) ? $field->errorClass : $field->class ]) }} /> @else @@ -45,3 +46,9 @@ @endif +@if($field->maskOptions) + @tfonce('scripts:imask') + + @endtfonce +@endif + diff --git a/src/Components/Input.php b/src/Components/Input.php index c7c7238..0c416bb 100644 --- a/src/Components/Input.php +++ b/src/Components/Input.php @@ -53,6 +53,7 @@ protected function defaults(): array 'min' => 0, 'max' => null, 'disabled' => false, + 'maskOptions' => '' ]; } diff --git a/src/Input.php b/src/Input.php index fb2e95b..1ebf4bd 100644 --- a/src/Input.php +++ b/src/Input.php @@ -25,6 +25,7 @@ class Input extends BaseField public $sfxTallIcon; public $sfxHtmlIcon; public bool $sfxHasIcon = false; + public string $maskOptions = ''; protected function overrides(): self { @@ -143,5 +144,14 @@ public function suffixHtmlIcon(string $html): self $this->sfxHasIcon = true; return $this; } + /** + * @param string $mask_options + * @return $this + */ + public function maskOptions(string $mask_options): self + { + $this->maskOptions = $mask_options; + return $this; + } }