createNested API
API reference for the createNested composable.
Related
Explore these related pages for additional context and usage patterns.
| Page | Category |
|---|---|
| createNested | Selection |
| Treeview | Disclosure |
| createGroup | Selection |
| createSelection | Selection |
Functions
createNested
(_options?: NestedOptions) => NestedContext<NestedTicketInput<unknown>, NestedTicket<NestedTicketInput<unknown>>>Creates a new nested tree instance with hierarchical management. Extends `createGroup` to support parent-child relationships, tree traversal, and open/close state management. Perfect for tree views, nested navigation, and hierarchical data structures.
createNestedContext
(_options?: NestedContextOptions) => ContextTrinity<NestedContext<NestedTicketInput<unknown>, NestedTicket<NestedTicketInput<unknown>>>>Creates a new nested context with provide/inject pattern.
useNested
(namespace?: string) => NestedContext<NestedTicketInput<unknown>, NestedTicket<NestedTicketInput<unknown>>>Returns the current nested instance from context.
Options
disabled
MaybeRefOrGetter<boolean> | undefinedDisabled state for the entire model instance
Default: false
multiple
MaybeRefOrGetter<boolean> | undefinedAllow multiple tickets to be selected simultaneously
Default: false
mandatory
MaybeRefOrGetter<boolean | "force"> | undefinedControls mandatory selection behavior: - `false` (default): No mandatory selection enforcement - `true`: Prevents deselecting the last selected item - `'force'`: Automatically selects the first non-disabled item on registration
open
NestedOpenMode | undefinedControls how nodes expand/collapse. - `'multiple'` (default): Multiple nodes can be open simultaneously - `'single'`: Only one node open at a time (accordion behavior)
openAll
boolean | undefinedWhen true, parent nodes automatically open when children are registered. Similar to `enroll` in selection composables but for open state.
reveal
boolean | undefinedWhen true, opening a node also opens all its ancestors. Ensures the opened node is always visible in the tree.
selection
NestedSelectionMode | undefinedControls how selection cascades through the hierarchy. - `'cascade'` (default): Selecting parent selects descendants; ancestors show mixed state - `'independent'`: Each node selected independently - `'leaf'`: Only leaf nodes selectable; parent selection selects leaf descendants
active
NestedActiveMode | undefinedControls how many items can be active/highlighted simultaneously. - `'single'` (default): Only one item active at a time - `'multiple'`: Multiple items can be active simultaneously
openStrategy
OpenStrategy | undefinedAdvanced: Custom strategy for open behavior. Overrides `open` option if provided.
Properties
selectedValues
ComputedRef<Set<E["value"] extends Ref<infer U, infer U> ? U : E["value"]>>Computed Set of selected ticket values
selectedIndexes
ComputedRef<Set<number>>children
ReadonlyMap<ID, readonly ID[]>Map of parent IDs to arrays of child IDs. Use register/unregister to modify.
parents
ReadonlyMap<ID, ID | undefined>Map of child IDs to their parent ID (or undefined for roots). Use register/unregister to modify.
activeIds
Reactive<Set<ID>>Reactive Set of active/highlighted item IDs. Use activate/deactivate to modify.
Methods
move
(id: ID, toIndex: number) => E | undefinedSeek for a ticket based on direction and optional predicate
seek
(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => E | undefinedon
<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => voidListen for registry events
off
<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => voidStop listening for registry events
emit
<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => voidEmit an event with data
batch
<R>(fn: () => R) => RExecute operations in a batch, deferring cache invalidation and event emission until complete
reveal
(ids: ID | ID[]) => voidReveal node(s) by opening all ancestors (makes node visible without opening it)
toFlat
() => Array<{ id: ID; parentId: ID | undefined; value: Z extends NestedTicketInput<infer V> ? V : unknown; }>Convert tree to flat array with parentId references
isAncestorOf
(ancestorId: ID, descendantId: ID) => booleanCheck if ancestorId is an ancestor of descendantId
hasAncestor
(id: ID, ancestorId: ID) => booleanCheck if id has ancestorId as an ancestor (semantic alias for isAncestorOf)
position
(id: ID) => numberGet 1-indexed position among siblings (for aria-posinset). Returns 0 if not found.
unselect
(ids: ID | ID[]) => voidUnselect item(s) and all descendants, updating ancestor mixed states
register
(registration?: NestedRegistration<Z>) => ERegister a node with optional inline children (accepts input type, returns output type)
onboard
(registrations: NestedRegistration<Z>[]) => E[]Batch register nodes with optional inline children