@itwin/tree-widget-react 3.11.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +2 -2
  3. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  4. package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
  5. package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +50 -0
  6. package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  7. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  8. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
  9. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  10. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  11. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  12. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +20 -2
  13. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +92 -37
  14. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  15. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +2 -2
  16. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  17. package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
  18. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +49 -0
  19. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  20. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  21. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
  22. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  23. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  24. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  25. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +20 -2
  26. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +93 -38
  27. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  28. package/lib/public/locales/en/TreeWidget.json +3 -0
  29. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/UseModelsTree.tsx"],"names":[],"mappings":";;AA2FA,sCAyKC;;AApQD;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAAoD;AACpD,gFAA4E;AAC5E,8EAA2G;AAC3G,0DAAoD;AACpD,qFAAkF;AAClF,2DAAmE;AACnE,qFAA+E;AAC/E,6EAAuE;AACvE,4EAAsE;AACtE,oEAA8D;AAC9D,8FAA8F;AAC9F,uEAAgG;AAoEhG;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,MAAM,EACN,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAAE,0BAA0B,GAC3B;IACnB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAuC,SAAS,CAAC,CAAC;IACtG,MAAM,sBAAsB,GAAG,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,uDAA6B;QAChC,GAAG,eAAe;KACnB,CAAC;IACF,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CACrC,CAAC;IACF,MAAM,EAAE,aAAa,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A,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyNode, HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache.js\";\nimport { ModelsTreeNode } from \"./internal/ModelsTreeNode.js\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition.js\";\n\nimport type { GroupingHierarchyNode, HierarchyFilteringPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition.js\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\n/** @beta */\nexport interface UseModelsTreeProps {\n /**\n * Optional search string used to filter tree nodes by label, as well as highlight matching substrings in the tree.\n * Nodes that do not contain this string in their label will be filtered out.\n *\n * If `getFilteredPaths` function is provided, it will take precedence and automatic filtering by this string will not be applied.\n * Instead, the string will be supplied to the given `getFilteredPaths` function for consumers to apply the filtering.\n */\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n /**\n * 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.\n *\n * When defined, this function takes precedence over filtering by `filter` string. If both are supplied, the `filter` is provided as an argument to `getFilteredPaths`.\n *\n * @param props Parameters provided when `getFilteredPaths` is called:\n * - `createInstanceKeyPaths`: Helper function to create filter paths.\n * - `filter`: The filter string which would otherwise be used for default filtering.\n *\n * **Example use cases:**\n * - You have a list of `InstanceKey` items, which you want to use for filtering the hierarchy.\n * - You want to create filter paths based on node label, but also apply some extra conditions (for example exclude paths with sub-models).\n * - You want to construct custom filtered paths. For example: create a filter path for each geometric element which has a parent element.\n *\n * @note Paths returned by `createInstanceKeyPaths` will not have `autoExpand` flag set. If you want nodes to be expanded, iterate over the paths and\n * set `autoExpand: true` manually.\n */\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<HierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[]>;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (props: { node: PresentationHierarchyNode; type: \"subject\" | \"model\" | \"category\" | \"element\" | \"elements-class-group\" }) => boolean;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\" | \"selectionPredicate\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"onNodeDoubleClick\">>;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate: nodeTypeSelectionPredicate,\n}: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory, onFilteredPathsChanged } = useCachedVisibility(\n activeView,\n hierarchyConfiguration,\n visibilityHandlerOverrides,\n );\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter) {\n onFilteredPathsChanged(undefined);\n }\n\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[], classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector);\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n filter,\n });\n void handlePaths(paths, imodelAccess);\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n });\n void handlePaths(paths, imodelAccess);\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return undefined;\n }, [filter, loadFocusedItems, getModelsTreeIdsCache, onFeatureUsed, getFilteredPaths, hierarchyConfiguration, onModelsFiltered, onFilteredPathsChanged]);\n\n const nodeSelectionPredicate = useCallback<NonNullable<VisibilityTreeProps[\"selectionPredicate\"]>>(\n (node) => {\n if (!nodeTypeSelectionPredicate) {\n return true;\n }\n return nodeTypeSelectionPredicate({ node, type: ModelsTreeNode.getType(node.nodeData) });\n },\n [nodeTypeSelectionPredicate],\n );\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths: getPaths,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n selectionPredicate: nodeSelectionPredicate,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModels = new Set<Id64String>();\n const targetSubjects = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === \"BisCore.Subject\") {\n targetSubjects.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, \"BisCore.GeometricModel3d\")) {\n targetModels.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjects]);\n return [...targetModels, ...matchingModels];\n}\n\nfunction getNoDataMessage(filter?: string, error?: ModelsTreeFilteringError) {\n if (isInstanceFocusError(error)) {\n return <InstanceFocusError error={error} />;\n }\n if (isFilterError(error)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n filteredPaths?: HierarchyFilteringPath[],\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides, filteredPaths });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const resetModelsTreeIdsCache = () => {\n cacheRef.current?.[Symbol.dispose]();\n cacheRef.current = undefined;\n };\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [filteredPaths, setFilteredPaths] = useState<HierarchyFilteringPath[]>();\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState<VisibilityTreeProps[\"visibilityHandlerFactory\"]>(() =>\n createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths),\n );\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n resetModelsTreeIdsCache();\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n return () => resetModelsTreeIdsCache();\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n onFilteredPathsChanged: useCallback((paths: HierarchyFilteringPath[] | undefined) => setFilteredPaths(paths), []),\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n );\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64String[];\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/UseModelsTree.tsx"],"names":[],"mappings":";;AA6GA,sCA0NC;;AAvUD;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAAoD;AACpD,gFAA4E;AAC5E,8EAAmI;AACnI,0DAAoD;AACpD,qFAAkF;AAClF,2DAAmE;AACnE,qFAA+E;AAC/E,6EAAuE;AACvE,iDAAiE;AACjE,4EAAsE;AACtE,oEAA8D;AAC9D,8FAA8F;AAC9F,uEAAgG;AAqFhG;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,MAAM,EACN,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAAE,0BAA0B,EAC9C,eAAe,GACI;IACnB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAuC,SAAS,CAAC,CAAC;IACtG,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAqC,SAAS,CAAC,CAAC;IAChG,MAAM,sBAAsB,GAAG,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,uDAA6B;QAChC,GAAG,eAAe;KACnB,CAAC;IACF,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CACrC,CAAC;IACF,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,GAAE,CAAC;IAEhD,MAAM,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,GAAG,mBAAmB,CACrG,UAAU,EACV,sBAAsB,EACtB,0BAA0B,CAC3B,CAAC;IACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,uDAA0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MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,OAAO,CACL,6DACG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAC/B,uBAAC,sBAAM,IACL,SAAS,QACT,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,OAAO,EAAE,EAAE,CAAC;gBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,0BAA0B,CAAC,EACxC,eAAe,EACf,iBAAiB,EACjB,WAAW,GAKZ;IACC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAEhG,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,sCAA2B,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACzG,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;IAC9B,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyFilteringPath, HierarchyNode, HierarchyNodeIdentifier, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { joinHierarchyFilteringPaths } from \"../common/Utils.js\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache.js\";\nimport { ModelsTreeNode } from \"./internal/ModelsTreeNode.js\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, HierarchyNodeIdentifiersPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition.js\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\ntype ModelsTreeSubTreeError = \"unknownSubTreeError\";\n\n/** @beta */\nexport interface UseModelsTreeProps {\n /**\n * Optional search string used to filter tree nodes by label, as well as highlight matching substrings in the tree.\n * Nodes that do not contain this string in their label will be filtered out.\n *\n * If `getFilteredPaths` function is provided, it will take precedence and automatic filtering by this string will not be applied.\n * Instead, the string will be supplied to the given `getFilteredPaths` function for consumers to apply the filtering.\n */\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n /**\n * 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.\n *\n * When defined, this function takes precedence over filtering by `filter` string. If both are supplied, the `filter` is provided as an argument to `getFilteredPaths`.\n *\n * @param props Parameters provided when `getFilteredPaths` is called:\n * - `createInstanceKeyPaths`: Helper function to create filter paths.\n * - `filter`: The filter string which would otherwise be used for default filtering.\n *\n * **Example use cases:**\n * - You have a list of `InstanceKey` items, which you want to use for filtering the hierarchy.\n * - You want to create filter paths based on node label, but also apply some extra conditions (for example exclude paths with sub-models).\n * - You want to construct custom filtered paths. For example: create a filter path for each geometric element which has a parent element.\n *\n * @note Paths returned by `createInstanceKeyPaths` will not have `autoExpand` flag set. If you want nodes to be expanded, iterate over the paths and\n * set `autoExpand: true` manually.\n */\n getFilteredPaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<HierarchyFilteringPath[]>;\n /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */\n filter?: string;\n }) => Promise<HierarchyFilteringPath[]>;\n /**\n * Optional function for restricting the visible hierarchy to a specific sub-tree of nodes, without changing how filtering works.\n *\n * Use when you want to display only part of the hierarchy, but still allow normal filtering within that sub-tree.\n *\n * When defined, only nodes that are in the provided paths or children of target nodes will be part of the hierarchy.\n * Filtering (by label or custom logic) will still apply within this sub-tree.\n *\n * Key difference:\n * - `getFilteredPaths` determines which nodes should be shown, giving you full control over filtering logic.\n * - `getSubTreePaths` restricts the hierarchy to a sub-tree, but does not override the filtering logic — filtering is still applied within the restricted sub-tree.\n */\n getSubTreePaths?: (props: {\n /** A function that creates filtering paths based on provided target instance keys. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> }) => Promise<HierarchyFilteringPath[]>;\n }) => Promise<HierarchyFilteringPath[]>;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (props: { node: PresentationHierarchyNode; type: \"subject\" | \"model\" | \"category\" | \"element\" | \"elements-class-group\" }) => boolean;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\" | \"selectionPredicate\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"onNodeDoubleClick\">>;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate: nodeTypeSelectionPredicate,\n getSubTreePaths,\n}: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const [subTreeError, setSubTreeError] = useState<ModelsTreeSubTreeError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory, onFilteredPathsChanged } = useCachedVisibility(\n activeView,\n hierarchyConfiguration,\n visibilityHandlerOverrides,\n );\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getSubTreePathsInternal = useMemo<\n ((...props: Parameters<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>) => Promise<HierarchyNodeIdentifiersPath[]>) | undefined\n >(() => {\n if (!getSubTreePaths) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getSubTreePaths({\n createInstanceKeyPaths: async ({ targetItems }) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n targetItems,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n });\n return paths.map((path) => HierarchyFilteringPath.normalize(path).path);\n } catch (e) {\n const newError = \"unknownSubTreeError\";\n setSubTreeError(newError);\n return [];\n }\n };\n }, [getModelsTreeIdsCache, hierarchyConfiguration, getSubTreePaths]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset filtered paths if there is no filters applied. This allows to keep current filtered paths until new paths are loaded.\n if (!loadFocusedItems && !getFilteredPaths && !filter && !getSubTreePathsInternal) {\n onFilteredPathsChanged(undefined);\n }\n\n const handlePaths = async (filteredPaths: HierarchyFilteringPath[], classInspector: ECClassHierarchyInspector) => {\n onFilteredPathsChanged(filteredPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = await getModels(filteredPaths, getModelsTreeIdsCache(), classInspector);\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n return await createFilteringPathsResult({\n getFilteringPaths: async () =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n }).then((createdPaths) => createdPaths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }))),\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () =>\n getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n }),\n filter,\n }),\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await createFilteringPathsResult({\n getFilteringPaths: async () =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n }).then((createdPaths) => createdPaths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }))),\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return getSubTreePathsInternal;\n }, [\n filter,\n loadFocusedItems,\n getModelsTreeIdsCache,\n onFeatureUsed,\n getFilteredPaths,\n hierarchyConfiguration,\n onModelsFiltered,\n onFilteredPathsChanged,\n getSubTreePathsInternal,\n ]);\n\n const nodeSelectionPredicate = useCallback<NonNullable<VisibilityTreeProps[\"selectionPredicate\"]>>(\n (node) => {\n if (!nodeTypeSelectionPredicate) {\n return true;\n }\n return nodeTypeSelectionPredicate({ node, type: ModelsTreeNode.getType(node.nodeData) });\n },\n [nodeTypeSelectionPredicate],\n );\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths: getPaths,\n noDataMessage: getNoDataMessage(filter, subTreeError, filteringError),\n highlight: filter ? { text: filter } : undefined,\n selectionPredicate: nodeSelectionPredicate,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nasync function getModels(paths: HierarchyFilteringPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModels = new Set<Id64String>();\n const targetSubjects = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === \"BisCore.Subject\") {\n targetSubjects.add(currStep.id);\n break;\n }\n\n // collect all the models from the filtered path\n if (await classInspector.classDerivesFrom(currStep.className, \"BisCore.GeometricModel3d\")) {\n targetModels.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await idsCache.getSubjectModelIds([...targetSubjects]);\n return [...targetModels, ...matchingModels];\n}\n\nfunction getNoDataMessage(filter?: string, subTreeError?: ModelsTreeSubTreeError, filteringError?: ModelsTreeFilteringError) {\n if (isSubTreeError(subTreeError)) {\n return <Text>{TreeWidget.translate(`modelsTree.subTree.${subTreeError}`)}</Text>;\n }\n if (isInstanceFocusError(filteringError)) {\n return <InstanceFocusError error={filteringError} />;\n }\n if (isFilterError(filteringError)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${filteringError}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isSubTreeError(error: ModelsTreeSubTreeError | undefined) {\n return error === \"unknownSubTreeError\";\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n filteredPaths?: HierarchyFilteringPath[],\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides, filteredPaths });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const resetModelsTreeIdsCache = () => {\n cacheRef.current?.[Symbol.dispose]();\n cacheRef.current = undefined;\n };\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [filteredPaths, setFilteredPaths] = useState<HierarchyFilteringPath[]>();\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState<VisibilityTreeProps[\"visibilityHandlerFactory\"]>(() =>\n createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths),\n );\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n resetModelsTreeIdsCache();\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides, filteredPaths));\n return () => resetModelsTreeIdsCache();\n }, [activeView, getModelsTreeIdsCache, overrides, filteredPaths]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n onFilteredPathsChanged: useCallback((paths: HierarchyFilteringPath[] | undefined) => setFilteredPaths(paths), []),\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n );\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64String[];\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n\nasync function createFilteringPathsResult({\n getSubTreePaths,\n getFilteringPaths,\n handlePaths,\n}: {\n getSubTreePaths: () => Promise<HierarchyNodeIdentifiersPath[] | undefined>;\n getFilteringPaths: () => Promise<HierarchyFilteringPath[]>;\n handlePaths: (filteredPaths: HierarchyFilteringPath[]) => Promise<void>;\n}): Promise<HierarchyFilteringPath[]> {\n const [subTreePaths, filterPaths] = await Promise.all([getSubTreePaths(), getFilteringPaths()]);\n\n const joinedPaths = !subTreePaths ? filterPaths : joinHierarchyFilteringPaths(subTreePaths, filterPaths);\n void handlePaths(joinedPaths);\n return joinedPaths;\n}\n"]}
@@ -49,10 +49,10 @@ export function useCategoriesTree({ filter, activeView, onCategoriesFiltered })
49
49
  if (!filter) {
50
50
  return undefined;
51
51
  }
52
- return async ({ imodelAccess }) => {
52
+ return async ({ imodelAccess, abortSignal }) => {
53
53
  onFeatureUsed({ featureId: "filtering", reportInteraction: true });
54
54
  try {
55
- const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType, idsCache });
55
+ const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType, idsCache, abortSignal });
56
56
  onCategoriesFiltered?.(await getCategoriesFromPaths(paths, idsCache));
57
57
  return paths;
58
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources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AAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;AACxC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useMemo, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition.js\";\nimport { CategoriesTreeIdsCache } from \"./internal/CategoriesTreeIdsCache.js\";\nimport { CategoriesVisibilityHandler } from \"./internal/CategoriesVisibilityHandler.js\";\nimport { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./internal/ClassNameDefinitions.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { ReactElement } from \"react\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\ntype HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>>;\n\n/** @beta */\nexport interface UseCategoriesTreeProps {\n filter: string;\n activeView: Viewport;\n onCategoriesFiltered?: (categories: CategoryInfo[] | undefined) => void;\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n categoriesTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"getSublabel\">>;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({ filter, activeView, onCategoriesFiltered }: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n\n const viewType = activeView.view.is2d() ? \"2d\" : \"3d\";\n const iModel = activeView.iModel;\n\n const idsCache = useMemo(() => {\n return new CategoriesTreeIdsCache(createECSqlQueryExecutor(iModel), viewType);\n }, [viewType, iModel]);\n\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n idsCache,\n });\n return {\n getVisibilityStatus: async (node: HierarchyNode) => visibilityHandler.getVisibilityStatus(node),\n changeVisibility: async (node: HierarchyNode, on: boolean) => visibilityHandler.changeVisibility(node, on),\n onVisibilityChange: visibilityHandler.onVisibilityChange,\n dispose: () => visibilityHandler.dispose(),\n };\n }, [activeView, idsCache]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType, idsCache });\n },\n [viewType, idsCache],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onCategoriesFiltered?.(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType, idsCache });\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, idsCache));\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, viewType, onFeatureUsed, onCategoriesFiltered, idsCache]);\n\n return {\n categoriesTreeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getFilteredPaths,\n visibilityHandlerFactory,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n getIcon,\n getSublabel,\n },\n };\n}\n\nasync function getCategoriesFromPaths(paths: HierarchyFilteringPaths, idsCache: CategoriesTreeIdsCache): Promise<CategoryInfo[] | undefined> {\n if (!paths) {\n return undefined;\n }\n\n const categories = new Map<Id64String, Id64String[]>();\n for (const path of paths) {\n const currPath = HierarchyFilteringPath.normalize(path).path;\n if (currPath.length === 0) {\n continue;\n }\n\n let category: HierarchyNodeIdentifier;\n let subCategory: HierarchyNodeIdentifier | undefined;\n const lastNode = currPath[currPath.length - 1];\n\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(lastNode)) {\n continue;\n }\n\n if (lastNode.className === DEFINITION_CONTAINER_CLASS) {\n const definitionContainerCategories = await idsCache.getAllContainedCategories([lastNode.id]);\n for (const categoryId of definitionContainerCategories) {\n const value = categories.get(categoryId);\n if (value === undefined) {\n categories.set(categoryId, []);\n }\n }\n continue;\n }\n\n if (lastNode.className === SUB_CATEGORY_CLASS) {\n const secondToLastNode = currPath.length > 1 ? currPath[currPath.length - 2] : undefined;\n assert(secondToLastNode !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(secondToLastNode));\n\n subCategory = lastNode;\n category = secondToLastNode;\n } else {\n category = lastNode;\n }\n\n let entry = categories.get(category.id);\n if (entry === undefined) {\n entry = [];\n categories.set(category.id, entry);\n }\n\n if (subCategory) {\n entry.push(subCategory.id);\n }\n }\n\n return [...categories.entries()].map(([categoryId, subCategoryIds]) => ({\n categoryId,\n subCategoryIds: subCategoryIds.length === 0 ? undefined : subCategoryIds,\n }));\n}\n\nfunction getNoDataMessage(filter: string, error?: CategoriesTreeFilteringError) {\n if (error) {\n return <Text>{TreeWidget.translate(`categoriesTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"categoriesTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction SvgLayersIsolate() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <g>\n <path d=\"M13,3.4938L6.5,0L0,3.4938l6.5,3.4938L13,3.4938z\" />\n <polygon points=\"6.5,8.21 7,7.94 7,9.24 6.5,9.51 0,6.01 1.22,5.36 \" />\n <polygon points=\"13,6.01 11.16,7 8.74,7 11.78,5.36 \" />\n <polygon points=\"7,10.37 7,11.67 6.5,11.94 0,8.45 1.22,7.8 6.5,10.64 \" />\n </g>\n <g transform=\"translate(-1-1)\">\n <path d=\"M9,13.5714h3.4286V17H9V13.5714z\" />\n <path d=\"M9,9v3.4286h3.4286V9H9z M11.8571,11.8571H9.5714V9.5714h2.2857V11.8571z\" />\n <path d=\"M13.5714,9v3.4286H17V9H13.5714 M16.4286,11.8571h-2.2857V9.5714h2.2857V11.8571\" />\n <path d=\"M13.5714,13.5714V17H17v-3.4286H13.5714z M16.4286,16.4286h-2.2857v-2.2857h2.2857V16.4286z\" />\n </g>\n </svg>\n );\n}\n\nfunction SvgBisDefinitionContainer() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" style={{ color: \"#7d7d7d\" }} viewBox=\"0 0 16 16\">\n <path\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n d=\"M7.748 1.726a.5.5 0 0 1 .504 0L13.008 4.5 8 7.421l-5.008-2.92 4.756-2.775ZM2.5 5.37v2.342l2 1.166V6.537l-2-1.166Zm3 1.75v2.342l2 1.167V8.287l-2-1.166Zm3 1.166v2.342l2-1.166V7.12l-2 1.166Zm3-1.75V8.88l2-1.166V5.37l-2 1.166Zm0 3.5 2-1.166v2.055a.5.5 0 0 1-.248.432L11.5 12.379v-2.342Zm-3 1.75 2-1.167v2.343l-2 1.167v-2.343Zm-3-1.167 2 1.167v2.342l-2-1.166V10.62Zm-3-1.75 2 1.167v2.342l-1.752-1.021a.5.5 0 0 1-.248-.432V8.87ZM8.756.863a1.5 1.5 0 0 0-1.512 0l-5 2.917A1.5 1.5 0 0 0 1.5 5.074v5.852a1.5 1.5 0 0 0 .744 1.295l5 2.917a1.5 1.5 0 0 0 1.512 0l5-2.917a1.5 1.5 0 0 0 .744-1.295V5.074a1.5 1.5 0 0 0-.744-1.295l-5-2.917Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n );\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-layers-isolate\":\n return <SvgLayersIsolate />;\n case \"icon-definition-container\":\n return <SvgBisDefinitionContainer />;\n }\n\n return undefined;\n}\n\nfunction getSublabel(node: PresentationHierarchyNode) {\n return node.extendedData?.description;\n}\n"]}
1
+ {"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,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4B,EAAC,OAAO,EAAC,WAAW,aACzD,wBACE,eAAM,CAAC,EAAC,iDAAiD,GAAG,EAC5D,kBAAS,MAAM,EAAC,oDAAoD,GAAG,EACvE,kBAAS,MAAM,EAAC,qCAAqC,GAAG,EACxD,kBAAS,MAAM,EAAC,uDAAuD,GAAG,IACxE,EACJ,aAAG,SAAS,EAAC,iBAAiB,aAC5B,eAAM,CAAC,EAAC,iCAAiC,GAAG,EAC5C,eAAM,CAAC,EAAC,wEAAwE,GAAG,EACnF,eAAM,CAAC,EAAC,+EAA+E,GAAG,EAC1F,eAAM,CAAC,EAAC,0FAA0F,GAAG,IACnG,IACA,CACP,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB;IAChC,OAAO,CACL,cAAK,KAAK,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAC,WAAW,YACtF,eACE,IAAI,EAAC,cAAc,EACnB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,gnBAAgnB,EAClnB,QAAQ,EAAC,SAAS,GAClB,GACE,CACP,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,IAA+B;IAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAClC,KAAK,aAAa;YAChB,OAAO,KAAC,SAAS,KAAG,CAAC;QACvB,KAAK,qBAAqB;YACxB,OAAO,KAAC,gBAAgB,KAAG,CAAC;QAC9B,KAAK,2BAA2B;YAC9B,OAAO,KAAC,yBAAyB,KAAG,CAAC;IACzC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;AACxC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useMemo, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext.js\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition.js\";\nimport { CategoriesTreeIdsCache } from \"./internal/CategoriesTreeIdsCache.js\";\nimport { CategoriesVisibilityHandler } from \"./internal/CategoriesVisibilityHandler.js\";\nimport { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./internal/ClassNameDefinitions.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { ReactElement } from \"react\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\ntype HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>>;\n\n/** @beta */\nexport interface UseCategoriesTreeProps {\n filter: string;\n activeView: Viewport;\n onCategoriesFiltered?: (categories: CategoryInfo[] | undefined) => void;\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n categoriesTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getIcon\" | \"getSublabel\">>;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({ filter, activeView, onCategoriesFiltered }: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n\n const viewType = activeView.view.is2d() ? \"2d\" : \"3d\";\n const iModel = activeView.iModel;\n\n const idsCache = useMemo(() => {\n return new CategoriesTreeIdsCache(createECSqlQueryExecutor(iModel), viewType);\n }, [viewType, iModel]);\n\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n idsCache,\n });\n return {\n getVisibilityStatus: async (node: HierarchyNode) => visibilityHandler.getVisibilityStatus(node),\n changeVisibility: async (node: HierarchyNode, on: boolean) => visibilityHandler.changeVisibility(node, on),\n onVisibilityChange: visibilityHandler.onVisibilityChange,\n dispose: () => visibilityHandler.dispose(),\n };\n }, [activeView, idsCache]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType, idsCache });\n },\n [viewType, idsCache],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n onCategoriesFiltered?.(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType, idsCache, abortSignal });\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, idsCache));\n return paths;\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, viewType, onFeatureUsed, onCategoriesFiltered, idsCache]);\n\n return {\n categoriesTreeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getFilteredPaths,\n visibilityHandlerFactory,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n getIcon,\n getSublabel,\n },\n };\n}\n\nasync function getCategoriesFromPaths(paths: HierarchyFilteringPaths, idsCache: CategoriesTreeIdsCache): Promise<CategoryInfo[] | undefined> {\n if (!paths) {\n return undefined;\n }\n\n const categories = new Map<Id64String, Id64String[]>();\n for (const path of paths) {\n const currPath = HierarchyFilteringPath.normalize(path).path;\n if (currPath.length === 0) {\n continue;\n }\n\n let category: HierarchyNodeIdentifier;\n let subCategory: HierarchyNodeIdentifier | undefined;\n const lastNode = currPath[currPath.length - 1];\n\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(lastNode)) {\n continue;\n }\n\n if (lastNode.className === DEFINITION_CONTAINER_CLASS) {\n const definitionContainerCategories = await idsCache.getAllContainedCategories([lastNode.id]);\n for (const categoryId of definitionContainerCategories) {\n const value = categories.get(categoryId);\n if (value === undefined) {\n categories.set(categoryId, []);\n }\n }\n continue;\n }\n\n if (lastNode.className === SUB_CATEGORY_CLASS) {\n const secondToLastNode = currPath.length > 1 ? currPath[currPath.length - 2] : undefined;\n assert(secondToLastNode !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(secondToLastNode));\n\n subCategory = lastNode;\n category = secondToLastNode;\n } else {\n category = lastNode;\n }\n\n let entry = categories.get(category.id);\n if (entry === undefined) {\n entry = [];\n categories.set(category.id, entry);\n }\n\n if (subCategory) {\n entry.push(subCategory.id);\n }\n }\n\n return [...categories.entries()].map(([categoryId, subCategoryIds]) => ({\n categoryId,\n subCategoryIds: subCategoryIds.length === 0 ? undefined : subCategoryIds,\n }));\n}\n\nfunction getNoDataMessage(filter: string, error?: CategoriesTreeFilteringError) {\n if (error) {\n return <Text>{TreeWidget.translate(`categoriesTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"categoriesTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction SvgLayersIsolate() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <g>\n <path d=\"M13,3.4938L6.5,0L0,3.4938l6.5,3.4938L13,3.4938z\" />\n <polygon points=\"6.5,8.21 7,7.94 7,9.24 6.5,9.51 0,6.01 1.22,5.36 \" />\n <polygon points=\"13,6.01 11.16,7 8.74,7 11.78,5.36 \" />\n <polygon points=\"7,10.37 7,11.67 6.5,11.94 0,8.45 1.22,7.8 6.5,10.64 \" />\n </g>\n <g transform=\"translate(-1-1)\">\n <path d=\"M9,13.5714h3.4286V17H9V13.5714z\" />\n <path d=\"M9,9v3.4286h3.4286V9H9z M11.8571,11.8571H9.5714V9.5714h2.2857V11.8571z\" />\n <path d=\"M13.5714,9v3.4286H17V9H13.5714 M16.4286,11.8571h-2.2857V9.5714h2.2857V11.8571\" />\n <path d=\"M13.5714,13.5714V17H17v-3.4286H13.5714z M16.4286,16.4286h-2.2857v-2.2857h2.2857V16.4286z\" />\n </g>\n </svg>\n );\n}\n\nfunction SvgBisDefinitionContainer() {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" style={{ color: \"#7d7d7d\" }} viewBox=\"0 0 16 16\">\n <path\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n d=\"M7.748 1.726a.5.5 0 0 1 .504 0L13.008 4.5 8 7.421l-5.008-2.92 4.756-2.775ZM2.5 5.37v2.342l2 1.166V6.537l-2-1.166Zm3 1.75v2.342l2 1.167V8.287l-2-1.166Zm3 1.166v2.342l2-1.166V7.12l-2 1.166Zm3-1.75V8.88l2-1.166V5.37l-2 1.166Zm0 3.5 2-1.166v2.055a.5.5 0 0 1-.248.432L11.5 12.379v-2.342Zm-3 1.75 2-1.167v2.343l-2 1.167v-2.343Zm-3-1.167 2 1.167v2.342l-2-1.166V10.62Zm-3-1.75 2 1.167v2.342l-1.752-1.021a.5.5 0 0 1-.248-.432V8.87ZM8.756.863a1.5 1.5 0 0 0-1.512 0l-5 2.917A1.5 1.5 0 0 0 1.5 5.074v5.852a1.5 1.5 0 0 0 .744 1.295l5 2.917a1.5 1.5 0 0 0 1.512 0l5-2.917a1.5 1.5 0 0 0 .744-1.295V5.074a1.5 1.5 0 0 0-.744-1.295l-5-2.917Z\"\n clipRule=\"evenodd\"\n />\n </svg>\n );\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-layers-isolate\":\n return <SvgLayersIsolate />;\n case \"icon-definition-container\":\n return <SvgBisDefinitionContainer />;\n }\n\n return undefined;\n}\n\nfunction getSublabel(node: PresentationHierarchyNode) {\n return node.extendedData?.description;\n}\n"]}
@@ -1,4 +1,6 @@
1
+ import { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
1
2
  import type { Id64Array } from "@itwin/core-bentley";
3
+ import type { HierarchyNodeIdentifiersPath } from "@itwin/presentation-hierarchies";
2
4
  /** @beta */
3
5
  export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
4
6
  /** @internal */
@@ -9,4 +11,6 @@ export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
9
11
  export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
10
12
  /** @internal */
11
13
  export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
14
+ /** @internal */
15
+ export declare function joinHierarchyFilteringPaths(subTreePaths: HierarchyNodeIdentifiersPath[], filteringPaths: HierarchyFilteringPath[]): HierarchyFilteringPath[];
12
16
  //# sourceMappingURL=Utils.d.ts.map
@@ -3,6 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { useEffect, useRef } from "react";
6
+ import { HierarchyFilteringPath, HierarchyNodeIdentifier } from "@itwin/presentation-hierarchies";
6
7
  /** @internal */
7
8
  export function createIdsSelector(ids) {
8
9
  // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
@@ -41,4 +42,52 @@ export function useLatest(value) {
41
42
  }, [value]);
42
43
  return ref;
43
44
  }
45
+ /** @internal */
46
+ export function joinHierarchyFilteringPaths(subTreePaths, filteringPaths) {
47
+ const normalizedFilteringPaths = filteringPaths.map((filteringPath) => HierarchyFilteringPath.normalize(filteringPath));
48
+ const result = new Array();
49
+ const filteringPathsToIncludeIndexes = new Set();
50
+ subTreePaths.forEach((subTreePath) => {
51
+ let options;
52
+ let addSubTreePathToResult = false;
53
+ for (let i = 0; i < normalizedFilteringPaths.length; ++i) {
54
+ const normalizedFilteringPath = normalizedFilteringPaths[i];
55
+ if (normalizedFilteringPath.path.length === 0) {
56
+ continue;
57
+ }
58
+ for (let j = 0; j < subTreePath.length; ++j) {
59
+ const identifier = subTreePath[j];
60
+ if (normalizedFilteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {
61
+ break;
62
+ }
63
+ // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result
64
+ if (normalizedFilteringPath.path.length === j + 1) {
65
+ addSubTreePathToResult = true;
66
+ // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node
67
+ // This is done by setting depthInPath
68
+ options =
69
+ normalizedFilteringPath.options?.autoExpand !== true
70
+ ? HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)
71
+ : { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };
72
+ break;
73
+ }
74
+ // filtering paths that are longer than subTree paths need to be added to the result
75
+ if (subTreePath.length === j + 1) {
76
+ addSubTreePathToResult = true;
77
+ filteringPathsToIncludeIndexes.add(i);
78
+ }
79
+ }
80
+ }
81
+ if (addSubTreePathToResult) {
82
+ result.push({
83
+ path: subTreePath,
84
+ options,
85
+ });
86
+ }
87
+ });
88
+ for (const index of filteringPathsToIncludeIndexes) {
89
+ result.push(normalizedFilteringPaths[index]);
90
+ }
91
+ return result;
92
+ }
44
93
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO1C,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC9C,sHAAsH;IACtH,oCAAoC;IACpC,MAAM,MAAM,GAAG,IAAI,KAAK,EAAgB,CAAC;IACzC,KAAK,IAAI,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI,GAAG,EAAE,CAAC;QACnF,IAAI,aAAa,GAAuB,eAAe,GAAG,GAAG,CAAC;QAC9D,IAAI,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;YAC/B,aAAa,GAAG,SAAS,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,cAAc,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAc,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACzH,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CAAC,cAAmB;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAA8B,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,EAAc,CAAC,CAAC;AAClJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAe,SAAiC,EAAE,GAAS,EAAE,KAAa;IACjG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef } from \"react\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,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AI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef } from \"react\";\nimport { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPathOptions, HierarchyNodeIdentifiersPath } from \"@itwin/presentation-hierarchies\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\n/** @internal */\nexport function joinHierarchyFilteringPaths(subTreePaths: HierarchyNodeIdentifiersPath[], filteringPaths: HierarchyFilteringPath[]): HierarchyFilteringPath[] {\n const normalizedFilteringPaths = filteringPaths.map((filteringPath) => HierarchyFilteringPath.normalize(filteringPath));\n\n const result = new Array<HierarchyFilteringPath>();\n const filteringPathsToIncludeIndexes = new Set<number>();\n\n subTreePaths.forEach((subTreePath) => {\n let options: HierarchyFilteringPathOptions | undefined;\n let addSubTreePathToResult = false;\n\n for (let i = 0; i < normalizedFilteringPaths.length; ++i) {\n const normalizedFilteringPath = normalizedFilteringPaths[i];\n if (normalizedFilteringPath.path.length === 0) {\n continue;\n }\n\n for (let j = 0; j < subTreePath.length; ++j) {\n const identifier = subTreePath[j];\n if (normalizedFilteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {\n break;\n }\n\n // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result\n if (normalizedFilteringPath.path.length === j + 1) {\n addSubTreePathToResult = true;\n // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node\n // This is done by setting depthInPath\n options =\n normalizedFilteringPath.options?.autoExpand !== true\n ? HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)\n : { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };\n break;\n }\n\n // filtering paths that are longer than subTree paths need to be added to the result\n if (subTreePath.length === j + 1) {\n addSubTreePathToResult = true;\n filteringPathsToIncludeIndexes.add(i);\n }\n }\n }\n\n if (addSubTreePathToResult) {\n result.push({\n path: subTreePath,\n options,\n });\n }\n });\n for (const index of filteringPathsToIncludeIndexes) {\n result.push(normalizedFilteringPaths[index]);\n }\n return result;\n}\n"]}
@@ -7,5 +7,5 @@ export type ModelsTreeProps = Pick<VisibilityTreeProps, "imodel" | "getSchemaCon
7
7
  };
8
8
  };
9
9
  /** @beta */
10
- export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }: ModelsTreeProps): JSX.Element;
10
+ export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }: ModelsTreeProps): JSX.Element;
11
11
  //# sourceMappingURL=ModelsTree.d.ts.map
@@ -7,7 +7,7 @@ import { VisibilityTree } from "../common/components/VisibilityTree.js";
7
7
  import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer.js";
8
8
  import { useModelsTree } from "./UseModelsTree.js";
9
9
  /** @beta */
10
- export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }) {
10
+ export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }) {
11
11
  const { modelsTreeProps, rendererProps } = useModelsTree({
12
12
  activeView,
13
13
  filter,
@@ -16,6 +16,7 @@ export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeV
16
16
  getFilteredPaths,
17
17
  onModelsFiltered,
18
18
  selectionPredicate,
19
+ getSubTreePaths,
19
20
  });
20
21
  return (_jsx(VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => _jsx(VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GACA;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;KACnB,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,cAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,sBAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACC;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,cAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,sBAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n getSubTreePaths,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n getSubTreePaths,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { ModelsTreeProps } from "./ModelsTree.js";
2
2
  import type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from "./ModelsTreeButtons.js";
3
3
  /** @public */
4
- interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths"> {
4
+ interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths" | "getSubTreePaths"> {
5
5
  /**
6
6
  * Renderers of header buttons. Defaults to:
7
7
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC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W,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,KAAC,0BAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA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a,GAAI;YACrG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACtG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,KAAC,0BAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n | \"getSubTreePaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
1
+ import { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
2
2
  import type { Id64String } from "@itwin/core-bentley";
3
3
  import type { InstanceKey } from "@itwin/presentation-shared";
4
4
  import type { Viewport } from "@itwin/core-frontend";
@@ -47,6 +47,24 @@ export interface UseModelsTreeProps {
47
47
  /** Filter which would be used to create filter paths if `getFilteredPaths` wouldn't be provided. */
48
48
  filter?: string;
49
49
  }) => Promise<HierarchyFilteringPath[]>;
50
+ /**
51
+ * Optional function for restricting the visible hierarchy to a specific sub-tree of nodes, without changing how filtering works.
52
+ *
53
+ * Use when you want to display only part of the hierarchy, but still allow normal filtering within that sub-tree.
54
+ *
55
+ * When defined, only nodes that are in the provided paths or children of target nodes will be part of the hierarchy.
56
+ * Filtering (by label or custom logic) will still apply within this sub-tree.
57
+ *
58
+ * Key difference:
59
+ * - `getFilteredPaths` determines which nodes should be shown, giving you full control over filtering logic.
60
+ * - `getSubTreePaths` restricts the hierarchy to a sub-tree, but does not override the filtering logic — filtering is still applied within the restricted sub-tree.
61
+ */
62
+ getSubTreePaths?: (props: {
63
+ /** A function that creates filtering paths based on provided target instance keys. */
64
+ createInstanceKeyPaths: (props: {
65
+ targetItems: Array<InstanceKey | ElementsGroupInfo>;
66
+ }) => Promise<HierarchyFilteringPath[]>;
67
+ }) => Promise<HierarchyFilteringPath[]>;
50
68
  onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;
51
69
  /**
52
70
  * An optional predicate to allow or prohibit selection of a node.
@@ -66,6 +84,6 @@ interface UseModelsTreeResult {
66
84
  * Custom hook to create and manage state for the models tree.
67
85
  * @beta
68
86
  */
69
- export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, selectionPredicate: nodeTypeSelectionPredicate, }: UseModelsTreeProps): UseModelsTreeResult;
87
+ export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, selectionPredicate: nodeTypeSelectionPredicate, getSubTreePaths, }: UseModelsTreeProps): UseModelsTreeResult;
70
88
  export {};
71
89
  //# sourceMappingURL=UseModelsTree.d.ts.map