{{-- 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
$message]) aria-live="polite" @if ($message) role="alert" @endif>
@if ($message)