Skip to content

TOPKNOXBITCH/filament-adjacency-list

 
 

Repository files navigation

Filament Adjacency List

Latest Version on Packagist Total Downloads

A Filament package to manage adjacency lists (aka trees).

Banner

Installation

You can install the package via composer:

composer require saade/filament-adjacency-list

Usage

use Saade\FilamentAdjacencyList\Forms\Components\AdjacencyList;

AdjacencyList::make('subjects')
    ->form([
        Forms\Components\TextInput::make('label')
            ->required(),
    ])

Configuration

Customizing the label and children keys.

AdjacencyList::make('subjects')
    ->labelKey('name')          // defaults to 'label'
    ->childrenKey('subitems')   // defaults to 'children'

Customizing the MaxDepth of the tree.

AdjacencyList::make('subjects')
    ->maxDepth(2)               // defaults to -1 (unlimited depth)

Creating items without a modal.

AdjacencyList::make('subjects')
    ->modal(false)      // defaults to true

Disabling creation, edition, deletion, and reordering.

AdjacencyList::make('subjects')
    ->addable(false)
    ->editable(false)
    ->deletable(false)
    ->reorderable(false)

Customizing actions

use Filament\Forms\Actions\Action;

AdjacencyList::make('subjects')
    ->addAction(fn (Action $action): Action => $action->icon('heroicon-o-plus')->color('primary'))
    ->addChildAction(fn (Action $action): Action => $action->button())
    ->editAction(fn (Action $action): Action => $action->icon('heroicon-o-pencil'))
    ->deleteAction(fn (Action $action): Action => $action->requiresConfirmation())
    ->reorderAction(fn (Action $action): Action => $action->icon('heroicon-o-arrow-path-rounded-square'))

Important

Reorder Action

If you want to add ->extraAttributes() to the action, you need to add the ['data-sortable-handle' => 'true'] attribute to the array.

if you want to trigger a livewire action on click, you need to chain ->livewireClickHandlerEnabled() on the action.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Sponsor Saade

About

A Filament package to manage adjacency lists (aka trees).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 75.4%
  • Blade 17.0%
  • JavaScript 7.5%
  • CSS 0.1%