class Nav extends BeartropyComponent

Nav component.

Renders a navigation menu, supporting nested items, permissions, and active state detection.

Traits

Trait HasPresets.

Trait HasErrorBag.

Properties

string|null $size

Component size (md, lg, etc.) used for preset resolution.

from  BeartropyComponent
array $items

Navigation items.

string $sidebarBind

Sidebar collapse binding.

string $highlightMode

'standard' or 'text'.

string|null $highlightParentClass

Custom highlight class for parents.

string|null $highlightChildClass

Custom highlight class for children.

string|null $itemClass

Base item class.

string|null $childItemClass

Base child item class.

string $categoryClass

Category header class.

string $iconClass

Icon class.

string $childBorderClass

Child border class.

string|null $hoverTextClass

Hover text class.

string|null $hoverTextChildClass

Child hover text class.

bool $withnavigate

Enable Wire:navigate.

Methods

array{0: array, 1: array, 2: bool, 3: array}
getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

compute component presets based on context.

array
loadPresets(string $componentName)

No description

array
loadComponentDefaults(string $componentName)

No description

bool
detectHasVariants(array $colors)

No description

array
computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

array
resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

array
resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

array
resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

array
resolveFill(array $supports, array $attributes, array $defaults)

No description

string
buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

void
syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

array
buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

void
debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

array{__bt_wireModel: string|null, __bt_finalError: string|null, __bt_hasError: bool}
getErrorState(string|null $error = null, ComponentAttributeBag|null $attributes = null, MessageBag|null $errors = null)

Retrieve the error state for a given attribute or context.

__construct(mixed $items = null, string $sidebarBind = 'sidebarCollapsed', string $highlightMode = 'standard', string|null $highlightParentClass = null, string|null $highlightChildClass = null, string|null $itemClass = null, string|null $childItemClass = null, string $categoryClass = 'text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase px-3 mb-1 tracking-wide select-none', string $iconClass = '', string $childBorderClass = 'border-l border-gray-300 dark:border-gray-700', string|null $hoverTextClass = null, string|null $hoverTextChildClass = null, string $color = 'beartropy', bool $withnavigate = false)

Create a new Nav component instance.

array{0: bool, 1: string|null, 2: bool, 3: string|null}
getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

array<string,mixed>
getComponentSizePreset(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Get the size preset configuration.

array<string,mixed>
getSizePreset(string|null $componentName = null, ComponentAttributeBag|array|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

array<string,mixed>
getColorPreset(string $component, string|null $color = null, string|null $variant = null)

Resolve the color preset configuration.

array
resolveItems(mixed $items)

Decide de dónde sacar el array de navegación

array
loadConfigNav(string $nav = 'default')

Carga el archivo de navegación: config/beartropy/ui/navs/

bool
isItemActive(array $item)

Determine if a navigation item is active based on current request.

string
renderIcon(string $icon, string $iconClass = '')

Render an icon for a navigation item.

array
filterNavCategories(array $categories, mixed $user = null)

Filter navigation categories and their items based on permissions.

array
filterNavItems(array $items, mixed $user = null)

Filter a list of navigation items based on user permissions.

string
navId(array $item)

Generate a unique ID for a navigation item.

View|Closure|string
render()

Get the view / contents that represent the component.

Details

in HasPresets at line 22
array{0: array, 1: array, 2: bool, 3: array} getComponentPresets(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

compute component presets based on context.

Parameters

string|null $componentName

Component key.

ComponentAttributeBag|null $attributes

Attributes bag.

Return Value

array{0: array, 1: array, 2: bool, 3: array}

[colorPreset, sizePreset, shouldFill, presetNames]

in HasPresets at line 64
protected array loadPresets(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 75
protected array loadComponentDefaults(string $componentName)

No description

Parameters

string $componentName

Return Value

array

in HasPresets at line 88
protected bool detectHasVariants(array $colors)

No description

Parameters

array $colors

Return Value

bool

in HasPresets at line 100
protected array computeSupports(array $sizes, array $colorsArray, array $defaults, array $magicProps)

No description

Parameters

array $sizes
array $colorsArray
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 118
protected array resolveSize(array $supports, array $sizes, array $defaults, array $magicProps)

No description

Parameters

array $supports
array $sizes
array $defaults
array $magicProps

Return Value

array

in HasPresets at line 149
protected array resolveVariant(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
bool $hasVariants

Return Value

array

in HasPresets at line 193
protected array resolveColor(array $supports, array $colorsArray, array $componentPresets, array $defaults, array $magicProps, string|null $variant, bool $hasVariants)

No description

Parameters

array $supports
array $colorsArray
array $componentPresets
array $defaults
array $magicProps
string|null $variant
bool $hasVariants

Return Value

array

in HasPresets at line 258
protected array resolveFill(array $supports, array $attributes, array $defaults)

No description

Parameters

array $supports
array $attributes
array $defaults

Return Value

array

in HasPresets at line 303
protected string buildCacheKey(string $component, array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill)

No description

Parameters

string $component
array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill

Return Value

string

in HasPresets at line 313
protected void syncInstanceProps(array $supports, string|null $size, string|null $variant, string|null $color)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color

Return Value

void

in HasPresets at line 326
protected array buildPresetNames(array $supports, string|null $size, string|null $variant, string|null $color, bool $shouldFill, string $sizeOrigin, string $variantOrigin, string $colorOrigin, string $fillOrigin)

No description

Parameters

array $supports
string|null $size
string|null $variant
string|null $color
bool $shouldFill
string $sizeOrigin
string $variantOrigin
string $colorOrigin
string $fillOrigin

Return Value

array

in HasPresets at line 344
protected void debugWarnings(array $supports, array $sizePreset, array $colorPreset, string $componentName, string|null $variant, string|null $color)

No description

Parameters

array $supports
array $sizePreset
array $colorPreset
string $componentName
string|null $variant
string|null $color

Return Value

void

in HasErrorBag at line 21
array{__bt_wireModel: string|null, __bt_finalError: string|null, __bt_hasError: bool} getErrorState(string|null $error = null, ComponentAttributeBag|null $attributes = null, MessageBag|null $errors = null)

Retrieve the error state for a given attribute or context.

Parameters

string|null $error

Direct error message.

ComponentAttributeBag|null $attributes

Component attributes.

MessageBag|null $errors

Global errors.

Return Value

array{__bt_wireModel: string|null, __bt_finalError: string|null, __bt_hasError: bool}

at line 76
__construct(mixed $items = null, string $sidebarBind = 'sidebarCollapsed', string $highlightMode = 'standard', string|null $highlightParentClass = null, string|null $highlightChildClass = null, string|null $itemClass = null, string|null $childItemClass = null, string $categoryClass = 'text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase px-3 mb-1 tracking-wide select-none', string $iconClass = '', string $childBorderClass = 'border-l border-gray-300 dark:border-gray-700', string|null $hoverTextClass = null, string|null $hoverTextChildClass = null, string $color = 'beartropy', bool $withnavigate = false)

Create a new Nav component instance.

Parameters

mixed $items

Array of items, or string config name.

string $sidebarBind

Sidebar bind variable.

string $highlightMode

Highlight mode.

string|null $highlightParentClass

Custom highlight parent.

string|null $highlightChildClass

Custom highlight child.

string|null $itemClass

Item class.

string|null $childItemClass

Child item class.

string $categoryClass

Category class.

string $iconClass

Icon class.

string $childBorderClass

Child border class.

string|null $hoverTextClass

Hover text class.

string|null $hoverTextChildClass

Child hover text class.

string $color

Color preset.

bool $withnavigate

Enable wire:navigate.

Blade Props

Slots

in BeartropyComponent at line 65
array{0: bool, 1: string|null, 2: bool, 3: string|null} getWireModelState(ComponentAttributeBag|null $attributes = null)

Analyze wire:model attributes to determine binding state.

Detects if wire:model is present and if it uses dot notation (e.g., user.name).

Parameters

ComponentAttributeBag|null $attributes

Component attributes.

Return Value

array{0: bool, 1: string|null, 2: bool, 3: string|null}

[hasWireModel, wireModelValue, hasDotNotation, parsedDotNotationValue]

in BeartropyComponent at line 92
array<string,mixed> getComponentSizePreset(string|null $componentName = null, ComponentAttributeBag|null $attributes = null)

Get the size preset configuration.

Legacy method for size resolution. Prioritizes size property, then magic attributes.

Parameters

string|null $componentName UNUSED.
ComponentAttributeBag|null $attributes

Component attributes to check for magic props.

Return Value

array<string,mixed>

The size configuration array.

in BeartropyComponent at line 133
array<string,mixed> getSizePreset(string|null $componentName = null, ComponentAttributeBag|array|null $attributes = null, string $defaultSize = 'md')

Resolve the size preset for the component.

Checks:

  1. Explicit $this->size.
  2. Magic attributes (e.g., <x-button sm />).
  3. Default size.

Parameters

string|null $componentName

Component name (used for context, optionally).

ComponentAttributeBag|array|null $attributes

Attributes array or bag.

string $defaultSize

Default size key (default: 'md').

Return Value

array<string,mixed>

The resolved size preset configuration.

in BeartropyComponent at line 167
array<string,mixed> getColorPreset(string $component, string|null $color = null, string|null $variant = null)

Resolve the color preset configuration.

Handles color resolution based on component config, variants, and defaults.

Parameters

string $component

Component key in configuration (e.g., 'button').

string|null $color

Explicit color name.

string|null $variant

Variant name (e.g., 'solid', 'outline').

Return Value

array<string,mixed>

The color configuration/classes.

at line 142
protected array resolveItems(mixed $items)

Decide de dónde sacar el array de navegación

Parameters

mixed $items

Return Value

array

at line 170
protected array loadConfigNav(string $nav = 'default')

Carga el archivo de navegación: config/beartropy/ui/navs/

Parameters

string $nav

Return Value

array

at line 188
bool isItemActive(array $item)

Determine if a navigation item is active based on current request.

Checks path matches, route name matches, and recursive child activation.

Parameters

array $item

Return Value

bool

at line 267
string renderIcon(string $icon, string $iconClass = '')

Render an icon for a navigation item.

Parameters

string $icon

Icon name or SVG string.

string $iconClass

Extra classes.

Return Value

string

at line 286
protected array filterNavCategories(array $categories, mixed $user = null)

Filter navigation categories and their items based on permissions.

Parameters

array $categories
mixed $user

Return Value

array

at line 317
array filterNavItems(array $items, mixed $user = null)

Filter a list of navigation items based on user permissions.

Parameters

array $items
mixed $user

Return Value

array

at line 424
string navId(array $item)

Generate a unique ID for a navigation item.

Parameters

array $item

Return Value

string

at line 434
View|Closure|string render()

Get the view / contents that represent the component.

Return Value

View|Closure|string