@itwin/tree-widget-react 3.15.1 → 3.16.1
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.
- package/CHANGELOG.md +22 -2
- package/lib/cjs/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/cjs/tree-widget-react/TreeWidget.js +12 -12
- package/lib/cjs/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -4
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -21
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js +14 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +20 -16
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js +46 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +68 -39
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +20 -14
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +66 -60
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +155 -177
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/esm/tree-widget-react/TreeWidget.js +12 -12
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -20
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +21 -17
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +44 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +70 -41
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +22 -16
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +67 -61
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +157 -179
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";;AAqDA,8CA6EC;;AAlID;;;gGAGgG;AAEhG,iCAAuD;AACvD,sDAA6C;AAC7C,oEAAuD;AACvD,wDAA4C;AAC5C,gFAA4E;AAC5E,8EAAkG;AAClG,0DAAoD;AACpD,mFAA6E;AAC7E,2DAAmE;AACnE,6EAAuE;AACvE,+EAAyE;AACzE,oFAA8E;AAC9E,8FAAwF;AACxF,gFAAoG;AA+BpG;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAA0B;IACpG,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAA4C,CAAC;IAEjG,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAEjC,MAAM,EAAE,QAAQ,EAAE,yBAAyB,EAAE,GAAG,IAAA,4BAAW,EAAoD;QAC7G,MAAM,EAAE,MAAM;QACd,WAAW;QACX,kBAAkB,EAAE,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9D,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,IAAI,4DAA2B,CAAC;YACxD,QAAQ,EAAE,UAAU;YACpB,QAAQ,EAAE,yBAAyB,EAAE;SACtC,C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AAS,WAAW,CAAC,KAAkD;IACrE,OAAO,IAAI,kDAAsB,CAAC,IAAA,oDAAwB,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AAC1G,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 { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.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 { ReactElement } from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.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 { getCache: getCategoriesTreeIdsCache } = useIdsCache<CategoriesTreeIdsCache, { viewType: \"2d\" | \"3d\" }>({\n imodel: iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ viewType }), [viewType]),\n });\n\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n idsCache: getCategoriesTreeIdsCache(),\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, getCategoriesTreeIdsCache]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType, idsCache: getCategoriesTreeIdsCache() });\n },\n [viewType, getCategoriesTreeIdsCache],\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({\n imodelAccess,\n label: filter,\n viewType,\n idsCache: getCategoriesTreeIdsCache(),\n abortSignal,\n });\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache()));\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, getCategoriesTreeIdsCache]);\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\nfunction createCache(props: CreateCacheProps<{ viewType: \"2d\" | \"3d\" }>) {\n return new CategoriesTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.viewType);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";;AAqDA,8CA+EC;;AApID;;;gGAGgG;AAEhG,iCAAuD;AACvD,sDAA6C;AAC7C,oEAAuD;AACvD,wDAA4C;AAC5C,gFAA4E;AAC5E,8EAAkG;AAClG,0DAAoD;AACpD,mFAA6E;AAC7E,2DAAmE;AACnE,qDAA+C;AAC/C,6EAAuE;AACvE,+EAAyE;AACzE,oFAA8E;AAC9E,8FAAwF;AACxF,gFAAoG;AA8BpG;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAA0B;IACpG,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAA4C,CAAC;IAEjG,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,MAAM,WAAW,GAAG,IAAA,oBAAO,GAAE,CAAC;IAC9B,MAAM,EAAE,QAAQ,EAAE,yBAAyB,EAAE,GAAG,IAAA,4BAAW,EAAoD;QAC7G,MAAM,EAAE,MAAM;QACd,WAAW;QACX,kBAAkB,EAAE,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC7D,WAAW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G,CAAC;QAC9B,KAAK,2BAA2B;YAC9B,OAAO,uBAAC,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;AAED,SAAS,WAAW,CAAC,KAAkD;IACrE,OAAO,IAAI,kDAAsB,CAAC,IAAA,oDAAwB,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AAC7H,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 { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\nimport { useGuid } from \"../common/useGuid.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 { ReactElement } from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\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 const componentId = useGuid();\n const { getCache: getCategoriesTreeIdsCache } = useIdsCache<CategoriesTreeIdsCache, { viewType: \"2d\" | \"3d\" }>({\n imodel: iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ viewType }), [viewType]),\n componentId,\n });\n\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n idsCache: getCategoriesTreeIdsCache(),\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, getCategoriesTreeIdsCache]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType, idsCache: getCategoriesTreeIdsCache() });\n },\n [viewType, getCategoriesTreeIdsCache],\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({\n imodelAccess,\n label: filter,\n viewType,\n idsCache: getCategoriesTreeIdsCache(),\n abortSignal,\n componentId,\n });\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache()));\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, getCategoriesTreeIdsCache, componentId]);\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\nfunction createCache(props: CreateCacheProps<{ viewType: \"2d\" | \"3d\" }>) {\n return new CategoriesTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.viewType, props.componentId);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Id64Array, Id64String } from "@itwin/core-bentley";
|
|
1
|
+
import type { GuidString, Id64Array, Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
4
4
|
interface CategoryInfo {
|
|
@@ -7,16 +7,8 @@ interface CategoryInfo {
|
|
|
7
7
|
}
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare class CategoriesTreeIdsCache implements Disposable {
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
private _modelsCategoriesInfo;
|
|
13
|
-
private _subCategoriesInfo;
|
|
14
|
-
private _elementModelsCategories;
|
|
15
|
-
private _categoryClass;
|
|
16
|
-
private _categoryElementClass;
|
|
17
|
-
private _categoryModelClass;
|
|
18
|
-
private _isDefinitionContainerSupported;
|
|
19
|
-
constructor(_queryExecutor: LimitingECSqlQueryExecutor, viewType: "3d" | "2d");
|
|
10
|
+
#private;
|
|
11
|
+
constructor(queryExecutor: LimitingECSqlQueryExecutor, viewType: "3d" | "2d", componentId?: GuidString);
|
|
20
12
|
[Symbol.dispose](): void;
|
|
21
13
|
private queryElementModelCategories;
|
|
22
14
|
private queryCategories;
|
|
@@ -6,35 +6,44 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CategoriesTreeIdsCache = void 0;
|
|
8
8
|
exports.getClassesByView = getClassesByView;
|
|
9
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
10
|
const ClassNameDefinitions_js_1 = require("./ClassNameDefinitions.js");
|
|
10
11
|
/** @internal */
|
|
11
12
|
class CategoriesTreeIdsCache {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
#definitionContainersInfo;
|
|
14
|
+
#modelsCategoriesInfo;
|
|
15
|
+
#subCategoriesInfo;
|
|
16
|
+
#elementModelsCategories;
|
|
17
|
+
#categoryClass;
|
|
18
|
+
#categoryElementClass;
|
|
19
|
+
#categoryModelClass;
|
|
20
|
+
#isDefinitionContainerSupported;
|
|
21
|
+
#queryExecutor;
|
|
22
|
+
#componentId;
|
|
23
|
+
#componentName;
|
|
24
|
+
constructor(queryExecutor, viewType, componentId) {
|
|
25
|
+
this.#queryExecutor = queryExecutor;
|
|
23
26
|
const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);
|
|
24
|
-
this
|
|
25
|
-
this
|
|
26
|
-
this
|
|
27
|
+
this.#categoryClass = categoryClass;
|
|
28
|
+
this.#categoryElementClass = categoryElementClass;
|
|
29
|
+
this.#categoryModelClass = categoryModelClass;
|
|
30
|
+
this.#componentId = componentId ?? core_bentley_1.Guid.createValue();
|
|
31
|
+
this.#componentName = "CategoriesTreeIdsCache";
|
|
27
32
|
}
|
|
28
33
|
[Symbol.dispose]() { }
|
|
29
34
|
async *queryElementModelCategories() {
|
|
30
35
|
const query = `
|
|
31
36
|
SELECT this.Model.Id modelId, this.Category.Id categoryId
|
|
32
|
-
FROM ${this
|
|
33
|
-
JOIN ${this
|
|
37
|
+
FROM ${this.#categoryModelClass} m
|
|
38
|
+
JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id
|
|
34
39
|
WHERE m.IsPrivate = false
|
|
35
40
|
GROUP BY modelId, categoryId
|
|
36
41
|
`;
|
|
37
|
-
for await (const row of this.
|
|
42
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, {
|
|
43
|
+
rowFormat: "ECSqlPropertyNames",
|
|
44
|
+
limit: "unbounded",
|
|
45
|
+
restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,
|
|
46
|
+
})) {
|
|
38
47
|
yield { modelId: row.modelId, categoryId: row.categoryId };
|
|
39
48
|
}
|
|
40
49
|
}
|
|
@@ -53,16 +62,16 @@ class CategoriesTreeIdsCache {
|
|
|
53
62
|
)`
|
|
54
63
|
: "false"} parentDefinitionContainerExists
|
|
55
64
|
FROM
|
|
56
|
-
${this
|
|
65
|
+
${this.#categoryClass} this
|
|
57
66
|
JOIN ${ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId
|
|
58
67
|
JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id
|
|
59
68
|
WHERE
|
|
60
69
|
NOT this.IsPrivate
|
|
61
70
|
AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))
|
|
62
|
-
AND EXISTS (SELECT 1 FROM ${this
|
|
71
|
+
AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)
|
|
63
72
|
GROUP BY this.ECInstanceId
|
|
64
73
|
`;
|
|
65
|
-
for await (const row of this.
|
|
74
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/categories` })) {
|
|
66
75
|
yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };
|
|
67
76
|
}
|
|
68
77
|
}
|
|
@@ -77,7 +86,7 @@ class CategoriesTreeIdsCache {
|
|
|
77
86
|
s.Name = 'BisCore'
|
|
78
87
|
AND c.Name = 'DefinitionContainer'
|
|
79
88
|
`;
|
|
80
|
-
for await (const _row of this.
|
|
89
|
+
for await (const _row of this.#queryExecutor.createQueryReader({ ecsql: query }, { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` })) {
|
|
81
90
|
return true;
|
|
82
91
|
}
|
|
83
92
|
return false;
|
|
@@ -97,7 +106,7 @@ class CategoriesTreeIdsCache {
|
|
|
97
106
|
FROM
|
|
98
107
|
${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} dc
|
|
99
108
|
WHERE
|
|
100
|
-
dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this
|
|
109
|
+
dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this.#categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))
|
|
101
110
|
AND NOT dc.IsPrivate
|
|
102
111
|
|
|
103
112
|
UNION ALL
|
|
@@ -116,7 +125,7 @@ class CategoriesTreeIdsCache {
|
|
|
116
125
|
const definitionsQuery = `
|
|
117
126
|
SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId
|
|
118
127
|
`;
|
|
119
|
-
for await (const row of this.
|
|
128
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` })) {
|
|
120
129
|
yield { id: row.id, modelId: row.modelId };
|
|
121
130
|
}
|
|
122
131
|
}
|
|
@@ -131,12 +140,12 @@ class CategoriesTreeIdsCache {
|
|
|
131
140
|
NOT sc.IsPrivate
|
|
132
141
|
AND sc.Parent.Id IN (${categoriesInfo.join(",")})
|
|
133
142
|
`;
|
|
134
|
-
for await (const row of this.
|
|
143
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` })) {
|
|
135
144
|
yield { id: row.id, parentId: row.categoryId };
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
async getModelsCategoriesInfo() {
|
|
139
|
-
this
|
|
148
|
+
this.#modelsCategoriesInfo ??= (async () => {
|
|
140
149
|
const allModelsCategories = new Map();
|
|
141
150
|
for await (const queriedCategory of this.queryCategories()) {
|
|
142
151
|
let modelCategories = allModelsCategories.get(queriedCategory.modelId);
|
|
@@ -148,10 +157,10 @@ class CategoriesTreeIdsCache {
|
|
|
148
157
|
}
|
|
149
158
|
return allModelsCategories;
|
|
150
159
|
})();
|
|
151
|
-
return this
|
|
160
|
+
return this.#modelsCategoriesInfo;
|
|
152
161
|
}
|
|
153
162
|
async getElementModelsCategories() {
|
|
154
|
-
this
|
|
163
|
+
this.#elementModelsCategories ??= (async () => {
|
|
155
164
|
const elementModelsCategories = new Map();
|
|
156
165
|
for await (const queriedCategory of this.queryElementModelCategories()) {
|
|
157
166
|
let modelEntry = elementModelsCategories.get(queriedCategory.modelId);
|
|
@@ -163,10 +172,10 @@ class CategoriesTreeIdsCache {
|
|
|
163
172
|
}
|
|
164
173
|
return elementModelsCategories;
|
|
165
174
|
})();
|
|
166
|
-
return this
|
|
175
|
+
return this.#elementModelsCategories;
|
|
167
176
|
}
|
|
168
177
|
async getSubCategoriesInfo() {
|
|
169
|
-
this
|
|
178
|
+
this.#subCategoriesInfo ??= (async () => {
|
|
170
179
|
const allSubCategories = new Map();
|
|
171
180
|
const modelsCategoriesInfo = await this.getModelsCategoriesInfo();
|
|
172
181
|
const categoriesWithMoreThanOneSubCategory = new Array();
|
|
@@ -181,10 +190,10 @@ class CategoriesTreeIdsCache {
|
|
|
181
190
|
}
|
|
182
191
|
return allSubCategories;
|
|
183
192
|
})();
|
|
184
|
-
return this
|
|
193
|
+
return this.#subCategoriesInfo;
|
|
185
194
|
}
|
|
186
195
|
async getDefinitionContainersInfo() {
|
|
187
|
-
this
|
|
196
|
+
this.#definitionContainersInfo ??= (async () => {
|
|
188
197
|
const definitionContainersInfo = new Map();
|
|
189
198
|
const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([
|
|
190
199
|
this.getIsDefinitionContainerSupported(),
|
|
@@ -211,7 +220,7 @@ class CategoriesTreeIdsCache {
|
|
|
211
220
|
}
|
|
212
221
|
return definitionContainersInfo;
|
|
213
222
|
})();
|
|
214
|
-
return this
|
|
223
|
+
return this.#definitionContainersInfo;
|
|
215
224
|
}
|
|
216
225
|
async getDirectChildDefinitionContainersAndCategories(parentDefinitionContainerIds) {
|
|
217
226
|
const definitionContainersInfo = await this.getDefinitionContainersInfo();
|
|
@@ -272,9 +281,9 @@ class CategoriesTreeIdsCache {
|
|
|
272
281
|
for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {
|
|
273
282
|
if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {
|
|
274
283
|
if (!modelCategoriesInfo.parentDefinitionContainerExists) {
|
|
275
|
-
return [{ id: props.categoryId, className: this
|
|
284
|
+
return [{ id: props.categoryId, className: this.#categoryClass }];
|
|
276
285
|
}
|
|
277
|
-
return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this
|
|
286
|
+
return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this.#categoryClass }];
|
|
278
287
|
}
|
|
279
288
|
}
|
|
280
289
|
return [];
|
|
@@ -326,8 +335,8 @@ class CategoriesTreeIdsCache {
|
|
|
326
335
|
return result;
|
|
327
336
|
}
|
|
328
337
|
async getIsDefinitionContainerSupported() {
|
|
329
|
-
this
|
|
330
|
-
return this
|
|
338
|
+
this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();
|
|
339
|
+
return this.#isDefinitionContainerSupported;
|
|
331
340
|
}
|
|
332
341
|
}
|
|
333
342
|
exports.CategoriesTreeIdsCache = CategoriesTreeIdsCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA6ZhG,4CAIC;AA/ZD,uEAA2F;AA2B3F,gBAAgB;AAChB,MAAa,sBAAsB;IAWvB;IAVF,yBAAyB,CAAgE;IACzF,qBAAqB,CAAuD;IAC5E,kBAAkB,CAAwD;IAC1E,wBAAwB,CAAgD;IACxE,cAAc,CAAS;IACvB,qBAAqB,CAAS;IAC9B,mBAAmB,CAAS;IAC5B,+BAA+B,CAA+B;IAEtE,YACU,cAA0C,EAClD,QAAqB;QADb,mBAAc,GAAd,cAAc,CAA4B;QAGlD,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC/F,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;IAChD,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAI,CAAC;IAEpB,KAAK,CAAC,CAAC,2BAA2B;QAIxC,MAAM,KAAK,GAAG;;aAEL,IAAI,CAAC,mBAAmB;aACxB,IAAI,CAAC,qBAAqB;;;KAGlC,CAAC;QACF,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,cAAc,CA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AAC,EAAE,aAAa,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,CAAC;AACvJ,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 { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./ClassNameDefinitions.js\";\n\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Id64Array;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\ninterface CategoryInfo {\n id: Id64String;\n childCount: number;\n}\n\ninterface SubCategoryInfo {\n categoryId: Id64String;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n private _definitionContainersInfo: Promise<Map<Id64String, DefinitionContainerInfo>> | undefined;\n private _modelsCategoriesInfo: Promise<Map<Id64String, CategoriesInfo>> | undefined;\n private _subCategoriesInfo: Promise<Map<Id64String, SubCategoryInfo>> | undefined;\n private _elementModelsCategories: Promise<Map<Id64String, Id64Set>> | undefined;\n private _categoryClass: string;\n private _categoryElementClass: string;\n private _categoryModelClass: string;\n private _isDefinitionContainerSupported: Promise<boolean> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n viewType: \"3d\" | \"2d\",\n ) {\n const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);\n this._categoryClass = categoryClass;\n this._categoryElementClass = categoryElementClass;\n this._categoryModelClass = categoryModelClass;\n }\n\n public [Symbol.dispose]() {}\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this._categoryModelClass} m\n JOIN ${this._categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/categories-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async *queryCategories(): AsyncIterableIterator<{\n id: Id64String;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCount: number;\n }> {\n const isDefinitionContainerSupported = await this.getIsDefinitionContainerSupported();\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) childCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${DEFINITION_CONTAINER_CLASS} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists\n FROM\n ${this._categoryClass} this\n JOIN ${SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${this._categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };\n }\n }\n\n private async queryIsDefinitionContainersSupported(): Promise<boolean> {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n for await (const _row of this._queryExecutor.createQueryReader({ ecsql: query })) {\n return true;\n }\n return false;\n }\n\n private async *queryDefinitionContainers(): AsyncIterableIterator<{ id: Id64String; modelId: Id64String }> {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const ctes = [\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id\n FROM\n ${DEFINITION_CONTAINER_CLASS} dc\n WHERE\n dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this._categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this._categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))\n AND NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE\n NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, modelId: row.modelId };\n }\n }\n\n private async *queryVisibleSubCategories(categoriesInfo: Id64Array): AsyncIterableIterator<{ id: Id64String; parentId: Id64String }> {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${SUB_CATEGORY_CLASS} sc\n WHERE\n NOT sc.IsPrivate\n AND sc.Parent.Id IN (${categoriesInfo.join(\",\")})\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.categoryId };\n }\n }\n\n private async getModelsCategoriesInfo() {\n this._modelsCategoriesInfo ??= (async () => {\n const allModelsCategories = new Map<Id64String, CategoriesInfo>();\n for await (const queriedCategory of this.queryCategories()) {\n let modelCategories = allModelsCategories.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n allModelsCategories.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount });\n }\n return allModelsCategories;\n })();\n return this._modelsCategoriesInfo;\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const elementModelsCategories = new Map<Id64String, Id64Set>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = new Set();\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.add(queriedCategory.categoryId);\n }\n return elementModelsCategories;\n })();\n return this._elementModelsCategories;\n }\n\n private async getSubCategoriesInfo() {\n this._subCategoriesInfo ??= (async () => {\n const allSubCategories = new Map<Id64String, SubCategoryInfo>();\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n const categoriesWithMoreThanOneSubCategory = new Array<Id64String>();\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n categoriesWithMoreThanOneSubCategory.push(\n ...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id),\n );\n }\n\n if (categoriesWithMoreThanOneSubCategory.length === 0) {\n return allSubCategories;\n }\n\n for await (const queriedSubCategory of this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory)) {\n allSubCategories.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });\n }\n return allSubCategories;\n })();\n return this._subCategoriesInfo;\n }\n\n private async getDefinitionContainersInfo() {\n this._definitionContainersInfo ??= (async () => {\n const definitionContainersInfo = new Map<Id64String, DefinitionContainerInfo>();\n const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([\n this.getIsDefinitionContainerSupported(),\n this.getModelsCategoriesInfo(),\n ]);\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return definitionContainersInfo;\n }\n\n for await (const queriedDefinitionContainer of this.queryDefinitionContainers()) {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n\n definitionContainersInfo.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n });\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n const parentDefinitionContainer = definitionContainersInfo.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push(definitionContainerId);\n definitionContainerInfo.parentDefinitionContainerExists = true;\n }\n }\n\n return definitionContainersInfo;\n })();\n return this._definitionContainersInfo;\n }\n\n public async getDirectChildDefinitionContainersAndCategories(\n parentDefinitionContainerIds: Id64Array,\n ): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n\n parentDefinitionContainerIds.forEach((parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n result.definitionContainers.push(...parentDefinitionContainerInfo.childDefinitionContainers);\n result.categories.push(...parentDefinitionContainerInfo.childCategories);\n }\n });\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array): Promise<Map<Id64String, Id64Array>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<Id64String, Id64Array>();\n for (const categoryId of categoryIds) {\n for (const [modelId, categories] of elementModelsCategories) {\n if (categories.has(categoryId)) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<Id64String>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getAllContainedCategories(definitionContainerIds: Id64Array): Promise<Id64Array> {\n const result = new Array<Id64String>();\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const indirectCategories = await Promise.all(\n definitionContainerIds.map(async (definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n result.push(...definitionContainerInfo.childCategories.map((category) => category.id));\n return this.getAllContainedCategories(definitionContainerInfo.childDefinitionContainers);\n }),\n );\n for (const categories of indirectCategories) {\n result.push(...categories);\n }\n\n return result;\n }\n\n public async getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Promise<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);\n if (subCategoryInfo === undefined) {\n return [];\n }\n return [...(await this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId })), { id: props.subCategoryId, className: SUB_CATEGORY_CLASS }];\n }\n\n if (\"categoryId\" in props) {\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return [{ id: props.categoryId, className: this._categoryClass }];\n }\n\n return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this._categoryClass }];\n }\n }\n return [];\n }\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return [{ id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS }];\n }\n\n return [\n ...(await this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId })),\n { id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS },\n ];\n }\n\n public async getAllDefinitionContainersAndCategories(): Promise<{ categories: Id64Array; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: [...definitionContainersInfo.keys()], categories: new Array<Id64String>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n result.categories.push(...modelCategoriesInfo.childCategories.map((childCategory) => childCategory.id));\n }\n\n return result;\n }\n\n public async getRootDefinitionContainersAndCategories(): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n result.categories.push(...modelCategoriesInfo.childCategories);\n }\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n result.definitionContainers.push(definitionContainerId);\n }\n }\n return result;\n }\n\n public async getSubCategories(categoryId: Id64String): Promise<Id64Array> {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const result = new Array<Id64String>();\n for (const [subCategoryId, subCategoryInfo] of subCategoriesInfo) {\n if (subCategoryInfo.categoryId === categoryId) {\n result.push(subCategoryId);\n }\n }\n return result;\n }\n\n public async getIsDefinitionContainerSupported(): Promise<boolean> {\n this._isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();\n return this._isDefinitionContainerSupported;\n }\n}\n\n/** @internal */\nexport function getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore.GeometricElement2d\", categoryModelClass: \"BisCore.GeometricModel2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore.GeometricElement3d\", categoryModelClass: \"BisCore.GeometricModel3d\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAibhG,4CAIC;AAnbD,sDAA2C;AAC3C,uEAA2F;AA2B3F,gBAAgB;AAChB,MAAa,sBAAsB;IACjC,yBAAyB,CAAgE;IACzF,qBAAqB,CAAuD;IAC5E,kBAAkB,CAAwD;IAC1E,wBAAwB,CAAgD;IACxE,cAAc,CAAS;IACvB,qBAAqB,CAAS;IAC9B,mBAAmB,CAAS;IAC5B,+BAA+B,CAA+B;IAC9D,cAAc,CAA6B;IAC3C,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,aAAyC,EAAE,QAAqB,EAAE,WAAwB;QACpG,IAAI,CAAC,cAAc,GAAG,aAAa,CA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,IAAI,wBAAwB,EAAE,CAAC;YACxF,IAAI,CAAC,uBAAuB,CAAC,+BAA+B,EAAE,CAAC;gBAC7D,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAsB;QAClD,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,IAAI,KAAK,EAAc,CAAC;QACvC,KAAK,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,iBAAiB,EAAE,CAAC;YACjE,IAAI,eAAe,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,iCAAiC;QAC5C,IAAI,CAAC,+BAA+B,KAAK,IAAI,CAAC,oCAAoC,EAAE,CAAC;QACrF,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAC9C,CAAC;CACF;AA/YD,wDA+YC;AAED,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,QAAqB;IACpD,OAAO,QAAQ,KAAK,IAAI;QACtB,CAAC,CAAC,EAAE,aAAa,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE;QAClJ,CAAC,CAAC,EAAE,aAAa,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,CAAC;AACvJ,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 { Guid } from \"@itwin/core-bentley\";\nimport { DEFINITION_CONTAINER_CLASS, SUB_CATEGORY_CLASS } from \"./ClassNameDefinitions.js\";\n\nimport type { GuidString, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Id64Array;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\ninterface CategoryInfo {\n id: Id64String;\n childCount: number;\n}\n\ninterface SubCategoryInfo {\n categoryId: Id64String;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n #definitionContainersInfo: Promise<Map<Id64String, DefinitionContainerInfo>> | undefined;\n #modelsCategoriesInfo: Promise<Map<Id64String, CategoriesInfo>> | undefined;\n #subCategoriesInfo: Promise<Map<Id64String, SubCategoryInfo>> | undefined;\n #elementModelsCategories: Promise<Map<Id64String, Id64Set>> | undefined;\n #categoryClass: string;\n #categoryElementClass: string;\n #categoryModelClass: string;\n #isDefinitionContainerSupported: Promise<boolean> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, viewType: \"3d\" | \"2d\", componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n const { categoryClass, categoryElementClass, categoryModelClass } = getClassesByView(viewType);\n this.#categoryClass = categoryClass;\n this.#categoryElementClass = categoryElementClass;\n this.#categoryModelClass = categoryModelClass;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"CategoriesTreeIdsCache\";\n }\n\n public [Symbol.dispose]() {}\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,\n },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async *queryCategories(): AsyncIterableIterator<{\n id: Id64String;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCount: number;\n }> {\n const isDefinitionContainerSupported = await this.getIsDefinitionContainerSupported();\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) childCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${DEFINITION_CONTAINER_CLASS} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists\n FROM\n ${this.#categoryClass} this\n JOIN ${SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: categoriesQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/categories` },\n )) {\n yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };\n }\n }\n\n private async queryIsDefinitionContainersSupported(): Promise<boolean> {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n for await (const _row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` },\n )) {\n return true;\n }\n return false;\n }\n\n private async *queryDefinitionContainers(): AsyncIterableIterator<{ id: Id64String; modelId: Id64String }> {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const ctes = [\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id\n FROM\n ${DEFINITION_CONTAINER_CLASS} dc\n WHERE\n dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this.#categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))\n AND NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE\n NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ctes, ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` },\n )) {\n yield { id: row.id, modelId: row.modelId };\n }\n }\n\n private async *queryVisibleSubCategories(categoriesInfo: Id64Array): AsyncIterableIterator<{ id: Id64String; parentId: Id64String }> {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${SUB_CATEGORY_CLASS} sc\n WHERE\n NOT sc.IsPrivate\n AND sc.Parent.Id IN (${categoriesInfo.join(\",\")})\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` },\n )) {\n yield { id: row.id, parentId: row.categoryId };\n }\n }\n\n private async getModelsCategoriesInfo() {\n this.#modelsCategoriesInfo ??= (async () => {\n const allModelsCategories = new Map<Id64String, CategoriesInfo>();\n for await (const queriedCategory of this.queryCategories()) {\n let modelCategories = allModelsCategories.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n allModelsCategories.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount });\n }\n return allModelsCategories;\n })();\n return this.#modelsCategoriesInfo;\n }\n\n private async getElementModelsCategories() {\n this.#elementModelsCategories ??= (async () => {\n const elementModelsCategories = new Map<Id64String, Id64Set>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = new Set();\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.add(queriedCategory.categoryId);\n }\n return elementModelsCategories;\n })();\n return this.#elementModelsCategories;\n }\n\n private async getSubCategoriesInfo() {\n this.#subCategoriesInfo ??= (async () => {\n const allSubCategories = new Map<Id64String, SubCategoryInfo>();\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n const categoriesWithMoreThanOneSubCategory = new Array<Id64String>();\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n categoriesWithMoreThanOneSubCategory.push(\n ...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id),\n );\n }\n\n if (categoriesWithMoreThanOneSubCategory.length === 0) {\n return allSubCategories;\n }\n\n for await (const queriedSubCategory of this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory)) {\n allSubCategories.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });\n }\n return allSubCategories;\n })();\n return this.#subCategoriesInfo;\n }\n\n private async getDefinitionContainersInfo() {\n this.#definitionContainersInfo ??= (async () => {\n const definitionContainersInfo = new Map<Id64String, DefinitionContainerInfo>();\n const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([\n this.getIsDefinitionContainerSupported(),\n this.getModelsCategoriesInfo(),\n ]);\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return definitionContainersInfo;\n }\n\n for await (const queriedDefinitionContainer of this.queryDefinitionContainers()) {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n\n definitionContainersInfo.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n });\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n const parentDefinitionContainer = definitionContainersInfo.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push(definitionContainerId);\n definitionContainerInfo.parentDefinitionContainerExists = true;\n }\n }\n\n return definitionContainersInfo;\n })();\n return this.#definitionContainersInfo;\n }\n\n public async getDirectChildDefinitionContainersAndCategories(\n parentDefinitionContainerIds: Id64Array,\n ): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n\n parentDefinitionContainerIds.forEach((parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n result.definitionContainers.push(...parentDefinitionContainerInfo.childDefinitionContainers);\n result.categories.push(...parentDefinitionContainerInfo.childCategories);\n }\n });\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array): Promise<Map<Id64String, Id64Array>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<Id64String, Id64Array>();\n for (const categoryId of categoryIds) {\n for (const [modelId, categories] of elementModelsCategories) {\n if (categories.has(categoryId)) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<Id64String>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getAllContainedCategories(definitionContainerIds: Id64Array): Promise<Id64Array> {\n const result = new Array<Id64String>();\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const indirectCategories = await Promise.all(\n definitionContainerIds.map(async (definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n result.push(...definitionContainerInfo.childCategories.map((category) => category.id));\n return this.getAllContainedCategories(definitionContainerInfo.childDefinitionContainers);\n }),\n );\n for (const categories of indirectCategories) {\n result.push(...categories);\n }\n\n return result;\n }\n\n public async getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Promise<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);\n if (subCategoryInfo === undefined) {\n return [];\n }\n return [...(await this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId })), { id: props.subCategoryId, className: SUB_CATEGORY_CLASS }];\n }\n\n if (\"categoryId\" in props) {\n const modelsCategoriesInfo = await this.getModelsCategoriesInfo();\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return [{ id: props.categoryId, className: this.#categoryClass }];\n }\n\n return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this.#categoryClass }];\n }\n }\n return [];\n }\n\n const definitionContainersInfo = await this.getDefinitionContainersInfo();\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return [];\n }\n\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return [{ id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS }];\n }\n\n return [\n ...(await this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId })),\n { id: props.definitionContainerId, className: DEFINITION_CONTAINER_CLASS },\n ];\n }\n\n public async getAllDefinitionContainersAndCategories(): Promise<{ categories: Id64Array; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: [...definitionContainersInfo.keys()], categories: new Array<Id64String>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n result.categories.push(...modelCategoriesInfo.childCategories.map((childCategory) => childCategory.id));\n }\n\n return result;\n }\n\n public async getRootDefinitionContainersAndCategories(): Promise<{ categories: CategoryInfo[]; definitionContainers: Id64Array }> {\n const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);\n const result = { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() };\n for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n result.categories.push(...modelCategoriesInfo.childCategories);\n }\n }\n\n for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n result.definitionContainers.push(definitionContainerId);\n }\n }\n return result;\n }\n\n public async getSubCategories(categoryId: Id64String): Promise<Id64Array> {\n const subCategoriesInfo = await this.getSubCategoriesInfo();\n const result = new Array<Id64String>();\n for (const [subCategoryId, subCategoryInfo] of subCategoriesInfo) {\n if (subCategoryInfo.categoryId === categoryId) {\n result.push(subCategoryId);\n }\n }\n return result;\n }\n\n public async getIsDefinitionContainerSupported(): Promise<boolean> {\n this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();\n return this.#isDefinitionContainerSupported;\n }\n}\n\n/** @internal */\nexport function getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore.GeometricElement2d\", categoryModelClass: \"BisCore.GeometricModel2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore.GeometricElement3d\", categoryModelClass: \"BisCore.GeometricModel3d\" };\n}\n"]}
|
|
@@ -10,9 +10,7 @@ export interface CategoriesVisibilityHandlerProps {
|
|
|
10
10
|
}
|
|
11
11
|
/** @internal */
|
|
12
12
|
export declare class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {
|
|
13
|
-
private
|
|
14
|
-
private _viewport;
|
|
15
|
-
private _idsCache;
|
|
13
|
+
#private;
|
|
16
14
|
constructor(props: CategoriesVisibilityHandlerProps);
|
|
17
15
|
dispose(): void;
|
|
18
16
|
[Symbol.dispose](): void;
|
|
@@ -13,26 +13,26 @@ const Tooltip_js_1 = require("../../common/Tooltip.js");
|
|
|
13
13
|
const CategoriesTreeNode_js_1 = require("./CategoriesTreeNode.js");
|
|
14
14
|
/** @internal */
|
|
15
15
|
class CategoriesVisibilityHandler {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
#pendingVisibilityChange;
|
|
17
|
+
#viewport;
|
|
18
|
+
#idsCache;
|
|
19
19
|
constructor(props) {
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
20
|
+
this.#idsCache = props.idsCache;
|
|
21
|
+
this.#viewport = props.viewport;
|
|
22
|
+
this.#viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
|
|
23
|
+
this.#viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
|
|
24
|
+
this.#viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);
|
|
25
|
+
this.#viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);
|
|
26
26
|
}
|
|
27
27
|
dispose() {
|
|
28
28
|
this[Symbol.dispose]();
|
|
29
29
|
}
|
|
30
30
|
[Symbol.dispose]() {
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
clearTimeout(this
|
|
31
|
+
this.#viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
|
|
32
|
+
this.#viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
|
|
33
|
+
this.#viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);
|
|
34
|
+
this.#viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);
|
|
35
|
+
clearTimeout(this.#pendingVisibilityChange);
|
|
36
36
|
}
|
|
37
37
|
onVisibilityChange = new core_bentley_1.BeEvent();
|
|
38
38
|
/** Returns visibility status of the tree node. */
|
|
@@ -70,10 +70,10 @@ class CategoriesVisibilityHandler {
|
|
|
70
70
|
}
|
|
71
71
|
async getSubCategoriesVisibility(subCategoryIds, parentCategoryId) {
|
|
72
72
|
let visibility = "unknown";
|
|
73
|
-
const categoryModels = [...(await this.
|
|
73
|
+
const categoryModels = [...(await this.#idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();
|
|
74
74
|
let nonDefaultModelDisplayStatesCount = 0;
|
|
75
75
|
for (const modelId of categoryModels) {
|
|
76
|
-
if (!this.
|
|
76
|
+
if (!this.#viewport.view.viewsModel(modelId)) {
|
|
77
77
|
if (visibility === "visible") {
|
|
78
78
|
return "partial";
|
|
79
79
|
}
|
|
@@ -81,7 +81,7 @@ class CategoriesVisibilityHandler {
|
|
|
81
81
|
++nonDefaultModelDisplayStatesCount;
|
|
82
82
|
continue;
|
|
83
83
|
}
|
|
84
|
-
const override = this.
|
|
84
|
+
const override = this.#viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);
|
|
85
85
|
if (override === core_frontend_1.PerModelCategoryVisibility.Override.Show) {
|
|
86
86
|
if (visibility === "hidden") {
|
|
87
87
|
return "partial";
|
|
@@ -103,7 +103,7 @@ class CategoriesVisibilityHandler {
|
|
|
103
103
|
(0, core_bentley_1.assert)(visibility === "visible" || visibility === "hidden");
|
|
104
104
|
return visibility;
|
|
105
105
|
}
|
|
106
|
-
if (!this.
|
|
106
|
+
if (!this.#viewport.view.viewsCategory(parentCategoryId)) {
|
|
107
107
|
return visibility === "visible" ? "partial" : "hidden";
|
|
108
108
|
}
|
|
109
109
|
if (subCategoryIds.length === 0) {
|
|
@@ -113,7 +113,7 @@ class CategoriesVisibilityHandler {
|
|
|
113
113
|
return "visible";
|
|
114
114
|
}
|
|
115
115
|
for (const subCategoryId of subCategoryIds) {
|
|
116
|
-
const isSubCategoryVisible = this.
|
|
116
|
+
const isSubCategoryVisible = this.#viewport.isSubCategoryVisible(subCategoryId);
|
|
117
117
|
if (isSubCategoryVisible && visibility === "hidden") {
|
|
118
118
|
return "partial";
|
|
119
119
|
}
|
|
@@ -126,12 +126,12 @@ class CategoriesVisibilityHandler {
|
|
|
126
126
|
return visibility;
|
|
127
127
|
}
|
|
128
128
|
async getDefinitionContainerVisibility(node) {
|
|
129
|
-
const categoryIds = await this.
|
|
129
|
+
const categoryIds = await this.#idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));
|
|
130
130
|
return this.getCategoriesVisibility(categoryIds);
|
|
131
131
|
}
|
|
132
132
|
async getCategoriesVisibility(categoryIds) {
|
|
133
133
|
const subCategoriesVisibilities = await Promise.all(categoryIds.map(async (categoryId) => {
|
|
134
|
-
const subCategories = await this.
|
|
134
|
+
const subCategories = await this.#idsCache.getSubCategories(categoryId);
|
|
135
135
|
return this.getSubCategoriesVisibility(subCategories, categoryId);
|
|
136
136
|
}));
|
|
137
137
|
let visibility = "unknown";
|
|
@@ -151,11 +151,11 @@ class CategoriesVisibilityHandler {
|
|
|
151
151
|
return visibility;
|
|
152
152
|
}
|
|
153
153
|
async enableCategoriesElementModelsVisibility(categoryIds) {
|
|
154
|
-
const categoriesModelsMap = await this.
|
|
154
|
+
const categoriesModelsMap = await this.#idsCache.getCategoriesElementModels(categoryIds);
|
|
155
155
|
const modelIds = [...categoriesModelsMap.values()].flat();
|
|
156
|
-
const hiddenModels = modelIds.filter((modelId) => !this.
|
|
156
|
+
const hiddenModels = modelIds.filter((modelId) => !this.#viewport.view.viewsModel(modelId));
|
|
157
157
|
if (hiddenModels.length > 0) {
|
|
158
|
-
this.
|
|
158
|
+
this.#viewport.changeModelDisplay(hiddenModels, true);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
async changeSubCategoryVisibility(node, on) {
|
|
@@ -178,7 +178,7 @@ class CategoriesVisibilityHandler {
|
|
|
178
178
|
}
|
|
179
179
|
async changeDefinitionContainerVisibility(node, on) {
|
|
180
180
|
const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);
|
|
181
|
-
const childCategories = await this.
|
|
181
|
+
const childCategories = await this.#idsCache.getAllContainedCategories(definitionContainerId);
|
|
182
182
|
return this.changeCategoryVisibility(childCategories, on);
|
|
183
183
|
}
|
|
184
184
|
onDisplayStyleChanged = () => {
|
|
@@ -194,22 +194,22 @@ class CategoriesVisibilityHandler {
|
|
|
194
194
|
this.onVisibilityChangeInternal();
|
|
195
195
|
};
|
|
196
196
|
onVisibilityChangeInternal() {
|
|
197
|
-
if (this
|
|
197
|
+
if (this.#pendingVisibilityChange) {
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
this
|
|
200
|
+
this.#pendingVisibilityChange = setTimeout(() => {
|
|
201
201
|
this.onVisibilityChange.raiseEvent();
|
|
202
|
-
this
|
|
202
|
+
this.#pendingVisibilityChange = undefined;
|
|
203
203
|
}, 0);
|
|
204
204
|
}
|
|
205
205
|
static getInstanceIdsFromHierarchyNode(node) {
|
|
206
206
|
return presentation_hierarchies_1.HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];
|
|
207
207
|
}
|
|
208
208
|
async changeCategoryState(ids, enabled, enableAllSubCategories) {
|
|
209
|
-
await (0, CategoriesVisibilityUtils_js_1.enableCategoryDisplay)(this
|
|
209
|
+
await (0, CategoriesVisibilityUtils_js_1.enableCategoryDisplay)(this.#viewport, ids, enabled, enableAllSubCategories);
|
|
210
210
|
}
|
|
211
211
|
changeSubCategoryState(key, enabled) {
|
|
212
|
-
(0, CategoriesVisibilityUtils_js_1.enableSubCategoryDisplay)(this
|
|
212
|
+
(0, CategoriesVisibilityUtils_js_1.enableSubCategoryDisplay)(this.#viewport, key, enabled);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
exports.CategoriesVisibilityHandler = CategoriesVisibilityHandler;
|