@itwin/tree-widget-react 3.14.1 → 3.15.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 +24 -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/common/UseHierarchyVisibility.js +4 -5
- package/lib/cjs/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +5 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js +22 -5
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.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 +36 -27
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +3 -3
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +20 -8
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +1 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.js +7 -3
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.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/common/UseHierarchyVisibility.js +4 -5
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +5 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js +22 -5
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.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 +36 -27
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +20 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.js +7 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
# Change Log - @itwin/tree-widget-react
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Fri, 03 Oct 2025 11:21:56 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.15.0
|
|
8
|
+
|
|
9
|
+
Fri, 03 Oct 2025 11:21:56 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Introduce an extra state to `TreeNodeCheckboxState` interface - `{ isLoading: true }`. When such state is returned, the "eye" checkboxes are not rendered by `<VisibilityTreeRenderer />` and `<TreeNodeRenderer />`. Previously, we were returning "disabled" state, resulting in disabled checkboxes being briefly shown until the states were loaded. ([#1458](https://github.com/iTwin/viewer-components-react/pull/1458))
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Models tree: reduce tree visibility icon flickering when changing visibility. ([#1462](https://github.com/iTwin/viewer-components-react/pull/1462))
|
|
18
|
+
- Models tree: Fixed adding elements to always/never drawn lists would cause model to not load its' visibility. ([#1461](https://github.com/iTwin/viewer-components-react/pull/1461))
|
|
19
|
+
|
|
20
|
+
## 3.14.2
|
|
21
|
+
|
|
22
|
+
Tue, 16 Sep 2025 11:13:44 GMT
|
|
23
|
+
|
|
24
|
+
### Patches
|
|
25
|
+
|
|
26
|
+
- 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))
|
|
27
|
+
- Fix a query being unnecessarily executed after every node visibility change. ([#1439](https://github.com/iTwin/viewer-components-react/pull/1439))
|
|
28
|
+
|
|
7
29
|
## 3.14.1
|
|
8
30
|
|
|
9
|
-
Thu, 28 Aug 2025 19:47:
|
|
31
|
+
Thu, 28 Aug 2025 19:47:46 GMT
|
|
10
32
|
|
|
11
33
|
### Patches
|
|
12
34
|
|
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;AACxD,oEAAqG;AACrG,wDAAkD;AAClD,0DAAoD;AACpD,yFAA+I;AAgB/I;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,4BAA4B,CAAC,EAAE,QAAQ,EAA0B;IAI/E,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,GAA8B,CAAC;IAC3F,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO;QACL,WAAW,EAAE;YACX,QAAQ;YACR,UAAU,EAAE,kBAAkB,IAAI,UAAU;SAC7C;QACD,oBAAoB,EAAE,qBAAqB;KAC5C,CAAC;AACJ,CAAC;AAKD,cAAc;AACd,SAAgB,aAAa,CAAC,KAAsC;IAClE,OAAO,CACL,uBAAC,0BAAU,IACT,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,0BAAU,CAAC,SAAS,CAAC,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,C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AC;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"]}
|
|
@@ -12,7 +12,7 @@ const UseTelemetryContext_js_1 = require("./UseTelemetryContext.js");
|
|
|
12
12
|
function useHierarchyVisibility({ visibilityHandlerFactory }) {
|
|
13
13
|
const visibilityStatusMap = (0, react_1.useRef)(new Map());
|
|
14
14
|
const [state, setState] = (0, react_1.useState)({
|
|
15
|
-
getCheckboxState: () => ({
|
|
15
|
+
getCheckboxState: () => ({ isLoading: true }),
|
|
16
16
|
onCheckboxClicked: () => { },
|
|
17
17
|
triggerRefresh: () => { },
|
|
18
18
|
});
|
|
@@ -60,7 +60,7 @@ function useHierarchyVisibility({ visibilityHandlerFactory }) {
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
entry.status.state = checked ? "visible" : "hidden";
|
|
63
|
-
entry.status.tooltip
|
|
63
|
+
delete entry.status.tooltip;
|
|
64
64
|
triggerCheckboxUpdate();
|
|
65
65
|
};
|
|
66
66
|
setState({
|
|
@@ -88,16 +88,15 @@ function createStateGetter(map, calculateVisibility) {
|
|
|
88
88
|
const entry = map.current.get(node.id);
|
|
89
89
|
if (entry === undefined) {
|
|
90
90
|
calculateVisibility(node);
|
|
91
|
-
return {
|
|
91
|
+
return { isLoading: true };
|
|
92
92
|
}
|
|
93
93
|
if (entry.needsRefresh) {
|
|
94
94
|
calculateVisibility(node);
|
|
95
95
|
}
|
|
96
96
|
const status = entry.status;
|
|
97
97
|
return {
|
|
98
|
+
...status,
|
|
98
99
|
state: status.state === "visible" ? "on" : status.state === "hidden" ? "off" : "partial",
|
|
99
|
-
tooltip: status.tooltip,
|
|
100
|
-
isDisabled: status.isDisabled,
|
|
101
100
|
};
|
|
102
101
|
};
|
|
103
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyDhG,wDA8FC;AAiDD,sEAeC;AArND,iCAAoD;AACpD,+BAcc;AACd,qEAA+D;AAuC/D,SAAgB,sBAAsB,CAAC,EAAE,wBAAwB,EAA+B;IAC9F,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAC,IAAI,GAAG,EAAgG,CAAC,CAAC;IAC5I,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqD;QACrF,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC5D,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;QAC3B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;KACzB,CAAC,CAAC;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,GAAE,CAAC;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,mBAAmB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;QAE3C,MAAM,iBAAiB,GAAG,IAAI,cAAO,EAAQ,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,cAAO,EAA6B,CAAC;QAC3D,MAAM,mBAAmB,GAAG,CAAC,IAA+B,EAAE,EAAE;YAC9D,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;QAEF,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,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EAAE,EAAE;QACd,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC5C,CAAC;QACD,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACxF,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA0BD,SAAgB,6BAA6B,CAC3C,OAAmC,EACnC,KAAqB,EACrB,GAAwB,EACxB,QAA8G;IAE9G,OAAO,QAAQ;QACb,CAAC,CAAC,IAAA,WAAI,EACF,QAAQ,CAAC;YACP,GAAG,KAAK;YACR,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;YAC9F,OAAO;SACR,CAAC,CACH;QACH,CAAC,CAAC,GAAG,CAAC;AACV,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { MutableRefObject } from \"react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeCheckboxProps } from \"./components/TreeNodeCheckbox.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n /** Tooltip that should be displayed when hovering over the visibility checkbox. */\n tooltip?: string;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface HierarchyVisibilityHandler extends IDisposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): TreeCheckboxProps & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>());\n const [state, setState] = useState<TreeCheckboxProps & { triggerRefresh: () => void }>({\n getCheckboxState: () => ({ state: \"off\", isDisabled: true }),\n onCheckboxClicked: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status,\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility = (node: PresentationHierarchyNode, checked: boolean) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n void handler.changeVisibility(node.nodeData, checked);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status.state = checked ? \"visible\" : \"hidden\";\n entry.status.tooltip = undefined;\n triggerCheckboxUpdate();\n };\n\n setState({\n onCheckboxClicked: changeVisibility,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler.dispose();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): TreeCheckboxProps[\"getCheckboxState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { state: \"off\", isDisabled: true };\n }\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n const status = entry.status;\n return {\n state: status.state === \"visible\" ? \"on\" : status.state === \"hidden\" ? \"off\" : \"partial\",\n tooltip: status.tooltip,\n isDisabled: status.isDisabled,\n };\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\nexport function createVisibilityHandlerResult<TResult, TOverrideProps>(\n handler: HierarchyVisibilityHandler,\n props: TOverrideProps,\n obs: Observable<TResult>,\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined,\n): Observable<TResult> {\n return override\n ? from(\n override({\n ...props,\n originalImplementation: async () => lastValueFrom(obs, { defaultValue: undefined as TResult }),\n handler,\n }),\n )\n : obs;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyDhG,w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E,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,OAAO;YACL,GAAG,MAAM;YACT,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACzF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA0BD,SAAgB,6BAA6B,CAC3C,OAAmC,EACnC,KAAqB,EACrB,GAAwB,EACxB,QAA8G;IAE9G,OAAO,QAAQ;QACb,CAAC,CAAC,IAAA,WAAI,EACF,QAAQ,CAAC;YACP,GAAG,KAAK;YACR,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;YAC9F,OAAO;SACR,CAAC,CACH;QACH,CAAC,CAAC,GAAG,CAAC;AACV,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { MutableRefObject } from \"react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeCheckboxProps } from \"./components/TreeNodeCheckbox.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n /** Tooltip that should be displayed when hovering over the visibility checkbox. */\n tooltip?: string;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface HierarchyVisibilityHandler extends IDisposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): TreeCheckboxProps & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>());\n const [state, setState] = useState<TreeCheckboxProps & { triggerRefresh: () => void }>({\n getCheckboxState: () => ({ isLoading: true }),\n onCheckboxClicked: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status,\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility = (node: PresentationHierarchyNode, checked: boolean) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n void handler.changeVisibility(node.nodeData, checked);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status.state = checked ? \"visible\" : \"hidden\";\n delete entry.status.tooltip;\n triggerCheckboxUpdate();\n };\n\n setState({\n onCheckboxClicked: changeVisibility,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler.dispose();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): TreeCheckboxProps[\"getCheckboxState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { isLoading: true };\n }\n\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n const status = entry.status;\n return {\n ...status,\n state: status.state === \"visible\" ? \"on\" : status.state === \"hidden\" ? \"off\" : \"partial\",\n };\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\nexport function createVisibilityHandlerResult<TResult, TOverrideProps>(\n handler: HierarchyVisibilityHandler,\n props: TOverrideProps,\n obs: Observable<TResult>,\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined,\n): Observable<TResult> {\n return override\n ? from(\n override({\n ...props,\n originalImplementation: async () => lastValueFrom(obs, { defaultValue: undefined as TResult }),\n handler,\n }),\n )\n : obs;\n}\n"]}
|
|
@@ -5,11 +5,14 @@ import type { ComponentPropsWithoutRef } from "react";
|
|
|
5
5
|
* Data structure that describes tree node checkbox state.
|
|
6
6
|
* @beta
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
type TreeNodeCheckboxState = ({
|
|
9
9
|
state: "on" | "off" | "partial";
|
|
10
10
|
isDisabled?: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
isLoading: true;
|
|
13
|
+
}) & {
|
|
11
14
|
tooltip?: string;
|
|
12
|
-
}
|
|
15
|
+
};
|
|
13
16
|
/** @beta */
|
|
14
17
|
export interface TreeCheckboxProps {
|
|
15
18
|
/** Callback that should be invoked when checkbox is clicked. */
|
|
@@ -14,11 +14,28 @@ function TreeNodeCheckbox({ node, onCheckboxClicked, getCheckboxState, ...props
|
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
const checkboxState = getCheckboxState(node);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const checkboxProps = {
|
|
18
|
+
...props,
|
|
19
|
+
"aria-label": checkboxState.tooltip,
|
|
20
|
+
onClick: (e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
},
|
|
23
|
+
onChange: (e) => {
|
|
24
|
+
onCheckboxClicked(node, e.currentTarget.checked);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
if ("isLoading" in checkboxState) {
|
|
28
|
+
checkboxProps.style = {
|
|
29
|
+
...checkboxProps.style,
|
|
30
|
+
visibility: "hidden",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
checkboxProps.checked = checkboxState.state === "on";
|
|
35
|
+
checkboxProps.indeterminate = checkboxState.state === "partial";
|
|
36
|
+
checkboxProps.disabled = checkboxState.isDisabled;
|
|
37
|
+
}
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(TooltipWrapper, { content: checkboxState.tooltip, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { ...checkboxProps }) }));
|
|
22
39
|
}
|
|
23
40
|
function TooltipWrapper({ content, children }) {
|
|
24
41
|
return !!content ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.Tooltip, { content: content, placement: "left", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeCheckbox.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"TreeNodeCheckbox.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.tsx"],"names":[],"mappings":";;AAwCA,4CA+BC;;A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CAAC,CAAC,CACjB,uBAAC,uBAAO,IAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YACxC,QAAQ,GACD,CACX,CAAC,CAAC,CAAC,CACF,2DAAG,QAAQ,GAAI,CAChB,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 { Checkbox, Tooltip } from \"@itwin/itwinui-react\";\nimport { isPresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\nimport type { PresentationHierarchyNode, RenderedTreeNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\n/**\n * Data structure that describes tree node checkbox state.\n * @beta\n */\ntype TreeNodeCheckboxState = (\n | {\n state: \"on\" | \"off\" | \"partial\";\n isDisabled?: boolean;\n }\n | {\n isLoading: true;\n }\n) & {\n tooltip?: string;\n};\n\n/** @beta */\nexport interface TreeCheckboxProps {\n /** Callback that should be invoked when checkbox is clicked. */\n onCheckboxClicked: (node: PresentationHierarchyNode, checked: boolean) => void;\n /** Callback that should be used to determine current checkbox state. */\n getCheckboxState: (node: PresentationHierarchyNode) => TreeNodeCheckboxState;\n}\n\n/** @internal */\ntype TreeNodeCheckboxProps = TreeCheckboxProps &\n Omit<ComponentPropsWithoutRef<typeof Checkbox>, \"onClick\" | \"checked\" | \"onChange\" | \"indeterminate\" | \"disabled\" | \"title\">;\n\n/** @internal */\nexport function TreeNodeCheckbox({ node, onCheckboxClicked, getCheckboxState, ...props }: TreeNodeCheckboxProps & { node: RenderedTreeNode }) {\n if (\"type\" in node || !isPresentationHierarchyNode(node)) {\n return null;\n }\n\n const checkboxState = getCheckboxState(node);\n const checkboxProps: ComponentPropsWithoutRef<typeof Checkbox> = {\n ...props,\n \"aria-label\": checkboxState.tooltip,\n onClick: (e) => {\n e.stopPropagation();\n },\n onChange: (e) => {\n onCheckboxClicked(node, e.currentTarget.checked);\n },\n };\n if (\"isLoading\" in checkboxState) {\n checkboxProps.style = {\n ...checkboxProps.style,\n visibility: \"hidden\",\n };\n } else {\n checkboxProps.checked = checkboxState.state === \"on\";\n checkboxProps.indeterminate = checkboxState.state === \"partial\";\n checkboxProps.disabled = checkboxState.isDisabled;\n }\n return (\n <TooltipWrapper content={checkboxState.tooltip}>\n <Checkbox {...checkboxProps} />\n </TooltipWrapper>\n );\n}\n\nfunction TooltipWrapper({ content, children }: { content?: string; children?: React.ReactNode }) {\n return !!content ? (\n <Tooltip content={content} placement=\"left\">\n {children}\n </Tooltip>\n ) : (\n <>{children}</>\n );\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,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,YAAuD,EAAE,EAAE,CAAC,IAAI,CAAC,+BAA+B,CAAC,YAAY,CAAC;qBACnI;iBACF;aACF;SACF,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,YAAY,CAAC;Q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AAK,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;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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pC,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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C,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;;;;;;;;;;;;;;;;;;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,C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AAQ,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];
|