lasthourcloud/resources/views/components/inputs/input.blade.php

41 lines
1.4 KiB
PHP
Raw Normal View History

2023-05-03 12:09:10 +00:00
@props([
2023-05-05 08:13:43 +00:00
'id' => $attributes->has('id') || $attributes->has('label'),
2023-05-04 08:00:08 +00:00
'type' => 'text',
2023-05-05 07:28:00 +00:00
'required' => $attributes->has('required'),
2023-05-05 08:13:43 +00:00
'label' => $attributes->has('label'),
'instantSave' => $attributes->has('instantSave'),
'noLabel' => $attributes->has('noLabel'),
'noDirty' => $attributes->has('noDirty'),
2023-05-03 12:09:10 +00:00
])
2023-05-04 08:00:08 +00:00
<span @class([
'flex justify-end' => $type === 'checkbox',
'flex flex-col' => $type !== 'checkbox',
])>
2023-05-05 07:28:00 +00:00
@if (!$noLabel)
2023-05-05 12:20:10 +00:00
<label for={{ $id }} @if (!$noDirty) wire:dirty.class="text-amber-300" @endif
wire:target={{ $id }}>
2023-05-05 07:28:00 +00:00
@if ($label)
{{ $label }}
@else
{{ $id }}
@endif
@if ($required)
*
@endif
</label>
@endif
@if ($type === 'textarea')
2023-05-05 07:28:00 +00:00
<textarea @if (!$noDirty) wire:dirty.class="text-black bg-amber-300" @endif {{ $attributes }}
required={{ $required }} type={{ $type }} id={{ $id }} wire:model.defer={{ $id }}></textarea>
@else
2023-05-05 08:13:43 +00:00
<input {{ $attributes }} @if ($required) required @endif
2023-05-05 12:20:10 +00:00
@if (!$noDirty) wire:dirty.class="text-black bg-amber-300" @endif
type={{ $type }} id={{ $id }}
2023-05-04 13:45:53 +00:00
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif />
@endif
2023-04-25 12:43:35 +00:00
@error($id)
<div class="text-red-500">{{ $message }}</div>
@enderror
2023-05-04 08:00:08 +00:00
</span>