@php $container_base_class = 'lqd-input-container relative'; $input_base_class = 'lqd-input block peer w-full px-4 py-2 border border-input-border bg-input-background text-input-foreground text-base ring-offset-0 transition-colors focus:border-secondary focus:outline-0 focus:ring focus:ring-secondary dark:focus:ring-foreground/10 sm:text-2xs'; $input_checkbox_base_class = 'lqd-input peer rounded border-input-border focus:ring focus:ring-secondary dark:focus:ring-foreground/10'; $input_checkbox_custom_wrapper_base_class = 'lqd-input-checkbox-custom-wrap inline-flex items-center justify-center size-[18px] shrink-0 rounded-full bg-foreground/10 text-heading-foreground bg-center bg-no-repeat peer-checked:bg-primary/[7%] peer-checked:text-primary'; $label_base_class = 'lqd-input-label flex cursor-pointer items-center gap-2 text-2xs font-medium leading-none text-label'; $label_extra_base_class = 'ms-auto'; $variations = [ 'size' => [ 'none' => 'lqd-input-size-none rounded-lg', 'sm' => 'lqd-input-sm h-9 rounded-md', 'md' => 'lqd-input-md h-10 rounded-lg', 'lg' => 'lqd-input-lg h-11 rounded-xl', 'xl' => 'lqd-input-xl h-14 rounded-2xl px-6', '2xl' => 'lqd-input-2xl h-16 rounded-full px-8', ], ]; if ($type === 'textarea') { $size = 'none'; } $size = isset($variations['size'][$size]) ? $variations['size'][$size] : $variations['size']['md']; if ($switcher) { $input_checkbox_base_class .= ' lqd-input-switcher w-12 h-6 border-2 border-input-border rounded-full cursor-pointer appearance-none [background-size:1.3rem] bg-left bg-no-repeat transition-all checked:bg-right checked:bg-heading-foreground checked:border-heading-foreground dark:checked:bg-label dark:checked:border-label'; } elseif ($custom) { $input_checkbox_base_class = 'lqd-input peer rounded size-0 invisible absolute top-0 start-0'; } if ($type !== 'checkbox' && $type !== 'radio') { $label_base_class .= ' mb-3'; } if (!empty($label) && empty($id)) { $id = str()->random(10); } if ($stepper) { $input_base_class .= ' lqd-input-stepper appearance-none text-center px-2'; } @endphp
withoutTwMergeClasses()->twMergeFor('container', $attributes->get('class:container'), $container_base_class, $containerClass) }} @if ($type === 'password') x-data='{ type: "{{ $type }}", get inputValueVisible() { return this.type !== "password" }, toggleType() { this.type = this.type === "text" ? "password" : "text"; } }' @endif @if ($stepper) x-data='{ value: {{ !empty($value) ? $value : 0 }}, min: {{ $attributes->has('min') ? $attributes->get('min') : 0 }}, max: {{ $attributes->has('max') ? $attributes->get('max') : 999999 }}, step: {{ $attributes->has('step') ? $attributes->get('step') : 1 }}, setValue(value) { this.value = value; this.$refs.input.setAttribute("value", this.value); } }' @endif @if ($type === 'select' && $addNew) x-data="{ 'newOptions': [] }" @endif > {{-- Label --}} @if (!empty($label) || ($type === 'checkbox' || $type === 'radio')) @endif {{-- Wrapper if there is icon over the input --}} @if ($type === 'password' || !empty($icon) || !empty($action) || $stepper)
@endif {{-- Inputs other than checkbox, radio and select --}} @if ($type !== 'checkbox' && $type !== 'radio' && $type !== 'select' && $type !== 'textarea' && $type !== 'color') withoutTwMergeClasses()->twMerge($input_base_class, $size, $attributes->get('class')) }} name="{{ $name }}" value="{{ $value }}" @if ($type === 'password') :type="type" @endif type={{ $type }} placeholder="{{ $placeholder }}" {{ $attributes }} @if ($stepper) :value="(value).toString().includes('.') ? parseFloat(value).toFixed(2) : value" x-ref="input" @endif /> {{ $slot }} @endif {{-- Select input --}} @if ($type === 'select') @if ($attributes->has('multiple')) {{ __('Hold cmd(on mac) or ctrl(on pc) to select multiple items.') }} @endif @if ($addNew) {{ __('Add New') }}
{{ __('Cancel') }} {{ __('Add') }}
@endif @endif {{-- Textarea input --}} @if ($type === 'textarea') @endif {{-- Color input --}} @if ($type === 'color')
withoutTwMergeClasses()->twMerge($input_base_class, 'flex items-center gap-3', $size, $attributes->get('class')) }} x-data="{ 'colorVal': '{{ $value }}' }" >
@endif {{-- Password visibility toggle button --}} @if ($type === 'password') @endif {{-- Icon --}} @if (!empty($icon)) {!! $icon !!} @endif {{-- Action --}} @if (!empty($action))
{{ $action }}
@endif {{-- Stepper --}} @if ($stepper) @endif {{-- Wrapper if there is icon over the input --}} @if ($type === 'password' || !empty($icon) || !empty($action) || $stepper)
@endif