import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js"; import { RootErrorRendererProps, TreeRendererProps } from "./Renderers.js"; import { ErrorInfo, TreeNode } from "./TreeNode.js"; import { GenericInstanceFilter, HierarchyNode, HierarchyProvider, HierarchySearchTree } from "@itwin/presentation-hierarchies"; import { IPrimitiveValueFormatter } from "@itwin/presentation-shared"; /** * A React hook that creates state for a tree component. * * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a * component-agnostic result which may be used to render the hierarchy using any UI framework. * * See `README.md` for an example * * @see `useUnifiedSelectionTree` * @see `useIModelTree` * @public */ declare function useTree(props: UseTreeProps): UseTreeResult; /** * A React hook that creates state for a tree component, that is integrated with unified selection * through the given selection storage (previously the storage was provided through the, now * deprecated, `UnifiedSelectionProvider`). * * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a * component-agnostic result which may be used to render the hierarchy using any UI framework. * * See `README.md` for an example * * @see `useTree` * @see `useIModelUnifiedSelectionTree` * @see `UnifiedSelectionProvider` * @public */ declare function useUnifiedSelectionTree({ sourceName, selectionStorage, createSelectableForGenericNode, ...props }: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult; /** @public */ interface UseTreeProps { /** Provides the hierarchy provider for the tree. */ getHierarchyProvider: () => HierarchyProvider; /** Provides paths to search nodes. */ getSearchPaths?: ({ abortSignal }: { abortSignal: AbortSignal; }) => Promise; /** * Callback that is called just after a certain action is finished. * Can be used for performance tracking. */ onPerformanceMeasured?: (action: "initial-load" | "hierarchy-level-load" | "reload", duration: number) => void; /** Action to perform when hierarchy level contains more items that the specified limit. */ onHierarchyLimitExceeded?: (props: { parentId?: string; filter?: GenericInstanceFilter; limit?: number | "unbounded"; }) => void; /** Action to perform when an error occurs while loading hierarchy. */ onHierarchyLoadError?: (props: { parentId?: string; type: "timeout" | "unknown"; error: unknown; }) => void; /** * Callback to set custom TreeNode errors. * Errors returned from this callback are combined with internal errors when populating `TreeNode.errors`. */ getTreeNodeErrors?: (node: HierarchyNode) => ErrorInfo[]; } /** @public */ type UseTreeResult = { /** * Specifies whether a tree load is in progress. */ isLoading: boolean; /** * Get a tree node by id */ getNode: (nodeId: string) => TreeNode | undefined; /** * Sets a formatter for the primitive values that are displayed in the hierarchy. */ setFormatter: (formatter: IPrimitiveValueFormatter | undefined) => void; } & RendererProps; /**. * @alpha */ type RendererProps = { /** * An object containing information used to render root error handling UI. * Use in combination with `RootErrorRenderer` or your custom implementation. * Defined when root nodes fail to load. */ rootErrorRendererProps: RootErrorRendererProps; } | { /** Is undefined when rootNodes were successfully loaded or are in initial loading process. */ rootErrorRendererProps: undefined; /** * An object containing information used to render tree. * Use with `TreeRenderer` or your custom implementation. * Is undefined on initial loading process. */ treeRendererProps?: TreeRendererProps; }; export { UseTreeProps, UseTreeResult, useTree, useUnifiedSelectionTree }; //# sourceMappingURL=UseTree.d.ts.map