@itwin/tree-widget-react 1.2.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -2
- package/README.md +1 -1
- package/lib/cjs/TreeWidget.d.ts +0 -1
- package/lib/cjs/TreeWidget.js +9 -10
- package/lib/cjs/TreeWidget.js.map +1 -1
- package/lib/cjs/components/SelectableTree.d.ts +9 -1
- package/lib/cjs/components/SelectableTree.js +28 -17
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/SelectableTree.scss +0 -16
- package/lib/cjs/components/TreeFilteringState.js +3 -3
- package/lib/cjs/components/TreeFilteringState.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +28 -0
- package/lib/cjs/components/TreeSelector.js +27 -0
- package/lib/cjs/components/TreeSelector.js.map +1 -0
- package/lib/cjs/components/TreeSelector.scss +27 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +9 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +21 -14
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.scss +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +3 -0
- package/lib/cjs/components/tree-header/TreeHeader.js +20 -15
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.scss +29 -1
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +13 -8
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeBase.scss +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +18 -10
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +20 -4
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +28 -10
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +7 -2
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +47 -30
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +27 -18
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -2
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +18 -13
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/common/ContextMenu.js +4 -4
- package/lib/cjs/components/trees/common/ContextMenu.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeNodeRenderer.d.ts +1 -1
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js +4 -4
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +15 -1
- package/lib/cjs/components/trees/common/TreeRenderer.js +17 -7
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +39 -2
- package/lib/cjs/components/trees/common/Types.d.ts +8 -0
- package/lib/cjs/components/trees/common/Types.js +3 -3
- package/lib/cjs/components/trees/common/Types.js.map +1 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +36 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +47 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -0
- package/lib/cjs/components/trees/common/Utils.js +7 -5
- package/lib/cjs/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +1 -3
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +9 -3
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +19 -7
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +4 -4
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +9 -3
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +16 -12
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +6 -5
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/index.js +3 -3
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +7 -2
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +76 -62
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +27 -29
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +9 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +31 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +125 -66
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/Utils.d.ts +4 -0
- package/lib/cjs/components/trees/models-tree/Utils.js +52 -58
- package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/components/utils/AutoSizer.js +7 -5
- package/lib/cjs/components/utils/AutoSizer.js.map +1 -1
- package/lib/cjs/components/utils/IsPromiseLike.js +4 -4
- package/lib/cjs/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/cjs/components/utils/UseTreeTransientState.js +3 -3
- package/lib/cjs/components/utils/UseTreeTransientState.js.map +1 -1
- package/lib/cjs/tree-widget-react.js +3 -3
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/TreeWidget.d.ts +0 -1
- package/lib/esm/TreeWidget.js +9 -10
- package/lib/esm/TreeWidget.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +9 -1
- package/lib/esm/components/SelectableTree.js +28 -17
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/SelectableTree.scss +0 -16
- package/lib/esm/components/TreeFilteringState.js +3 -3
- package/lib/esm/components/TreeFilteringState.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +28 -0
- package/lib/esm/components/TreeSelector.js +23 -0
- package/lib/esm/components/TreeSelector.js.map +1 -0
- package/lib/esm/components/TreeSelector.scss +27 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +9 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +19 -13
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.scss +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +3 -0
- package/lib/esm/components/tree-header/TreeHeader.js +20 -15
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.scss +29 -1
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js +13 -8
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeBase.scss +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +18 -10
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +20 -4
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +27 -10
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +7 -2
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +51 -34
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +24 -18
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -2
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +18 -13
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/common/ContextMenu.js +4 -4
- package/lib/esm/components/trees/common/ContextMenu.js.map +1 -1
- package/lib/esm/components/trees/common/TreeNodeRenderer.d.ts +1 -1
- package/lib/esm/components/trees/common/TreeNodeRenderer.js +4 -4
- package/lib/esm/components/trees/common/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +15 -1
- package/lib/esm/components/trees/common/TreeRenderer.js +15 -6
- package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +39 -2
- package/lib/esm/components/trees/common/Types.d.ts +8 -0
- package/lib/esm/components/trees/common/Types.js +3 -3
- package/lib/esm/components/trees/common/Types.js.map +1 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +36 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +43 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -0
- package/lib/esm/components/trees/common/Utils.js +7 -5
- package/lib/esm/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +1 -3
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +9 -3
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +22 -10
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +4 -4
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +9 -3
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +19 -15
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +6 -5
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/index.js +3 -3
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +7 -2
- package/lib/esm/components/trees/models-tree/ModelsTree.js +80 -66
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +25 -30
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +9 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +27 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +125 -66
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/Utils.d.ts +4 -0
- package/lib/esm/components/trees/models-tree/Utils.js +50 -57
- package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/components/utils/AutoSizer.js +7 -5
- package/lib/esm/components/utils/AutoSizer.js.map +1 -1
- package/lib/esm/components/utils/IsPromiseLike.js +4 -4
- package/lib/esm/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/esm/components/utils/UseTreeTransientState.js +3 -3
- package/lib/esm/components/utils/UseTreeTransientState.js.map +1 -1
- package/lib/esm/tree-widget-react.js +3 -3
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +1 -0
- package/package.json +47 -46
- package/lib/cjs/e2e-tests/TreeWidget.test.d.ts +0 -2
- package/lib/cjs/e2e-tests/TreeWidget.test.js +0 -51
- package/lib/cjs/e2e-tests/TreeWidget.test.js.map +0 -1
- package/lib/cjs/e2e-tests/utils.d.ts +0 -9
- package/lib/cjs/e2e-tests/utils.js +0 -51
- package/lib/cjs/e2e-tests/utils.js.map +0 -1
- package/lib/esm/e2e-tests/TreeWidget.test.d.ts +0 -2
- package/lib/esm/e2e-tests/TreeWidget.test.js +0 -46
- package/lib/esm/e2e-tests/TreeWidget.test.js.map +0 -1
- package/lib/esm/e2e-tests/utils.d.ts +0 -9
- package/lib/esm/e2e-tests/utils.js +0 -40
- package/lib/esm/e2e-tests/utils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/Utils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oEAAqD;AAOrD,gBAAgB;AAChB,MAAa,0BAA0B;IAErC,YAAoB,UAAsC;QAAtC,eAAU,GAAV,UAAU,CAA4B;QADlD,SAAI,GAAG,IAAI,KAAK,EAAc,CAAC;IAEvC,CAAC;IAEO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAE9D,KAAK,CAAA,CAAE,aAAa;QACzB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE;YAC1B,MAAM,EAAE,CAAC;SACV;QAED,IAAI,MAAM,CAAC;QACX,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CA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C;AAC9B,CAAC;AAJD,gEAIC","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 { NodeKey } from \"@itwin/presentation-common\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { ChildNodeSpecification, Node, Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { DelayLoadedTreeNodeItem } from \"@itwin/components-react\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTree\";\n\n/** @internal */\nexport class CachingElementIdsContainer {\n private _ids = new Array<Id64String>();\n constructor(private _generator: AsyncGenerator<Id64String>) {\n }\n\n private async next() { return (await this._generator.next()).value; }\n\n public async* getElementIds() {\n for (const id of this._ids) {\n yield id;\n }\n\n let nextId;\n while (nextId = await this.next()) {\n this._ids.push(nextId);\n yield nextId;\n }\n }\n}\n\n/** @internal */\nexport type CreateRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\"> & {\n enableElementsClassGrouping?: boolean;\n};\n\n/** @internal */\nexport function createRuleset(props: CreateRulesetProps): Ruleset {\n const context: SpecificationsContext = {\n elementClassSpecification: props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" },\n groupElements: !!props.enableElementsClassGrouping,\n showEmptyModels: !!props.showEmptyModels,\n };\n\n return {\n id: \"tree-widget-react/ModelsTree\",\n requiredSchemas: [\n {\n name: \"BisCore\",\n },\n ],\n rules: [\n {\n ruleType: \"RootNodes\",\n autoExpand: true,\n specifications: [\n createRootSubjectSpecification(),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-imodel-hollow-2\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n createRelatedHierarchySubjectSpecification(),\n createRelatedNonHierarchySubjectSpecification(),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-folder\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n createNonContentModelsSpecification(context),\n createContentModelsSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"ISubModeledElement\", \"BisCore\")`,\n specifications: [\n createElementModelSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n createModelCategoriesSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isCategory: \"true\",\n modelId: \"ParentNode.InstanceId\",\n icon: \"\\\"icon-layers\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"SpatialCategory\", \"BisCore\")`,\n specifications: [\n createCategoryElementsSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: \"\\\"icon-item\\\"\",\n groupIcon: \"\\\"icon-ec-class\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricElement3d\", \"BisCore\")`,\n specifications: [\n createEementElementsSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: \"\\\"icon-item\\\"\",\n groupIcon: \"\\\"icon-ec-class\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"SpatialCategory\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Content\",\n condition: `ContentDisplayType = \"AssemblyElementsRequest\"`,\n specifications: [\n {\n specType: \"SelectedNodeInstances\",\n },\n {\n specType: \"ContentRelatedInstances\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n count: \"*\",\n },\n ],\n },\n ],\n },\n ],\n };\n}\n\n/** @internal */\nexport type CreateSearchRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\">;\n\n/** @internal */\nexport function createSearchRuleset(props: CreateSearchRulesetProps): Ruleset {\n const context: SpecificationsContext = {\n elementClassSpecification: props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" },\n groupElements: false,\n showEmptyModels: !!props.showEmptyModels,\n };\n\n return {\n id: \"tree-widget-react/ModelsTreeSearch\",\n rules: [\n {\n ruleType: \"RootNodes\",\n specifications: [\n createRootSubjectSpecification(),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-imodel-hollow-2\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n createRelatedHierarchySubjectSpecification(),\n {\n ...createRelatedNonHierarchySubjectSpecification(),\n hideExpression: `NOT ThisNode.HasChildren ANDALSO NOT ThisNode.ChildrenArtifacts.AnyMatches(x => x.isContentModel)`,\n hideIfNoChildren: undefined,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-folder\\\"\",\n },\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n ...createNonContentModelsSpecification(context),\n hasChildren: \"Unknown\",\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n ...createContentModelsSpecification(context),\n hasChildren: \"Unknown\",\n },\n ],\n customizationRules: [\n {\n ruleType: \"NodeArtifacts\",\n items: {\n isContentModel: \"true\",\n },\n },\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n createModelSubModelsSpecification(context),\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n ],\n };\n}\n\ninterface SpecificationsContext {\n elementClassSpecification: SingleSchemaClassSpecification;\n groupElements: boolean;\n showEmptyModels: boolean;\n}\n\nfunction createRootSubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\n \"Subject\",\n ],\n },\n ],\n instanceFilter: `this.Parent = NULL`,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createRelatedHierarchySubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createRelatedNonHierarchySubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createNonContentModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)`;\n const modelHasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n\n const hasNoContent = `json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") = NULL AND json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") = NULL`;\n const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND ${hasNoContent}${showEmptyModels ? \"\" : ` AND ${modelHasElements}`}`;\n\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n instanceFilter,\n hasChildren: showEmptyModels ? \"Unknown\" : \"Always\",\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createContentModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)`;\n const modelHasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n\n const hasContent = `json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") <> NULL OR json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") <> NULL`;\n const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND (${hasContent})${showEmptyModels ? \"\" : ` AND ${modelHasElements}`}`;\n\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\"GeometricModel3d\"],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n instanceFilter,\n hasChildren: showEmptyModels ? \"Unknown\" : \"Always\",\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createElementModelSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const hasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? \"\" : ` AND ${hasElements}`}`;\n\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Backward\",\n },\n ],\n instanceFilter,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createModelCategoriesSpecification({ elementClassSpecification }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelContainsElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Forward\",\n },\n ],\n ],\n instanceFilter: `NOT this.IsPrivate`,\n suppressSimilarAncestorsCheck: true,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createCategoryElementsSpecification({ elementClassSpecification, groupElements }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Backward\",\n targetClass: elementClassSpecification,\n },\n ],\n instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,\n groupByClass: groupElements,\n groupByLabel: false,\n };\n}\n\nfunction createEementElementsSpecification({ elementClassSpecification, groupElements }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n ],\n groupByClass: groupElements,\n groupByLabel: false,\n };\n}\n\nfunction createModelSubModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const hasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? \"\" : ` AND ${hasElements}`}`;\n\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelOwnsSubModel\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"GeometricModel3d\",\n },\n },\n ],\n instanceFilter,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\n/** @internal */\nexport function addModelsTreeNodeItemIcons(item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) {\n item.icon = node.key && NodeKey.isClassGroupingNodeKey(node.key)\n ? node.extendedData?.groupIcon\n : node.extendedData?.icon;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAIhG,oEAAqD;AAQrD,gBAAgB;AAChB,MAAa,0BAA0B;IAErC,YAAoB,UAAsC;QAAtC,eAAU,GAAV,UAAU,CAA4B;QADlD,SAAI,GAAG,IAAI,KAAK,EAAc,CAAC;IACsB,CAAC;IAEtD,KAAK,CAAC,IAAI;QAChB,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,CAAC,aAAa;QACzB,KAAK,MA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AAG,IAAI,CAAC,GAAG,IAAI,6BAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;AAC5H,CAAC;AAFD,gEAEC;AAED,gBAAgB;AACT,KAAK,UAAU,2BAA2B,CAAC,MAAwB;IACxE,MAAM,WAAW,GAAqB;QACpC,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE;;;;;;;OAOJ;QACH,WAAW,EAAE,KAAK;KACnB,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAgB,CAAC;AAC/I,CAAC;AAhBD,kEAgBC","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 type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\n\nimport type { ModelInfo } from \"./ModelsTreeComponent\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { ChildNodeSpecification, Node, Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { DelayLoadedTreeNodeItem } from \"@itwin/components-react\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTree\";\n/** @internal */\nexport class CachingElementIdsContainer {\n private _ids = new Array<Id64String>();\n constructor(private _generator: AsyncGenerator<Id64String>) {}\n\n private async next() {\n return (await this._generator.next()).value;\n }\n\n public async *getElementIds() {\n for (const id of this._ids) {\n yield id;\n }\n\n let nextId;\n while ((nextId = await this.next())) {\n this._ids.push(nextId);\n yield nextId;\n }\n }\n}\n\n/** @internal */\nexport type CreateRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\"> & {\n enableElementsClassGrouping?: boolean;\n};\n\n/** @internal */\nexport function createRuleset(props: CreateRulesetProps): Ruleset {\n const context: SpecificationsContext = {\n elementClassSpecification: props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" },\n groupElements: !!props.enableElementsClassGrouping,\n showEmptyModels: !!props.showEmptyModels,\n };\n\n return {\n id: \"tree-widget-react/ModelsTree\",\n requiredSchemas: [\n {\n name: \"BisCore\",\n },\n ],\n rules: [\n {\n ruleType: \"RootNodes\",\n autoExpand: true,\n specifications: [createRootSubjectSpecification()],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: '\"icon-imodel-hollow-2\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [createRelatedHierarchySubjectSpecification(), createRelatedNonHierarchySubjectSpecification()],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: '\"icon-folder\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [createNonContentModelsSpecification(context), createContentModelsSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: '\"icon-model\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"ISubModeledElement\", \"BisCore\")`,\n specifications: [createElementModelSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: '\"icon-model\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [createModelCategoriesSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isCategory: \"true\",\n modelId: \"ParentNode.InstanceId\",\n icon: '\"icon-layers\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"SpatialCategory\", \"BisCore\")`,\n specifications: [createCategoryElementsSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: '\"icon-item\"',\n groupIcon: '\"icon-ec-class\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricElement3d\", \"BisCore\")`,\n specifications: [createEementElementsSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: '\"icon-item\"',\n groupIcon: '\"icon-ec-class\"',\n },\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"SpatialCategory\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Content\",\n condition: `ContentDisplayType = \"AssemblyElementsRequest\"`,\n specifications: [\n {\n specType: \"SelectedNodeInstances\",\n },\n {\n specType: \"ContentRelatedInstances\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n count: \"*\",\n },\n ],\n },\n ],\n },\n ],\n };\n}\n\n/** @internal */\nexport type CreateSearchRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\">;\n\n/** @internal */\nexport function createSearchRuleset(props: CreateSearchRulesetProps): Ruleset {\n const context: SpecificationsContext = {\n elementClassSpecification: props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" },\n groupElements: false,\n showEmptyModels: !!props.showEmptyModels,\n };\n\n return {\n id: \"tree-widget-react/ModelsTreeSearch\",\n rules: [\n {\n ruleType: \"RootNodes\",\n specifications: [createRootSubjectSpecification()],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: '\"icon-imodel-hollow-2\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n createRelatedHierarchySubjectSpecification(),\n {\n ...createRelatedNonHierarchySubjectSpecification(),\n hideExpression: `NOT ThisNode.HasChildren ANDALSO NOT ThisNode.ChildrenArtifacts.AnyMatches(x => x.isContentModel)`,\n hideIfNoChildren: undefined,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: '\"icon-folder\"',\n },\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n ...createNonContentModelsSpecification(context),\n hasChildren: \"Unknown\",\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: '\"icon-model\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n ...createContentModelsSpecification(context),\n hasChildren: \"Unknown\",\n },\n ],\n customizationRules: [\n {\n ruleType: \"NodeArtifacts\",\n items: {\n isContentModel: \"true\",\n },\n },\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: '\"icon-model\"',\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [createModelSubModelsSpecification(context)],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: '\"icon-model\"',\n },\n },\n ],\n },\n ],\n };\n}\n\ninterface SpecificationsContext {\n elementClassSpecification: SingleSchemaClassSpecification;\n groupElements: boolean;\n showEmptyModels: boolean;\n}\n\nfunction createRootSubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\"Subject\"],\n },\n ],\n instanceFilter: `this.Parent = NULL`,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createRelatedHierarchySubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createRelatedNonHierarchySubjectSpecification(): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createNonContentModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)`;\n const modelHasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n\n const hasNoContent = `json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") = NULL AND json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") = NULL`;\n const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND ${hasNoContent}${showEmptyModels ? \"\" : ` AND ${modelHasElements}`}`;\n\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\"GeometricModel3d\"],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n instanceFilter,\n hasChildren: showEmptyModels ? \"Unknown\" : \"Always\",\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createContentModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)`;\n const modelHasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n\n const hasContent = `json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") <> NULL OR json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") <> NULL`;\n const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND (${hasContent})${showEmptyModels ? \"\" : ` AND ${modelHasElements}`}`;\n\n return {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\"GeometricModel3d\"],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n instanceFilter,\n hasChildren: showEmptyModels ? \"Unknown\" : \"Always\",\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createElementModelSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const hasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? \"\" : ` AND ${hasElements}`}`;\n\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Backward\",\n },\n ],\n instanceFilter,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createModelCategoriesSpecification({ elementClassSpecification }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelContainsElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Forward\",\n },\n ],\n ],\n instanceFilter: `NOT this.IsPrivate`,\n suppressSimilarAncestorsCheck: true,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\nfunction createCategoryElementsSpecification({ elementClassSpecification, groupElements }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Backward\",\n targetClass: elementClassSpecification,\n },\n ],\n instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,\n groupByClass: groupElements,\n groupByLabel: false,\n };\n}\n\nfunction createEementElementsSpecification({ elementClassSpecification, groupElements }: SpecificationsContext): ChildNodeSpecification {\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n ],\n groupByClass: groupElements,\n groupByLabel: false,\n };\n}\n\nfunction createModelSubModelsSpecification({ elementClassSpecification, showEmptyModels }: SpecificationsContext): ChildNodeSpecification {\n const hasElements = `this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`;\n const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? \"\" : ` AND ${hasElements}`}`;\n\n return {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelOwnsSubModel\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"GeometricModel3d\",\n },\n },\n ],\n instanceFilter,\n groupByClass: false,\n groupByLabel: false,\n };\n}\n\n/** @internal */\nexport function addModelsTreeNodeItemIcons(item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) {\n item.icon = node.key && NodeKey.isClassGroupingNodeKey(node.key) ? node.extendedData?.groupIcon : node.extendedData?.icon;\n}\n\n/** @internal */\nexport async function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n"]}
|
|
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AutoSizer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
/*---------------------------------------------------------------------------------------------
|
|
6
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const core_react_1 = require("@itwin/core-react");
|
|
11
11
|
// istanbul ignore next
|
|
12
12
|
/** @internal */
|
|
13
13
|
function AutoSizer(props) {
|
|
14
14
|
const [{ height, width }, setSize] = (0, react_1.useState)({ height: 0, width: 0 });
|
|
15
|
-
const handleResize = (0, react_1.useCallback)((w, h) => {
|
|
16
|
-
|
|
15
|
+
const handleResize = (0, react_1.useCallback)((w, h) => {
|
|
16
|
+
setSize({ height: h, width: w });
|
|
17
|
+
}, []);
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(core_react_1.ResizableContainerObserver, { onResize: handleResize, children: props.children({ height, width }) });
|
|
17
19
|
}
|
|
18
20
|
exports.AutoSizer = AutoSizer;
|
|
19
21
|
//# sourceMappingURL=AutoSizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoSizer.js","sourceRoot":"","sources":["../../../../src/components/utils/AutoSizer.tsx"],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"AutoSizer.js","sourceRoot":"","sources":["../../../../src/components/utils/AutoSizer.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA8C;AAC9C,kDAA+D;AAa/D,uBAAuB;AACvB,gBAAgB;AAChB,SAAgB,SAAS,CAAC,KAAqB;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,IAAA,mBAAW,EAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACxD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,uBAAC,uCAA0B,IAAC,QAAQ,EAAE,YAAY,YAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAA8B,CAAC;AAC9H,CAAC;AAPD,8BAOC","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 { ResizableContainerObserver } from \"@itwin/core-react\";\n\n/** @internal */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** @internal */\nexport interface AutoSizerProps {\n children: (size: Size) => React.ReactNode;\n}\n\n// istanbul ignore next\n/** @internal */\nexport function AutoSizer(props: AutoSizerProps) {\n const [{ height, width }, setSize] = useState<Size>({ height: 0, width: 0 });\n const handleResize = useCallback((w: number, h: number) => {\n setSize({ height: h, width: w });\n }, []);\n\n return <ResizableContainerObserver onResize={handleResize}>{props.children({ height, width })}</ResizableContainerObserver>;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.isPromiseLike = void 0;
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ exports.isPromiseLike = void 0;
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
function isPromiseLike(obj) {
|
|
13
|
-
return !!(obj &&
|
|
13
|
+
return !!(obj && typeof obj === "object" && typeof obj.then === "function");
|
|
14
14
|
}
|
|
15
15
|
exports.isPromiseLike = isPromiseLike;
|
|
16
16
|
//# sourceMappingURL=IsPromiseLike.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsPromiseLike.js","sourceRoot":"","sources":["../../../../src/components/utils/IsPromiseLike.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"IsPromiseLike.js","sourceRoot":"","sources":["../../../../src/components/utils/IsPromiseLike.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;GAGG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAQ,GAAW,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;AACvF,CAAC;AAFD,sCAEC","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\n/**\n * Checks if the specified argument is a promise\n * @internal\n */\nexport function isPromiseLike(obj: unknown): obj is PromiseLike<unknown> {\n return !!(obj && typeof obj === \"object\" && typeof (obj as any).then === \"function\");\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.useTreeTransientState = void 0;
|
|
8
8
|
const appui_react_1 = require("@itwin/appui-react");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseTreeTransientState.js","sourceRoot":"","sources":["../../../../src/components/utils/UseTreeTransientState.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"UseTreeTransientState.js","sourceRoot":"","sources":["../../../../src/components/utils/UseTreeTransientState.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAuD;AACvD,8DAAyE;AAEzE,uBAAuB;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,qBAAqB;IACnC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,iDAA8B,GAAK,CAAC;IACtE,IAAA,+BAAiB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAJD,sDAIC","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 { useTransientState } from \"@itwin/appui-react\";\nimport { useControlledTreeLayoutStorage } from \"@itwin/components-react\";\n\n// istanbul ignore file\n\n/**\n * Allows to persist tree scroll position when tree is used in `@itwin/appui-react` Widgets.\n * Returned `ref` should be passed to container element containing tree component.\n *\n * Example:\n * ```typescript\n * function ModelsTreeWidget() {\n * const ref = useTreeTransientState<HTMLDivElement>();\n * return <div ref={ref}>\n * <ModelsTree />\n * </div>\n * }\n * ```\n *\n * @public\n */\nexport function useTreeTransientState<T extends Element>() {\n const { ref, persist, restore } = useControlledTreeLayoutStorage<T>();\n useTransientState(persist, restore);\n return ref;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
8
8
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;AAEhG,+CAA6B;AAC7B,8DAA4C;AAC5C,qDAAmC;AACnC,yEAAuD;AACvD,2EAAyD","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\nexport * from \"./TreeWidget\";\nexport * from \"./components/SelectableTree\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\nexport * from \"./components/utils/UseTreeTransientState\";\n"]}
|
package/lib/esm/TreeWidget.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export declare class TreeWidget {
|
|
|
19
19
|
static get i18n(): Localization;
|
|
20
20
|
/** The internationalization service namespace. */
|
|
21
21
|
static get i18nNamespace(): string;
|
|
22
|
-
static get packageName(): string;
|
|
23
22
|
/** Calls i18n.translateWithNamespace with the "TreeWidget" namespace. Do NOT include the namespace in the key.
|
|
24
23
|
*/
|
|
25
24
|
static translate(key: string | string[], options?: LocalizationOptions): string;
|
package/lib/esm/TreeWidget.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { BentleyError, BentleyStatus } from "@itwin/core-common";
|
|
6
6
|
import { IModelApp } from "@itwin/core-frontend";
|
|
7
7
|
import { registerRenderers } from "./components/trees/common/Utils";
|
|
8
8
|
/**
|
|
@@ -15,8 +15,9 @@ export class TreeWidget {
|
|
|
15
15
|
* @param i18n - The internationalization service created by the IModelApp.
|
|
16
16
|
*/
|
|
17
17
|
static async initialize(i18n) {
|
|
18
|
-
if (this._initialized)
|
|
18
|
+
if (this._initialized) {
|
|
19
19
|
return;
|
|
20
|
+
}
|
|
20
21
|
TreeWidget._initialized = true;
|
|
21
22
|
TreeWidget._i18n = i18n ?? IModelApp.localization;
|
|
22
23
|
TreeWidget._dispose = registerRenderers();
|
|
@@ -36,17 +37,15 @@ export class TreeWidget {
|
|
|
36
37
|
}
|
|
37
38
|
/** The internationalization service created by the IModelApp. */
|
|
38
39
|
static get i18n() {
|
|
39
|
-
if (!TreeWidget._i18n)
|
|
40
|
-
throw new
|
|
40
|
+
if (!TreeWidget._i18n) {
|
|
41
|
+
throw new BentleyError(BentleyStatus.ERROR, "TreeWidget not initialized");
|
|
42
|
+
}
|
|
41
43
|
return TreeWidget._i18n;
|
|
42
44
|
}
|
|
43
45
|
/** The internationalization service namespace. */
|
|
44
46
|
static get i18nNamespace() {
|
|
45
47
|
return "TreeWidget";
|
|
46
48
|
}
|
|
47
|
-
static get packageName() {
|
|
48
|
-
return "tree-widget-react";
|
|
49
|
-
}
|
|
50
49
|
/** Calls i18n.translateWithNamespace with the "TreeWidget" namespace. Do NOT include the namespace in the key.
|
|
51
50
|
*/
|
|
52
51
|
static translate(key, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeWidget.js","sourceRoot":"","sources":["../../src/TreeWidget.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"TreeWidget.js","sourceRoot":"","sources":["../../src/TreeWidget.ts"],"names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B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;OACG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB,EAAE,OAA6B;QAC3E,MAAM,SAAS,GAAG,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF","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 type { Localization } from \"@itwin/core-common\";\nimport { BentleyError, BentleyStatus } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { registerRenderers } from \"./components/trees/common/Utils\";\n\nimport type { LocalizationOptions } from \"@itwin/core-i18n\";\n\n/**\n * Entry point for static initialization required by various components used in the package.\n * @public\n */\nexport class TreeWidget {\n private static _i18n?: Localization;\n private static _initialized?: boolean;\n private static _dispose?: () => void;\n\n /**\n * Called by IModelApp to initialize the Tree Widget\n * @param i18n - The internationalization service created by the IModelApp.\n */\n public static async initialize(i18n?: Localization): Promise<void> {\n if (this._initialized) {\n return;\n }\n\n TreeWidget._initialized = true;\n TreeWidget._i18n = i18n ?? IModelApp.localization;\n TreeWidget._dispose = registerRenderers();\n return TreeWidget._i18n.registerNamespace(TreeWidget.i18nNamespace);\n }\n\n /** Unregisters the TreeWidget internationalization service namespace */\n public static terminate() {\n if (TreeWidget._i18n) {\n TreeWidget._i18n.unregisterNamespace(TreeWidget.i18nNamespace);\n TreeWidget._i18n = undefined;\n }\n\n if (TreeWidget._dispose) {\n TreeWidget._dispose();\n TreeWidget._dispose = undefined;\n }\n\n TreeWidget._initialized = false;\n }\n\n /** The internationalization service created by the IModelApp. */\n public static get i18n(): Localization {\n if (!TreeWidget._i18n) {\n throw new BentleyError(BentleyStatus.ERROR, \"TreeWidget not initialized\");\n }\n return TreeWidget._i18n;\n }\n\n /** The internationalization service namespace. */\n public static get i18nNamespace(): string {\n return \"TreeWidget\";\n }\n\n /** Calls i18n.translateWithNamespace with the \"TreeWidget\" namespace. Do NOT include the namespace in the key.\n */\n public static translate(key: string | string[], options?: LocalizationOptions): string {\n const stringKey = `${TreeWidget.i18nNamespace}:${key}`;\n return TreeWidget.i18n.getLocalizedString(stringKey, options);\n }\n}\n"]}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./SelectableTree.scss";
|
|
3
3
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
4
|
+
/**
|
|
5
|
+
* Props for rendering trees
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface TreeRenderProps {
|
|
9
|
+
density?: "enlarged" | "default";
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
12
|
* Definition of a tree component displayed in [[SelectableTree]]
|
|
6
13
|
* @public
|
|
@@ -11,7 +18,7 @@ export interface TreeDefinition {
|
|
|
11
18
|
/** Callback that is used to get tree label */
|
|
12
19
|
getLabel: () => string;
|
|
13
20
|
/** Callback that is used to render tree component */
|
|
14
|
-
render: () => React.ReactNode;
|
|
21
|
+
render: (props: TreeRenderProps) => React.ReactNode;
|
|
15
22
|
/**
|
|
16
23
|
* Callback that is used to determine if tree should be shown for current active iModel connection.
|
|
17
24
|
* If callback is `undefined` tree is shown for all iModel connections.
|
|
@@ -24,6 +31,7 @@ export interface TreeDefinition {
|
|
|
24
31
|
*/
|
|
25
32
|
export interface SelectableTreeProps {
|
|
26
33
|
trees: TreeDefinition[];
|
|
34
|
+
density?: "enlarged" | "default";
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
37
|
* A component that renders a tree (combo box) selector and the selected tree component.
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
import "./SelectableTree.scss";
|
|
7
7
|
import { useEffect, useState } from "react";
|
|
8
8
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
9
|
-
import { SelectableContent } from "@itwin/components-react";
|
|
10
9
|
import { FillCentered } from "@itwin/core-react";
|
|
11
10
|
import { ProgressLinear } from "@itwin/itwinui-react";
|
|
12
11
|
import { TreeWidget } from "../TreeWidget";
|
|
12
|
+
import { TreeSelector } from "./TreeSelector";
|
|
13
13
|
/**
|
|
14
14
|
* A component that renders a tree (combo box) selector and the selected tree component.
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export function SelectableTree(props) {
|
|
18
18
|
const imodel = useActiveIModelConnection();
|
|
19
|
-
if (!imodel)
|
|
19
|
+
if (!imodel) {
|
|
20
20
|
return null;
|
|
21
|
+
}
|
|
21
22
|
return _jsx(SelectableTreeContent, { ...props, imodel: imodel });
|
|
22
23
|
}
|
|
23
24
|
function SelectableTreeContent(props) {
|
|
24
25
|
const { trees: treeDefinitions, imodel } = props;
|
|
25
26
|
const trees = useActiveTrees(treeDefinitions, imodel);
|
|
26
|
-
return (_jsx("div", { className: "tree-widget-selectable-tree", children: _jsx(
|
|
27
|
+
return (_jsx("div", { className: "tree-widget-selectable-tree", children: _jsx(TreeSelector, { ...getTreeSelectorProps(trees), density: props.density }) }));
|
|
27
28
|
}
|
|
28
29
|
function useActiveTrees(treeDefinitions, imodel) {
|
|
29
30
|
const [trees, setTrees] = useState();
|
|
30
31
|
useEffect(() => {
|
|
31
32
|
let disposed = false;
|
|
32
|
-
(async () => {
|
|
33
|
+
void (async () => {
|
|
33
34
|
const visibleTrees = await getActiveTrees(treeDefinitions, imodel);
|
|
34
35
|
// istanbul ignore else
|
|
35
36
|
if (!disposed) {
|
|
36
37
|
setTrees(visibleTrees);
|
|
37
38
|
}
|
|
38
39
|
})();
|
|
39
|
-
return () => {
|
|
40
|
+
return () => {
|
|
41
|
+
disposed = true;
|
|
42
|
+
};
|
|
40
43
|
}, [treeDefinitions, imodel]);
|
|
41
44
|
return trees;
|
|
42
45
|
}
|
|
@@ -53,37 +56,45 @@ async function getActiveTrees(treeDefinitions, imodel) {
|
|
|
53
56
|
};
|
|
54
57
|
return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined);
|
|
55
58
|
}
|
|
56
|
-
function
|
|
59
|
+
function getTreeSelectorProps(trees) {
|
|
57
60
|
if (trees === undefined) {
|
|
58
61
|
return {
|
|
59
62
|
defaultSelectedContentId: "loading",
|
|
60
|
-
|
|
63
|
+
trees: [
|
|
64
|
+
{
|
|
61
65
|
id: "loading",
|
|
62
66
|
label: "",
|
|
63
67
|
render: () => (_jsx(Delayed, { children: _jsx(ProgressLinear, { indeterminate: true }) })),
|
|
64
|
-
}
|
|
68
|
+
},
|
|
69
|
+
],
|
|
65
70
|
};
|
|
66
71
|
}
|
|
67
72
|
if (trees.length === 0) {
|
|
68
73
|
return {
|
|
69
74
|
defaultSelectedContentId: "no-trees",
|
|
70
|
-
|
|
75
|
+
trees: [
|
|
76
|
+
{
|
|
71
77
|
id: "no-trees",
|
|
72
78
|
label: "",
|
|
73
|
-
render: () =>
|
|
74
|
-
}
|
|
79
|
+
render: () => _jsx(FillCentered, { children: TreeWidget.translate("noTrees") }),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
84
|
return {
|
|
78
85
|
defaultSelectedContentId: trees[0].id,
|
|
79
|
-
|
|
86
|
+
trees,
|
|
80
87
|
};
|
|
81
88
|
}
|
|
82
89
|
function Delayed({ delay = 200, children }) {
|
|
83
90
|
const [show, setShow] = useState(false);
|
|
84
91
|
useEffect(() => {
|
|
85
|
-
const id = setTimeout(() => {
|
|
86
|
-
|
|
92
|
+
const id = setTimeout(() => {
|
|
93
|
+
setShow(true);
|
|
94
|
+
}, delay);
|
|
95
|
+
return () => {
|
|
96
|
+
clearTimeout(id);
|
|
97
|
+
};
|
|
87
98
|
}, [delay]);
|
|
88
99
|
if (!show) {
|
|
89
100
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectableTree.js","sourceRoot":"","sources":["../../../src/components/SelectableTree.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"SelectableTree.js","sourceRoot":"","sources":["../../../src/components/SelectableTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqC9C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAC,qBAAqB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AAC9D,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAyD;IACtF,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,KAAK,GAA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CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,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 \"./SelectableTree.scss\";\nimport { useEffect, useState } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { ProgressLinear } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../TreeWidget\";\n\nimport type { PropsWithChildren } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeContentDefinition, TreeSelectorProps } from \"./TreeSelector\";\nimport { TreeSelector } from \"./TreeSelector\";\n\n/**\n * Props for rendering trees\n * @public\n */\nexport interface TreeRenderProps {\n density?: \"enlarged\" | \"default\";\n}\n\n/**\n * Definition of a tree component displayed in [[SelectableTree]]\n * @public\n */\nexport interface TreeDefinition {\n /** Id of the tree */\n id: string;\n /** Callback that is used to get tree label */\n getLabel: () => string;\n /** Callback that is used to render tree component */\n render: (props: TreeRenderProps) => React.ReactNode;\n /**\n * Callback that is used to determine if tree should be shown for current active iModel connection.\n * If callback is `undefined` tree is shown for all iModel connections.\n */\n shouldShow?: (imodel: IModelConnection) => Promise<boolean>;\n}\n\n/**\n * Props for [[SelectableTree]]\n * @public\n */\nexport interface SelectableTreeProps {\n trees: TreeDefinition[];\n density?: \"enlarged\" | \"default\";\n}\n\n/**\n * A component that renders a tree (combo box) selector and the selected tree component.\n * @public\n */\nexport function SelectableTree(props: SelectableTreeProps) {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return <SelectableTreeContent {...props} imodel={imodel} />;\n}\n\nfunction SelectableTreeContent(props: SelectableTreeProps & { imodel: IModelConnection }) {\n const { trees: treeDefinitions, imodel } = props;\n const trees = useActiveTrees(treeDefinitions, imodel);\n\n return (\n <div className=\"tree-widget-selectable-tree\">\n <TreeSelector {...getTreeSelectorProps(trees)} density={props.density} />\n </div>\n );\n}\n\nfunction useActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection) {\n const [trees, setTrees] = useState<TreeContentDefinition[]>();\n\n useEffect(() => {\n let disposed = false;\n void (async () => {\n const visibleTrees = await getActiveTrees(treeDefinitions, imodel);\n // istanbul ignore else\n if (!disposed) {\n setTrees(visibleTrees);\n }\n })();\n\n return () => {\n disposed = true;\n };\n }, [treeDefinitions, imodel]);\n\n return trees;\n}\n\nasync function getActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection): Promise<TreeContentDefinition[]> {\n const handleDefinition = async (treeDef: TreeDefinition) => {\n if (treeDef.shouldShow !== undefined && !(await treeDef.shouldShow(imodel))) {\n return undefined;\n }\n return {\n id: treeDef.id,\n label: treeDef.getLabel(),\n render: treeDef.render,\n };\n };\n\n return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined) as TreeContentDefinition[];\n}\n\nfunction getTreeSelectorProps(trees?: TreeContentDefinition[]): TreeSelectorProps {\n if (trees === undefined) {\n return {\n defaultSelectedContentId: \"loading\",\n trees: [\n {\n id: \"loading\",\n label: \"\",\n render: () => (\n <Delayed>\n <ProgressLinear indeterminate={true} />\n </Delayed>\n ),\n },\n ],\n };\n }\n\n if (trees.length === 0) {\n return {\n defaultSelectedContentId: \"no-trees\",\n trees: [\n {\n id: \"no-trees\",\n label: \"\",\n render: () => <FillCentered>{TreeWidget.translate(\"noTrees\")}</FillCentered>,\n },\n ],\n };\n }\n\n return {\n defaultSelectedContentId: trees[0].id,\n trees,\n };\n}\n\nfunction Delayed({ delay = 200, children }: PropsWithChildren<{ delay?: number }>) {\n const [show, setShow] = useState(false);\n\n useEffect(() => {\n const id = setTimeout(() => {\n setShow(true);\n }, delay);\n return () => {\n clearTimeout(id);\n };\n }, [delay]);\n\n if (!show) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}
|
|
@@ -10,20 +10,4 @@
|
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
|
-
|
|
14
|
-
.components-selectable-content {
|
|
15
|
-
flex: 1;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.components-selectable-content-header {
|
|
20
|
-
padding-bottom: var(--iui-size-2xs);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.components-selectable-content-wrapper {
|
|
24
|
-
display: flex;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
flex-grow: 1;
|
|
27
|
-
height: 100%;
|
|
28
|
-
}
|
|
29
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useCallback, useState } from "react";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export const useTreeFilteringState = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeFilteringState.js","sourceRoot":"","sources":["../../../src/components/TreeFilteringState.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"TreeFilteringState.js","sourceRoot":"","sources":["../../../src/components/TreeFilteringState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAqB9C,gBAAgB;AACh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C;IACvE,MAAM,aAAa,GAAkB;QACnC,WAAW;QACX,cAAc;QACd,aAAa;QACb,uBAAuB;QACvB,kBAAkB;QAClB,gBAAgB;KACjB,CAAC;IAEF,OAAO;QACL,aAAa;QACb,YAAY;QACZ,eAAe;QACf,gBAAgB;KACjB,CAAC;AACJ,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 { useCallback, useState } from \"react\";\n\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\n\n/** @internal */\nexport interface SearchOptions {\n isFiltering: boolean;\n onFilterCancel: () => void;\n onFilterStart: (newFilter: string) => void;\n onResultSelectedChanged: (index: number) => void;\n matchedResultCount: number | undefined;\n activeMatchIndex: number | undefined;\n}\n\ninterface TreeFilteringState {\n filterString: string;\n matchedResultCount?: number;\n activeMatchIndex?: number;\n filteredProvider?: IPresentationTreeDataProvider;\n}\n\n/** @internal */\nexport const useTreeFilteringState = () => {\n const [{ filterString, matchedResultCount, activeMatchIndex, filteredProvider }, setState] = useState<TreeFilteringState>({ filterString: \"\" });\n\n const onFilterCancel = useCallback(() => {\n setState({ filterString: \"\" });\n }, []);\n\n const onFilterStart = useCallback((newFilter: string) => {\n setState({ filterString: newFilter });\n }, []);\n\n const onResultSelectedChanged = useCallback((index: number) => {\n setState((prev) => ({ ...prev, activeMatchIndex: index }));\n }, []);\n\n const onFilterApplied = useCallback((provider: IPresentationTreeDataProvider, matches: number) => {\n setState((prev) => ({\n ...prev,\n activeMatchIndex: prev.activeMatchIndex === undefined ? 1 : Math.min(prev.activeMatchIndex, matches),\n matchedResultCount: matches,\n filteredProvider: provider,\n }));\n }, []);\n\n const isFiltering = !!filterString && matchedResultCount === undefined;\n const searchOptions: SearchOptions = {\n isFiltering,\n onFilterCancel,\n onFilterStart,\n onResultSelectedChanged,\n matchedResultCount,\n activeMatchIndex,\n };\n\n return {\n searchOptions,\n filterString,\n onFilterApplied,\n filteredProvider,\n };\n};\n"]}
|