@props([
'id' => null,
'htmlId' => null,
'label' => null,
'helper' => null,
'required' => false,
'options' => [], // list of ['value' => ..., 'label' => ..., 'disabled' => bool]
'placeholder' => 'Select…',
'emptyText' => 'No options available.',
'live' => false,
'onChange' => null, // optional $wire method to call after a selection
'onChangeArgs' => null, // optional arguments followed by the selected value
'wire' => true, // false = purely client-side value (no Livewire binding)
'value' => null, // initial value when wire=false
'disabled' => false,
'tooltip' => true,
'portal' => false,
'preserveValue' => false,
'canGate' => null,
'canResource' => null,
'autoDisable' => true,
])
@php
if ($canGate && $canResource && $autoDisable && ! Illuminate\Support\Facades\Gate::allows($canGate, $canResource)) {
$disabled = true;
}
$triggerId = ($htmlId ?? $id).'-trigger';
$panelId = ($htmlId ?? $id).'-panel';
@endphp
@if ($label)
{{--
Keep helper outside the label so taps do not open the listbox trigger.
Margin lives only on this wrapper (mb-0 on the label) so spacing matches
plain text labels and is not doubled by .application-settings-form label rules.
--}}
{{-- Fixed h-4 matches the helper icon so side-by-side fields align with or without a helper. --}}
{{-- Non-selectable group header (options with header: true). Each header is the
only child of its x-for wrapper, so `first:` can't target it — the divider
is an unconditional top border, which reads as a separator between groups. --}}
@else
{{ $emptyText }}
{{-- Non-selectable group header (options with header: true). --}}