import { HierarchyFilteringPath } from "@itwin/presentation-hierarchies"; import type { Id64String } from "@itwin/core-bentley"; import type { Viewport } from "@itwin/core-frontend"; import type { PresentationHierarchyNode } from "@itwin/presentation-hierarchies-react"; import type { InstanceKey } from "@itwin/presentation-shared"; import type { VisibilityTreeProps } from "../common/components/VisibilityTree.js"; import type { VisibilityTreeRendererProps } from "../common/components/VisibilityTreeRenderer.js"; import type { NormalizedHierarchyFilteringPath } from "../common/Utils.js"; import type { ModelsTreeVisibilityHandlerOverrides } from "./internal/ModelsTreeVisibilityHandler.js"; import type { ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition.js"; /** @beta */ export interface UseModelsTreeProps { /** * Optional search string used to filter tree nodes by label, as well as highlight matching substrings in the tree. * Nodes that do not contain this string in their label will be filtered out. * * If `getFilteredPaths` function is provided, it will take precedence and automatic filtering by this string will not be applied. * Instead, the string will be supplied to the given `getFilteredPaths` function for consumers to apply the filtering. */ filter?: string; activeView: Viewport; hierarchyConfig?: Partial; visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides; /** * Optional function for applying custom filtering on the hierarchy. Use it when you want full control over which nodes should be displayed, based on more complex logic or known instance keys. * * When defined, this function takes precedence over filtering by `filter` string. If both are supplied, the `filter` is provided as an argument to `getFilteredPaths`. * * @param props Parameters provided when `getFilteredPaths` is called: * - `createInstanceKeyPaths`: Helper function to create filter paths. * - `filter`: The filter string which would otherwise be used for default filtering. * * **Example use cases:** * - You have a list of `InstanceKey` items, which you want to use for filtering the hierarchy. * - You want to create filter paths based on node label, but also apply some extra conditions (for example exclude paths with sub-models). * - You want to construct custom filtered paths. For example: create a filter path for each geometric element which has a parent element. * * @note Paths returned by `createInstanceKeyPaths` will not have `autoExpand` flag set. If you want nodes to be expanded, iterate over the paths and * set `autoExpand: true` manually. */ getFilteredPaths?: (props: { /** A function that creates filtering paths based on provided target instance keys or node label. */ createInstanceKeyPaths: (props: { targetItems: Array; } | { label: string; }) => Promise; /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */ filter?: string; }) => Promise; /** * Optional function for restricting the visible hierarchy to a specific sub-tree of nodes, without changing how filtering works. * * Use when you want to display only part of the hierarchy, but still allow normal filtering within that sub-tree. * * When defined, only nodes that are in the provided paths or children of target nodes will be part of the hierarchy. * Filtering (by label or custom logic) will still apply within this sub-tree. * * Key difference: * - `getFilteredPaths` determines which nodes should be shown, giving you full control over filtering logic. * - `getSubTreePaths` restricts the hierarchy to a sub-tree, but does not override the filtering logic — filtering is still applied within the restricted sub-tree. */ getSubTreePaths?: (props: { /** A function that creates filtering paths based on provided target instance keys. */ createInstanceKeyPaths: (props: { targetItems: Array; }) => Promise; }) => Promise; onModelsFiltered?: (modelIds: Id64String[] | undefined) => void; /** * An optional predicate to allow or prohibit selection of a node. * When not supplied, all nodes are selectable. */ selectionPredicate?: (props: { node: PresentationHierarchyNode; type: "subject" | "model" | "category" | "element" | "elements-class-group"; }) => boolean; } /** @beta */ interface UseModelsTreeResult { modelsTreeProps: Pick; rendererProps: Required>; } /** * Custom hook to create and manage state for the models tree. * @beta */ export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, selectionPredicate: nodeTypeSelectionPredicate, getSubTreePaths, }: UseModelsTreeProps): UseModelsTreeResult; export {}; //# sourceMappingURL=UseModelsTree.d.ts.map