@itwin/tree-widget-react 3.14.1 → 3.14.2
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 +11 -2
- package/README.md +3 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +2 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +4 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +1 -1
- 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/AlwaysAndNeverDrawnElementInfo.d.ts +8 -11
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +67 -76
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +13 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +7 -7
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +2 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +4 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +1 -1
- 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/AlwaysAndNeverDrawnElementInfo.d.ts +8 -11
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +68 -77
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +13 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# Change Log - @itwin/tree-widget-react
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Tue, 16 Sep 2025 11:13:29 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.14.2
|
|
8
|
+
|
|
9
|
+
Tue, 16 Sep 2025 11:13:29 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Models tree: Fixed turning on category visibility under a hidden model causing categories of child elements to also become visible. ([#1452](https://github.com/iTwin/viewer-components-react/pull/1452))
|
|
14
|
+
- Fix a query being unnecessarily executed after every node visibility change. ([#1439](https://github.com/iTwin/viewer-components-react/pull/1439))
|
|
15
|
+
|
|
7
16
|
## 3.14.1
|
|
8
17
|
|
|
9
|
-
Thu, 28 Aug 2025 19:47:
|
|
18
|
+
Thu, 28 Aug 2025 19:47:46 GMT
|
|
10
19
|
|
|
11
20
|
### Patches
|
|
12
21
|
|
package/README.md
CHANGED
|
@@ -857,6 +857,8 @@ Components from this package allows consumers to track the usage of specific fea
|
|
|
857
857
|
|
|
858
858
|
This can be achieved by passing `onFeatureUsed` function to `CategoriesTreeComponent`, `ModelsTreeComponent`, `IModelContentTreeComponent`. The function is invoked with feature id as the component is being used. List of tracked features:
|
|
859
859
|
|
|
860
|
+
<!-- cspell:disable -->
|
|
861
|
+
|
|
860
862
|
- `"choose-{tree}"` - when a tree is selected in the tree selector.
|
|
861
863
|
- `"use-{tree}"` - when an interaction with a tree hierarchy happens. This includes any kind of interaction with nodes, including them being expanded/collapsed, selected, filtered, their visibility change, etc.
|
|
862
864
|
- `"{tree}-visibility-change"` - when visibility is toggled using an "eye" button.
|
|
@@ -875,6 +877,7 @@ This can be achieved by passing `onFeatureUsed` function to `CategoriesTreeCompo
|
|
|
875
877
|
- `"categories-tree-showall"` - when "Show All" button is used in `CategoriesTreeComponent`.
|
|
876
878
|
- `"categories-tree-hideall"` - when "Hide All" button is used in `CategoriesTreeComponent`.
|
|
877
879
|
- `"categories-tree-invert"` - when "Invert" button is used in `CategoriesTreeComponent`.
|
|
880
|
+
<!-- cspell:enable -->
|
|
878
881
|
|
|
879
882
|
Where `{tree}` specifies which tree component the feature is of.
|
|
880
883
|
|
|
@@ -48,6 +48,7 @@ function useCategoriesTreeButtonProps({ viewport }) {
|
|
|
48
48
|
/** @public */
|
|
49
49
|
function ShowAllButton(props) {
|
|
50
50
|
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", label: TreeWidget_js_1.TreeWidget.translate("categoriesTree.buttons.showAll.tooltip"), onClick: () => {
|
|
51
|
+
// cspell:disable-next-line
|
|
51
52
|
props.onFeatureUsed?.(`categories-tree-showall`);
|
|
52
53
|
void (0, CategoriesVisibilityUtils_js_1.showAllCategories)(props.categories.map((category) => category.categoryId), props.viewport);
|
|
53
54
|
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
|
|
@@ -55,6 +56,7 @@ function ShowAllButton(props) {
|
|
|
55
56
|
/** @public */
|
|
56
57
|
function HideAllButton(props) {
|
|
57
58
|
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", label: TreeWidget_js_1.TreeWidget.translate("categoriesTree.buttons.hideAll.tooltip"), onClick: () => {
|
|
59
|
+
// cspell:disable-next-line
|
|
58
60
|
props.onFeatureUsed?.(`categories-tree-hideall`);
|
|
59
61
|
void (0, CategoriesVisibilityUtils_js_1.hideAllCategories)(props.categories.map((category) => category.categoryId), props.viewport);
|
|
60
62
|
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
|
package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.tsx"],"names":[],"mappings":";;AA4CA,oEAaC;AAMD,
|
|
1
|
+
{"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.tsx"],"names":[],"mappings":";;AA4CA,oEAaC;AAMD,sCAkBC;AAGD,sCAkBC;AAGD,0CAcC;AAID,sCAGC;;AA9HD;;;gGAGgG;AAEhG,iCAA0C;AAC1C,8DAAwD;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C,wCAAwC,CAAC,EACrE,OAAO,EAAE,GAAG,EAAE;YACZ,2BAA2B;YAC3B,KAAK,CAAC,aAAa,EAAE,CAAC,yBAAyB,CAAC,CAAC;YACjD,KAAK,IAAA,gDAAiB,EACpB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACvD,KAAK,CAAC,QAAQ,CACf,CAAC;QACJ,CAAC,YAED,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,cAAc;AACd,SAAgB,eAAe,CAAC,KAAsC;IACpE,OAAO,CACL,uBAAC,0BAAU,IACT,KAAK,EAAE,0BAAU,CAAC,SAAS,CAAC,uCAAuC,CAAC,EACpE,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,wBAAwB,CAAC,CAAC;YAChD,KAAK,IAAA,kDAAmB,EAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC,YAED,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD,SAAgB,aAAa,CAAC,QAAkB;IAC9C,MAAM,iBAAiB,GAAG,IAAA,eAAO,EAAC,KAAK,IAAI,EAAE,CAAC,IAAA,yDAA0B,EAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChG,OAAO,IAAA,gCAAa,EAAC,iBAAiB,CAAC,IAAI,sBAAsB,CAAC;AACpE,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, useState } from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { hideAllCategories, invertAllCategories, loadCategoriesFromViewport, showAllCategories } from \"../common/CategoriesVisibilityUtils.js\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader.js\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Props that get passed to `CategoriesTreeComponent` header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `CategoriesTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onCategoriesFiltered } = useCategoriesTreeButtonProps({ viewport });\n * <TreeWithHeader\n * buttons={[\n * <CategoriesTreeComponent.ShowAllButton {...buttonProps} />,\n * <CategoriesTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <CategoriesTree {...treeProps} onCategoriesFiltered={onCategoriesFiltered} />\n * </TreeWithHeader>\n * ```\n *\n * @public\n */\nexport function useCategoriesTreeButtonProps({ viewport }: { viewport: Viewport }): {\n buttonProps: Pick<CategoriesTreeHeaderButtonProps, \"categories\" | \"viewport\">;\n onCategoriesFiltered: (categories: CategoryInfo[] | undefined) => void;\n} {\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[] | undefined>();\n const categories = useCategories(viewport);\n return {\n buttonProps: {\n viewport,\n categories: filteredCategories ?? categories,\n },\n onCategoriesFiltered: setFilteredCategories,\n };\n}\n\n/** @public */\nexport type CategoriesTreeHeaderButtonType = (props: CategoriesTreeHeaderButtonProps) => JSX.Element | null;\n\n/** @public */\nexport function ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"categoriesTree.buttons.showAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(`categories-tree-showall`);\n void showAllCategories(\n props.categories.map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"categoriesTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(`categories-tree-hideall`);\n void hideAllCategories(\n props.categories.map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n label={TreeWidget.translate(\"categoriesTree.buttons.invert.tooltip\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-invert`);\n void invertAllCategories(props.categories, props.viewport);\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\nexport function useCategories(viewport: Viewport) {\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(viewport), [viewport]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n"]}
|
|
@@ -62,6 +62,7 @@ class ExternalSourcesTreeDefinition {
|
|
|
62
62
|
filter: props.instanceFilter,
|
|
63
63
|
contentClass: { fullName: "BisCore.ExternalSource", alias: "this" },
|
|
64
64
|
});
|
|
65
|
+
// cspell:disable
|
|
65
66
|
return [
|
|
66
67
|
{
|
|
67
68
|
fullClassName: "BisCore.ExternalSource",
|
|
@@ -89,12 +90,14 @@ class ExternalSourcesTreeDefinition {
|
|
|
89
90
|
},
|
|
90
91
|
},
|
|
91
92
|
];
|
|
93
|
+
// cspell:enable
|
|
92
94
|
}
|
|
93
95
|
async createExternalSourcesGroupChildrenQuery({ parentNodeInstanceIds: groupIds, instanceFilter, }) {
|
|
94
96
|
const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({
|
|
95
97
|
filter: instanceFilter,
|
|
96
98
|
contentClass: { fullName: "BisCore.ExternalSource", alias: "this" },
|
|
97
99
|
});
|
|
100
|
+
// cspell:disable
|
|
98
101
|
return [
|
|
99
102
|
{
|
|
100
103
|
fullClassName: "BisCore.ExternalSource",
|
|
@@ -124,6 +127,7 @@ class ExternalSourcesTreeDefinition {
|
|
|
124
127
|
},
|
|
125
128
|
},
|
|
126
129
|
];
|
|
130
|
+
// cspell:enable
|
|
127
131
|
}
|
|
128
132
|
async createExternalSourceChildrenQuery({ parentNodeInstanceIds: sourceIds, instanceFilter, }) {
|
|
129
133
|
const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSourcesTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,8EAAwI;AACxI,oEAA8F;AAmB9F,MAAa,6BAA6B;IAChC,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6BAA6B,CAAoC;IACjE,cAAc,CAA6B;IAC3C,YAAY,CAAoB;IAExC,YAAmB,KAAyC;QAC1D,IAAI,CAAC,KAAK,GAAG,IAAA,kEAAuC,EAAC;YACnD,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAA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;KAIb,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArRD,sEAqRC","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 { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\n\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\n\ninterface ExternalSourcesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n}\n\nexport class ExternalSourcesTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ExternalSourcesTreeDefinitionProps) {\n this._impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSourceGroup\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourcesGroupChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSource\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourceChildrenQuery(requestProps),\n },\n {\n parentGenericNodePredicate: async ({ id }) => id === \"ElementsNode\",\n definitions: async (requestProps: DefineGenericNodeChildHierarchyLevelProps) => this.createElementsNodeChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._queryExecutor = props.imodelAccess;\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n this._selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: props.imodelAccess,\n instanceLabelSelectClauseFactory: this._nodeLabelSelectClauseFactory,\n });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to be handled during post-processing\n return { ...node, extendedData: { ...node.extendedData, imageId: \"icon-ec-class\" } };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n autoExpand: true,\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.SynchronizationConfigSpecifiesRootSources scsrs ON scsrs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.where ? `WHERE ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createExternalSourcesGroupChildrenQuery({\n parentNodeInstanceIds: groupIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceGroupGroupsSources esggs ON esggs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esggs.SourceECInstanceId IN (${groupIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: groupIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createExternalSourceChildrenQuery({\n parentNodeInstanceIds: sourceIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAttachment esa ON esa.Attaches.Id = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esa.Parent.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n {\n node: {\n key: \"ElementsNode\",\n label: \"Elements\",\n extendedData: {\n sourceIds,\n imageId: \"icon-ec-schema\",\n },\n supportsFiltering: true,\n processingParams: {\n hideIfNoChildren: true,\n },\n },\n },\n ];\n }\n\n private createExternalSourceSupportsFilteringSelector(alias: string) {\n return `\n IFNULL((\n SELECT 1\n FROM (\n SELECT 1 FROM BisCore.ExternalSourceGroupGroupsSources WHERE SourceECInstanceId = ${alias}.ECInstanceId\n UNION ALL\n SELECT 1 FROM BisCore.ExternalSourceAttachment WHERE Parent.Id = ${alias}.ECInstanceId\n )\n LIMIT 1\n ), 0)\n `;\n }\n\n private async createElementsNodeChildrenQuery({ parentNode, instanceFilter }: DefineGenericNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceIds: string[] = parentNode.extendedData?.sourceIds;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricElement\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.GeometricElement\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.GeometricElement\",\n }),\n },\n extendedData: {\n imageId: \"icon-item\",\n },\n grouping: { byClass: true },\n hasChildren: false,\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAspect esa ON esa.Element.Id = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n esa.Source.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createCompositeLabelSelectClause({ externalSourceAlias, repositoryLinkAlias }: { externalSourceAlias: string; repositoryLinkAlias: string }) {\n return ECSql.createConcatenatedValueJsonSelector([\n {\n selector: `IIF(\n ${repositoryLinkAlias}.ECInstanceId IS NOT NULL,\n ${ECSql.createConcatenatedValueJsonSelector([\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: repositoryLinkAlias,\n className: \"BisCore.RepositoryLink\",\n }),\n },\n {\n type: \"String\",\n value: \" - \",\n },\n ])},\n ''\n )`,\n },\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: externalSourceAlias,\n className: \"BisCore.ExternalSource\",\n }),\n },\n ]);\n }\n\n private async isSupported() {\n const query = `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef\n WHERE Name = 'BisCore' AND (VersionMajor > 1 OR (VersionMajor = 1 AND VersionMinor > 12))\n `;\n\n for await (const _row of this._queryExecutor.createQueryReader({ ecsql: query })) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,8EAAwI;AACxI,oEAA8F;AAmB9F,MAAa,6BAA6B;IAChC,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6BAA6B,CAAoC;IACjE,cAAc,CAA6B;IAC3C,YAAY,CAAoB;IAExC,YAAmB,KAAyC;QAC1D,IAAI,CAAC,KAAK,GAAG,IAAA,kEAAuC,EAAC;YACnD,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC;gBACxF,UAAU,EAAE;oBACV;wBACE,4BAA4B,EAAE,6BAA6B;wBAC3D,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,uCAAuC,CAAC,YAAY,CAAC;qBAC5I;oBACD;wBACE,4BAA4B,EAAE,wBAAwB;wBACtD,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAAC,YAAY,CAAC;qBACtI;oBACD;wBACE,0BAA0B,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,cAAc;wBACnE,WAAW,EAAE,KAAK,EAAE,Y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AE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;iBAC7D;aACF;SACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,gCAAgC,CAAC,EAAE,mBAAmB,EAAE,mBAAmB,EAAgE;QACvJ,OAAO,2BAAK,CAAC,mCAAmC,CAAC;YAC/C;gBACE,QAAQ,EAAE;YACN,mBAAmB;YACnB,2BAAK,CAAC,mCAAmC,CAAC;oBAC1C;wBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;4BACpE,UAAU,EAAE,mBAAmB;4BAC/B,SAAS,EAAE,wBAAwB;yBACpC,CAAC;qBACH;oBACD;wBACE,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,KAAK;qBACb;iBACF,CAAC;;UAEF;aACH;YACD;gBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;oBACpE,UAAU,EAAE,mBAAmB;oBAC/B,SAAS,EAAE,wBAAwB;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,MAAM,KAAK,GAAG;;;;KAIb,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1RD,sEA0RC","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 { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\n\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\n\ninterface ExternalSourcesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n}\n\nexport class ExternalSourcesTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ExternalSourcesTreeDefinitionProps) {\n this._impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSourceGroup\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourcesGroupChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSource\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourceChildrenQuery(requestProps),\n },\n {\n parentGenericNodePredicate: async ({ id }) => id === \"ElementsNode\",\n definitions: async (requestProps: DefineGenericNodeChildHierarchyLevelProps) => this.createElementsNodeChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._queryExecutor = props.imodelAccess;\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n this._selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: props.imodelAccess,\n instanceLabelSelectClauseFactory: this._nodeLabelSelectClauseFactory,\n });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to be handled during post-processing\n return { ...node, extendedData: { ...node.extendedData, imageId: \"icon-ec-class\" } };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n autoExpand: true,\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.SynchronizationConfigSpecifiesRootSources scsrs ON scsrs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.where ? `WHERE ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourcesGroupChildrenQuery({\n parentNodeInstanceIds: groupIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceGroupGroupsSources esggs ON esggs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esggs.SourceECInstanceId IN (${groupIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: groupIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourceChildrenQuery({\n parentNodeInstanceIds: sourceIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAttachment esa ON esa.Attaches.Id = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esa.Parent.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n {\n node: {\n key: \"ElementsNode\",\n label: \"Elements\",\n extendedData: {\n sourceIds,\n imageId: \"icon-ec-schema\",\n },\n supportsFiltering: true,\n processingParams: {\n hideIfNoChildren: true,\n },\n },\n },\n ];\n }\n\n private createExternalSourceSupportsFilteringSelector(alias: string) {\n return `\n IFNULL((\n SELECT 1\n FROM (\n SELECT 1 FROM BisCore.ExternalSourceGroupGroupsSources WHERE SourceECInstanceId = ${alias}.ECInstanceId\n UNION ALL\n SELECT 1 FROM BisCore.ExternalSourceAttachment WHERE Parent.Id = ${alias}.ECInstanceId\n )\n LIMIT 1\n ), 0)\n `;\n }\n\n private async createElementsNodeChildrenQuery({ parentNode, instanceFilter }: DefineGenericNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceIds: string[] = parentNode.extendedData?.sourceIds;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricElement\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.GeometricElement\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.GeometricElement\",\n }),\n },\n extendedData: {\n imageId: \"icon-item\",\n },\n grouping: { byClass: true },\n hasChildren: false,\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAspect esa ON esa.Element.Id = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n esa.Source.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createCompositeLabelSelectClause({ externalSourceAlias, repositoryLinkAlias }: { externalSourceAlias: string; repositoryLinkAlias: string }) {\n return ECSql.createConcatenatedValueJsonSelector([\n {\n selector: `IIF(\n ${repositoryLinkAlias}.ECInstanceId IS NOT NULL,\n ${ECSql.createConcatenatedValueJsonSelector([\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: repositoryLinkAlias,\n className: \"BisCore.RepositoryLink\",\n }),\n },\n {\n type: \"String\",\n value: \" - \",\n },\n ])},\n ''\n )`,\n },\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: externalSourceAlias,\n className: \"BisCore.ExternalSource\",\n }),\n },\n ]);\n }\n\n private async isSupported() {\n const query = `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef\n WHERE Name = 'BisCore' AND (VersionMajor > 1 OR (VersionMajor = 1 AND VersionMinor > 12))\n `;\n\n for await (const _row of this._queryExecutor.createQueryReader({ ecsql: query })) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
@@ -81,6 +81,7 @@ async function queryModelsForHeaderActions(iModel) {
|
|
|
81
81
|
/** @public */
|
|
82
82
|
function ShowAllButton(props) {
|
|
83
83
|
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", label: TreeWidget_js_1.TreeWidget.translate("modelsTree.buttons.showAll.tooltip"), onClick: () => {
|
|
84
|
+
// cspell:disable-next-line
|
|
84
85
|
props.onFeatureUsed?.("models-tree-showall");
|
|
85
86
|
void (0, ModelsTreeVisibilityHandler_js_1.showAllModels)(props.models.map((model) => model.id), props.viewport);
|
|
86
87
|
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
|
|
@@ -88,6 +89,7 @@ function ShowAllButton(props) {
|
|
|
88
89
|
/** @public */
|
|
89
90
|
function HideAllButton(props) {
|
|
90
91
|
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", label: TreeWidget_js_1.TreeWidget.translate("modelsTree.buttons.hideAll.tooltip"), onClick: () => {
|
|
92
|
+
// cspell:disable-next-line
|
|
91
93
|
props.onFeatureUsed?.("models-tree-hideall");
|
|
92
94
|
void (0, ModelsTreeVisibilityHandler_js_1.hideAllModels)(props.models.map((model) => model.id), props.viewport);
|
|
93
95
|
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
|
|
@@ -136,6 +138,7 @@ function ToggleInstancesFocusButton({ density, onFeatureUsed }) {
|
|
|
136
138
|
? TreeWidget_js_1.TreeWidget.translate("modelsTree.buttons.toggleFocusMode.disable.tooltip")
|
|
137
139
|
: TreeWidget_js_1.TreeWidget.translate("modelsTree.buttons.toggleFocusMode.enable.tooltip");
|
|
138
140
|
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { styleType: "borderless", size: density === "enlarged" ? "large" : "small", label: label, onClick: () => {
|
|
141
|
+
// cspell:disable-next-line
|
|
139
142
|
onFeatureUsed?.("models-tree-instancesfocus");
|
|
140
143
|
toggle();
|
|
141
144
|
}, isActive: enabled, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgCursorClick, {}) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;AAuDA,4DAcC;AAwCD,sCAiBC;AAGD,sCAiBC;AAGD,oCAiBC;AAGD,oCA4BC;AAGD,oCA4BC;AAGD,gEAmBC;;AA1PD;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqH;AACrH,wDAAmE;AACnE,0DAAoD;AACpD,qFAAkF;AAClF,8FAA6I;AA0B7I;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,wBAAwB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAoD;IAI7G,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAA4B,CAAC;IACjF,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAC1J,OAAO;QACL,WAAW,EAAE;YACX,MAAM,EAAE,eAAe;YACvB,QAAQ;SACT;QACD,gBAAgB,EAAE,iBAAiB;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAwB;IAClD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAc,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,2BAA2B,CAAC,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,UAAuB,E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Y,EACtB,OAAO,EAAE,GAAG,EAAE;gBACZ,KAAK,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,CAAC;gBAC5C,KAAK,IAAA,6CAAY,EAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;YAChE,CAAC,EACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,YAExE,0BAAU,CAAC,SAAS,CAAC,mCAAmC,CAAC,GACnD,GACD,CACX,CAAC;AACJ,CAAC;AAED,cAAc;AACd,SAAgB,0BAA0B,CAAC,EAAE,OAAO,EAAE,aAAa,EAAmF;IACpJ,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,uDAA0B,GAAE,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO;QACnB,CAAC,CAAC,0BAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QAC5E,CAAC,CAAC,0BAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC9E,OAAO,CACL,uBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,EACtB,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAChD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,EACD,QAAQ,EAAE,OAAO,YAEjB,uBAAC,oCAAc,KAAG,GACP,CACd,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 { useEffect, useMemo, useState } from \"react\";\nimport { SvgCursorClick, SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton, Tooltip } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader.js\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: Viewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync 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\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => JSX.Element | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Tooltip content={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}>\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n </Tooltip>\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Tooltip content={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}>\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n </Tooltip>\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ density, onFeatureUsed }: { density?: \"default\" | \"enlarged\"; onFeatureUsed?: (feature: string) => void }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n styleType=\"borderless\"\n size={density === \"enlarged\" ? \"large\" : \"small\"}\n label={label}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n isActive={enabled}\n >\n <SvgCursorClick />\n </IconButton>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;AAuDA,4DAcC;AAwCD,sCAkBC;AAGD,sCAkBC;AAGD,oCAiBC;AAGD,oCA4BC;AAGD,oCA4BC;AAGD,gEAoBC;;AA7PD;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqH;AACrH,wDAAmE;AACnE,0DAAoD;AACpD,qFAAkF;AAClF,8FAA6I;AA0B7I;;;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,YAExE,0BAAU,CAAC,SAAS,CAAC,mCAAmC,CAAC,GACnD,GACD,CACX,CAAC;AACJ,CAAC;AAED,cAAc;AACd,SAAgB,0BAA0B,CAAC,EAAE,OAAO,EAAE,aAAa,EAAmF;IACpJ,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,uDAA0B,GAAE,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO;QACnB,CAAC,CAAC,0BAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QAC5E,CAAC,CAAC,0BAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC9E,OAAO,CACL,uBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,EACtB,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAChD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,2BAA2B;YAC3B,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,EACD,QAAQ,EAAE,OAAO,YAEjB,uBAAC,oCAAc,KAAG,GACP,CACd,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 { useEffect, useMemo, useState } from \"react\";\nimport { SvgCursorClick, SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton, Tooltip } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader.js\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: Viewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync 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\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => JSX.Element | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Tooltip content={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}>\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n </Tooltip>\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Tooltip content={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}>\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n </Tooltip>\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ density, onFeatureUsed }: { density?: \"default\" | \"enlarged\"; onFeatureUsed?: (feature: string) => void }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n styleType=\"borderless\"\n size={density === \"enlarged\" ? \"large\" : \"small\"}\n label={label}\n onClick={() => {\n // cspell:disable-next-line\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n isActive={enabled}\n >\n <SvgCursorClick />\n </IconButton>\n );\n}\n"]}
|
|
@@ -501,7 +501,7 @@ function createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarch
|
|
|
501
501
|
`;
|
|
502
502
|
return imodelAccess.createQueryReader({ ctes, ecsql }, { rowFormat: "Indexes", limit: "unbounded" });
|
|
503
503
|
}).pipe((0, Utils_js_2.releaseMainThreadOnItemsCount)(300), (0, rxjs_1.map)((row) => parseQueryRow(row, groupInfos, separator, hierarchyConfig.elementClassSpecification)), (0, rxjs_1.mergeMap)(({ modelId, elementHierarchyPath, groupingNode }) => (0, rxjs_1.from)(idsCache.createModelInstanceKeyPaths(modelId)).pipe((0, rxjs_1.mergeAll)(), (0, rxjs_1.map)((modelPath) => {
|
|
504
|
-
// We
|
|
504
|
+
// We don't want to modify the original path, we create a copy that we can modify
|
|
505
505
|
const newModelPath = [...modelPath];
|
|
506
506
|
newModelPath.pop(); // model is already included in the element hierarchy path
|
|
507
507
|
const path = [...newModelPath, ...elementHierarchyPath];
|