{{-- Label + input + bantuan/galat. Type "password" otomatis mendapat tombol tampil/sembunyikan (hanya jika JS aktif). Atribut lain (required, autofocus, autocomplete, inputmode, maxlength...) diteruskan ke . --}} @props([ 'name', 'label', 'type' => 'text', 'value' => null, 'hint' => null, 'error' => null, 'optional' => false, 'id' => null, 'prefix' => null, 'suffix' => null, ]) @php $id ??= 'field-'.\Illuminate\Support\Str::slug($name); $isPassword = $type === 'password'; $message = $error ?? (isset($errors) ? $errors->first($name) : null); $current = $isPassword ? null : old($name, $value); $helpId = $id.'-help'; // Lebar prefiks/sufiks diperkirakan dengan satuan ch agar teks input tidak menimpa satuan $pads = collect(['--pad-start' => $prefix, '--pad-end' => $suffix]) ->filter(fn ($text) => filled($text)) ->map(fn ($text, $var) => $var.': calc('.mb_strlen($text).'ch + 1.75rem)') ->implode('; '); @endphp
@if (filled($prefix)) {{ $prefix }} @endif get('required')) aria-required="true" @endif aria-describedby="{{ $helpId }}" @if ($pads) style="{{ $pads }}" @endif @if ($isPassword) x-bind:type="show ? 'text' : 'password'" @endif {{ $attributes->class(['field__input', 'field__input--password' => $isPassword]) }} > @if (filled($suffix)) {{ $suffix }} @endif @if ($isPassword) @endif

$message]) aria-live="polite" @if ($message) role="alert" @endif> @if ($message) {{ $message }} @elseif ($hint) {{ $hint }} @endif