UNPKG

@itwin/presentation-hierarchies-react

Version:

React components based on `@itwin/presentation-hierarchies`

46 lines 2.3 kB
import { GenericNodeKey, NonGroupingHierarchyNode } from "@itwin/presentation-hierarchies"; import { Selectable, SelectionStorage } from "@itwin/unified-selection"; import { SelectionChangeType } from "../UseSelectionHandler.js"; import { TreeModelNode, TreeModelRootNode } from "./TreeModel.js"; /** @internal */ export interface TreeSelectionOptions { isNodeSelected: (nodeId: string) => boolean; selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void; } /** @public */ export interface UseUnifiedTreeSelectionProps { /** * Identifier to distinguish this source of changes to the unified selection from another ones in the application. */ sourceName: string; /** * An optional function that allows customizing the `Selectable` object that gets created for generic hierarchy nodes. When * not supplied, the `Selectable` is created using the following signature: * ```ts * { * identifier: treeModelNodeId, * data: node, * async *loadInstanceKeys() {}, * } * ``` * * @param node Hierarchy node to create a selectable for. * @param treeModelNodeId ID of the hierarchy node in the internal tree model. This ID uniquely identifies the node in the whole hierarchy, as opposed to `GenericNodeKey.id` contained within the `node`, which may not be unique. */ createSelectableForGenericNode?: (node: NonGroupingHierarchyNode & { key: GenericNodeKey; }, treeModelNodeId: string) => Selectable; /** * Unified selection storage to use for listening, getting and changing active selection. * * When not specified, the deprecated unified selection React context is used to access the * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the * next major release, where the deprecated context will also be removed. */ selectionStorage?: SelectionStorage; } /** @internal */ export declare function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, createSelectableForGenericNode, }: UseUnifiedTreeSelectionProps & { getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined; }): TreeSelectionOptions; //# sourceMappingURL=UseUnifiedSelection.d.ts.map