@props([ 'id', 'name', 'options' => [], 'selected' => null, 'placeholder' => 'Selecione…', 'allLabel' => 'Todos', 'width' => 'w-56', ]) @php // options: [['value' => 1, 'label' => 'Nome', 'sub' => 'linha secundária'], ...] $options = array_values(array_map(fn($o) => (array) $o, (array) $options)); $selected = $selected === null || $selected === '' ? null : (string) $selected; $current = null; foreach ($options as $option) { if ((string) $option['value'] === $selected) { $current = $option; break; } } @endphp