@props([ 'action', 'actionAlignment' => null, 'afterItem' => null, 'blocks', 'columns' => null, 'key', 'noSearchResultsMessage' => null, 'searchable' => false, 'searchDebounce' => 0, 'searchPrompt' => null, 'trigger', 'width' => null, ]) @php use Filament\Support\Enums\Alignment; use Filament\Support\Enums\GridDirection; use Filament\Support\Enums\Width; use Filament\Support\Facades\FilamentAsset; use Filament\Support\View\ComponentAttributeBag as FilamentComponentAttributeBag; use Illuminate\Contracts\Support\Htmlable; use Illuminate\Support\Js; use Illuminate\Support\Str; $placement = match ($actionAlignment) { Alignment::Start, Alignment::Left => 'bottom-start', Alignment::End, Alignment::Right => 'bottom-end', default => null, }; if (is_string($width)) { $width = Width::tryFrom($width) ?? $width; } $widthClass = ($width instanceof Width) ? "fi-width-{$width->value}" : (is_string($width) ? $width : null); $listAttributes = $searchable ? new FilamentComponentAttributeBag([ 'x-load' => true, 'x-load-src' => FilamentAsset::getAlpineComponentSrc('builder', 'filament/forms'), 'x-data' => 'builderBlockPickerFormComponent()', 'x-on:dropdown-escape' => 'handleEscape($event)', 'data-dropdown-escape' => true, ]) : new FilamentComponentAttributeBag; @endphp {{ $trigger }} @if (filled($blocks)) @if ($searchable)
@endif
grid($columns, GridDirection::Column) }} > @foreach ($blocks as $block) @php $blockIcon = $block->getIcon(); $blockLabel = $block->getLabel(); $blockSearchLabel = null; if ($searchable) { $blockSearchLabel = $blockLabel; if ($blockSearchLabel instanceof Htmlable) { $blockSearchLabel = html_entity_decode(strip_tags($blockSearchLabel->toHtml()), ENT_QUOTES | ENT_HTML5, 'UTF-8'); } $blockSearchLabel = Str::lower($blockSearchLabel); } $wireClickActionArguments = ['block' => $block->getName()]; if (filled($afterItem)) { $wireClickActionArguments['afterItem'] = $afterItem; } $wireClickActionArguments = Js::from($wireClickActionArguments); $wireClickAction = "mountAction('{$action->getName()}', {$wireClickActionArguments}, { schemaComponent: '{$key}' })"; @endphp {{ $blockLabel }} @endforeach
@if ($searchable)
{{ $noSearchResultsMessage }}
@endif
@endif