@itwin/tree-widget-react 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @itwin/tree-widget-react
2
2
 
3
- This log was last generated on Wed, 22 May 2024 16:03:32 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 10 Jun 2024 12:47:40 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.3.2
8
+
9
+ Mon, 10 Jun 2024 12:47:40 GMT
10
+
11
+ ### Patches
12
+
13
+ - Removed usage of `require` as it is not supported in ES modules ([#902](https://github.com/iTwin/viewer-components-react/pull/902))
14
+
7
15
  ## 2.3.1
8
16
 
9
- Wed, 22 May 2024 16:03:32 GMT
17
+ Wed, 22 May 2024 16:03:40 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -23,6 +46,7 @@ const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
23
46
  const UseVisibilityTreeState_1 = require("../common/UseVisibilityTreeState");
24
47
  const Utils_1 = require("../common/Utils");
25
48
  const VisibilityTreeRenderer_1 = require("../VisibilityTreeRenderer");
49
+ const RULESET_CATEGORIES_IMPORT = __importStar(require("./Categories.json"));
26
50
  const CategoriesTreeComponent_1 = require("./CategoriesTreeComponent");
27
51
  const CategoryVisibilityHandler_1 = require("./CategoryVisibilityHandler");
28
52
  const PAGING_SIZE = 20;
@@ -30,7 +54,7 @@ const PAGING_SIZE = 20;
30
54
  * Presentation rules used by ControlledCategoriesTree
31
55
  * @internal
32
56
  */
33
- exports.RULESET_CATEGORIES = require("./Categories.json"); // eslint-disable-line @typescript-eslint/no-var-requires
57
+ exports.RULESET_CATEGORIES = RULESET_CATEGORIES_IMPORT;
34
58
  /**
35
59
  * Tree which displays and manages display of categories contained in an iModel.
36
60
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAAyD;AACzD,8DAAwD;AACxD,wDAAiD;AACjD,4EAAkE;AAClE,wEAA4D;AAC5D,oDAAiD;AACjD,yDAAgE;AAChE,uEAAoE;AACpE,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,uEAAoE;AACpE,2EAAwE;AAQxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AA6ClI;;;GAGG;AACH,SAAgB,YAAY,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EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;QACpH,QAAQ,CAAC,cAAc,CAAC,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEnF,OAAO,iBAAiB,IAAI,KAAK,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,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 \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\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 width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
1
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAAyD;AACzD,8DAAwD;AACxD,wDAAiD;AACjD,4EAAkE;AAClE,wEAA4D;AAC5D,oDAAiD;AACjD,yDAAgE;AAChE,uEAAoE;AACpE,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,6EAA+D;AAC/D,uEAAoE;AACpE,2EAAwE;AAQxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAG,yBAAoC,CAAC;AA6CvE;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,uBAAuB;IACvB,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,yBAAS,CAAC,WAAW,CAAC;IAC/D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAE5J,MAAM,iBAAiB,GAAG,4BAA4B,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACzJ,MAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,CAAC,YAAoD,E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,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,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 \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport * as RULESET_CATEGORIES_IMPORT from \"./Categories.json\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES = RULESET_CATEGORIES_IMPORT as Ruleset;\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\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 width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.IModelContentTree = exports.RULESET_IMODEL_CONTENT = void 0;
4
27
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -14,12 +37,13 @@ const TreeRenderer_1 = require("../common/TreeRenderer");
14
37
  const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
15
38
  const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
16
39
  const Utils_1 = require("../common/Utils");
40
+ const RULESET_IMODEL_CONTENT_IMPORT = __importStar(require("./IModelContent.json"));
17
41
  const IModelContentTreeComponent_1 = require("./IModelContentTreeComponent");
18
42
  /**
19
43
  * Presentation rules used by IModelContentTree
20
44
  * @internal
21
45
  */
22
- exports.RULESET_IMODEL_CONTENT = require("./IModelContent.json"); // eslint-disable-line @typescript-eslint/no-var-requires
46
+ exports.RULESET_IMODEL_CONTENT = RULESET_IMODEL_CONTENT_IMPORT;
23
47
  /**
24
48
  * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child
25
49
  * Subjects, their Models and Elements contained in those Models.
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-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AmC,EAAE,IAAI;QACzC,qBAAqB;QACrB,uBAAuB,EAAE,oBAAoB,EAAE,SAAS;QACxD,yBAAyB,EAAE,IAAI;QAC/B,YAAY;QACZ,mBAAmB;KACpB,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;AAlEW,QAAA,iBAAiB,qBAkE5B;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 { useCallback } from \"react\";\nimport { SelectionMode, TreeEventHandler } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => 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, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: IModelContentTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const nodeLoader = handlerProps.nodeLoader;\n const eventHandler = new TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\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,\n eventHandlerFactory,\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,iCAAoC;AACpC,8DAA0E;AAC1E,4EAA0H;AAC1H,mFAAgF;AAChF,yDAA8E;AAC9E,uEAAoE;AACpE,+EAA4E;AAC5E,2CAAwG;AACxG,oF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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;AAlEW,QAAA,iBAAiB,qBAkE5B;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 { useCallback } from \"react\";\nimport { SelectionMode, TreeEventHandler } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport * as RULESET_IMODEL_CONTENT_IMPORT from \"./IModelContent.json\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\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_IMODEL_CONTENT_IMPORT as Ruleset;\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => 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, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: IModelContentTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const nodeLoader = handlerProps.nodeLoader;\n const eventHandler = new TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\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,\n eventHandlerFactory,\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"]}
@@ -17,6 +17,7 @@ import { usePerformanceReporting } from "../common/UsePerformanceReporting";
17
17
  import { useVisibilityTreeState } from "../common/UseVisibilityTreeState";
18
18
  import { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from "../common/Utils";
19
19
  import { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from "../VisibilityTreeRenderer";
20
+ import * as RULESET_CATEGORIES_IMPORT from "./Categories.json";
20
21
  import { CategoriesTreeComponent } from "./CategoriesTreeComponent";
21
22
  import { CategoryVisibilityHandler } from "./CategoryVisibilityHandler";
22
23
  const PAGING_SIZE = 20;
@@ -24,7 +25,7 @@ const PAGING_SIZE = 20;
24
25
  * Presentation rules used by ControlledCategoriesTree
25
26
  * @internal
26
27
  */
27
- export const RULESET_CATEGORIES = require("./Categories.json"); // eslint-disable-line @typescript-eslint/no-var-requires
28
+ export const RULESET_CATEGORIES = RULESET_CATEGORIES_IMPORT;
28
29
  /**
29
30
  * Tree which displays and manages display of categories contained in an iModel.
30
31
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,4BAA4B,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC7I,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAQxE,MAAM,WAAW,GAAG,EAAE,CAAC;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QAED,MAAM,cAAc,GAAG,IAAI,yBAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;QACpH,QAAQ,CAAC,cAAc,CAAC,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEnF,OAAO,iBAAiB,IAAI,KAAK,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,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, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\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 width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
1
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,4BAA4B,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC7I,OAAO,KAAK,yBAAyB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,uB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Q,EAA6B,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,EAAE;YACrB,OAAO;SACR;QAED,MAAM,cAAc,GAAG,IAAI,yBAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;QACpH,QAAQ,CAAC,cAAc,CAAC,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEnF,OAAO,iBAAiB,IAAI,KAAK,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,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, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport * as RULESET_CATEGORIES_IMPORT from \"./Categories.json\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES = RULESET_CATEGORIES_IMPORT as Ruleset;\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\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 width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
@@ -11,12 +11,13 @@ import { FilterableTreeRenderer, TreeRenderer } from "../common/TreeRenderer";
11
11
  import { useFeatureReporting } from "../common/UseFeatureReporting";
12
12
  import { usePerformanceReporting } from "../common/UsePerformanceReporting";
13
13
  import { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from "../common/Utils";
14
+ import * as RULESET_IMODEL_CONTENT_IMPORT from "./IModelContent.json";
14
15
  import { IModelContentTreeComponent } from "./IModelContentTreeComponent";
15
16
  /**
16
17
  * Presentation rules used by IModelContentTree
17
18
  * @internal
18
19
  */
19
- export const RULESET_IMODEL_CONTENT = require("./IModelContent.json"); // eslint-disable-line @typescript-eslint/no-var-requires
20
+ export const RULESET_IMODEL_CONTENT = RULESET_IMODEL_CONTENT_IMPORT;
20
21
  /**
21
22
  * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child
22
23
  * Subjects, their Models and Elements contained in those Models.
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE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------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { SelectionMode, TreeEventHandler } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => 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, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: IModelContentTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const nodeLoader = handlerProps.nodeLoader;\n const eventHandler = new TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\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,\n eventHandlerFactory,\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":";AAA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SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,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 { useCallback } from \"react\";\nimport { SelectionMode, TreeEventHandler } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport * as RULESET_IMODEL_CONTENT_IMPORT from \"./IModelContent.json\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\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_IMODEL_CONTENT_IMPORT as Ruleset;\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 * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => 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, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: IModelContentTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const nodeLoader = handlerProps.nodeLoader;\n const eventHandler = new TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\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,\n eventHandlerFactory,\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/tree-widget-react",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Tree Widget React",
5
5
  "keywords": [
6
6
  "Bentley",