diff --git a/resources/views/components/input.blade.php b/resources/views/components/input.blade.php index 6f22390..dbd82fa 100644 --- a/resources/views/components/input.blade.php +++ b/resources/views/components/input.blade.php @@ -16,10 +16,10 @@ @endif
- required) required @endif @if($field->disabled) disabled @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 ]) }} /> @error($field->key) @@ -43,3 +43,8 @@ @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; + } }