feat(panels): add configurable Livewire sidebar component

Introduce support for configuring the sidebar Livewire component via `sidebarLivewireComponent` method. Updated Blade template and queue registration to use the specified component dynamically.
This commit is contained in:
Jefferson Gonçalves
2025-08-03 15:03:12 -03:00
parent f34840c1da
commit 65169194cf
4 changed files with 29 additions and 3 deletions
@@ -47,7 +47,7 @@
class="fi-sidebar-close-overlay"
></div>
@livewire(\Filament\Livewire\Sidebar::class)
@livewire(filament()->getSidebarLivewireComponent())
@endif
<div
+5
View File
@@ -488,6 +488,11 @@ class FilamentManager
return $this->getCurrentOrDefaultPanel()->getProfilePage();
}
public function getSidebarLivewireComponent(): string
{
return $this->getCurrentOrDefaultPanel()->getSidebarLivewireComponent();
}
public function getTenantProfilePage(): ?string
{
return $this->getCurrentOrDefaultPanel()->getTenantProfilePage();
@@ -7,7 +7,6 @@ use Filament\Auth\Pages\EditProfile;
use Filament\Clusters\Cluster;
use Filament\Livewire\GlobalSearch;
use Filament\Livewire\Notifications;
use Filament\Livewire\Sidebar;
use Filament\Livewire\SimpleUserMenu;
use Filament\Livewire\Topbar;
use Filament\Pages\Page;
@@ -491,7 +490,7 @@ trait HasComponents
$this->queueLivewireComponentForRegistration(EditProfile::class);
$this->queueLivewireComponentForRegistration(GlobalSearch::class);
$this->queueLivewireComponentForRegistration(Notifications::class);
$this->queueLivewireComponentForRegistration(Sidebar::class);
$this->queueLivewireComponentForRegistration($this->getSidebarLivewireComponent());
$this->queueLivewireComponentForRegistration(SimpleUserMenu::class);
$this->queueLivewireComponentForRegistration(Topbar::class);
@@ -3,6 +3,8 @@
namespace Filament\Panel\Concerns;
use Closure;
use Filament\Livewire\Sidebar;
use Livewire\Component;
trait HasSidebar
{
@@ -16,6 +18,8 @@ trait HasSidebar
protected bool | Closure $hasCollapsibleNavigationGroups = true;
protected string | Closure | null $sidebarLivewireComponent = null;
public function sidebarCollapsibleOnDesktop(bool | Closure $condition = true): static
{
$this->isSidebarCollapsibleOnDesktop = $condition;
@@ -37,6 +41,16 @@ trait HasSidebar
return $this;
}
/**
* @param class-string<Component> | Closure | null $component
*/
public function sidebarLivewireComponent(string | Closure | null $component): static
{
$this->sidebarLivewireComponent = $component;
return $this;
}
public function sidebarWidth(string $width): static
{
$this->sidebarWidth = $width;
@@ -75,4 +89,12 @@ trait HasSidebar
{
return (bool) $this->evaluate($this->hasCollapsibleNavigationGroups);
}
/**
* @return class-string<Component>
*/
public function getSidebarLivewireComponent(): string
{
return $this->evaluate($this->sidebarLivewireComponent) ?? Sidebar::class;
}
}