@itwin/tree-widget-react 3.5.1 → 3.6.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 +24 -2
- package/README.md +2 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +49 -4
- 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 +4 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +91 -96
- 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/UseIModelAccess.d.ts +18 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js +34 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +1 -16
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js +16 -9
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js +8 -4
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +12 -8
- 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/IModelContentTreeComponent.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +12 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +14 -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/models-tree/ModelsTreeDefinition.d.ts +5 -3
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +26 -60
- 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/internal/ModelsTreeIdsCache.js +22 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +49 -4
- 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 +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +92 -97
- 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/UseIModelAccess.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js +30 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +15 -9
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js +10 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +13 -9
- 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/IModelContentTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +12 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +14 -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/models-tree/ModelsTreeDefinition.d.ts +5 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +27 -61
- 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/internal/ModelsTreeIdsCache.js +22 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA8C;AAC9C,8EAAgE;AAChE,4FAA4G;AAC5G,wDAAiE;AACjE,mEAA6D;AAa7D,gBAAgB;AAChB,MAAa,2BAA2B;IAKtC,YAAY,KAAuC;QAiB5C,uBAAkB,GAAG,IAAI,sBAAO,EAAE,CAAC;QA4L1C,gEAAgE;QACxD,0BAAqB,GAAG,GAAG,EAAE;YACnC,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACpC,CAAC,CAAC;QAEF,gEAAgE;QACxD,8BAAyB,GAAG,GAAG,EAAE;YACvC,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACpC,CAAC,CAAC;QApNA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC7E,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACvF,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,cAAc,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAChF,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,cAAc,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACxF,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAID,kDAAkD;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wB,EAAE;YACjC,OAAO;SACR;QAED,IAAI,CAAC,wBAAwB,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEO,MAAM,CAAC,+BAA+B,CAAC,IAAmB;QAChE,OAAO,wCAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC1I,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAA+B;QAChG,MAAM,IAAA,oDAAqB,EAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAEO,sBAAsB,CAAC,GAAW,EAAE,OAAgB;QAC1D,IAAA,uDAAwB,EAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACF;AAlPD,kEAkPC","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 { BeEvent } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Id64Array } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n private _idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._idsCache = props.idsCache;\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return createVisibilityStatus(this.getSubCategoryVisibility(node));\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private getSubCategoryVisibility(node: HierarchyNode): VisibilityStatus[\"state\"] {\n const parentCategoryId = node.extendedData?.categoryId;\n if (!parentCategoryId) {\n return \"hidden\";\n }\n\n const categoryOverrideResult = this.getCategoryVisibilityFromOverrides(parentCategoryId);\n if (categoryOverrideResult === \"hidden\" || categoryOverrideResult === \"visible\") {\n return categoryOverrideResult;\n }\n\n if (!this._viewport.view.viewsCategory(parentCategoryId)) {\n return \"hidden\";\n }\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n let visibleCount = 0;\n let hiddenCount = 0;\n for (const subCategoryId of subCategoryIds) {\n const isVisible = this._viewport.isSubCategoryVisible(subCategoryId);\n if (isVisible) {\n ++visibleCount;\n } else {\n ++hiddenCount;\n }\n if (visibleCount > 0 && hiddenCount > 0) {\n return \"partial\";\n }\n }\n return visibleCount > 0 ? \"visible\" : \"hidden\";\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<VisibilityStatus[\"state\"]> {\n const childrenResult = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n let hiddenCount = 0;\n let visibleCount = 0;\n for (const categoryId of childrenResult) {\n const categoryVisibility = await this.getCategoriesVisibility([categoryId]);\n if (categoryVisibility === \"partial\") {\n return \"partial\";\n }\n\n if (categoryVisibility === \"hidden\") {\n ++hiddenCount;\n } else {\n ++visibleCount;\n }\n\n if (hiddenCount > 0 && visibleCount > 0) {\n return \"partial\";\n }\n }\n\n return hiddenCount > 0 ? \"hidden\" : \"visible\";\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<VisibilityStatus[\"state\"]> {\n const overrideResult = this.getCategoryVisibilityFromOverrides(categoryIds);\n if (overrideResult !== \"none\") {\n return overrideResult;\n }\n let visibleCount = 0;\n let hiddenCount = 0;\n for (const categoryId of categoryIds) {\n const isVisible = this._viewport.view.viewsCategory(categoryId);\n if (isVisible) {\n ++visibleCount;\n } else {\n ++hiddenCount;\n }\n if (visibleCount > 0 && hiddenCount > 0) {\n return \"partial\";\n }\n }\n\n if (hiddenCount > 0) {\n return \"hidden\";\n }\n\n const subCategories = (await Promise.all(categoryIds.map(async (id) => this._idsCache.getSubCategories(id)))).reduce((acc, val) => acc.concat(val), []);\n let visibleSubCategoryCount = 0;\n let hiddenSubCategoryCount = 0;\n\n for (const subCategory of subCategories) {\n const isVisible = this._viewport.isSubCategoryVisible(subCategory);\n if (isVisible) {\n ++visibleSubCategoryCount;\n } else {\n ++hiddenSubCategoryCount;\n }\n if (hiddenSubCategoryCount > 0 && visibleSubCategoryCount > 0) {\n return \"partial\";\n }\n }\n\n return hiddenSubCategoryCount > 0 ? \"hidden\" : \"visible\";\n }\n\n private getCategoryVisibilityFromOverrides(categoryIds: Id64Array): VisibilityStatus[\"state\"] | \"none\" {\n let showOverrides = 0;\n let hideOverrides = 0;\n\n for (const currentOverride of this._viewport.perModelCategoryVisibility) {\n if (categoryIds.includes(currentOverride.categoryId)) {\n if (currentOverride.visible) {\n ++showOverrides;\n } else {\n ++hideOverrides;\n }\n\n if (showOverrides > 0 && hideOverrides > 0) {\n return \"partial\";\n }\n }\n }\n\n if (showOverrides === 0 && hideOverrides === 0) {\n return \"none\";\n }\n\n return showOverrides > 0 ? \"visible\" : \"hidden\";\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category is enabled\n if (on && parentCategoryId) {\n await this.changeCategoryState([parentCategoryId], true, false);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n\n private async changeCategoryVisibility(node: HierarchyNode, on: boolean) {\n const categoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryState(childCategories, on, on);\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAAsD;AACtD,wDAAkE;AAClE,8EAAgE;AAChE,4FAA4G;AAC5G,wDAAiE;AACjE,mEAA6D;AAc7D,gBAAgB;AAChB,MAAa,2BAA2B;IAKtC,YAAY,KAAuC;QAqB5C,uBAAkB,GAAG,IAAI,sBAAO,EAA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ACF;AA7OD,kEA6OC","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 { assert, BeEvent } from \"@itwin/core-bentley\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { Visibility } from \"../../common/Tooltip.js\";\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n private _idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._idsCache = props.idsCache;\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n if (!node.extendedData?.categoryId) {\n return { state: \"hidden\", isDisabled: true };\n }\n return createVisibilityStatus(\n await this.getSubCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), node.extendedData.categoryId),\n );\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private async getSubCategoriesVisibility(subCategoryIds: Id64Array, parentCategoryId: Id64String): Promise<Visibility> {\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n const categoryModels = [...(await this._idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();\n let nonDefaultModelDisplayStatesCount = 0;\n for (const modelId of categoryModels) {\n if (!this._viewport.view.viewsModel(modelId)) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n const override = this._viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);\n if (override === PerModelCategoryVisibility.Override.Show) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = \"visible\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n if (override === PerModelCategoryVisibility.Override.Hide) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n }\n if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n if (!this._viewport.view.viewsCategory(parentCategoryId)) {\n return visibility === \"visible\" ? \"partial\" : \"hidden\";\n }\n\n if (subCategoryIds.length === 0) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n return \"visible\";\n }\n\n for (const subCategoryId of subCategoryIds) {\n const isSubCategoryVisible = this._viewport.isSubCategoryVisible(subCategoryId);\n if (isSubCategoryVisible && visibility === \"hidden\") {\n return \"partial\";\n }\n if (!isSubCategoryVisible && visibility === \"visible\") {\n return \"partial\";\n }\n visibility = isSubCategoryVisible ? \"visible\" : \"hidden\";\n }\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<Visibility> {\n const categoryIds = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n return this.getCategoriesVisibility(categoryIds);\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<Visibility> {\n const subCategoriesVisibilities = await Promise.all(\n categoryIds.map(async (categoryId) => {\n const subCategories = await this._idsCache.getSubCategories(categoryId);\n return this.getSubCategoriesVisibility(subCategories, categoryId);\n }),\n );\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n\n for (const subCategoriesVisibility of subCategoriesVisibilities) {\n if (subCategoriesVisibility === \"partial\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"hidden\" && visibility === \"visible\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"visible\" && visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = subCategoriesVisibility;\n }\n assert(visibility !== \"unknown\");\n return visibility;\n }\n\n private async enableCategoriesElementModelsVisibility(categoryIds: Id64Array) {\n const categoriesModelsMap = await this._idsCache.getCategoriesElementModels(categoryIds);\n const modelIds = [...categoriesModelsMap.values()].flat();\n const hiddenModels = modelIds.filter((modelId) => !this._viewport.view.viewsModel(modelId));\n if (hiddenModels.length > 0) {\n this._viewport.changeModelDisplay(hiddenModels, true);\n }\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category and models are enabled\n if (on && parentCategoryId) {\n await Promise.all([this.enableCategoriesElementModelsVisibility([parentCategoryId]), this.changeCategoryState([parentCategoryId], true, false)]);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n private async changeCategoryVisibility(categoryIds: Id64Array, on: boolean) {\n // make sure models are enabled\n if (on) {\n await this.enableCategoriesElementModelsVisibility(categoryIds);\n }\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryVisibility(childCategories, on);\n }\n\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesPerModelChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedModelsChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IModelConnection } from "@itwin/core-frontend";
|
|
2
|
+
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
3
|
+
import type { useIModelTree } from "@itwin/presentation-hierarchies-react";
|
|
4
|
+
import type { FunctionProps } from "./Utils.js";
|
|
5
|
+
type IModelAccess = FunctionProps<typeof useIModelTree>["imodelAccess"];
|
|
6
|
+
export interface UseIModelAccessProps {
|
|
7
|
+
imodel: IModelConnection;
|
|
8
|
+
getSchemaContext: (imodel: IModelConnection) => SchemaContext;
|
|
9
|
+
imodelAccess?: IModelAccess;
|
|
10
|
+
hierarchyLevelSizeLimit?: number;
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }: UseIModelAccessProps): {
|
|
14
|
+
imodelAccess: IModelAccess;
|
|
15
|
+
currentHierarchyLevelSizeLimit: number;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=UseIModelAccess.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useIModelAccess = void 0;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
|
|
10
|
+
const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
|
|
11
|
+
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
12
|
+
/** @internal */
|
|
13
|
+
function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }) {
|
|
14
|
+
const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;
|
|
15
|
+
const imodelAccess = (0, react_1.useMemo)(() => {
|
|
16
|
+
return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });
|
|
17
|
+
}, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);
|
|
18
|
+
return {
|
|
19
|
+
imodelAccess,
|
|
20
|
+
currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.useIModelAccess = useIModelAccess;
|
|
24
|
+
function createIModelAccess({ imodel, getSchemaContext, hierarchyLevelSizeLimit, }) {
|
|
25
|
+
const schemas = getSchemaContext(imodel);
|
|
26
|
+
const schemaProvider = (0, presentation_core_interop_1.createECSchemaProvider)(schemas);
|
|
27
|
+
return {
|
|
28
|
+
imodelKey: imodel.key,
|
|
29
|
+
...schemaProvider,
|
|
30
|
+
...(0, presentation_shared_1.createCachingECClassHierarchyInspector)({ schemaProvider, cacheSize: 100 }),
|
|
31
|
+
...(0, presentation_hierarchies_1.createLimitingECSqlQueryExecutor)((0, presentation_core_interop_1.createECSqlQueryExecutor)(imodel), hierarchyLevelSizeLimit),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=UseIModelAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseIModelAccess.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAgC;AAChC,gFAAoG;AACpG,8EAAmF;AACnF,oEAAoF;AAgBpF,gBAAgB;AAChB,SAAgB,eAAe,CAAC,EAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAuB;IAIzI,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAC3I,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAErF,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAA;AACL,CAAC;AAbD,0CAaC;AAED,SAAS,kBAAkB,CAAC,EAC1B,MAAM,EACN,gBAAgB,EAChB,uBAAuB,GAKxB;IACC,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,IAAA,kDAAsB,EAAC,OAAO,CAAC,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,IAAA,4DAAsC,EAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,IAAA,2DAAgC,EAAC,IAAA,oDAAwB,EAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,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 { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"./Utils.js\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit}: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n }\n}\n\nfunction createIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n}: {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n hierarchyLevelSizeLimit: number;\n}) {\n const schemas = getSchemaContext(imodel);\n const schemaProvider = createECSchemaProvider(schemas);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Id64Array } from "@itwin/core-bentley";
|
|
3
|
-
import type { IModelConnection } from "@itwin/core-frontend";
|
|
4
|
-
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
5
3
|
/** @beta */
|
|
6
4
|
export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
|
|
7
5
|
/** @internal */
|
|
@@ -11,17 +9,5 @@ export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
|
|
|
11
9
|
/** @internal */
|
|
12
10
|
export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
|
|
13
11
|
/** @internal */
|
|
14
|
-
export declare function createIModelAccess({ imodel, getSchemaContext }: {
|
|
15
|
-
imodel: IModelConnection;
|
|
16
|
-
getSchemaContext: (imodel: IModelConnection) => SchemaContext;
|
|
17
|
-
}): {
|
|
18
|
-
createQueryReader(query: import("@itwin/presentation-shared").ECSqlQueryDef, config?: (import("@itwin/presentation-shared").ECSqlQueryReaderOptions & {
|
|
19
|
-
limit?: number | "unbounded" | undefined;
|
|
20
|
-
}) | undefined): AsyncIterableIterator<import("@itwin/presentation-shared").ECSqlQueryRow>;
|
|
21
|
-
classDerivesFrom(derivedClassFullName: string, candidateBaseClassFullName: string): boolean | Promise<boolean>;
|
|
22
|
-
getSchema(schemaName: string): Promise<import("@itwin/presentation-shared").EC.Schema | undefined>;
|
|
23
|
-
imodelKey: string;
|
|
24
|
-
};
|
|
25
|
-
/** @internal */
|
|
26
12
|
export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
|
|
27
13
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.useLatest = exports.
|
|
7
|
+
exports.useLatest = exports.pushToMap = exports.parseIdsSelectorResult = exports.createIdsSelector = void 0;
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
|
|
10
|
-
const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
|
|
11
|
-
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
12
9
|
/** @internal */
|
|
13
10
|
function createIdsSelector(ids) {
|
|
14
11
|
// Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
|
|
@@ -43,18 +40,6 @@ function pushToMap(targetMap, key, value) {
|
|
|
43
40
|
}
|
|
44
41
|
exports.pushToMap = pushToMap;
|
|
45
42
|
/** @internal */
|
|
46
|
-
function createIModelAccess({ imodel, getSchemaContext }) {
|
|
47
|
-
const schemas = getSchemaContext(imodel);
|
|
48
|
-
const schemaProvider = (0, presentation_core_interop_1.createECSchemaProvider)(schemas);
|
|
49
|
-
return {
|
|
50
|
-
imodelKey: imodel.key,
|
|
51
|
-
...schemaProvider,
|
|
52
|
-
...(0, presentation_shared_1.createCachingECClassHierarchyInspector)({ schemaProvider, cacheSize: 100 }),
|
|
53
|
-
...(0, presentation_hierarchies_1.createLimitingECSqlQueryExecutor)((0, presentation_core_interop_1.createECSqlQueryExecutor)(imodel), 1000),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
exports.createIModelAccess = createIModelAccess;
|
|
57
|
-
/** @internal */
|
|
58
43
|
function useLatest(value) {
|
|
59
44
|
const ref = (0, react_1.useRef)(value);
|
|
60
45
|
(0, react_1.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA0C;
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA0C;AAO1C,gBAAgB;AAChB,SAAgB,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;QAClF,IAAI,aAAa,GAAuB,eAAe,GAAG,GAAG,CAAC;QAC9D,IAAI,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE;YAC9B,aAAa,GAAG,SAAS,CAAC;SAC3B;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;KACxD;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;AAZD,8CAYC;AAED,gBAAgB;AAChB,SAAgB,sBAAsB,CAAC,cAAmB;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QAClC,OAAO,EAAE,CAAC;KACX;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;AALD,wDAKC;AAED,gBAAgB;AAChB,SAAgB,SAAS,CAAe,SAAiC,EAAE,GAAS,EAAE,KAAa;IACjG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzB;IACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAPD,8BAOC;AAED,gBAAgB;AAChB,SAAgB,SAAS,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAC1B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,CAAC;AAND,8BAMC","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,4 +1,5 @@
|
|
|
1
1
|
import { useSelectionHandler } from "@itwin/presentation-hierarchies-react";
|
|
2
|
+
import type { MarkRequired } from "@itwin/core-bentley";
|
|
2
3
|
import type { FunctionProps } from "../Utils.js";
|
|
3
4
|
import type { ReactNode } from "react";
|
|
4
5
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
@@ -41,4 +42,8 @@ export type TreeProps = Pick<FunctionProps<typeof useIModelTree>, "getFilteredPa
|
|
|
41
42
|
* @beta
|
|
42
43
|
*/
|
|
43
44
|
export declare function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps): JSX.Element;
|
|
45
|
+
/** @internal */
|
|
46
|
+
export declare function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, "imodelAccess"> & {
|
|
47
|
+
currentHierarchyLevelSizeLimit: number;
|
|
48
|
+
}): JSX.Element;
|
|
44
49
|
//# sourceMappingURL=Tree.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tree = void 0;
|
|
3
|
+
exports.TreeBase = exports.Tree = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
/*---------------------------------------------------------------------------------------------
|
|
6
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -14,10 +14,10 @@ const presentation_hierarchies_react_1 = require("@itwin/presentation-hierarchie
|
|
|
14
14
|
const TreeWidget_js_1 = require("../../../../TreeWidget.js");
|
|
15
15
|
const UseHierarchiesLocalization_js_1 = require("../UseHierarchiesLocalization.js");
|
|
16
16
|
const UseHierarchyFiltering_js_1 = require("../UseHierarchyFiltering.js");
|
|
17
|
+
const UseIModelAccess_js_1 = require("../UseIModelAccess.js");
|
|
17
18
|
const UseIModelChangeListener_js_1 = require("../UseIModelChangeListener.js");
|
|
18
19
|
const UseNodeHighlighting_js_1 = require("../UseNodeHighlighting.js");
|
|
19
20
|
const UseTelemetryContext_js_1 = require("../UseTelemetryContext.js");
|
|
20
|
-
const Utils_js_1 = require("../Utils.js");
|
|
21
21
|
const Delayed_js_1 = require("./Delayed.js");
|
|
22
22
|
const ProgressOverlay_js_1 = require("./ProgressOverlay.js");
|
|
23
23
|
/**
|
|
@@ -25,14 +25,21 @@ const ProgressOverlay_js_1 = require("./ProgressOverlay.js");
|
|
|
25
25
|
* @beta
|
|
26
26
|
*/
|
|
27
27
|
function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const { imodelAccess, currentHierarchyLevelSizeLimit } = (0, UseIModelAccess_js_1.useIModelAccess)({
|
|
29
|
+
imodel: props.imodel,
|
|
30
|
+
imodelAccess: providedIModelAccess,
|
|
31
|
+
getSchemaContext,
|
|
32
|
+
hierarchyLevelSizeLimit,
|
|
33
|
+
});
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(TreeBase, { ...props, getSchemaContext: getSchemaContext, selectionStorage: selectionStorage, imodelAccess: imodelAccess, currentHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit }));
|
|
33
35
|
}
|
|
34
36
|
exports.Tree = Tree;
|
|
35
|
-
|
|
37
|
+
/** @internal */
|
|
38
|
+
function TreeBase({ getSchemaContext, ...props }) {
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(presentation_components_1.SchemaMetadataContextProvider, { imodel: props.imodel, schemaContextProvider: getSchemaContext, children: (0, jsx_runtime_1.jsx)(TreeBaseImpl, { ...props }) }));
|
|
40
|
+
}
|
|
41
|
+
exports.TreeBase = TreeBase;
|
|
42
|
+
function TreeBaseImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPaths, currentHierarchyLevelSizeLimit, getHierarchyDefinition, selectionPredicate, selectionMode, onReload, treeRenderer, density, highlight, selectionStorage, }) {
|
|
36
43
|
const localizedStrings = (0, UseHierarchiesLocalization_js_1.useHierarchiesLocalization)();
|
|
37
44
|
const { onFeatureUsed, onPerformanceMeasured } = (0, UseTelemetryContext_js_1.useTelemetryContext)();
|
|
38
45
|
const [imodelChanged] = (0, react_1.useState)(new core_bentley_1.BeEvent());
|
|
@@ -66,7 +73,7 @@ function TreeImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPa
|
|
|
66
73
|
const { onNodeClick, onNodeKeyDown } = (0, presentation_hierarchies_react_1.useSelectionHandler)({ rootNodes, selectNodes, selectionMode: selectionMode ?? "single" });
|
|
67
74
|
const { filteringDialog, onFilterClick } = (0, UseHierarchyFiltering_js_1.useHierarchyLevelFiltering)({
|
|
68
75
|
imodel,
|
|
69
|
-
defaultHierarchyLevelSizeLimit,
|
|
76
|
+
defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,
|
|
70
77
|
});
|
|
71
78
|
const reportingExpandNode = (0, UseTelemetryContext_js_1.useReportingAction)({ action: expandNode });
|
|
72
79
|
const reportingOnFilterClicked = (0, UseTelemetryContext_js_1.useReportingAction)({ action: onFilterClick });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAuD;AACvD,sDAA8C;AAC9C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA2G;AAC3G,6DAAuD;AACvD,oFAA8E;AAC9E,0EAAyE;AACzE,8EAAwE;AACxE,sEAAgE;AAChE,sEAAoF;AACpF,0CAAiD;AACjD,6CAAuC;AACvC,6DAAuD;AAkDvD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IAEvE,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,IAAA,6BAAkB,EAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D,OAAO,CACL,uBAAC,uDAA6B,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,YAC1F,uBAAC,QAAQ,OAAK,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,Y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OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,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, useMemo, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { createIModelAccess } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeImpl {...props} selectionStorage={selectionStorage} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA8C;AAC9C,sDAA8C;AAC9C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA2G;AAC3G,6DAAuD;AACvD,oFAA8E;AAC9E,0EAAyE;AACzE,8DAAwD;AACxD,8EAAwE;AACxE,sEAAgE;AAChE,sEAAoF;AACpF,6CAAuC;AACvC,6DAAuD;AAkDvD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,oBAAoB;QAClC,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IACH,OAAO,CACL,uBAAC,QAAQ,OACH,KAAK,EACT,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,GAC9D,CACH,CAAC;AACJ,CAAC;AAhBD,oBAgBC;AAED,gBAAgB;AAChB,SAAgB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAwF;IAC3I,OAAO,CACL,uBAAC,uDAA6B,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,YAC1F,uBAAC,YAAY,OAAK,KAAK,GAAI,GACG,CACjC,CAAC;AACJ,CAAC;AAND,4BAMC;AAED,SAAS,YAAY,CAAC,EACpB,MAAM,EACN,YAAY,EACZ,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IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,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, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n return (\n <TreeBase\n {...props}\n getSchemaContext={getSchemaContext}\n selectionStorage={selectionStorage}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\n/** @internal */\nexport function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n currentHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FunctionProps } from "../Utils.js";
|
|
2
1
|
import type { TreeProps } from "./Tree.js";
|
|
2
|
+
import type { FunctionProps } from "../Utils.js";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
import type { VisibilityTreeRendererProps } from "./VisibilityTreeRenderer.js";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
@@ -17,5 +17,5 @@ export type VisibilityTreeProps = Omit<TreeProps, "treeRenderer" | "imodelAccess
|
|
|
17
17
|
* Tree component that can control visibility of instances represented by tree nodes.
|
|
18
18
|
* @beta
|
|
19
19
|
*/
|
|
20
|
-
export declare function VisibilityTree({ visibilityHandlerFactory, treeRenderer, ...props }: VisibilityTreeProps): JSX.Element;
|
|
20
|
+
export declare function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps): JSX.Element;
|
|
21
21
|
//# sourceMappingURL=VisibilityTree.d.ts.map
|
|
@@ -8,19 +8,23 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const UseHierarchyVisibility_js_1 = require("../UseHierarchyVisibility.js");
|
|
11
|
-
const
|
|
11
|
+
const UseIModelAccess_js_1 = require("../UseIModelAccess.js");
|
|
12
12
|
const Tree_js_1 = require("./Tree.js");
|
|
13
13
|
/**
|
|
14
14
|
* Tree component that can control visibility of instances represented by tree nodes.
|
|
15
15
|
* @beta
|
|
16
16
|
*/
|
|
17
|
-
function VisibilityTree({ visibilityHandlerFactory, treeRenderer, ...props }) {
|
|
17
|
+
function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }) {
|
|
18
18
|
const { imodel, getSchemaContext } = props;
|
|
19
|
-
const imodelAccess
|
|
19
|
+
const { imodelAccess, currentHierarchyLevelSizeLimit } = (0, UseIModelAccess_js_1.useIModelAccess)({
|
|
20
|
+
imodel,
|
|
21
|
+
getSchemaContext,
|
|
22
|
+
hierarchyLevelSizeLimit,
|
|
23
|
+
});
|
|
20
24
|
const { getCheckboxState, onCheckboxClicked, triggerRefresh } = (0, UseHierarchyVisibility_js_1.useHierarchyVisibility)({
|
|
21
25
|
visibilityHandlerFactory: (0, react_1.useCallback)(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),
|
|
22
26
|
});
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(Tree_js_1.
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(Tree_js_1.TreeBase, { ...props, onReload: triggerRefresh, imodelAccess: imodelAccess, currentHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit, treeRenderer: (treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked }) }));
|
|
24
28
|
}
|
|
25
29
|
exports.VisibilityTree = VisibilityTree;
|
|
26
30
|
//# sourceMappingURL=VisibilityTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,
|
|
1
|
+
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAoC;AACpC,4EAAsE;AACtE,8DAAwD;AACxD,uCAAqC;AAmBrC;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM;QACN,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAA,kDAAsB,EAAC;QACrF,wBAAwB,EAAE,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kBAAQ,OACH,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,EAC9D,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,GAChG,CACH,CAAC;AACJ,CAAC;AArBD,wCAqBC","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 } from \"react\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { TreeBase } from \"./Tree.js\";\n\nimport type { TreeProps } from \"./Tree.js\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { VisibilityTreeRendererProps } from \"./VisibilityTreeRenderer.js\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { HierarchyVisibilityHandler } from \"../UseHierarchyVisibility.js\";\n\n/** @beta */\nexport type VisibilityTreeProps = Omit<TreeProps, \"treeRenderer\" | \"imodelAccess\"> & {\n /** Callback for creating visibility handler used to control visibility of instances represented by tree nodes. */\n visibilityHandlerFactory: (props: { imodelAccess: ECClassHierarchyInspector }) => HierarchyVisibilityHandler;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: FunctionProps<TreeProps[\"treeRenderer\"]> & Pick<VisibilityTreeRendererProps, \"getCheckboxState\" | \"onCheckboxClicked\">,\n ) => ReactNode;\n};\n\n/**\n * Tree component that can control visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps) {\n const { imodel, getSchemaContext } = props;\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n\n const { getCheckboxState, onCheckboxClicked, triggerRefresh } = useHierarchyVisibility({\n visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),\n });\n\n return (\n <TreeBase\n {...props}\n onReload={triggerRefresh}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n treeRenderer={(treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked })}\n />\n );\n}\n"]}
|
package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { IModelContentTreeHierarchyConfiguration } from "./IModelContentTreeDefinition.js";
|
|
2
3
|
import type { TreeProps } from "../common/components/Tree.js";
|
|
3
4
|
/** @beta */
|
|
4
5
|
export type IModelContentTreeProps = Pick<TreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode"> & {
|
|
5
6
|
hierarchyLevelConfig?: {
|
|
6
7
|
sizeLimit?: number;
|
|
7
8
|
};
|
|
9
|
+
hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;
|
|
8
10
|
};
|
|
9
11
|
/** @beta */
|
|
10
|
-
export declare function IModelContentTree(props: IModelContentTreeProps): JSX.Element;
|
|
12
|
+
export declare function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }: IModelContentTreeProps): JSX.Element;
|
|
11
13
|
//# sourceMappingURL=IModelContentTree.d.ts.map
|
|
@@ -6,6 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
const react_1 = require("react");
|
|
9
10
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
10
11
|
const Tree_js_1 = require("../common/components/Tree.js");
|
|
11
12
|
const TreeRenderer_js_1 = require("../common/components/TreeRenderer.js");
|
|
@@ -13,16 +14,19 @@ const IModelContentTreeComponent_js_1 = require("./IModelContentTreeComponent.js
|
|
|
13
14
|
const IModelContentTreeDefinition_js_1 = require("./IModelContentTreeDefinition.js");
|
|
14
15
|
const IModelContentTreeIdsCache_js_1 = require("./internal/IModelContentTreeIdsCache.js");
|
|
15
16
|
/** @beta */
|
|
16
|
-
function IModelContentTree(props) {
|
|
17
|
-
|
|
17
|
+
function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }) {
|
|
18
|
+
const getHierarchyDefinition = (0, react_1.useCallback)(({ imodelAccess }) => {
|
|
19
|
+
const hierarchyConfig = {
|
|
20
|
+
...IModelContentTreeDefinition_js_1.defaultHierarchyConfiguration,
|
|
21
|
+
...hierarchyConfigProp,
|
|
22
|
+
};
|
|
23
|
+
return new IModelContentTreeDefinition_js_1.IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache_js_1.IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });
|
|
24
|
+
},
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
Object.values(hierarchyConfigProp ?? {}));
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(Tree_js_1.Tree, { ...props, treeName: IModelContentTreeComponent_js_1.IModelContentTreeComponent.id, getHierarchyDefinition: getHierarchyDefinition, selectionMode: props.selectionMode ?? "extended", treeRenderer: (treeProps) => (0, jsx_runtime_1.jsx)(TreeRenderer_js_1.TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
18
28
|
}
|
|
19
29
|
exports.IModelContentTree = IModelContentTree;
|
|
20
|
-
const getDefinitionsProvider = ({ imodelAccess }) => {
|
|
21
|
-
return new IModelContentTreeDefinition_js_1.IModelContentTreeDefinition({
|
|
22
|
-
imodelAccess,
|
|
23
|
-
idsCache: new IModelContentTreeIdsCache_js_1.IModelContentTreeIdsCache(imodelAccess),
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
30
|
function getIcon(node) {
|
|
27
31
|
if (node.extendedData?.imageId === undefined) {
|
|
28
32
|
return undefined;
|
package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,oEAAkI;AAClI,0DAAoD;AACpD,0EAAoE;AACpE,mFAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAoC;AACpC,oEAAkI;AAClI,0DAAoD;AACpD,0EAAoE;AACpE,mFAA6E;AAC7E,qFAA8G;AAC9G,0FAAoF;AAepF,YAAY;AACZ,SAAgB,iBAAiB,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG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B;YACxB,OAAO,uBAAC,sCAAgB,KAAG,CAAC;QAC9B,KAAK,YAAY;YACf,OAAO,uBAAC,8BAAQ,KAAG,CAAC;KACvB;IAED,OAAO,SAAS,CAAC;AACnB,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 } from \"react\";\nimport { SvgFolder, SvgGroup, SvgHierarchyTree, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { ReactElement } from \"react\";\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n};\n\n/** @beta */\nexport function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }: IModelContentTreeProps) {\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfigProp ?? {}),\n );\n\n return (\n <Tree\n {...props}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={props.selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\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-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgItem />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n case \"icon-hierarchy-tree\":\n return <SvgHierarchyTree />;\n case \"icon-group\":\n return <SvgGroup />;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IModelContentTreeProps } from "./IModelContentTree.js";
|
|
3
3
|
/** @beta */
|
|
4
|
-
interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode"> {
|
|
4
|
+
interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyConfig" | "hierarchyLevelConfig" | "selectionMode"> {
|
|
5
5
|
onPerformanceMeasured?: (featureId: string, duration: number) => void;
|
|
6
6
|
onFeatureUsed?: (feature: string) => void;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,oDAA+D;AAC/D,0DAAoD;AACpD,6EAA4E;AAC5E,iEAA2D;AAW3D;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAChI,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,uBAAC,iDAAwB,IAAC,mBAAmB,EAAE,kCAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,uBAAC,wCAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,GACvB,CAC5B,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC;AAEF;;;GAGG;AACH,kCAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,kCAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,0BAAU,CAAC,SAAS,CAAC,yBAAyB,CAAC,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<IModelContentTreeProps, \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\"> {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <IModelContentTree {...props} imodel={imodel} />\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
|
|
1
|
+
{"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,oDAA+D;AAC/D,0DAAoD;AACpD,6EAA4E;AAC5E,iEAA2D;AAW3D;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAChI,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,uBAAC,iDAAwB,IAAC,mBAAmB,EAAE,kCAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,uBAAC,wCAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,GACvB,CAC5B,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC;AAEF;;;GAGG;AACH,kCAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,kCAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,0BAAU,CAAC,SAAS,CAAC,yBAAyB,CAAC,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<IModelContentTreeProps, \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyConfig\" | \"hierarchyLevelConfig\" | \"selectionMode\"> {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <IModelContentTree {...props} imodel={imodel} />\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
|
|
@@ -2,19 +2,30 @@ import { ProcessedHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
|
2
2
|
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
|
|
4
4
|
import type { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
|
|
5
|
+
/**
|
|
6
|
+
* Defines hierarchy configuration supported by `IModelContentTree`.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface IModelContentTreeHierarchyConfiguration {
|
|
10
|
+
/** Should the root Subject node be hidden. Defaults to `false`. */
|
|
11
|
+
hideRootSubject: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const defaultHierarchyConfiguration: IModelContentTreeHierarchyConfiguration;
|
|
5
15
|
interface IModelContentTreeDefinitionProps {
|
|
6
16
|
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;
|
|
7
17
|
idsCache: IModelContentTreeIdsCache;
|
|
18
|
+
hierarchyConfig: IModelContentTreeHierarchyConfiguration;
|
|
8
19
|
}
|
|
9
20
|
export declare class IModelContentTreeDefinition implements HierarchyDefinition {
|
|
10
21
|
private _impl;
|
|
11
22
|
private _idsCache;
|
|
23
|
+
private _hierarchyConfig;
|
|
12
24
|
private _selectQueryFactory;
|
|
13
25
|
private _nodeLabelSelectClauseFactory;
|
|
14
26
|
constructor(props: IModelContentTreeDefinitionProps);
|
|
15
27
|
postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode>;
|
|
16
28
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
17
|
-
private createRootHierarchyLevelDefinition;
|
|
18
29
|
private createSubjectChildrenQuery;
|
|
19
30
|
private createISubModeledElementChildrenQuery;
|
|
20
31
|
private createGeometricModelChildrenQuery;
|