* If `true`, groups (items with children) expand on click.
* @defaulttrue
*/
expandOnClick?:MaybeGetter<boolean|undefined>;
/**
* The items contained in the tree.
* @required
*/
items:IterableProp<Item>;
/**
* How many time (in ms) the typeahead string is held before it is cleared
* @default500
*/
typeaheadTimeout?:MaybeGetter<number|undefined>;
};
Methods
The methods returned from
newTree()
newTree()
isSelected
(id:string)=> boolean
(id:string)=> boolean
Checks if an item is currently selected
@param id - ID of the item to check
isExpanded
(id:string)=> boolean
(id:string)=> boolean
Checks if an item is currently expanded
@param id - ID of the item to check
getItem
(id:string)=> I |undefined
(id:string)=> I |undefined
getItemId
(id:string)=> string
(id:string)=> string
Gets the DOM ID for a specific tree item
@param id - ID of the item
getItemEl
(id:string)=> HTMLElement |null
(id:string)=> HTMLElement |null
Gets the DOM element for a specific tree item
@param id - ID of the item
selectUntil
(id:string)=>void
(id:string)=>void
Selects all items between the last selected item and the specified item
@param id - ID of the item to select until
getAllChildren
typeof Tree.getAllChildren
typeof Tree.getAllChildren
Helper function to get all child items in a tree or subtree
@param treeOrChild - Tree or Child instance to get children from
@param onlyVisible - If true, only returns visible (expanded) children
Properties
The properties returned from
newTree()
newTree()
collection
Collection<I>
Collection<I>
The items contained in the tree
multiple
Multiple
Multiple
If
true
true
, the user can select multiple items holding
Control
Control
/
Meta
Meta
or
Shift
Shift
expandOnClick
boolean
boolean
If
true
true
, groups (items with children) expand on click
typeaheadTimeout
number
number
typeahead
(
letter: string,
) =>
|{
readonlychild:Child<I>
readonlyvalue:string
readonlytypeahead:string
readonlycurrent:boolean
}
|undefined
(
letter: string,
) =>
|{
readonlychild:Child<I>
readonlyvalue:string
readonlytypeahead:string
readonlycurrent:boolean
}
|undefined
expand
(id:string)=>void
(id:string)=>void
Expands a specific item
@param id - ID of the item to expand
expandAll
()=>void
()=>void
Expands all items
collapse
(id:string)=>void
(id:string)=>void
Collapses a specific item
@param id - ID of the item to collapse
collapseAll
()=>void
()=>void
Collapses all items
toggleExpand
(id:string)=>void
(id:string)=>void
Toggles the expanded state of an item
@param id - ID of the item to toggle
select
(id:string)=>void
(id:string)=>void
Selects a specific item
@param id - ID of the item to select
deselect
(id:string)=>void
(id:string)=>void
Deselects a specific item
@param id - ID of the item to deselect
clearSelection
()=>void
()=>void
Clears all current selections
toggleSelect
(id:string)=>void
(id:string)=>void
Toggles the selected state of an item
@param id - ID of the item to toggle
selectAll
()=>void
()=>void
Selects all visible items.
If all items are already selected, clears the selection.
items
I[]
I[]
selected
FalseIfUndefined<Multiple>>
FalseIfUndefined<Multiple>>
Currently selected item(s)
For multiple selection, returns a Set of IDs
For single selection, returns a single ID or undefined
expanded
SvelteSet<string>
SvelteSet<string>
Set of currently expanded item IDs
root
{role:string;"data-melt-tree-root": string}
{role:string;"data-melt-tree-root": string}
Gets ARIA attributes for the root tree element
group
{role:string;"data-melt-tree-group": string}
{role:string;"data-melt-tree-group": string}
ARIA attributes for group elements
children
Child<I>[]
Child<I>[]
Array of Child instances representing the top-level items