@props([
'type' => 'text',
'name',
'id' => null,
'label' => null,
'value' => null,
'placeholder' => null,
'required' => false,
'disabled' => false,
'errorMassage' => null,
'icon' => null, // icon classes, e.g. "fa-solid fa-envelope"; if null = no icon
'showPasswordToggle' => false, // show password toggle button on the right
'maxlength' => 255,
])
@php
$id = $id ?? $name;
$isRequired = filter_var($required, FILTER_VALIDATE_BOOLEAN) || $attributes->has('required');
@endphp
@if ($label)
{{ $label }}
@endif
@php
$hasIcon = !empty($icon);
$hasToggle = $type === 'password' || $showPasswordToggle;
$needsWrapper = $hasIcon || $hasToggle;
$inputClasses = 'med-input border border-gray-300 rounded-md px-3 py-2 w-full focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500';
if ($hasIcon) {
$inputClasses .= ' med-input-icon';
}
if ($type === 'password' || $hasToggle) {
$inputClasses .= ' med-input-password';
}
if ($type === 'tel') {
$inputClasses .= ' tel-number';
}
@endphp
@if ($needsWrapper)
@if ($hasIcon)
@endif
class($inputClasses) }} @if ($disabled) disabled @endif maxlength="{{ $maxlength }}" />
@if ($hasToggle)
@endif
@else
class($inputClasses) }} @if ($disabled) disabled @endif maxlength="{{ $maxlength }}" />
@endif