@itwin/tree-widget-react 2.0.1 → 2.1.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +46 -0
  3. package/lib/cjs/components/SelectableTree.d.ts +2 -0
  4. package/lib/cjs/components/SelectableTree.js +1 -1
  5. package/lib/cjs/components/SelectableTree.js.map +1 -1
  6. package/lib/cjs/components/TreeSelector.d.ts +1 -0
  7. package/lib/cjs/components/TreeSelector.js +1 -1
  8. package/lib/cjs/components/TreeSelector.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +2 -0
  10. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +7 -7
  11. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  12. package/lib/cjs/components/tree-header/TreeHeader.js +1 -1
  13. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  14. package/lib/cjs/components/tree-header/TreeHeader.scss +2 -8
  15. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -4
  16. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  17. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +7 -0
  18. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +7 -0
  19. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  20. package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +18 -0
  21. package/lib/cjs/components/trees/common/UsePerformanceReporting.js +25 -0
  22. package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +1 -0
  23. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +7 -0
  24. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -0
  25. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  26. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +7 -0
  27. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +7 -0
  28. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  29. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +7 -0
  30. package/lib/cjs/components/trees/models-tree/ModelsTree.js +8 -1
  31. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  32. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +1 -1
  33. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  34. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
  35. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
  36. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  37. package/lib/esm/components/SelectableTree.d.ts +2 -0
  38. package/lib/esm/components/SelectableTree.js +1 -1
  39. package/lib/esm/components/SelectableTree.js.map +1 -1
  40. package/lib/esm/components/TreeSelector.d.ts +1 -0
  41. package/lib/esm/components/TreeSelector.js +1 -1
  42. package/lib/esm/components/TreeSelector.js.map +1 -1
  43. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +2 -0
  44. package/lib/esm/components/TreeWidgetUiItemsProvider.js +7 -7
  45. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  46. package/lib/esm/components/tree-header/TreeHeader.js +1 -1
  47. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  48. package/lib/esm/components/tree-header/TreeHeader.scss +2 -8
  49. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +7 -5
  50. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  51. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +7 -0
  52. package/lib/esm/components/trees/category-tree/CategoriesTree.js +7 -0
  53. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  54. package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +18 -0
  55. package/lib/esm/components/trees/common/UsePerformanceReporting.js +21 -0
  56. package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +1 -0
  57. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +7 -0
  58. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -0
  59. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  60. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +7 -0
  61. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +7 -0
  62. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  63. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +7 -0
  64. package/lib/esm/components/trees/models-tree/ModelsTree.js +8 -1
  65. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  66. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +1 -1
  67. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  68. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
  69. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
  70. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  71. package/package.json +3 -3
@@ -0,0 +1,18 @@
1
+ /** @internal */
2
+ export interface UsePerformanceReportingProps {
3
+ treeIdentifier: string;
4
+ onPerformanceMeasured?: (featureId: string, duration: number) => void;
5
+ }
6
+ /** @internal */
7
+ export interface UsePerformanceReportingResult {
8
+ onNodeLoaded?: (props: {
9
+ node: string;
10
+ duration: number;
11
+ }) => void;
12
+ }
13
+ /**
14
+ * Enables performance reporting for a tree component.
15
+ * @internal
16
+ */
17
+ export declare function usePerformanceReporting(props: UsePerformanceReportingProps): UsePerformanceReportingResult;
18
+ //# sourceMappingURL=UsePerformanceReporting.d.ts.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.usePerformanceReporting = void 0;
8
+ /**
9
+ * Enables performance reporting for a tree component.
10
+ * @internal
11
+ */
12
+ function usePerformanceReporting(props) {
13
+ const { treeIdentifier, onPerformanceMeasured } = props;
14
+ if (!onPerformanceMeasured) {
15
+ return { onNodeLoaded: undefined };
16
+ }
17
+ return {
18
+ onNodeLoaded: ({ node, duration }) => {
19
+ const feature = `${treeIdentifier}-${node === "root" ? "initial-load" : "hierarchy-level-load"}`;
20
+ onPerformanceMeasured(feature, duration);
21
+ },
22
+ };
23
+ }
24
+ exports.usePerformanceReporting = usePerformanceReporting;
25
+ //# sourceMappingURL=UsePerformanceReporting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UsePerformanceReporting.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UsePerformanceReporting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAahG;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,KAAmC;IACzE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IAExD,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;KACpC;IAED,OAAO;QACL,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAsC,EAAE,EAAE;YACvE,MAAM,OAAO,GAAG,GAAG,cAAc,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,sBAAsB,EAAE,CAAC;YACjG,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC;AAbD,0DAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @internal */\nexport interface UsePerformanceReportingProps {\n treeIdentifier: string;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n}\n\n/** @internal */\nexport interface UsePerformanceReportingResult {\n onNodeLoaded?: (props: { node: string; duration: number }) => void;\n}\n\n/**\n * Enables performance reporting for a tree component.\n * @internal\n */\nexport function usePerformanceReporting(props: UsePerformanceReportingProps): UsePerformanceReportingResult {\n const { treeIdentifier, onPerformanceMeasured } = props;\n\n if (!onPerformanceMeasured) {\n return { onNodeLoaded: undefined };\n }\n\n return {\n onNodeLoaded: ({ node, duration }: { node: string; duration: number }) => {\n const feature = `${treeIdentifier}-${node === \"root\" ? \"initial-load\" : \"hierarchy-level-load\"}`;\n onPerformanceMeasured(feature, duration);\n },\n };\n}\n"]}
@@ -17,6 +17,13 @@ export interface ExternalSourcesTreeProps extends BaseTreeProps {
17
17
  * @beta
18
18
  */
19
19
  hierarchyLevelConfig?: HierarchyLevelConfig;
20
+ /**
21
+ * Reports performance of a feature.
22
+ * @param featureId ID of the feature.
23
+ * @param elapsedTime Elapsed time of the feature.
24
+ * @beta
25
+ */
26
+ onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
20
27
  }
21
28
  /**
22
29
  * Tree which displays a hierarchy of ExternalSources and their elements.
@@ -33,8 +33,10 @@ require("../VisibilityTreeBase.scss");
33
33
  const components_react_1 = require("@itwin/components-react");
34
34
  const presentation_components_1 = require("@itwin/presentation-components");
35
35
  const TreeRenderer_1 = require("../common/TreeRenderer");
36
+ const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
36
37
  const Utils_1 = require("../common/Utils");
37
38
  const RULESET_EXTERNAL_SOURCES_IMPORT = __importStar(require("./ExternalSources.json"));
39
+ const ExternalSourcesTreeComponent_1 = require("./ExternalSourcesTreeComponent");
38
40
  /**
39
41
  * Presentation rules used by ControlledCategoriesTree
40
42
  * @internal
@@ -47,6 +49,10 @@ const PAGING_SIZE = 20;
47
49
  */
48
50
  function ExternalSourcesTree(props) {
49
51
  const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density } = props;
52
+ const reporting = (0, UsePerformanceReporting_1.usePerformanceReporting)({
53
+ treeIdentifier: ExternalSourcesTreeComponent_1.ExternalSourcesTreeComponent.id,
54
+ onPerformanceMeasured: props.onPerformanceMeasured,
55
+ });
50
56
  const state = (0, presentation_components_1.usePresentationTreeState)({
51
57
  imodel: props.iModel,
52
58
  ruleset: exports.RULESET_EXTERNAL_SOURCES,
@@ -55,6 +61,7 @@ function ExternalSourcesTree(props) {
55
61
  customizeTreeNodeItem,
56
62
  hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
57
63
  enableHierarchyAutoUpdate: true,
64
+ onNodeLoaded: reporting.onNodeLoaded,
58
65
  });
59
66
  const treeRendererProps = {
60
67
  contextMenuItems,
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,8DAAwD;AACxD,4EAEwC;AACxC,yDAA8E;AAC9E,2CAAwG;AACxG,wFAA0E;AAK1E;;;GAGG;AACU,QAAA,wBAAwB,GAAG,+BAA0C,CAAC;AAEnF,MAAM,WAAW,GAAG,EAAE,CAAC;AAcvB;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAErF,MAAM,KAAK,GAAG,IAAA,kDAAwB,EAAC;QACrC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,gCAAwB;QACjC,UAAU,EAAE,WAAW;QACvB,mBAAmB,EAAE,uCAAuC;QAC5D,qBAAqB;QACrB,uBAAuB,EAAE,oBAAoB,EAAE,SAAS;QACxD,yBAAyB,EAAE,IAAI;KAChC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG;QACxB,gBAAgB;QAChB,iBAAiB;QACjB,OAAO;KACR,CAAC;IAEF,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,gCAAK,SAAS,EAAC,4BAA4B,YACzC,uBAAC,0CAAgB,IACf,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,gCAAa,CAAC,QAAQ,EAC5D,YAAY,EAAE,IAAI,EAClB,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1B,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CACzC,uBAAC,qCAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,uBAAC,sDAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC;AA9CD,kDA8CC;AAED,SAAS,uCAAuC,CAAC,KAAwC;IACvF,OAAO,IAAI,0DAAgC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC;IAC9D,0CAAkC;IAClC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;IACzC,CAAC;CACF,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport {\n PresentationTree, PresentationTreeNodeRenderer, UnifiedSelectionTreeEventHandler, usePresentationTreeState,\n} from \"@itwin/presentation-components\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport * as RULESET_EXTERNAL_SOURCES_IMPORT from \"./ExternalSources.json\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_EXTERNAL_SOURCES = RULESET_EXTERNAL_SOURCES_IMPORT as Ruleset;\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for the [[ExternalSourcesTree]] component\n * @alpha\n */\nexport interface ExternalSourcesTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * Tree which displays a hierarchy of ExternalSources and their elements.\n * @alpha\n */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density } = props;\n\n const state = usePresentationTreeState({\n imodel: props.iModel,\n ruleset: RULESET_EXTERNAL_SOURCES,\n pagingSize: PAGING_SIZE,\n eventHandlerFactory: unifiedSelectionTreeEventHandlerFactory,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n });\n\n const treeRendererProps = {\n contextMenuItems,\n nodeLabelRenderer,\n density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.Extended}\n iconsEnabled={true}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n}\n\nfunction unifiedSelectionTreeEventHandlerFactory(props: PresentationTreeEventHandlerProps) {\n return new UnifiedSelectionTreeEventHandler({ nodeLoader: props.nodeLoader });\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([\n addCustomTreeNodeItemLabelRenderer,\n (item, node) => {\n item.icon = node.extendedData?.imageId;\n },\n]);\n"]}
1
+ {"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,8DAAwD;AACxD,4EAEwC;AACxC,yDAA8E;AAC9E,+EAA4E;AAC5E,2CAAwG;AACxG,wFAA0E;AAC1E,iFAA8E;AAK9E;;;GAGG;AACU,QAAA,wBAAwB,GAAG,+BAA0C,CAAC;AAEnF,MAAM,WAAW,GAAG,EAAE,CAAC;AAqBvB;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAErF,MAAM,SAAS,GAAG,IAAA,iDAAuB,EAAC;QACxC,cAAc,EAAE,2DAA4B,CAAC,EAAE;QAC/C,qBAAqB,EAAE,KAAK,CAAC,qBAA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AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC;IAC9D,0CAAkC;IAClC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;IACzC,CAAC;CACF,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport {\n PresentationTree, PresentationTreeNodeRenderer, UnifiedSelectionTreeEventHandler, usePresentationTreeState,\n} from \"@itwin/presentation-components\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport * as RULESET_EXTERNAL_SOURCES_IMPORT from \"./ExternalSources.json\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_EXTERNAL_SOURCES = RULESET_EXTERNAL_SOURCES_IMPORT as Ruleset;\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for the [[ExternalSourcesTree]] component\n * @alpha\n */\nexport interface ExternalSourcesTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n}\n\n/**\n * Tree which displays a hierarchy of ExternalSources and their elements.\n * @alpha\n */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density } = props;\n\n const reporting = usePerformanceReporting({\n treeIdentifier: ExternalSourcesTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const state = usePresentationTreeState({\n imodel: props.iModel,\n ruleset: RULESET_EXTERNAL_SOURCES,\n pagingSize: PAGING_SIZE,\n eventHandlerFactory: unifiedSelectionTreeEventHandlerFactory,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded: reporting.onNodeLoaded,\n });\n\n const treeRendererProps = {\n contextMenuItems,\n nodeLabelRenderer,\n density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.Extended}\n iconsEnabled={true}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n}\n\nfunction unifiedSelectionTreeEventHandlerFactory(props: PresentationTreeEventHandlerProps) {\n return new UnifiedSelectionTreeEventHandler({ nodeLoader: props.nodeLoader });\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([\n addCustomTreeNodeItemLabelRenderer,\n (item, node) => {\n item.icon = node.extendedData?.imageId;\n },\n]);\n"]}
@@ -16,6 +16,13 @@ export interface IModelContentTreeProps extends BaseTreeProps {
16
16
  * @beta
17
17
  */
18
18
  hierarchyLevelConfig?: HierarchyLevelConfig;
19
+ /**
20
+ * Reports performance of a feature.
21
+ * @param featureId ID of the feature.
22
+ * @param elapsedTime Elapsed time of the feature.
23
+ * @beta
24
+ */
25
+ onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
19
26
  }
20
27
  /**
21
28
  * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child
@@ -9,7 +9,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const components_react_1 = require("@itwin/components-react");
10
10
  const presentation_components_1 = require("@itwin/presentation-components");
11
11
  const TreeRenderer_1 = require("../common/TreeRenderer");
12
+ const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
12
13
  const Utils_1 = require("../common/Utils");
14
+ const IModelContentTreeComponent_1 = require("./IModelContentTreeComponent");
13
15
  /**
14
16
  * Presentation rules used by IModelContentTree
15
17
  * @internal
@@ -22,6 +24,10 @@ exports.RULESET_IMODEL_CONTENT = require("./IModelContent.json"); // eslint-disa
22
24
  */
23
25
  const IModelContentTree = (props) => {
24
26
  const { iModel, width, height, selectionMode, hierarchyLevelConfig } = props;
27
+ const reporting = (0, UsePerformanceReporting_1.usePerformanceReporting)({
28
+ treeIdentifier: IModelContentTreeComponent_1.IModelContentTreeComponent.id,
29
+ onPerformanceMeasured: props.onPerformanceMeasured,
30
+ });
25
31
  const state = (0, presentation_components_1.usePresentationTreeState)({
26
32
  imodel: iModel,
27
33
  ruleset: exports.RULESET_IMODEL_CONTENT,
@@ -30,6 +36,7 @@ const IModelContentTree = (props) => {
30
36
  customizeTreeNodeItem,
31
37
  hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
32
38
  enableHierarchyAutoUpdate: true,
39
+ onNodeLoaded: reporting.onNodeLoaded,
33
40
  });
34
41
  const treeRendererProps = {
35
42
  contextMenuItems: props.contextMenuItems,
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.t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AA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,iBAAiB,qBA6C5B;AAEF,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by IModelContentTree\n * @internal\n */\nexport const RULESET_IMODEL_CONTENT: Ruleset = require(\"./IModelContent.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Props for [[IModelContentTree]].\n * @public\n */\nexport interface IModelContentTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child\n * Subjects, their Models and Elements contained in those Models.\n * @public\n */\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, width, height, selectionMode, hierarchyLevelConfig } = props;\n\n const state = usePresentationTreeState({\n imodel: iModel,\n ruleset: RULESET_IMODEL_CONTENT,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n });\n\n const treeRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={width}\n height={height}\n state={state}\n selectionMode={selectionMode ?? SelectionMode.None}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n};\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
1
+ {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,8DAAwD;AACxD,4EAA0H;AAC1H,yDAA8E;AAC9E,+EAA4E;AAC5E,2CAAwG;AACxG,6EAA0E;AAI1E;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAqBzI;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;IAE7E,MAAM,SAAS,GAAG,IAAA,iDAAuB,EAAC;QACxC,cAAc,EAAE,uDAA0B,CAAC,EAAE;QAC7C,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;KACnD,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,IAAA,kDAAwB,EAAC;QACrC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,8BAAsB;QAC/B,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;QACzC,qBAAqB;QACrB,uBAAuB,EAAE,oBAAoB,EAAE,SAAS;QACxD,yBAAyB,EAAE,IAAI;QAC/B,YAAY,EAAE,SAAS,CAAC,YAAY;KACrC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG;QACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;IAEF,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,gCAAK,SAAS,EAAC,4BAA4B,YACzC,uBAAC,0CAAgB,IACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,IAAI,gCAAa,CAAC,IAAI,EAClD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1B,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CACzC,uBAAC,qCAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,uBAAC,sDAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,iBAAiB,qBAmD5B;AAEF,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by IModelContentTree\n * @internal\n */\nexport const RULESET_IMODEL_CONTENT: Ruleset = require(\"./IModelContent.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Props for [[IModelContentTree]].\n * @public\n */\nexport interface IModelContentTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n}\n\n/**\n * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child\n * Subjects, their Models and Elements contained in those Models.\n * @public\n */\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, width, height, selectionMode, hierarchyLevelConfig } = props;\n\n const reporting = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const state = usePresentationTreeState({\n imodel: iModel,\n ruleset: RULESET_IMODEL_CONTENT,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded: reporting.onNodeLoaded,\n });\n\n const treeRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={width}\n height={height}\n state={state}\n selectionMode={selectionMode ?? SelectionMode.None}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n};\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
@@ -53,6 +53,13 @@ export interface ModelsTreeProps extends BaseFilterableTreeProps {
53
53
  * @beta
54
54
  */
55
55
  hierarchyLevelConfig?: HierarchyLevelConfig;
56
+ /**
57
+ * Reports performance of a feature.
58
+ * @param featureId ID of the feature.
59
+ * @param elapsedTime Elapsed time of the feature.
60
+ * @beta
61
+ */
62
+ onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
56
63
  }
57
64
  /**
58
65
  * A tree component that shows a subject - model - category - element
@@ -17,9 +17,11 @@ const presentation_components_1 = require("@itwin/presentation-components");
17
17
  const TreeWidget_1 = require("../../../TreeWidget");
18
18
  const TreeRenderer_1 = require("../common/TreeRenderer");
19
19
  const Types_1 = require("../common/Types");
20
+ const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
20
21
  const UseVisibilityTreeState_1 = require("../common/UseVisibilityTreeState");
21
22
  const Utils_1 = require("../common/Utils");
22
23
  const VisibilityTreeRenderer_1 = require("../VisibilityTreeRenderer");
24
+ const ModelsTreeComponent_1 = require("./ModelsTreeComponent");
23
25
  const ModelsTreeEventHandler_1 = require("./ModelsTreeEventHandler");
24
26
  const ModelsVisibilityHandler_1 = require("./ModelsVisibilityHandler");
25
27
  const Utils_2 = require("./Utils");
@@ -85,7 +87,7 @@ function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
85
87
  });
86
88
  return filterInfo?.filter ? filteredTreeState : treeState;
87
89
  }
88
- function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, }) {
90
+ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, onPerformanceMeasured, }) {
89
91
  const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);
90
92
  const selectionPredicateRef = (0, react_1.useRef)(selectionPredicate);
91
93
  (0, react_1.useEffect)(() => {
@@ -99,6 +101,10 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
99
101
  visibilityHandler.setFilteredDataProvider(dataProvider);
100
102
  }
101
103
  }, [onFilterApplied, visibilityHandler]);
104
+ const reporting = (0, UsePerformanceReporting_1.usePerformanceReporting)({
105
+ treeIdentifier: ModelsTreeComponent_1.ModelsTreeComponent.id,
106
+ onPerformanceMeasured,
107
+ });
102
108
  return (0, UseVisibilityTreeState_1.useVisibilityTreeState)({
103
109
  imodel: iModel,
104
110
  ruleset,
@@ -114,6 +120,7 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
114
120
  : selectionPredicateRef.current(node.key, ModelsVisibilityHandler_1.ModelsVisibilityHandler.getNodeType(node)), []),
115
121
  eventHandler: eventHandlerFactory,
116
122
  hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
123
+ onNodeLoaded: filterInfo ? undefined : reporting.onNodeLoaded,
117
124
  });
118
125
  }
119
126
  function eventHandlerFactory(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;;;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MAAwB,EACxB,UAAoB,EACpB,iBAAgH,EAChH,0BAAoC;IAEpC,MAAM,oBAAoB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,8CAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAA2B,CAAC;IAE9D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE;YAChE,OAAO;SACR;QAED,MAAM,sBAAsB,GAAiC;YAC3D,SAAS;YACT,QAAQ,EAAE,UAAU;YACpB,0BAA0B;YAC1B,oBAAoB;SACrB,CAAC;QAEF,MAAM,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,iDAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjG,OAAO,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;AAClG,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,EAAE,+BAAuB,EAAE,kCAA0B,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { isPresentationTreeNodeItem, PresentationTree } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { ClassGroupingOption } from \"../common/Types\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { hierarchyLevelConfig, density, height, width, selectionMode } = props;\n const state = useModelsTreeState(props);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n },\n };\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData title={TreeWidget.translate(\"modelTree.noModelFound\")} message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")} />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n state={state}\n selectionMode={selectionMode || SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <ModelsTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n width={width}\n height={height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction ModelsTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(\n () =>\n createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n search: useMemo(\n () =>\n createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n };\n\n const treeState = useTreeState({\n ...props,\n ruleset: rulesets.general,\n });\n\n const filteredTreeState = useTreeState({\n ...props,\n ruleset: rulesets.search,\n filterInfo,\n onFilterApplied,\n });\n\n return filterInfo?.filter ? filteredTreeState : treeState;\n}\n\ninterface UseTreeProps extends ModelsTreeProps {\n ruleset: Ruleset;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n}: UseTreeProps) {\n const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);\n const selectionPredicateRef = useRef(selectionPredicate);\n useEffect(() => {\n selectionPredicateRef.current = selectionPredicate;\n }, [selectionPredicate]);\n\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, visibilityHandler],\n );\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n });\n}\n\nfunction eventHandlerFactory(props: VisibilityTreeEventHandlerParams) {\n return new ModelsTreeEventHandler(props);\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler),\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const [state, setState] = useState<ModelsVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler && typeof visibilityHandler !== \"function\") {\n return;\n }\n\n const visibilityHandlerProps: ModelsVisibilityHandlerProps = {\n rulesetId,\n viewport: activeView,\n hierarchyAutoUpdateEnabled,\n subjectModelIdsCache,\n };\n\n const handler = visibilityHandler ? visibilityHandler(visibilityHandlerProps) : new ModelsVisibilityHandler(visibilityHandlerProps);\n setState(handler);\n return () => {\n handler.dispose();\n };\n }, [rulesetId, activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache, visibilityHandler]);\n\n return visibilityHandler && typeof visibilityHandler !== \"function\" ? visibilityHandler : state;\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, addModelsTreeNodeItemIcons]);\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAA0E;AAC1E,8DAAwD;AACxD,4EAA8F;AAC9F,oDAAiD;AACjD,yDAAgE;AAChE,2CAAsD;AACtD,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAiI;AACjI,sEAA6I;AAC7I,+DAA4D;AAC5D,qEAAkE;AAClE,uEAA0F;AAC1F,mCAAyF;AASzF,MAAM,WAAW,GAAG,EAAE,CAAC;AA2DvB;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAC9E,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAExC,MAAM,iBAAiB,GAAG;QACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;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O;SACR;QAED,MAAM,sBAAsB,GAAiC;YAC3D,SAAS;YACT,QAAQ,EAAE,UAAU;YACpB,0BAA0B;YAC1B,oBAAoB;SACrB,CAAC;QAEF,MAAM,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,iDAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjG,OAAO,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;AAClG,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,EAAE,+BAAuB,EAAE,kCAA0B,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { isPresentationTreeNodeItem, PresentationTree } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { ClassGroupingOption } from \"../common/Types\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { hierarchyLevelConfig, density, height, width, selectionMode } = props;\n const state = useModelsTreeState(props);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n },\n };\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData title={TreeWidget.translate(\"modelTree.noModelFound\")} message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")} />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n state={state}\n selectionMode={selectionMode || SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <ModelsTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n width={width}\n height={height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction ModelsTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(\n () =>\n createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n search: useMemo(\n () =>\n createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n };\n\n const treeState = useTreeState({\n ...props,\n ruleset: rulesets.general,\n });\n\n const filteredTreeState = useTreeState({\n ...props,\n ruleset: rulesets.search,\n filterInfo,\n onFilterApplied,\n });\n\n return filterInfo?.filter ? filteredTreeState : treeState;\n}\n\ninterface UseTreeProps extends ModelsTreeProps {\n ruleset: Ruleset;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n onPerformanceMeasured,\n}: UseTreeProps) {\n const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);\n const selectionPredicateRef = useRef(selectionPredicate);\n useEffect(() => {\n selectionPredicateRef.current = selectionPredicate;\n }, [selectionPredicate]);\n\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, visibilityHandler],\n );\n\n const reporting = usePerformanceReporting({\n treeIdentifier: ModelsTreeComponent.id,\n onPerformanceMeasured,\n });\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n onNodeLoaded: filterInfo ? undefined : reporting.onNodeLoaded,\n });\n}\n\nfunction eventHandlerFactory(props: VisibilityTreeEventHandlerParams) {\n return new ModelsTreeEventHandler(props);\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler),\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const [state, setState] = useState<ModelsVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler && typeof visibilityHandler !== \"function\") {\n return;\n }\n\n const visibilityHandlerProps: ModelsVisibilityHandlerProps = {\n rulesetId,\n viewport: activeView,\n hierarchyAutoUpdateEnabled,\n subjectModelIdsCache,\n };\n\n const handler = visibilityHandler ? visibilityHandler(visibilityHandlerProps) : new ModelsVisibilityHandler(visibilityHandlerProps);\n setState(handler);\n return () => {\n handler.dispose();\n };\n }, [rulesetId, activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache, visibilityHandler]);\n\n return visibilityHandler && typeof visibilityHandler !== \"function\" ? visibilityHandler : state;\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, addModelsTreeNodeItemIcons]);\n"]}
@@ -10,6 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
10
10
  * See LICENSE.md in the project root for license terms and full copyright notice.
11
11
  *--------------------------------------------------------------------------------------------*/
12
12
  require("../VisibilityTreeBase.scss");
13
+ const classnames_1 = __importDefault(require("classnames"));
13
14
  const react_1 = require("react");
14
15
  const appui_react_1 = require("@itwin/appui-react");
15
16
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
@@ -21,7 +22,6 @@ const AutoSizer_1 = require("../../utils/AutoSizer");
21
22
  const ModelsTree_1 = require("./ModelsTree");
22
23
  const ModelsVisibilityHandler_1 = require("./ModelsVisibilityHandler");
23
24
  const Utils_1 = require("./Utils");
24
- const classnames_1 = __importDefault(require("classnames"));
25
25
  /**
26
26
  * A component that renders [[ModelsTree]] and a header with filtering capabilities
27
27
  * and header buttons.
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,iCAA+D;AAC/D,oDAAkF;AAClF,oEAAqG;AACrG,wDAA0D;AAC1D,oDAAiD;A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,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,YAExE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,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 \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\nimport classNames from \"classnames\";\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 * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, models: availableModels })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() =>\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction 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 <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => void toggleModels(models2d, is2dToggleActive, props.viewport)}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction 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 <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => void toggleModels(models3d, is3dToggleActive, props.viewport)}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAA+D;AAC/D,oDAAkF;AAClF,oEAAqG;AACrG,wDAA0D;AAC1D,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,qDAAkD;AAClD,6CAA0C;AAC1C,uEAA6H;AAC7H,mCAAsD;AA4CtD;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA8B,EAAE,EAAE;IACpE,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,uBAAC,uBAAuB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACpF,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B;AAEF;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,aAAa,CAAC;AAElD;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,aAAa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AAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,EAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAA,6CAAmB,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpI,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,uBAAC,sBAAM,IACL,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,eAAe,CAAC,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,sCAAY,EAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAC5E,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,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,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 \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\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 * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, models: availableModels })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() =>\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction 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 <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => void toggleModels(models2d, is2dToggleActive, props.viewport)}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction 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 <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => void toggleModels(models3d, is3dToggleActive, props.viewport)}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
@@ -72,8 +72,11 @@ export declare class ModelsVisibilityHandler implements IVisibilityHandler {
72
72
  protected changeModelsVisibility(ids: Id64String[], visible: boolean): Promise<void>;
73
73
  protected changeCategoryState(categoryId: Id64String, parentModelId: Id64String | undefined, on: boolean): void;
74
74
  protected changeElementGroupingNodeState(key: ECClassGroupingNodeKey, on: boolean): Promise<void>;
75
- protected changeElementState(id: Id64String, modelId: Id64String | undefined, categoryId: Id64String | undefined, on: boolean): Promise<void>;
75
+ protected changeElementState(id: Id64String, modelId: Id64String | undefined, categoryId: Id64String | undefined, on: boolean, hasChildren?: boolean): Promise<void>;
76
76
  protected changeElementsState(modelId: Id64String | undefined, categoryId: Id64String | undefined, elementIds: AsyncGenerator<Id64String>, on: boolean): Promise<void>;
77
+ private changeElementStateInternal;
78
+ private isElementDisplayedByDefault;
79
+ private hasExclusiveAlwaysDrawnElements;
77
80
  private onVisibilityChangeInternal;
78
81
  private onViewChanged;
79
82
  private onElementAlwaysDrawnChanged;
@@ -123,10 +123,10 @@ class ModelsVisibilityHandler {
123
123
  }
124
124
  /** Changes visibility of the items represented by the tree node. */
125
125
  async changeVisibility(node, on) {
126
- const nodeKey = (0, presentation_components_1.isPresentationTreeNodeItem)(node) ? node.key : undefined;
127
- if (!nodeKey) {
126
+ if (!(0, presentation_components_1.isPresentationTreeNodeItem)(node)) {
128
127
  return;
129
128
  }
129
+ const nodeKey = node.key;
130
130
  if (presentation_common_1.NodeKey.isClassGroupingNodeKey(nodeKey)) {
131
131
  await this.changeElementGroupingNodeState(nodeKey, on);
132
132
  return;
@@ -144,7 +144,7 @@ class ModelsVisibilityHandler {
144
144
  this.changeCategoryState(nodeKey.instanceKeys[0].id, this.getCategoryParentModelId(node), on);
145
145
  }
146
146
  else {
147
- await this.changeElementState(nodeKey.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node), on);
147
+ await this.changeElementState(nodeKey.instanceKeys[0].id, this.getElementModelId(node), this.getElementCategoryId(node), on, node.hasChildren);
148
148
  }
149
149
  }
150
150
  async getSubjectNodeVisibility(ids, node) {
@@ -317,40 +317,55 @@ class ModelsVisibilityHandler {
317
317
  const { modelId, categoryId, elementIds } = await this.getGroupedElementIds(key);
318
318
  await this.changeElementsState(modelId, categoryId, elementIds.getElementIds(), on);
319
319
  }
320
- async changeElementState(id, modelId, categoryId, on) {
320
+ async changeElementState(id, modelId, categoryId, on, hasChildren) {
321
+ const isDisplayedByDefault = this.isElementDisplayedByDefault(modelId, categoryId);
322
+ const isHiddenDueToExclusiveAlwaysDrawnElements = this.hasExclusiveAlwaysDrawnElements();
323
+ this.changeElementStateInternal(id, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
324
+ if (!hasChildren) {
325
+ return;
326
+ }
321
327
  const childIdsContainer = this.getAssemblyElementIds(id);
322
- async function* elementIds() {
323
- yield id;
324
- for await (const childId of childIdsContainer.getElementIds()) {
325
- yield childId;
326
- }
328
+ for await (const childId of childIdsContainer.getElementIds()) {
329
+ this.changeElementStateInternal(childId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
327
330
  }
328
- await this.changeElementsState(modelId, categoryId, elementIds(), on);
329
331
  }
330
332
  async changeElementsState(modelId, categoryId, elementIds, on) {
331
- const isDisplayedByDefault = modelId &&
332
- this.getModelDisplayStatus(modelId).state === "visible" &&
333
- categoryId &&
334
- this.getCategoryDisplayStatus(categoryId, modelId).state === "visible";
335
- const isHiddenDueToExclusiveAlwaysDrawnElements = this._props.viewport.isAlwaysDrawnExclusive && this._props.viewport.alwaysDrawn && 0 !== this._props.viewport.alwaysDrawn.size;
333
+ const isDisplayedByDefault = this.isElementDisplayedByDefault(modelId, categoryId);
334
+ const isHiddenDueToExclusiveAlwaysDrawnElements = this.hasExclusiveAlwaysDrawnElements();
335
+ for await (const elementId of elementIds) {
336
+ this.changeElementStateInternal(elementId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements);
337
+ }
338
+ }
339
+ changeElementStateInternal(elementId, on, isDisplayedByDefault, isHiddenDueToExclusiveAlwaysDrawnElements) {
340
+ let changedNeverDraw = false;
341
+ let changedAlwaysDrawn = false;
336
342
  const currNeverDrawn = new Set(this._props.viewport.neverDrawn ? this._props.viewport.neverDrawn : []);
337
343
  const currAlwaysDrawn = new Set(this._props.viewport.alwaysDrawn ? this._props.viewport.alwaysDrawn : /* istanbul ignore next */ []);
338
- for await (const elementId of elementIds) {
339
- if (on) {
340
- currNeverDrawn.delete(elementId);
341
- if (!isDisplayedByDefault || isHiddenDueToExclusiveAlwaysDrawnElements) {
342
- currAlwaysDrawn.add(elementId);
343
- }
344
+ if (on) {
345
+ changedNeverDraw = changedNeverDraw || currNeverDrawn.delete(elementId);
346
+ if ((!isDisplayedByDefault || isHiddenDueToExclusiveAlwaysDrawnElements) && !currAlwaysDrawn.has(elementId)) {
347
+ currAlwaysDrawn.add(elementId);
348
+ changedAlwaysDrawn = true;
344
349
  }
345
- else {
346
- currAlwaysDrawn.delete(elementId);
347
- if (isDisplayedByDefault && !isHiddenDueToExclusiveAlwaysDrawnElements) {
348
- currNeverDrawn.add(elementId);
349
- }
350
+ }
351
+ else {
352
+ changedAlwaysDrawn = changedAlwaysDrawn || currAlwaysDrawn.delete(elementId);
353
+ if (isDisplayedByDefault && !isHiddenDueToExclusiveAlwaysDrawnElements && !currNeverDrawn.has(elementId)) {
354
+ currNeverDrawn.add(elementId);
355
+ changedNeverDraw = true;
350
356
  }
351
357
  }
352
- this._props.viewport.setNeverDrawn(currNeverDrawn);
353
- this._props.viewport.setAlwaysDrawn(currAlwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
358
+ changedNeverDraw && this._props.viewport.setNeverDrawn(currNeverDrawn);
359
+ changedAlwaysDrawn && this._props.viewport.setAlwaysDrawn(currAlwaysDrawn, this._props.viewport.isAlwaysDrawnExclusive);
360
+ }
361
+ isElementDisplayedByDefault(modelId, categoryId) {
362
+ return (!!modelId &&
363
+ this.getModelDisplayStatus(modelId).state === "visible" &&
364
+ !!categoryId &&
365
+ this.getCategoryDisplayStatus(categoryId, modelId).state === "visible");
366
+ }
367
+ hasExclusiveAlwaysDrawnElements() {
368
+ return this._props.viewport.isAlwaysDrawnExclusive && 0 !== this._props.viewport.alwaysDrawn?.size;
354
369
  }
355
370
  onVisibilityChangeInternal() {
356
371
  if (this._pendingVisibilityChange) {