{{-- M3's search: a search bar that opens into a search view with the results. Bind the input like any other (`wire:model.live.debounce.300ms="query"`) and render the results in the slot, from a Livewire property or computed property that follows the query; `empty` is shown instead when the slot renders nothing (say, "No shares match"). Results are usually ``s with a `link`, or buttons: choosing one closes the view. Docked under the bar from `medium` over a scrim, full screen below it with a back arrow (resources/css/components/search.css); `docked` keeps it docked at every width. The bar is never wider than M3's 720px and grows to that width while it is focused: set `--search-width` on a wrapper for a narrower resting bar (M3's own is 360px). `placeholder` ("Search"), `label` (the input's name when it differs from the placeholder), leading `icon` (`search`), and a `trailing` slot for an avatar or icon buttons in the bar. Every other attribute reaches the ``. `trigger="icon"` is M3's second entry point, the search icon button: search as a secondary action in a toolbar or an app bar, a single 48px button that expands into the full-screen view and hands focus to the field (so `docked` has nothing to say about it). The bar itself is the view's header there, and closing gives the button its focus back. `suggestions` is a slot shown in the view until the first keystroke — M3's suggestions behaviour: recent searches, popular queries. The results slot takes over once something is typed, and whichever of the two is on screen is what the live region counts. The bar is a combobox: the wrapper around the input carries `role="combobox"` with `aria-expanded` and `aria-controls`, because ARIA gives a bare textbox neither. The results are a list, and a polite live region says how many of them there are whenever they change — M3 asks for both (docs/reference/m3/components-navigation-selection-inputs.md § Search). The root renders `data-md-search` with `data-md-trigger`, and `data-md-open` and `data-md-full-screen` while they hold; the parts are `data-md-search-*`, drawn by resources/css/components/search.css. `class`, `style` and `wire:key` land on the root. --}} @props([ 'placeholder' => null, 'label' => null, 'icon' => 'search', 'docked' => false, 'trigger' => 'bar', ]) @php $model = $attributes->wire('model')->value() ?: null; $placeholder ??= __('Search'); $id = $attributes->get('id') ?? 'material-search-'.substr(md5($model.'|'.$placeholder), 0, 10); $trigger = $trigger === 'icon' ? 'icon' : 'bar'; $announce = [ 'none' => __('No results'), 'one' => __('1 result'), 'many' => __(':count results'), 'suggestionOne' => __('1 suggestion'), 'suggestionMany' => __(':count suggestions'), ]; @endphp
only(['class', 'style', 'wire:key']) }} > @if ($trigger === 'icon') @endif
@isset($trailing) {{ $trailing }} @endisset
@isset($suggestions)
{{ $suggestions }}
@endisset @if ($slot->hasActualContent())
{{ $slot }}
@elseif (isset($empty))

{{ $empty }}

@endif