@props([ 'name', 'id' => null, 'value' => '', 'placeholder' => '— Select —', 'options' => [], 'required' => false, 'submitOnChange' => false, 'nullable' => true, ]) @php $id = $id ?: $name; $normalized = collect($options)->map(function ($option, $key) { if (is_array($option)) { return [ 'value' => (string) ($option['value'] ?? ''), 'label' => (string) ($option['label'] ?? $option['value'] ?? ''), ]; } return [ 'value' => (string) $key, 'label' => (string) $option, ]; })->values()->all(); @endphp
class('relative') }} x-data="themeSelect({ value: @js((string) $value), options: @js($normalized), placeholder: @js($placeholder), submitOnChange: @js((bool) $submitOnChange), nullable: @js((bool) $nullable), })" @keydown.escape.window="open = false" @click.outside="open = false" >