@headless-tree/core
Index
Async Data Loader/General
Other
- DropTargetPosition
- AsyncDataLoaderFeatureConfig
- AsyncDataLoaderFeatureItemInstance
- AsyncDataLoaderFeatureState
- AsyncDataLoaderFeatureTreeInstance
- DragAndDropFeatureConfig
- DragAndDropFeatureItemInstance
- DragAndDropFeatureState
- DragAndDropFeatureTreeInstance
- ExpandAllFeatureConfig
- ExpandAllFeatureItemInstance
- ExpandAllFeatureState
- ExpandAllFeatureTreeInstance
- HotkeyConfig
- HotkeysCoreFeatureConfig
- HotkeysCoreFeatureItemInstance
- HotkeysCoreFeatureState
- HotkeysCoreFeatureTreeInstance
- ItemInstance
- MainFeatureConfig
- MainFeatureItemInstance
- MainFeatureState
- MainFeatureTreeInstance
- RenamingFeatureConfig
- RenamingFeatureItemInstance
- RenamingFeatureState
- RenamingFeatureTreeInstance
- SearchFeatureConfig
- SearchFeatureItemInstance
- SearchFeatureState
- SearchFeatureTreeInstance
- SelectionFeatureConfig
- SelectionFeatureItemInstance
- SelectionFeatureState
- SelectionFeatureTreeInstance
- SyncDataLoaderFeatureConfig
- SyncDataLoaderFeatureItemInstance
- SyncDataLoaderFeatureState
- SyncDataLoaderFeatureTreeInstance
- TreeConfig
- TreeFeatureConfig
- TreeFeatureItemInstance
- TreeFeatureState
- TreeFeatureTreeInstance
- TreeInstance
- TreeState
- AsyncDataLoaderFeatureHotkeys
- AsyncDataLoaderRef
- AsyncTreeDataLoader
- CustomHotkeysConfig
- DefaultFeatures
- DndDataRef
- DndState
- DragAndDropFeatureDef
- DragAndDropFeatureHotkeys
- DragLineData
- DropTarget
- EmptyFeatureDef
- ExpandAllFeatureDef
- ExpandAllFeatureHotkeys
- FeatureDef
- FeatureDefs
- FeatureImplementation
- HotkeyName
- HotkeysConfig
- HotkeysCoreDataRef
- HotkeysCoreFeatureDef
- HotkeysCoreFeatureHotkeys
- InstanceBuilder
- ItemInstanceOpts
- ItemMeta
- MainFeatureDef
- MainFeatureHotkeys
- RenamingFeatureDef
- RenamingFeatureHotkeys
- SearchFeatureDataRef
- SearchFeatureDef
- SearchFeatureHotkeys
- SelectionFeatureDef
- SelectionFeatureHotkeys
- SetStateFn
- SyncDataLoaderFeatureDef
- SyncDataLoaderFeatureHotkeys
- SyncTreeDataLoader
- TreeFeatureDef
- TreeFeatureHotkeys
- TreeInstanceOpts
- TreeItemDataRef
- Updater
- asyncDataLoaderFeature
- dragAndDropFeature
- expandAllFeature
- hotkeysCoreFeature
- renamingFeature
- searchFeature
- selectionFeature
- syncDataLoaderFeature
- buildProxiedInstance
- buildStaticInstance
- createOnDropHandler
- createTree
- insertItemsAtTarget
- removeItemsFromParents
Async Data Loader/General
AsyncDataLoaderFeatureDef
Type parameters
- T
Type declaration
config: { asyncDataLoader?: AsyncTreeDataLoader<T>; createLoadingItemData?: () => T; onLoadedChildren?: (itemId: string, childrenIds: string[]) => void; onLoadedItem?: (itemId: string, item: T) => void; rootItemId: string; setLoadingItems?: SetStateFn<string[]> }
optionalasyncDataLoader?: AsyncTreeDataLoader<T>
optionalcreateLoadingItemData?: () => T
Returns T
optionalonLoadedChildren?: (itemId: string, childrenIds: string[]) => void
Parameters
itemId: string
childrenIds: string[]
Returns void
optionalonLoadedItem?: (itemId: string, item: T) => void
Parameters
itemId: string
item: T
Returns void
rootItemId: string
optionalsetLoadingItems?: SetStateFn<string[]>
hotkeys: SyncDataLoaderFeatureDef<T>[hotkeys]
itemInstance: SyncDataLoaderFeatureDef<T>[itemInstance] & { invalidateChildrenIds: () => void; invalidateItemData: () => void; isLoading: () => void }
state: { loadingItems: string[] }
loadingItems: string[]
treeInstance: SyncDataLoaderFeatureDef<T>[treeInstance] & { invalidateChildrenIds: (itemId: string) => void; invalidateItemData: (itemId: string) => void }
Other
AsyncDataLoaderFeatureHotkeys
Type parameters
- T
AsyncDataLoaderRef
Type parameters
- T = any
Type declaration
childrenIds: Record<string, string[]>
itemData: Record<string, T>
AsyncTreeDataLoader
Type parameters
- T
Type declaration
getChildren: (itemId: string) => Promise<string[]>
Parameters
itemId: string
Returns Promise<string[]>
optionalgetChildrenWithData?: (itemId: string) => Promise<{ data: T; id: string }[]>
Parameters
itemId: string
Returns Promise<{ data: T; id: string }[]>
getItem: (itemId: string) => Promise<T>
Parameters
itemId: string
Returns Promise<T>
CustomHotkeysConfig
Type parameters
- T
- F: FeatureDef = FeatureDefs<T>
DefaultFeatures
Type parameters
- T
DndDataRef
Type declaration
optionallastDragCode?: string
DndState
Type parameters
- T
Type declaration
optionaldragTarget?: DropTarget<T>
optionaldraggedItems?: ItemInstance<T>[]
optionaldraggingOverItem?: ItemInstance<T>
DragAndDropFeatureDef
Type parameters
- T
Type declaration
config: { bottomLinePercentage?: number; canDrag?: (items: ItemInstance<T>[]) => boolean; canDrop?: (items: ItemInstance<T>[], target: DropTarget<T>) => boolean; canDropForeignDragObject?: (dataTransfer: DataTransfer, target: DropTarget<T>) => boolean; canDropInbetween?: boolean; createForeignDragObject?: (items: ItemInstance<T>[]) => { data: any; format: string }; isItemDraggable?: (item: ItemInstance<T>) => boolean; onCompleteForeignDrop?: (items: ItemInstance<T>[]) => void; onDrop?: (items: ItemInstance<T>[], target: DropTarget<T>) => void; onDropForeignDragObject?: (dataTransfer: DataTransfer, target: DropTarget<T>) => void; setDndState?: SetStateFn<DndState<T> | null>; topLinePercentage?: number }
optionalbottomLinePercentage?: number
optionalcanDrag?: (items: ItemInstance<T>[]) => boolean
Parameters
items: ItemInstance<T>[]
Returns boolean
optionalcanDrop?: (items: ItemInstance<T>[], target: DropTarget<T>) => boolean
Parameters
items: ItemInstance<T>[]
target: DropTarget<T>
Returns boolean
optionalcanDropForeignDragObject?: (dataTransfer: DataTransfer, target: DropTarget<T>) => boolean
Parameters
dataTransfer: DataTransfer
target: DropTarget<T>
Returns boolean
optionalcanDropInbetween?: boolean
optionalcreateForeignDragObject?: (items: ItemInstance<T>[]) => { data: any; format: string }
Parameters
items: ItemInstance<T>[]
Returns { data: any; format: string }
data: any
format: string
optionalisItemDraggable?: (item: ItemInstance<T>) => boolean
Parameters
item: ItemInstance<T>
Returns boolean
optionalonCompleteForeignDrop?: (items: ItemInstance<T>[]) => void
Parameters
items: ItemInstance<T>[]
Returns void
optionalonDrop?: (items: ItemInstance<T>[], target: DropTarget<T>) => void
Parameters
items: ItemInstance<T>[]
target: DropTarget<T>
Returns void
optionalonDropForeignDragObject?: (dataTransfer: DataTransfer, target: DropTarget<T>) => void
Parameters
dataTransfer: DataTransfer
target: DropTarget<T>
Returns void
optionalsetDndState?: SetStateFn<DndState<T> | null>
optionaltopLinePercentage?: number
hotkeys: never
itemInstance: { isDraggingOver: () => boolean; isDropTarget: () => boolean; isDropTargetAbove: () => boolean; isDropTargetBelow: () => boolean }
isDraggingOver: () => boolean
Returns boolean
isDropTarget: () => boolean
Returns boolean
isDropTargetAbove: () => boolean
Returns boolean
isDropTargetBelow: () => boolean
Returns boolean
state: { dnd?: DndState<T> | null }
optionaldnd?: DndState<T> | null
treeInstance: { getDragLineData: () => DragLineData | null; getDropTarget: () => DropTarget<T> | null }
getDragLineData: () => DragLineData | null
Returns DragLineData | null
getDropTarget: () => DropTarget<T> | null
Returns DropTarget<T> | null
DragAndDropFeatureHotkeys
Type parameters
- T
DragLineData
Type declaration
intend: number
left: number
right: number
top: number
DropTarget
Type parameters
- T
EmptyFeatureDef
Type declaration
config: {}
hotkeys: never
itemInstance: {}
state: {}
treeInstance: {}
ExpandAllFeatureDef
Type declaration
config: {}
hotkeys: never
itemInstance: { collapseAll: () => void; expandAll: (cancelToken?: { current: boolean }) => Promise<void> }
collapseAll: () => void
Returns void
expandAll: (cancelToken?: { current: boolean }) => Promise<void>
Parameters
optionalcancelToken: { current: boolean }
Returns Promise<void>
state: {}
treeInstance: { collapseAll: () => void; expandAll: (cancelToken?: { current: boolean }) => Promise<void> }
collapseAll: () => void
Returns void
expandAll: (cancelToken?: { current: boolean }) => Promise<void>
Parameters
optionalcancelToken: { current: boolean }
Returns Promise<void>
ExpandAllFeatureHotkeys
FeatureDef
Type declaration
config: any
hotkeys: string
itemInstance: FunctionMap
state: any
treeInstance: FunctionMap
FeatureDefs
Type parameters
- T
FeatureImplementation
Type parameters
- T = any
- SelfFeatureDef: FeatureDef = any
- DepFeaturesDef: FeatureDef = EmptyFeatureDef
Type declaration
optionaldeps?: string[]
optionalgetDefaultConfig?: (defaultConfig: Partial<MergedFeatures<DepFeaturesDef>[config]>, tree: MergedFeatures<DepFeaturesDef>[treeInstance]) => Partial<SelfFeatureDef[config] & MergedFeatures<DepFeaturesDef>[config]>
Parameters
defaultConfig: Partial<MergedFeatures<DepFeaturesDef>[config]>
tree: MergedFeatures<DepFeaturesDef>[treeInstance]
Returns Partial<SelfFeatureDef[config] & MergedFeatures<DepFeaturesDef>[config]>
optionalgetInitialState?: (initialState: Partial<MergedFeatures<DepFeaturesDef>[state]>, tree: MergedFeatures<DepFeaturesDef>[treeInstance]) => Partial<SelfFeatureDef[state] & MergedFeatures<DepFeaturesDef>[state]>
Parameters
initialState: Partial<MergedFeatures<DepFeaturesDef>[state]>
tree: MergedFeatures<DepFeaturesDef>[treeInstance]
Returns Partial<SelfFeatureDef[state] & MergedFeatures<DepFeaturesDef>[state]>
optionalhotkeys?: HotkeysConfig<T, SelfFeatureDef>
optionalitemInstance?: { [ key in keyof SelfFeatureDef[itemInstance] & MergedFeatures<DepFeaturesDef>[itemInstance] ]?: (opts: ItemInstanceOpts<SelfFeatureDef[itemInstance] & MergedFeatures<DepFeaturesDef>[itemInstance], SelfFeatureDef[treeInstance] & MergedFeatures<DepFeaturesDef>[treeInstance], key>, ...args: Parameters<SelfFeatureDef[itemInstance] & MergedFeatures<DepFeaturesDef>[itemInstance][key]>) => void }
optionalkey?: string
optionalonItemMount?: (instance: MergedFeatures<DepFeaturesDef>[itemInstance], itemElement: HTMLElement, tree: MergedFeatures<DepFeaturesDef>[treeInstance]) => void
Parameters
instance: MergedFeatures<DepFeaturesDef>[itemInstance]
itemElement: HTMLElement
tree: MergedFeatures<DepFeaturesDef>[treeInstance]
Returns void
optionalonItemUnmount?: (instance: MergedFeatures<DepFeaturesDef>[itemInstance], itemElement: HTMLElement, tree: MergedFeatures<DepFeaturesDef>[treeInstance]) => void
Parameters
instance: MergedFeatures<DepFeaturesDef>[itemInstance]
itemElement: HTMLElement
tree: MergedFeatures<DepFeaturesDef>[treeInstance]
Returns void
optionalonTreeMount?: (instance: MergedFeatures<DepFeaturesDef>[treeInstance], treeElement: HTMLElement) => void
Parameters
instance: MergedFeatures<DepFeaturesDef>[treeInstance]
treeElement: HTMLElement
Returns void
optionalonTreeUnmount?: (instance: MergedFeatures<DepFeaturesDef>[treeInstance], treeElement: HTMLElement) => void
Parameters
instance: MergedFeatures<DepFeaturesDef>[treeInstance]
treeElement: HTMLElement
Returns void
optionaloverwrites?: string[]
optionalstateHandlerNames?: Partial<Record<keyof MergedFeatures<DepFeaturesDef>[state], keyof MergedFeatures<DepFeaturesDef>[config]>>
optionaltreeInstance?: { [ key in keyof SelfFeatureDef[treeInstance] & MergedFeatures<DepFeaturesDef>[treeInstance] ]?: (opts: TreeInstanceOpts<SelfFeatureDef[treeInstance] & MergedFeatures<DepFeaturesDef>[treeInstance], key>, ...args: Parameters<SelfFeatureDef[treeInstance] & MergedFeatures<DepFeaturesDef>[treeInstance][key]>) => void }
HotkeyName
Type parameters
- F: FeatureDef = FeatureDefs<any>
HotkeysConfig
Type parameters
- T
- F: FeatureDef = FeatureDefs<T>
HotkeysCoreDataRef
Type declaration
optionalkeydownHandler?: (e: KeyboardEvent) => void
Parameters
e: KeyboardEvent
Returns void
optionalkeyupHandler?: (e: KeyboardEvent) => void
Parameters
e: KeyboardEvent
Returns void
pressedKeys: Set<string>
HotkeysCoreFeatureDef
Type parameters
- T
Type declaration
config: { hotkeys?: CustomHotkeysConfig<T>; onItemHotkey?: (name: string, item: ItemInstance<T>, element: HTMLElement) => void; onTreeHotkey?: (name: string, element: HTMLElement) => void }
optionalhotkeys?: CustomHotkeysConfig<T>
optionalonItemHotkey?: (name: string, item: ItemInstance<T>, element: HTMLElement) => void
Parameters
name: string
item: ItemInstance<T>
element: HTMLElement
Returns void
optionalonTreeHotkey?: (name: string, element: HTMLElement) => void
Parameters
name: string
element: HTMLElement
Returns void
hotkeys: never
itemInstance: {}
state: {}
treeInstance: {}
HotkeysCoreFeatureHotkeys
Type parameters
- T
InstanceBuilder
Type declaration
Type parameters
- T: keyof InstanceTypeMap
Parameters
features: FeatureImplementation[]
instanceType: T
buildOpts: (self: any) => any
Returns [instance: InstanceTypeMap[T], finalize: () => void]
ItemInstanceOpts
Type parameters
- ItemInstance: FunctionMap = FunctionMap
- TreeInstance: FunctionMap = FunctionMap
- Key: keyof ItemInstance = any
Type declaration
item: ItemInstance
itemId: string
prev: MayReturnNull<ItemInstance[Key]>
tree: TreeInstance
ItemMeta
Type declaration
index: number
itemId: string
level: number
parentId: string
posInSet: number
setSize: number
MainFeatureDef
Type parameters
- T = any
Type declaration
config: { features?: FeatureImplementation<any>[]; initialState?: Partial<TreeState<T>>; instanceBuilder?: InstanceBuilder; setState?: SetStateFn<TreeState<T>>; state?: Partial<TreeState<T>> }
optionalfeatures?: FeatureImplementation<any>[]
optionalinitialState?: Partial<TreeState<T>>
optionalinstanceBuilder?: InstanceBuilder
optionalsetState?: SetStateFn<TreeState<T>>
optionalstate?: Partial<TreeState<T>>
hotkeys: never
itemInstance: { getElement: () => HTMLElement | undefined | null; getItemMeta: () => ItemMeta; registerElement: (element: HTMLElement | null) => void }
state: {}
treeInstance: { getConfig: () => TreeConfig<T>; getElement: () => HTMLElement | undefined | null; getHotkeyPresets: () => HotkeysConfig<T>; getItemInstance: (itemId: string) => ItemInstance<T>; getItems: () => ItemInstance<T>[]; getState: () => TreeState<T>; rebuildTree: () => void; registerElement: (element: HTMLElement | null) => void; setConfig: SetStateFn<TreeConfig<T>>; setState: SetStateFn<TreeState<T>> }
getConfig: () => TreeConfig<T>
Returns TreeConfig<T>
getElement: () => HTMLElement | undefined | null
Returns HTMLElement | undefined | null
getHotkeyPresets: () => HotkeysConfig<T>
Returns HotkeysConfig<T>
getItemInstance: (itemId: string) => ItemInstance<T>
Parameters
itemId: string
Returns ItemInstance<T>
getItems: () => ItemInstance<T>[]
Returns ItemInstance<T>[]
getState: () => TreeState<T>
Returns TreeState<T>
rebuildTree: () => void
Returns void
registerElement: (element: HTMLElement | null) => void
Parameters
element: HTMLElement | null
Returns void
setConfig: SetStateFn<TreeConfig<T>>
setState: SetStateFn<TreeState<T>>
MainFeatureHotkeys
RenamingFeatureDef
Type parameters
- T
Type declaration
config: { canRename?: (item: ItemInstance<T>) => boolean; onRename?: (item: ItemInstance<T>, value: string) => void; setRenamingItem?: SetStateFn<string | null>; setRenamingValue?: SetStateFn<string | undefined> }
optionalcanRename?: (item: ItemInstance<T>) => boolean
Parameters
item: ItemInstance<T>
Returns boolean
optionalonRename?: (item: ItemInstance<T>, value: string) => void
Parameters
item: ItemInstance<T>
value: string
Returns void
optionalsetRenamingItem?: SetStateFn<string | null>
optionalsetRenamingValue?: SetStateFn<string | undefined>
hotkeys: renameItem | abortRenaming | completeRenaming
itemInstance: { canRename: () => boolean; getRenameInputProps: () => any; isRenaming: () => boolean }
canRename: () => boolean
Returns boolean
getRenameInputProps: () => any
Returns any
isRenaming: () => boolean
Returns boolean
state: { renamingItem?: string | null; renamingValue?: string }
optionalrenamingItem?: string | null
optionalrenamingValue?: string
treeInstance: { abortRenaming: () => void; completeRenaming: () => void; getRenamingItem: () => ItemInstance<T> | null; getRenamingValue: () => string; isRenamingItem: () => boolean; startRenamingItem: (itemId: string) => void }
abortRenaming: () => void
Returns void
completeRenaming: () => void
Returns void
getRenamingItem: () => ItemInstance<T> | null
Returns ItemInstance<T> | null
getRenamingValue: () => string
Returns string
isRenamingItem: () => boolean
Returns boolean
startRenamingItem: (itemId: string) => void
Parameters
itemId: string
Returns void
RenamingFeatureHotkeys
Type parameters
- T
SearchFeatureDataRef
Type parameters
- T = any
SearchFeatureDef
Type parameters
- T
Type declaration
config: { isSearchMatchingItem?: (search: string, item: ItemInstance<T>) => boolean; onCloseSearch?: () => void; onOpenSearch?: () => void; onSearchMatchesItems?: (search: string, items: ItemInstance<T>[]) => void; setSearch?: SetStateFn<string | null> }
optionalisSearchMatchingItem?: (search: string, item: ItemInstance<T>) => boolean
Parameters
search: string
item: ItemInstance<T>
Returns boolean
optionalonCloseSearch?: () => void
Returns void
optionalonOpenSearch?: () => void
Returns void
optionalonSearchMatchesItems?: (search: string, items: ItemInstance<T>[]) => void
Parameters
search: string
items: ItemInstance<T>[]
Returns void
optionalsetSearch?: SetStateFn<string | null>
hotkeys: openSearch | closeSearch | submitSearch | nextSearchItem | previousSearchItem
itemInstance: { isMatchingSearch: () => boolean }
isMatchingSearch: () => boolean
Returns boolean
state: { search: string | null }
search: string | null
treeInstance: { closeSearch: () => void; getSearchInputElement: () => HTMLInputElement | null; getSearchInputElementProps: () => any; getSearchMatchingItems: () => ItemInstance<T>[]; getSearchValue: () => string; isSearchOpen: () => boolean; openSearch: (initialValue?: string) => void; registerSearchInputElement: (element: HTMLInputElement | null) => void; setSearch: (search: string | null) => void }
closeSearch: () => void
Returns void
getSearchInputElement: () => HTMLInputElement | null
Returns HTMLInputElement | null
getSearchInputElementProps: () => any
Returns any
getSearchMatchingItems: () => ItemInstance<T>[]
Returns ItemInstance<T>[]
getSearchValue: () => string
Returns string
isSearchOpen: () => boolean
Returns boolean
openSearch: (initialValue?: string) => void
Parameters
optionalinitialValue: string
Returns void
registerSearchInputElement: (element: HTMLInputElement | null) => void
Parameters
element: HTMLInputElement | null
Returns void
setSearch: (search: string | null) => void
Parameters
search: string | null
Returns void
SearchFeatureHotkeys
Type parameters
- T
SelectionFeatureDef
Type parameters
- T
Type declaration
config: { setSelectedItems?: SetStateFn<string[]> }
optionalsetSelectedItems?: SetStateFn<string[]>
hotkeys: toggleSelectItem | selectUpwards | selectDownwards | selectUpwardsCtrl | selectDownwardsCtrl | selectAll
itemInstance: { deselect: () => void; isSelected: () => boolean; select: () => void; selectUpTo: (ctrl: boolean) => void; toggleSelect: () => void }
deselect: () => void
Returns void
isSelected: () => boolean
Returns boolean
select: () => void
Returns void
selectUpTo: (ctrl: boolean) => void
Parameters
ctrl: boolean
Returns void
toggleSelect: () => void
Returns void
state: { selectedItems: string[] }
selectedItems: string[]
treeInstance: { getSelectedItems: () => ItemInstance<T>[]; setSelectedItems: (selectedItems: string[]) => void }
getSelectedItems: () => ItemInstance<T>[]
Returns ItemInstance<T>[]
setSelectedItems: (selectedItems: string[]) => void
Parameters
selectedItems: string[]
Returns void
SelectionFeatureHotkeys
Type parameters
- T
SetStateFn
Type parameters
- T
Type declaration
Parameters
updaterOrValue: Updater<T>
Returns void
SyncDataLoaderFeatureDef
Type parameters
- T
Type declaration
config: { dataLoader?: SyncTreeDataLoader<T>; rootItemId: string }
optionaldataLoader?: SyncTreeDataLoader<T>
rootItemId: string
hotkeys: never
itemInstance: { isLoading: () => boolean }
isLoading: () => boolean
Returns boolean
state: {}
treeInstance: { retrieveChildrenIds: (itemId: string) => string[]; retrieveItemData: (itemId: string) => T }
retrieveChildrenIds: (itemId: string) => string[]
Parameters
itemId: string
Returns string[]
retrieveItemData: (itemId: string) => T
Parameters
itemId: string
Returns T
SyncDataLoaderFeatureHotkeys
Type parameters
- T
SyncTreeDataLoader
Type parameters
- T
Type declaration
getChildren: (itemId: string) => string[]
Parameters
itemId: string
Returns string[]
getItem: (itemId: string) => T
Parameters
itemId: string
Returns T
TreeFeatureDef
Type parameters
- T
Type declaration
config: { getItemName: (item: ItemInstance<T>) => string; isItemFolder: (item: ItemInstance<T>) => boolean; onPrimaryAction?: (item: ItemInstance<T>) => void; scrollToItem?: (item: ItemInstance<T>) => void; setExpandedItems?: SetStateFn<string[]>; setFocusedItem?: SetStateFn<string | null> }
getItemName: (item: ItemInstance<T>) => string
Parameters
item: ItemInstance<T>
Returns string
isItemFolder: (item: ItemInstance<T>) => boolean
Parameters
item: ItemInstance<T>
Returns boolean
optionalonPrimaryAction?: (item: ItemInstance<T>) => void
Parameters
item: ItemInstance<T>
Returns void
optionalscrollToItem?: (item: ItemInstance<T>) => void
Parameters
item: ItemInstance<T>
Returns void
optionalsetExpandedItems?: SetStateFn<string[]>
optionalsetFocusedItem?: SetStateFn<string | null>
hotkeys: focusNextItem | focusPreviousItem | expandOrDown | collapseOrUp | focusFirstItem | focusLastItem
itemInstance: { collapse: () => void; expand: () => void; getChildren: () => ItemInstance<T>[]; getId: () => string; getIndexInParent: () => number; getItemAbove: () => ItemInstance<T> | null; getItemBelow: () => ItemInstance<T> | null; getItemData: () => T; getItemName: () => string; getMemoizedProp: <X>(name: string, create: () => X, deps?: any[]) => X; getParent: () => ItemInstance<T>; getProps: () => Record<string, any>; getTree: () => TreeInstance<T>; isExpanded: () => boolean; isFocused: () => boolean; isFolder: () => boolean; primaryAction: () => void; scrollTo: (scrollIntoViewArg?: boolean | ScrollIntoViewOptions) => Promise<void>; setFocused: () => void }
collapse: () => void
Returns void
expand: () => void
Returns void
getChildren: () => ItemInstance<T>[]
Returns ItemInstance<T>[]
getId: () => string
Returns string
getIndexInParent: () => number
Returns number
getItemAbove: () => ItemInstance<T> | null
Returns ItemInstance<T> | null
getItemBelow: () => ItemInstance<T> | null
Returns ItemInstance<T> | null
getItemData: () => T
Returns T
getItemName: () => string
Returns string
getMemoizedProp: <X>(name: string, create: () => X, deps?: any[]) => X
Type parameters
- X
Parameters
name: string
create: () => X
optionaldeps: any[]
Returns X
getParent: () => ItemInstance<T>
Returns ItemInstance<T>
getProps: () => Record<string, any>
Returns Record<string, any>
getTree: () => TreeInstance<T>
Returns TreeInstance<T>
isExpanded: () => boolean
Returns boolean
isFocused: () => boolean
Returns boolean
isFolder: () => boolean
Returns boolean
primaryAction: () => void
Returns void
scrollTo: (scrollIntoViewArg?: boolean | ScrollIntoViewOptions) => Promise<void>
Parameters
optionalscrollIntoViewArg: boolean | ScrollIntoViewOptions
Returns Promise<void>
setFocused: () => void
Returns void
state: { expandedItems: string[]; focusedItem: string | null }
expandedItems: string[]
focusedItem: string | null
treeInstance: { collapseItem: (itemId: string) => void; expandItem: (itemId: string) => void; focusItem: (itemId: string) => void; focusNextItem: () => void; focusPreviousItem: () => void; getContainerProps: () => Record<string, any>; getFocusedItem: () => ItemInstance<any>; isItemExpanded: (itemId: string) => boolean; updateDomFocus: () => void }
collapseItem: (itemId: string) => void
Parameters
itemId: string
Returns void
expandItem: (itemId: string) => void
Parameters
itemId: string
Returns void
focusItem: (itemId: string) => void
Parameters
itemId: string
Returns void
focusNextItem: () => void
Returns void
focusPreviousItem: () => void
Returns void
getContainerProps: () => Record<string, any>
Returns Record<string, any>
getFocusedItem: () => ItemInstance<any>
Returns ItemInstance<any>
isItemExpanded: (itemId: string) => boolean
Parameters
itemId: string
Returns boolean
updateDomFocus: () => void
Returns void
TreeFeatureHotkeys
Type parameters
- T
TreeInstanceOpts
Type parameters
- TreeInstance: FunctionMap = FunctionMap
- Key: keyof TreeInstance = any
Type declaration
prev: MayReturnNull<TreeInstance[Key]>
tree: TreeInstance
TreeItemDataRef
Type declaration
memoizedDeps: Record<string, any[] | undefined>
memoizedValues: Record<string, any>
Updater
Type parameters
- T
Runs in the onDragEnd event, if
ev.dataTransfer.dropEffect
is notnone
, i.e. the drop was not aborted. No target is provided as parameter since the target may be a foreign drop target. This is useful to seperate out the logic to move dragged items out of their previous parents. UseonDrop
to handle drop-related logic.This ignores the
canDrop
handler, since the drop target is unknown in this handler.