{{-- Select2-Alpine Component ====================== A reusable select component that combines Select2 with Alpine.js for enhanced select functionality. This component mimics Vue's v-select behavior and provides additional features. Props: ------- name: string - Name attribute for the select element id: string - ID attribute for the select element options: array - Array of options in format [{id: value, text: label}] selected: string|array - Currently selected value(s) placeholder: string - Placeholder text multiple: boolean - Enable multiple selection disabled: boolean - Disable the select required: boolean - Make the select required searchable: boolean - Enable search functionality clearable: boolean - Show clear button model: string - Alpine.js model name for two-way binding url: string - API endpoint for AJAX loading minInputLength: number - Minimum characters to trigger search delay: number - Delay in milliseconds for search debouncing Usage Examples: -------------- 1. Basic Usage: 2. With AJAX Loading: 3. Multiple Selection: 4. With Alpine.js Model:
5. With Event Handling: Events: ------- select2-change: Emitted when selection changes - detail.value: Selected value(s) - detail.text: Selected text(s) select2-open: Emitted when dropdown opens select2-close: Emitted when dropdown closes select2-clear: Emitted when selection is cleared Dependencies: ------------ - Select2 4.1.0-rc.0 - Alpine.js - jQuery (required by Select2) Notes: ------ - For AJAX loading, the API should return data in format: { data: [{id: value, text: label}], next_page_url: string|null } - The component automatically handles cleanup on destroy - All Select2 options are supported through the props --}} @props([ 'name' => '', 'id' => '', 'options' => [], 'selected' => '', 'placeholder' => 'Select an option', 'multiple' => false, 'disabled' => false, 'required' => false, 'searchable' => true, 'clearable' => true, 'model' => '', 'url' => '', 'minInputLength' => 0, 'delay' => 250 ])
@push('scripts') @endpush @push('styles') @endpush @push('scripts') @endpush