Files
filament/packages/forms/resources/views/components/text-input.blade.php
T
2021-11-17 19:53:29 +00:00

77 lines
3.3 KiB
PHP

@php
$datalistOptions = $getDatalistOptions();
$sideLabelClasses = [
'whitespace-nowrap transition group-focus-within:text-primary-500',
'text-gray-400' => ! $errors->has($getStatePath()),
'text-danger-400' => $errors->has($getStatePath()),
];
@endphp
<x-forms::field-wrapper
:id="$getId()"
:label="$getLabel()"
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:required="$isRequired()"
:state-path="$getStatePath()"
>
<div class="flex items-center space-x-1 group">
@if ($label = $getPrefixLabel())
<span @class($sideLabelClasses)>
{{ $label }}
</span>
@endif
<div class="flex-1">
<input
@unless ($hasMask())
{{ $applyStateBindingModifiers('wire:model') }}="{{ $getStatePath() }}"
type="{{ $getType() }}"
@else
x-data="textInputFormComponent({
{{ $hasMask() ? "getMaskOptionsUsing: (IMask) => ({$getJsonMaskConfiguration()})," : null }}
state: $wire.{{ $applyStateBindingModifiers('entangle(\'' . $getStatePath() . '\')') }},
})"
type="text"
wire:ignore
@endunless
{!! ($autocapitalize = $getAutocapitalize()) ? "autocapitalize=\"{$autocapitalize}\"" : null !!}
{!! ($autocomplete = $getAutocomplete()) ? "autocomplete=\"{$autocomplete}\"" : null !!}
{!! $isAutofocused() ? 'autofocus' : null !!}
{!! $isDisabled() ? 'disabled' : null !!}
id="{{ $getId() }}"
{!! ($inputMode = $getInputMode()) ? "inputmode=\"{$inputMode}\"" : null !!}
{!! $datalistOptions ? "list=\"{$getId()}-list\"" : null !!}
{!! ($length = $getMaxLength()) ? "maxlength=\"{$length}\"" : null !!}
{!! ($value = $getMaxValue()) ? "max=\"{$value}\"" : null !!}
{!! ($length = $getMinLength()) ? "minlength=\"{$length}\"" : null !!}
{!! ($value = $getMinValue()) ? "min=\"{$value}\"" : null !!}
{!! ($placeholder = $getPlaceholder()) ? "placeholder=\"{$placeholder}\"" : null !!}
{!! ($interval = $getStep()) ? "step=\"{$interval}\"" : null !!}
{!! $isRequired() ? 'required' : null !!}
{{ $attributes->merge($getExtraAttributes())->class([
'block w-full h-10 transition duration-75 rounded-lg shadow-sm focus:border-primary-600 focus:ring-1 focus:ring-inset focus:ring-primary-600',
'border-gray-300' => ! $errors->has($getStatePath()),
'border-danger-600 ring-danger-600' => $errors->has($getStatePath()),
]) }}
/>
</div>
@if ($label = $getPostfixLabel())
<span @class($sideLabelClasses)>
{{ $label }}
</span>
@endif
</div>
@if ($datalistOptions)
<datalist id="{{ $getId() }}-list">
@foreach ($datalistOptions as $option)
<option value="{{ $option }}" />
@endforeach
</datalist>
@endif
</x-forms::field-wrapper>