@itwin/tree-widget-react 2.0.0 → 2.0.1
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 +10 -2
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +1 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +1 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +1 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +1 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +1 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +2 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +1 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +1 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/package.json +1 -1
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
|
|
3
|
+
This log was last generated on Thu, 07 Mar 2024 13:36:50 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.0.1
|
|
8
|
+
|
|
9
|
+
Thu, 07 Mar 2024 13:36:50 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Updated trees to always react to data changes and auto update. ([#795](https://github.com/iTwin/viewer-components-react/pull/795))
|
|
14
|
+
|
|
7
15
|
## 2.0.0
|
|
8
16
|
|
|
9
|
-
Wed, 06 Mar 2024 15:24:
|
|
17
|
+
Wed, 06 Mar 2024 15:24:33 GMT
|
|
10
18
|
|
|
11
19
|
### Major changes
|
|
12
20
|
|
|
@@ -51,6 +51,7 @@ function CategoryTree(props) {
|
|
|
51
51
|
filterInfo: props.filterInfo,
|
|
52
52
|
onFilterChange,
|
|
53
53
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
54
|
+
enableHierarchyAutoUpdate: true,
|
|
54
55
|
});
|
|
55
56
|
(0, react_1.useEffect)(() => {
|
|
56
57
|
setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
@@ -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,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,2EAAwE;AAOxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AAgClI;;;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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CAAkC,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 { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } 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\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 } = 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 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 });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\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\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\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,6EAA0E;AAC1E,2CAAwG;AACxG,sEAA6I;AAC7I,2EAAwE;AAOxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AAgClI;;;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,GAAG,KAAK,CAAC;IAEtH,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,EAAE,YAAqB,EAAE,EAAE;QAC9E,IAAI,eAAe,IAAI,YAAY,IAAI,YAAY,KAAK,SAAS,EAAE;YACjE,eAAe,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;SAC7C;IACH,CAAC,EACD,CAAC,eAAe,CAAC,CAClB,CAAC;IACF,MAAM,KAAK,GAAG,IAAA,+CAAsB,EAAC;QACnC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,0BAAkB;QAC3B,UAAU,EAAE,WAAW;QACvB,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H,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 { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } 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\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 } = 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 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 });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\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\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\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"]}
|
|
@@ -54,6 +54,7 @@ function ExternalSourcesTree(props) {
|
|
|
54
54
|
eventHandlerFactory: unifiedSelectionTreeEventHandlerFactory,
|
|
55
55
|
customizeTreeNodeItem,
|
|
56
56
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
57
|
+
enableHierarchyAutoUpdate: true,
|
|
57
58
|
});
|
|
58
59
|
const treeRendererProps = {
|
|
59
60
|
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,
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot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AE,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"]}
|
|
@@ -29,6 +29,7 @@ const IModelContentTree = (props) => {
|
|
|
29
29
|
appendChildrenCountForGroupingNodes: true,
|
|
30
30
|
customizeTreeNodeItem,
|
|
31
31
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
32
|
+
enableHierarchyAutoUpdate: true,
|
|
32
33
|
});
|
|
33
34
|
const treeRendererProps = {
|
|
34
35
|
contextMenuItems: props.contextMenuItems,
|
|
@@ -1 +1 @@
|
|
|
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,2CAAwG;AAIxG;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAczI;;;;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,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;
|
|
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,2CAAwG;AAIxG;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAczI;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,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AC,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"]}
|
|
@@ -41,6 +41,7 @@ export interface ModelsTreeProps extends BaseFilterableTreeProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* Auto-update the hierarchy when data in the iModel changes.
|
|
43
43
|
* @alpha
|
|
44
|
+
* @deprecated in 2.0.1. It does not have any effect, auto update is always on.
|
|
44
45
|
*/
|
|
45
46
|
enableHierarchyAutoUpdate?: boolean;
|
|
46
47
|
/**
|
|
@@ -85,7 +85,7 @@ function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
|
85
85
|
});
|
|
86
86
|
return filterInfo?.filter ? filteredTreeState : treeState;
|
|
87
87
|
}
|
|
88
|
-
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset,
|
|
88
|
+
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, }) {
|
|
89
89
|
const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);
|
|
90
90
|
const selectionPredicateRef = (0, react_1.useRef)(selectionPredicate);
|
|
91
91
|
(0, react_1.useEffect)(() => {
|
|
@@ -104,7 +104,7 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
|
|
|
104
104
|
ruleset,
|
|
105
105
|
pagingSize: PAGING_SIZE,
|
|
106
106
|
appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === Types_1.ClassGroupingOption.YesWithCounts,
|
|
107
|
-
enableHierarchyAutoUpdate,
|
|
107
|
+
enableHierarchyAutoUpdate: true,
|
|
108
108
|
customizeTreeNodeItem,
|
|
109
109
|
visibilityHandler,
|
|
110
110
|
filterInfo,
|
|
@@ -1 +1 @@
|
|
|
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,6EAA0E;AAC1E,2CAAiI;AACjI,sEAA6I;AAC7I,qEAAkE;AAClE,uEAA0F;AAC1F,mCAAyF;AASzF,MAAM,WAAW,GAAG,EAAE,CAAC;AAmDvB;;;;;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;QAC1C,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,iBAAiB,EAAE;YACjB,YAAY,EAAE,IAAI;YAClB,kBAAkB,EAAE,KAAK;YACzB,WAAW,EAAE,EAAE;YACf,uBAAuB,EAAE,IAAI;SAC9B;KACF,CAAC;IAEF,uBAAuB;IACvB,MAAM,sBAAsB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC9C,OAAO,CACL,uBAAC,qDAA4B,IAAC,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAAE,OAAO,EAAE,uBAAU,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;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 */\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 enableHierarchyAutoUpdate,\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,\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,6EAA0E;AAC1E,2CAAiI;AACjI,sEAA6I;AAC7I,qEAAkE;AAClE,uEAA0F;AAC1F,mCAAyF;AASzF,MAAM,WAAW,GAAG,EAAE,CAAC;AAoDvB;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,o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B,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"]}
|
|
@@ -45,6 +45,7 @@ export function CategoryTree(props) {
|
|
|
45
45
|
filterInfo: props.filterInfo,
|
|
46
46
|
onFilterChange,
|
|
47
47
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
48
|
+
enableHierarchyAutoUpdate: true,
|
|
48
49
|
});
|
|
49
50
|
useEffect(() => {
|
|
50
51
|
setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
@@ -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,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,4BAA4B,EAAE,oCAAoC,EAAE,4BAA4B,EAAE,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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 { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } 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\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 } = 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 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 });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\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\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\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,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,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAY,OAAO,C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Y,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 { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } 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\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 } = 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 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 });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\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\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\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"]}
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "../VisibilityTreeBase.scss";
|
|
7
7
|
import { SelectionMode } from "@itwin/components-react";
|
|
8
|
-
import { PresentationTree, PresentationTreeNodeRenderer, UnifiedSelectionTreeEventHandler, usePresentationTreeState } from "@itwin/presentation-components";
|
|
8
|
+
import { PresentationTree, PresentationTreeNodeRenderer, UnifiedSelectionTreeEventHandler, usePresentationTreeState, } from "@itwin/presentation-components";
|
|
9
9
|
import { FilterableTreeRenderer, TreeRenderer } from "../common/TreeRenderer";
|
|
10
10
|
import { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from "../common/Utils";
|
|
11
11
|
import * as RULESET_EXTERNAL_SOURCES_IMPORT from "./ExternalSources.json";
|
|
@@ -28,6 +28,7 @@ export function ExternalSourcesTree(props) {
|
|
|
28
28
|
eventHandlerFactory: unifiedSelectionTreeEventHandlerFactory,
|
|
29
29
|
customizeTreeNodeItem,
|
|
30
30
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
31
|
+
enableHierarchyAutoUpdate: true,
|
|
31
32
|
});
|
|
32
33
|
const treeRendererProps = {
|
|
33
34
|
contextMenuItems,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,gBAAgB,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,wBAAwB,GAC3G,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,KAAK,+BAA+B,MAAM,wBAAwB,CAAC;AAK1E;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA0C,CAAC;AAEnF,MAAM,WAAW,GAAG,EAAE,CAAC;AAcvB;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAErF,MAAM,KAAK,GAAG,wBAAwB,CAAC;QACrC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,wBAAwB;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,cAAK,SAAS,EAAC,4BAA4B,YACzC,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,aAAa,CAAC,QAAQ,EAC5D,YAAY,EAAE,IAAI,EAClB,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1B,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CACzC,KAAC,sBAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,KAAC,4BAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC;AAED,SAAS,uCAAuC,CAAC,KAAwC;IACvF,OAAO,IAAI,gCAAgC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;IAC9D,kCAAkC;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"]}
|
|
@@ -26,6 +26,7 @@ export const IModelContentTree = (props) => {
|
|
|
26
26
|
appendChildrenCountForGroupingNodes: true,
|
|
27
27
|
customizeTreeNodeItem,
|
|
28
28
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
29
|
+
enableHierarchyAutoUpdate: true,
|
|
29
30
|
});
|
|
30
31
|
const treeRendererProps = {
|
|
31
32
|
contextMenuItems: props.contextMenuItems,
|
|
@@ -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,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1H,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAIxG;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAczI;;;;GAIG;AACH,MAAM,CAAC,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,KAAK,GAAG,wBAAwB,CAAC;QACrC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,sBAAsB;QAC/B,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;QACzC,qBAAqB;QACrB,uBAAuB,EAAE,oBAAoB,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1H,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAIxG;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAczI;;;;GAIG;AACH,MAAM,CAAC,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,KAAK,GAAG,wBAAwB,CAAC;QACrC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,sBAAsB;QAC/B,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;QACzC,qBAAqB;QACrB,uBAAuB,EAAE,oBAAoB,EAAE,SAAS;QACxD,yBAAyB,EAAE,IAAI;KAChC,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,cAAK,SAAS,EAAC,4BAA4B,YACzC,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,IAAI,aAAa,CAAC,IAAI,EAClD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1B,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CACzC,KAAC,sBAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,KAAC,4BAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,OAAK,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 { 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"]}
|
|
@@ -41,6 +41,7 @@ export interface ModelsTreeProps extends BaseFilterableTreeProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* Auto-update the hierarchy when data in the iModel changes.
|
|
43
43
|
* @alpha
|
|
44
|
+
* @deprecated in 2.0.1. It does not have any effect, auto update is always on.
|
|
44
45
|
*/
|
|
45
46
|
enableHierarchyAutoUpdate?: boolean;
|
|
46
47
|
/**
|
|
@@ -78,7 +78,7 @@ function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
|
78
78
|
});
|
|
79
79
|
return filterInfo?.filter ? filteredTreeState : treeState;
|
|
80
80
|
}
|
|
81
|
-
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset,
|
|
81
|
+
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, }) {
|
|
82
82
|
const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);
|
|
83
83
|
const selectionPredicateRef = useRef(selectionPredicate);
|
|
84
84
|
useEffect(() => {
|
|
@@ -97,7 +97,7 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
|
|
|
97
97
|
ruleset,
|
|
98
98
|
pagingSize: PAGING_SIZE,
|
|
99
99
|
appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,
|
|
100
|
-
enableHierarchyAutoUpdate,
|
|
100
|
+
enableHierarchyAutoUpdate: true,
|
|
101
101
|
customizeTreeNodeItem,
|
|
102
102
|
visibilityHandler,
|
|
103
103
|
filterInfo,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OA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AuB,EAAE,0BAA0B,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 */\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 enableHierarchyAutoUpdate,\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,\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,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBA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AC,KAAuC;IAClE,OAAO,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,oBAAoB,CAC3B,SAAiB,EACjB,MAAwB,EACxB,UAAoB,EACpB,iBAAgH,EAChH,0BAAoC;IAEpC,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAC;IAE9D,SAAS,CAAC,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,uBAAuB,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,iCAAiC,CAAC,CAAC,kCAAkC,EAAE,uBAAuB,EAAE,0BAA0B,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"]}
|