@props([
'active' => false,
'collapsible' => true,
'icon' => null,
'items' => [],
'label' => null,
'sidebarCollapsible' => true,
'subNavigation' => false,
])
@php
$sidebarCollapsible = $sidebarCollapsible && filament()->isSidebarCollapsibleOnDesktop();
$hasDropdown = filled($label) && filled($icon) && $sidebarCollapsible;
// A slug alone is not unique: non-Latin labels slug to an empty string and distinct labels can
// share a slug, producing duplicate ids that break each disclosure button's `aria-controls`.
// A short hash of the raw label keeps the id unique per label and stable across renders.
$groupLabel = $subNavigation ? "sub_navigation_{$label}" : (string) $label;
$groupItemsId = 'fi-sidebar-group-items-' . \Illuminate\Support\Str::slug($groupLabel) . '-' . substr(md5($groupLabel), 0, 8);
@endphp
class([
'fi-sidebar-group',
'fi-active' => $active,
'fi-collapsible' => $collapsible,
])
}}
>
@if ($label)
@endif
@if ($hasDropdown)
@php
$lists = [];
foreach ($items as $item) {
if ($childItems = $item->getChildItems()) {
$lists[] = [
$item,
...$childItems,
];
$lists[] = [];
continue;
}
if (empty($lists)) {
$lists[] = [$item];
continue;
}
$lists[count($lists) - 1][] = $item;
}
if (empty($lists[count($lists) - 1])) {
array_pop($lists);
}
@endphp
@if (filled($label))
{{ $label }}
@endif
@foreach ($lists as $list)
@foreach ($list as $item)
@php
$itemIsActive = $item->isActive();
$itemBadge = $item->getBadge();
$itemBadgeColor = $item->getBadgeColor($itemBadge);
$itemBadgeTooltip = $item->getBadgeTooltip($itemBadge);
$itemUrl = $item->getUrl();
$itemIcon = $itemIsActive ? ($item->getActiveIcon() ?? $item->getIcon()) : $item->getIcon();
$shouldItemOpenUrlInNewTab = $item->shouldOpenUrlInNewTab();
$itemExtraAttributes = $item->getExtraAttributeBag();
@endphp
{{ $item->getLabel() }}
@endforeach
@endforeach
@endif