@itwin/tree-widget-react 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -4
- package/README.md +85 -0
- package/lib/cjs/components/SelectableTree.d.ts +4 -0
- package/lib/cjs/components/SelectableTree.js +2 -1
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +2 -0
- package/lib/cjs/components/TreeSelector.js +5 -2
- package/lib/cjs/components/TreeSelector.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +2 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +6 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +10 -5
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js +51 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/cjs/components/trees/common/TreeRenderer.js +19 -3
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js +30 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +6 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +16 -7
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +6 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +17 -3
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +19 -12
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +26 -11
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +35 -12
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/Utils.js +0 -22
- package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +4 -0
- package/lib/esm/components/SelectableTree.js +2 -1
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +2 -0
- package/lib/esm/components/TreeSelector.js +5 -2
- package/lib/esm/components/TreeSelector.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +2 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +6 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +10 -5
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js +47 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/esm/components/trees/common/TreeRenderer.js +19 -3
- package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js +26 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +6 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +17 -8
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +6 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +18 -4
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js +19 -12
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +26 -11
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +35 -12
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/Utils.js +0 -22
- package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseVisibilityTreeState.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseVisibilityTreeState.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA+C;AAC/C,4EAA0E;AAC1E,8EAA2E;
|
|
1
|
+
{"version":3,"file":"UseVisibilityTreeState.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseVisibilityTreeState.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA+C;AAC/C,4EAA0E;AAC1E,8EAA2E;AAC3E,2EAAwE;AAiCxE;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,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AAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;IAE7G,OAAO,SAAS,CAAC;AACnB,CAAC;AA/CD,wDA+CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect } from \"react\";\nimport { usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { ReportingTreeEventHandler } from \"./ReportingTreeEventHandler\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeEventHandlerProps, UsePresentationTreeStateProps } from \"@itwin/presentation-components\";\nimport type { IVisibilityHandler, VisibilityTreeEventHandlerParams, VisibilityTreeSelectionPredicate } from \"../VisibilityTreeEventHandler\";\nimport type { VisibilityTreeFilterInfo } from \"./Types\";\nimport type { UsageTrackedFeatures } from \"./UseFeatureReporting\";\n/**\n * Props for [[useVisibilityTreeState]] hook.\n * @beta\n */\nexport interface UseVisibilityTreeStateProps extends Omit<UsePresentationTreeStateProps<VisibilityTreeEventHandler>, \"rulesetOrId\"> {\n /** iModel to pull data from. */\n imodel: IModelConnection;\n /** Presentation rules to use when pulling data from iModel. */\n ruleset: Ruleset;\n /** Visibility handler that will be used to determine tree node visibility or change it. */\n visibilityHandler?: IVisibilityHandler;\n /** Info about filter that should be applied on tree. */\n filterInfo?: VisibilityTreeFilterInfo;\n /** Callback that is invoked when filter is applied, changed or removed. */\n onFilterChange?: (filteredDataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => void;\n /** Callback that is used to determine if node can be selected. If not provided all nodes are selectable. */\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n /** Factory for custom `VisibilityTreeEventHandler`. Defaults to `VisibilityTreeEventHandler`. */\n eventHandler?: (props: VisibilityTreeEventHandlerParams) => VisibilityTreeEventHandler;\n /** The limit for how many items should be loaded for a single hierarchy level. */\n hierarchyLevelSizeLimit?: number;\n /** Callback called when a feature is used. */\n reportUsage?: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\n/**\n * Custom hook for creating visibility tree component state.\n *\n * @returns `undefined` on first render cycle. On all other render cycles state is initialized and valid object is returned.\n * @beta\n */\nexport function useVisibilityTreeState({\n imodel,\n ruleset,\n filterInfo,\n onFilterChange,\n visibilityHandler,\n selectionPredicate,\n eventHandler,\n reportUsage,\n ...props\n}: UseVisibilityTreeStateProps) {\n const eventHandlerFactory = useCallback(\n (params: PresentationTreeEventHandlerProps) => {\n if (!visibilityHandler) {\n return undefined;\n }\n\n const eventHandlerProps: VisibilityTreeEventHandlerParams = {\n nodeLoader: params.nodeLoader,\n visibilityHandler,\n selectionPredicate,\n };\n\n const handler = eventHandler ? eventHandler(eventHandlerProps) : new VisibilityTreeEventHandler(eventHandlerProps);\n return reportUsage ? new ReportingTreeEventHandler({ eventHandler: handler, reportUsage, nodeLoader: eventHandlerProps.nodeLoader }) : handler;\n },\n [visibilityHandler, selectionPredicate, eventHandler, reportUsage],\n );\n\n const treeState = usePresentationTreeState({\n ...props,\n imodel,\n ruleset,\n eventHandlerFactory,\n filteringParams: filterInfo?.filter\n ? {\n filter: filterInfo.filter,\n activeMatchIndex: filterInfo?.activeMatchIndex,\n }\n : undefined,\n });\n\n useEffect(() => {\n onFilterChange && onFilterChange(treeState?.filteringResult?.filteredProvider, treeState?.filteringResult?.matchesCount);\n }, [treeState?.filteringResult?.matchesCount, treeState?.filteringResult?.filteredProvider, onFilterChange]);\n\n return treeState;\n}\n"]}
|
|
@@ -24,6 +24,12 @@ export interface ExternalSourcesTreeProps extends BaseTreeProps {
|
|
|
24
24
|
* @beta
|
|
25
25
|
*/
|
|
26
26
|
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback that is invoked when a tracked feature is used.
|
|
29
|
+
* @param featureId ID of the feature.
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
32
|
+
onFeatureUsed?: (feature: string) => void;
|
|
27
33
|
}
|
|
28
34
|
/**
|
|
29
35
|
* Tree which displays a hierarchy of ExternalSources and their elements.
|
|
@@ -30,9 +30,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
30
30
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
31
31
|
*--------------------------------------------------------------------------------------------*/
|
|
32
32
|
require("../VisibilityTreeBase.scss");
|
|
33
|
+
const react_1 = require("react");
|
|
33
34
|
const components_react_1 = require("@itwin/components-react");
|
|
34
35
|
const presentation_components_1 = require("@itwin/presentation-components");
|
|
36
|
+
const ReportingTreeEventHandler_1 = require("../common/ReportingTreeEventHandler");
|
|
35
37
|
const TreeRenderer_1 = require("../common/TreeRenderer");
|
|
38
|
+
const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
|
|
36
39
|
const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
|
|
37
40
|
const Utils_1 = require("../common/Utils");
|
|
38
41
|
const RULESET_EXTERNAL_SOURCES_IMPORT = __importStar(require("./ExternalSources.json"));
|
|
@@ -48,20 +51,29 @@ const PAGING_SIZE = 20;
|
|
|
48
51
|
* @alpha
|
|
49
52
|
*/
|
|
50
53
|
function ExternalSourcesTree(props) {
|
|
51
|
-
const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density } = props;
|
|
52
|
-
const
|
|
54
|
+
const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density, onFeatureUsed } = props;
|
|
55
|
+
const { reportUsage } = (0, UseFeatureReporting_1.useFeatureReporting)({ treeIdentifier: ExternalSourcesTreeComponent_1.ExternalSourcesTreeComponent.id, onFeatureUsed });
|
|
56
|
+
const { onNodeLoaded } = (0, UsePerformanceReporting_1.usePerformanceReporting)({
|
|
53
57
|
treeIdentifier: ExternalSourcesTreeComponent_1.ExternalSourcesTreeComponent.id,
|
|
54
58
|
onPerformanceMeasured: props.onPerformanceMeasured,
|
|
55
59
|
});
|
|
60
|
+
const eventHandlerFactory = (0, react_1.useCallback)((handlerProps) => {
|
|
61
|
+
const eventHandler = new presentation_components_1.UnifiedSelectionTreeEventHandler({ nodeLoader: handlerProps.nodeLoader });
|
|
62
|
+
return new ReportingTreeEventHandler_1.ReportingTreeEventHandler({
|
|
63
|
+
nodeLoader: handlerProps.nodeLoader,
|
|
64
|
+
eventHandler,
|
|
65
|
+
reportUsage,
|
|
66
|
+
});
|
|
67
|
+
}, [reportUsage]);
|
|
56
68
|
const state = (0, presentation_components_1.usePresentationTreeState)({
|
|
57
69
|
imodel: props.iModel,
|
|
58
70
|
ruleset: exports.RULESET_EXTERNAL_SOURCES,
|
|
59
71
|
pagingSize: PAGING_SIZE,
|
|
60
|
-
eventHandlerFactory
|
|
72
|
+
eventHandlerFactory,
|
|
61
73
|
customizeTreeNodeItem,
|
|
62
74
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
63
75
|
enableHierarchyAutoUpdate: true,
|
|
64
|
-
onNodeLoaded
|
|
76
|
+
onNodeLoaded,
|
|
65
77
|
});
|
|
66
78
|
const treeRendererProps = {
|
|
67
79
|
contextMenuItems,
|
|
@@ -74,9 +86,6 @@ function ExternalSourcesTree(props) {
|
|
|
74
86
|
return ((0, jsx_runtime_1.jsx)("div", { className: "tree-widget-tree-container", children: (0, jsx_runtime_1.jsx)(presentation_components_1.PresentationTree, { width: props.width, height: props.height, state: state, selectionMode: props.selectionMode ?? components_react_1.SelectionMode.Extended, iconsEnabled: true, treeRenderer: (treeProps) => hierarchyLevelConfig?.isFilteringEnabled ? ((0, jsx_runtime_1.jsx)(TreeRenderer_1.FilterableTreeRenderer, { ...treeProps, ...treeRendererProps, nodeLoader: state.nodeLoader, nodeRenderer: (nodeRendererProps) => (0, jsx_runtime_1.jsx)(presentation_components_1.PresentationTreeNodeRenderer, { ...nodeRendererProps }) })) : ((0, jsx_runtime_1.jsx)(TreeRenderer_1.TreeRenderer, { ...treeProps, ...treeRendererProps })) }) }));
|
|
75
87
|
}
|
|
76
88
|
exports.ExternalSourcesTree = ExternalSourcesTree;
|
|
77
|
-
function unifiedSelectionTreeEventHandlerFactory(props) {
|
|
78
|
-
return new presentation_components_1.UnifiedSelectionTreeEventHandler({ nodeLoader: props.nodeLoader });
|
|
79
|
-
}
|
|
80
89
|
const customizeTreeNodeItem = (0, Utils_1.combineTreeNodeItemCustomizations)([
|
|
81
90
|
Utils_1.addCustomTreeNodeItemLabelRenderer,
|
|
82
91
|
(item, node) => {
|
|
@@ -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":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,iCAAoC;AACpC,8DAAwD;AACxD,4EAA4J;AAC5J,mFAAgF;AAChF,yDAA8E;AAC9E,uEAAoE;AACpE,+EAA4E;AAC5E,2CAAwG;AACxG,wFAA0E;AAC1E,iFAA8E;AAK9E;;;GAGG;AACU,QAAA,wBAAwB,GAAG,+BAA0C,CAAC;AAEnF,MAAM,WAAW,GAAG,EAAE,CAAC;AA2BvB;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAEpG,MAAM,EAAE,WAAW,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AY,EAAE,CAAC,SAAS,EAAE,EAAE,CAC1B,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CACzC,uBAAC,qCAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,uBAAC,sDAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC;AAjED,kDAiEC;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 { useCallback } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, UnifiedSelectionTreeEventHandler, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport * as RULESET_EXTERNAL_SOURCES_IMPORT from \"./ExternalSources.json\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_EXTERNAL_SOURCES = RULESET_EXTERNAL_SOURCES_IMPORT as Ruleset;\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for the [[ExternalSourcesTree]] component\n * @alpha\n */\nexport interface ExternalSourcesTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays a hierarchy of ExternalSources and their elements.\n * @alpha\n */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n const { hierarchyLevelConfig, contextMenuItems, nodeLabelRenderer, density, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: ExternalSourcesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: ExternalSourcesTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const eventHandler = new UnifiedSelectionTreeEventHandler({ nodeLoader: handlerProps.nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader: handlerProps.nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\n );\n\n const state = usePresentationTreeState({\n imodel: props.iModel,\n ruleset: RULESET_EXTERNAL_SOURCES,\n pagingSize: PAGING_SIZE,\n eventHandlerFactory,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n });\n\n const treeRendererProps = {\n contextMenuItems,\n nodeLabelRenderer,\n density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.Extended}\n iconsEnabled={true}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([\n addCustomTreeNodeItemLabelRenderer,\n (item, node) => {\n item.icon = node.extendedData?.imageId;\n },\n]);\n"]}
|
|
@@ -23,6 +23,12 @@ export interface IModelContentTreeProps extends BaseTreeProps {
|
|
|
23
23
|
* @beta
|
|
24
24
|
*/
|
|
25
25
|
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Callback that is invoked when a tracked feature is used.
|
|
28
|
+
* @param featureId ID of the feature.
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
onFeatureUsed?: (feature: string) => void;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* A tree that shows all iModel content starting from the root Subject, then the hierarchy of child
|
|
@@ -6,9 +6,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
const react_1 = require("react");
|
|
9
10
|
const components_react_1 = require("@itwin/components-react");
|
|
10
11
|
const presentation_components_1 = require("@itwin/presentation-components");
|
|
12
|
+
const ReportingTreeEventHandler_1 = require("../common/ReportingTreeEventHandler");
|
|
11
13
|
const TreeRenderer_1 = require("../common/TreeRenderer");
|
|
14
|
+
const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
|
|
12
15
|
const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
|
|
13
16
|
const Utils_1 = require("../common/Utils");
|
|
14
17
|
const IModelContentTreeComponent_1 = require("./IModelContentTreeComponent");
|
|
@@ -23,11 +26,21 @@ exports.RULESET_IMODEL_CONTENT = require("./IModelContent.json"); // eslint-disa
|
|
|
23
26
|
* @public
|
|
24
27
|
*/
|
|
25
28
|
const IModelContentTree = (props) => {
|
|
26
|
-
const { iModel, width, height, selectionMode, hierarchyLevelConfig } = props;
|
|
27
|
-
const
|
|
29
|
+
const { iModel, width, height, selectionMode, hierarchyLevelConfig, onFeatureUsed } = props;
|
|
30
|
+
const { reportUsage } = (0, UseFeatureReporting_1.useFeatureReporting)({ treeIdentifier: IModelContentTreeComponent_1.IModelContentTreeComponent.id, onFeatureUsed });
|
|
31
|
+
const { onNodeLoaded } = (0, UsePerformanceReporting_1.usePerformanceReporting)({
|
|
28
32
|
treeIdentifier: IModelContentTreeComponent_1.IModelContentTreeComponent.id,
|
|
29
33
|
onPerformanceMeasured: props.onPerformanceMeasured,
|
|
30
34
|
});
|
|
35
|
+
const eventHandlerFactory = (0, react_1.useCallback)((handlerProps) => {
|
|
36
|
+
const nodeLoader = handlerProps.nodeLoader;
|
|
37
|
+
const eventHandler = new components_react_1.TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });
|
|
38
|
+
return new ReportingTreeEventHandler_1.ReportingTreeEventHandler({
|
|
39
|
+
nodeLoader,
|
|
40
|
+
eventHandler,
|
|
41
|
+
reportUsage,
|
|
42
|
+
});
|
|
43
|
+
}, [reportUsage]);
|
|
31
44
|
const state = (0, presentation_components_1.usePresentationTreeState)({
|
|
32
45
|
imodel: iModel,
|
|
33
46
|
ruleset: exports.RULESET_IMODEL_CONTENT,
|
|
@@ -36,7 +49,8 @@ const IModelContentTree = (props) => {
|
|
|
36
49
|
customizeTreeNodeItem,
|
|
37
50
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
38
51
|
enableHierarchyAutoUpdate: true,
|
|
39
|
-
onNodeLoaded
|
|
52
|
+
onNodeLoaded,
|
|
53
|
+
eventHandlerFactory,
|
|
40
54
|
});
|
|
41
55
|
const treeRendererProps = {
|
|
42
56
|
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,
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAoC;AACpC,8DAA0E;AAC1E,4EAA0H;AAC1H,mFAAgF;AAChF,yDAA8E;AAC9E,uEAAoE;AACpE,+EAA4E;AAC5E,2CAAwG;AACxG,6EAA0E;AAK1E;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AA2BzI;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAE5F,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,yCAAmB,EAAC,EAAE,cAAc,EAAE,uDAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9G,MAAM,EAAE,YAAY,EAAE,GAAG,IAA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C,CAAC,CACzC,uBAAC,qCAAsB,OACjB,SAAS,KACT,iBAAiB,EACrB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,uBAAC,sDAA4B,OAAK,iBAAiB,GAAI,GAC5F,CACH,CAAC,CAAC,CAAC,CACF,uBAAC,2BAAY,OAAK,SAAS,KAAM,iBAAiB,GAAI,CACvD,GAEH,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAlEW,QAAA,iBAAiB,qBAkE5B;AAEF,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { SelectionMode, TreeEventHandler } from \"@itwin/components-react\";\nimport { PresentationTree, PresentationTreeNodeRenderer, usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { ReportingTreeEventHandler } from \"../common/ReportingTreeEventHandler\";\nimport { FilterableTreeRenderer, TreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent\";\n\nimport type { PresentationTreeEventHandlerProps } from \"@itwin/presentation-components\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseTreeProps, HierarchyLevelConfig } from \"../common/Types\";\n/**\n * Presentation rules used by IModelContentTree\n * @internal\n */\nexport const RULESET_IMODEL_CONTENT: Ruleset = require(\"./IModelContent.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Props for [[IModelContentTree]].\n * @public\n */\nexport interface IModelContentTreeProps extends BaseTreeProps {\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child\n * Subjects, their Models and Elements contained in those Models.\n * @public\n */\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, width, height, selectionMode, hierarchyLevelConfig, onFeatureUsed } = props;\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: IModelContentTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: IModelContentTreeComponent.id,\n onPerformanceMeasured: props.onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: PresentationTreeEventHandlerProps) => {\n const nodeLoader = handlerProps.nodeLoader;\n const eventHandler = new TreeEventHandler({ modelSource: nodeLoader.modelSource, nodeLoader });\n return new ReportingTreeEventHandler({\n nodeLoader,\n eventHandler,\n reportUsage,\n });\n },\n [reportUsage],\n );\n\n const state = usePresentationTreeState({\n imodel: iModel,\n ruleset: RULESET_IMODEL_CONTENT,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n customizeTreeNodeItem,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n eventHandlerFactory,\n });\n\n const treeRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n };\n\n if (!state) {\n return null;\n }\n\n return (\n <div className=\"tree-widget-tree-container\">\n <PresentationTree\n width={width}\n height={height}\n state={state}\n selectionMode={selectionMode ?? SelectionMode.None}\n treeRenderer={(treeProps) =>\n hierarchyLevelConfig?.isFilteringEnabled ? (\n <FilterableTreeRenderer\n {...treeProps}\n {...treeRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeRendererProps) => <PresentationTreeNodeRenderer {...nodeRendererProps} />}\n />\n ) : (\n <TreeRenderer {...treeProps} {...treeRendererProps} />\n )\n }\n />\n </div>\n );\n};\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
|
|
@@ -60,6 +60,12 @@ export interface ModelsTreeProps extends BaseFilterableTreeProps {
|
|
|
60
60
|
* @beta
|
|
61
61
|
*/
|
|
62
62
|
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Callback that is invoked when a tracked feature is used.
|
|
65
|
+
* @param featureId ID of the feature.
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
onFeatureUsed?: (feature: string) => void;
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* A tree component that shows a subject - model - category - element
|
|
@@ -17,6 +17,7 @@ const presentation_components_1 = require("@itwin/presentation-components");
|
|
|
17
17
|
const TreeWidget_1 = require("../../../TreeWidget");
|
|
18
18
|
const TreeRenderer_1 = require("../common/TreeRenderer");
|
|
19
19
|
const Types_1 = require("../common/Types");
|
|
20
|
+
const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
|
|
20
21
|
const UsePerformanceReporting_1 = require("../common/UsePerformanceReporting");
|
|
21
22
|
const UseVisibilityTreeState_1 = require("../common/UseVisibilityTreeState");
|
|
22
23
|
const Utils_1 = require("../common/Utils");
|
|
@@ -33,9 +34,11 @@ const PAGING_SIZE = 20;
|
|
|
33
34
|
* @public
|
|
34
35
|
*/
|
|
35
36
|
function ModelsTree(props) {
|
|
36
|
-
const { hierarchyLevelConfig, density, height, width, selectionMode } = props;
|
|
37
|
-
const
|
|
37
|
+
const { hierarchyLevelConfig, density, height, width, selectionMode, onFeatureUsed } = props;
|
|
38
|
+
const { reportUsage } = (0, UseFeatureReporting_1.useFeatureReporting)({ treeIdentifier: ModelsTreeComponent_1.ModelsTreeComponent.id, onFeatureUsed });
|
|
39
|
+
const state = useModelsTreeState({ ...props, reportUsage });
|
|
38
40
|
const baseRendererProps = {
|
|
41
|
+
reportUsage,
|
|
39
42
|
contextMenuItems: props.contextMenuItems,
|
|
40
43
|
nodeLabelRenderer: props.nodeLabelRenderer,
|
|
41
44
|
density: props.density,
|
|
@@ -44,6 +47,7 @@ function ModelsTree(props) {
|
|
|
44
47
|
descriptionEnabled: false,
|
|
45
48
|
levelOffset: 10,
|
|
46
49
|
disableRootNodeCollapse: true,
|
|
50
|
+
onVisibilityToggled: () => reportUsage({ featureId: "visibility-change", reportInteraction: true }),
|
|
47
51
|
},
|
|
48
52
|
};
|
|
49
53
|
// istanbul ignore next
|
|
@@ -61,7 +65,7 @@ function ModelsTree(props) {
|
|
|
61
65
|
}
|
|
62
66
|
exports.ModelsTree = ModelsTree;
|
|
63
67
|
function ModelsTreeNodeRenderer(props) {
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true, isEnlarged: props.density === "enlarged" }));
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true, isEnlarged: props.density === "enlarged", onVisibilityToggled: () => props.reportUsage?.({ featureId: "visibility-change", reportInteraction: true }) }));
|
|
65
69
|
}
|
|
66
70
|
function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
67
71
|
const rulesets = {
|
|
@@ -87,24 +91,28 @@ function useModelsTreeState({ filterInfo, onFilterApplied, ...props }) {
|
|
|
87
91
|
});
|
|
88
92
|
return filterInfo?.filter ? filteredTreeState : treeState;
|
|
89
93
|
}
|
|
90
|
-
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, onPerformanceMeasured, }) {
|
|
94
|
+
function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate, hierarchyConfig, iModel, ruleset, filterInfo, onFilterApplied, hierarchyLevelConfig, onPerformanceMeasured, reportUsage, }) {
|
|
91
95
|
const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);
|
|
92
96
|
const selectionPredicateRef = (0, react_1.useRef)(selectionPredicate);
|
|
93
97
|
(0, react_1.useEffect)(() => {
|
|
94
98
|
selectionPredicateRef.current = selectionPredicate;
|
|
95
99
|
}, [selectionPredicate]);
|
|
96
100
|
const onFilterChange = (0, react_1.useCallback)((dataProvider, matchesCount) => {
|
|
97
|
-
if (
|
|
98
|
-
|
|
101
|
+
if (dataProvider && matchesCount !== undefined) {
|
|
102
|
+
reportUsage({ featureId: "filtering", reportInteraction: false });
|
|
103
|
+
onFilterApplied?.(dataProvider, matchesCount);
|
|
99
104
|
}
|
|
100
105
|
if (visibilityHandler) {
|
|
101
106
|
visibilityHandler.setFilteredDataProvider(dataProvider);
|
|
102
107
|
}
|
|
103
|
-
}, [onFilterApplied, visibilityHandler]);
|
|
104
|
-
const
|
|
108
|
+
}, [onFilterApplied, reportUsage, visibilityHandler]);
|
|
109
|
+
const { onNodeLoaded } = (0, UsePerformanceReporting_1.usePerformanceReporting)({
|
|
105
110
|
treeIdentifier: ModelsTreeComponent_1.ModelsTreeComponent.id,
|
|
106
111
|
onPerformanceMeasured,
|
|
107
112
|
});
|
|
113
|
+
const eventHandlerFactory = (0, react_1.useCallback)((handlerProps) => {
|
|
114
|
+
return new ModelsTreeEventHandler_1.ModelsTreeEventHandler({ ...handlerProps, reportUsage });
|
|
115
|
+
}, [reportUsage]);
|
|
108
116
|
return (0, UseVisibilityTreeState_1.useVisibilityTreeState)({
|
|
109
117
|
imodel: iModel,
|
|
110
118
|
ruleset,
|
|
@@ -120,12 +128,11 @@ function useTreeState({ modelsVisibilityHandler, activeView, selectionPredicate,
|
|
|
120
128
|
: selectionPredicateRef.current(node.key, ModelsVisibilityHandler_1.ModelsVisibilityHandler.getNodeType(node)), []),
|
|
121
129
|
eventHandler: eventHandlerFactory,
|
|
122
130
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
123
|
-
onNodeLoaded: filterInfo ? undefined :
|
|
131
|
+
onNodeLoaded: filterInfo ? undefined : onNodeLoaded,
|
|
132
|
+
reportUsage: filterInfo ? undefined : reportUsage,
|
|
133
|
+
onHierarchyLimitExceeded: () => reportUsage({ featureId: "hierarchy-level-size-limit-hit", reportInteraction: false }),
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
|
-
function eventHandlerFactory(props) {
|
|
127
|
-
return new ModelsTreeEventHandler_1.ModelsTreeEventHandler(props);
|
|
128
|
-
}
|
|
129
136
|
function useVisibilityHandler(rulesetId, iModel, activeView, visibilityHandler, hierarchyAutoUpdateEnabled) {
|
|
130
137
|
const subjectModelIdsCache = (0, react_1.useMemo)(() => new ModelsVisibilityHandler_1.SubjectModelIdsCache(iModel), [iModel]);
|
|
131
138
|
const [state, setState] = (0, react_1.useState)();
|
|
@@ -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,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAiI;AACjI,sEAA6I;AAC7I,+DAA4D;AAC5D,qEAAkE;AAClE,uEAA0F;AAC1F,mCAAyF;A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UAAoB,EACpB,iBAAgH,EAChH,0BAAoC;IAEpC,MAAM,oBAAoB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,8CAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAA2B,CAAC;IAE9D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE;YAChE,OAAO;SACR;QAED,MAAM,sBAAsB,GAAiC;YAC3D,SAAS;YACT,QAAQ,EAAE,UAAU;YACpB,0BAA0B;YAC1B,oBAAoB;SACrB,CAAC;QAEF,MAAM,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,iDAAuB,CAAC,sBAAsB,CAAC,CAAC;QACpI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEjG,OAAO,iBAAiB,IAAI,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC;AAClG,CAAC;AAED,MAAM,qBAAqB,GAAG,IAAA,yCAAiC,EAAC,CAAC,0CAAkC,EAAE,+BAAuB,EAAE,kCAA0B,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { isPresentationTreeNodeItem, PresentationTree } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { ClassGroupingOption } from \"../common/Types\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { VisibilityTreeEventHandlerParams } from \"../VisibilityTreeEventHandler\";\nimport type { Ruleset, SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { hierarchyLevelConfig, density, height, width, selectionMode } = props;\n const state = useModelsTreeState(props);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n },\n };\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData title={TreeWidget.translate(\"modelTree.noModelFound\")} message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")} />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n state={state}\n selectionMode={selectionMode || SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <ModelsTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n width={width}\n height={height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction ModelsTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(\n () =>\n createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n search: useMemo(\n () =>\n createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n showEmptyModels: props.hierarchyConfig?.showEmptyModels,\n }),\n [props.hierarchyConfig?.elementClassSpecification, props.hierarchyConfig?.showEmptyModels],\n ),\n };\n\n const treeState = useTreeState({\n ...props,\n ruleset: rulesets.general,\n });\n\n const filteredTreeState = useTreeState({\n ...props,\n ruleset: rulesets.search,\n filterInfo,\n onFilterApplied,\n });\n\n return filterInfo?.filter ? filteredTreeState : treeState;\n}\n\ninterface UseTreeProps extends ModelsTreeProps {\n ruleset: Ruleset;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n onPerformanceMeasured,\n}: UseTreeProps) {\n const visibilityHandler = useVisibilityHandler(ruleset.id, iModel, activeView, modelsVisibilityHandler);\n const selectionPredicateRef = useRef(selectionPredicate);\n useEffect(() => {\n selectionPredicateRef.current = selectionPredicate;\n }, [selectionPredicate]);\n\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, visibilityHandler],\n );\n\n const reporting = usePerformanceReporting({\n treeIdentifier: ModelsTreeComponent.id,\n onPerformanceMeasured,\n });\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n onNodeLoaded: filterInfo ? undefined : reporting.onNodeLoaded,\n });\n}\n\nfunction eventHandlerFactory(props: VisibilityTreeEventHandlerParams) {\n return new ModelsTreeEventHandler(props);\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler),\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const [state, setState] = useState<ModelsVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler && typeof visibilityHandler !== \"function\") {\n return;\n }\n\n const visibilityHandlerProps: ModelsVisibilityHandlerProps = {\n rulesetId,\n viewport: activeView,\n hierarchyAutoUpdateEnabled,\n subjectModelIdsCache,\n };\n\n const handler = visibilityHandler ? visibilityHandler(visibilityHandlerProps) : new ModelsVisibilityHandler(visibilityHandlerProps);\n setState(handler);\n return () => {\n handler.dispose();\n };\n }, [rulesetId, activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache, visibilityHandler]);\n\n return visibilityHandler && typeof visibilityHandler !== \"function\" ? visibilityHandler : state;\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, addModelsTreeNodeItemIcons]);\n"]}
|
|
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,uEAAoE;AACpE,+EAA4E;AAC5E,6EAA0E;AAC1E,2CAAiI;AACjI,sEAA6I;AAC7I,+DAA4D;AAC5D,qEAAkE;AAClE,uEAA0F;AAC1F,mCAAyF;AAWzF,MAAM,WAAW,GAA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pB,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 { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, addTreeNodeItemCheckbox, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { ModelsTreeEventHandler } from \"./ModelsTreeEventHandler\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { addModelsTreeNodeItemIcons, createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { UsageTrackedFeatures } from \"../common/UseFeatureReporting\";\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 } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { ModelsTreeSelectionPredicate, ModelsVisibilityHandlerProps } from \"./ModelsVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n /** Should the tree show models without elements. */\n showEmptyModels?: boolean;\n}\n\n/**\n * Props for [[ModelsTree]] component.\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n * @deprecated in 2.0.1. It does not have any effect, auto update is always on.\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler | ((props: ModelsVisibilityHandlerProps) => ModelsVisibilityHandler);\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Reports performance of a feature.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A tree 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, onFeatureUsed } = props;\n const { reportUsage } = useFeatureReporting({ treeIdentifier: ModelsTreeComponent.id, onFeatureUsed });\n const state = useModelsTreeState({ ...props, reportUsage });\n\n const baseRendererProps = {\n reportUsage,\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 onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: 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\ninterface ModelsTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction ModelsTreeNodeRenderer(props: ModelsTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={true}\n descriptionEnabled={false}\n levelOffset={10}\n disableRootNodeCollapse={true}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\ninterface UseModelsTreeStateProps extends Omit<ModelsTreeProps, \"onFeatureUsed\"> {\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nfunction useModelsTreeState({ filterInfo, onFilterApplied, ...props }: UseModelsTreeStateProps) {\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 Omit<ModelsTreeProps, \"onFeatureUsed\"> {\n ruleset: Ruleset;\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nfunction useTreeState({\n modelsVisibilityHandler,\n activeView,\n selectionPredicate,\n hierarchyConfig,\n iModel,\n ruleset,\n filterInfo,\n onFilterApplied,\n hierarchyLevelConfig,\n onPerformanceMeasured,\n reportUsage,\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 (dataProvider && matchesCount !== undefined) {\n reportUsage({ featureId: \"filtering\", reportInteraction: false });\n onFilterApplied?.(dataProvider, matchesCount);\n }\n\n if (visibilityHandler) {\n visibilityHandler.setFilteredDataProvider(dataProvider);\n }\n },\n [onFilterApplied, reportUsage, visibilityHandler],\n );\n\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: ModelsTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const eventHandlerFactory = useCallback(\n (handlerProps: VisibilityTreeEventHandlerParams) => {\n return new ModelsTreeEventHandler({ ...handlerProps, reportUsage });\n },\n [reportUsage],\n );\n\n return useVisibilityTreeState({\n imodel: iModel,\n ruleset,\n pagingSize: PAGING_SIZE,\n appendChildrenCountForGroupingNodes: hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts,\n enableHierarchyAutoUpdate: true,\n customizeTreeNodeItem,\n visibilityHandler,\n filterInfo,\n onFilterChange,\n selectionPredicate: useCallback(\n (node: TreeNodeItem) =>\n !selectionPredicateRef.current || !isPresentationTreeNodeItem(node)\n ? true\n : selectionPredicateRef.current(node.key, ModelsVisibilityHandler.getNodeType(node)),\n [],\n ),\n eventHandler: eventHandlerFactory,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n onNodeLoaded: filterInfo ? undefined : onNodeLoaded,\n reportUsage: filterInfo ? undefined : reportUsage,\n onHierarchyLimitExceeded: () => reportUsage({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n });\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"]}
|
|
@@ -87,23 +87,32 @@ function ModelsTreeComponentImpl(props) {
|
|
|
87
87
|
}, [iModel]);
|
|
88
88
|
const filterInfo = (0, react_1.useMemo)(() => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }), [filterString, searchOptions.activeMatchIndex]);
|
|
89
89
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-tree-with-header", children: [(0, jsx_runtime_1.jsx)(TreeHeader_1.TreeHeader, { onFilterClear: searchOptions.onFilterCancel, onFilterStart: searchOptions.onFilterStart, onSelectedChanged: searchOptions.onResultSelectedChanged, resultCount: searchOptions.matchedResultCount, selectedIndex: searchOptions.activeMatchIndex, density: props.density, children: props.headerButtons
|
|
90
|
-
? props.headerButtons.map((btn, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: btn({ viewport, models: availableModels }) }, index))
|
|
90
|
+
? props.headerButtons.map((btn, index) => ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: btn({ viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }) }, index)))
|
|
91
91
|
: [
|
|
92
|
-
(0, jsx_runtime_1.jsx)(ShowAllButton, { viewport: viewport, models: availableModels, density: props.density }, "show-all-btn"),
|
|
93
|
-
(0, jsx_runtime_1.jsx)(HideAllButton, { viewport: viewport, models: availableModels, density: props.density }, "hide-all-btn"),
|
|
94
|
-
(0, jsx_runtime_1.jsx)(InvertButton, { viewport: viewport, models: availableModels, density: props.density }, "invert-all-btn"),
|
|
95
|
-
(0, jsx_runtime_1.jsx)(View2DButton, { viewport: viewport, models: availableModels, density: props.density }, "view-2d-btn"),
|
|
96
|
-
(0, jsx_runtime_1.jsx)(View3DButton, { viewport: viewport, models: availableModels, density: props.density }, "view-3d-btn"),
|
|
92
|
+
(0, jsx_runtime_1.jsx)(ShowAllButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "show-all-btn"),
|
|
93
|
+
(0, jsx_runtime_1.jsx)(HideAllButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "hide-all-btn"),
|
|
94
|
+
(0, jsx_runtime_1.jsx)(InvertButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "invert-all-btn"),
|
|
95
|
+
(0, jsx_runtime_1.jsx)(View2DButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "view-2d-btn"),
|
|
96
|
+
(0, jsx_runtime_1.jsx)(View3DButton, { viewport: viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed }, "view-3d-btn"),
|
|
97
97
|
] }), (0, jsx_runtime_1.jsx)("div", { className: contentClassName, children: (0, jsx_runtime_1.jsx)(AutoSizer_1.AutoSizer, { children: ({ width, height }) => ((0, jsx_runtime_1.jsx)(ModelsTree_1.ModelsTree, { ...props, iModel: iModel, activeView: viewport, width: width, height: height, filterInfo: filterInfo, onFilterApplied: onFilterApplied })) }) })] }));
|
|
98
98
|
}
|
|
99
99
|
function ShowAllButton(props) {
|
|
100
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: () =>
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: () => {
|
|
101
|
+
props.onFeatureUsed?.(`${exports.ModelsTreeComponent.id}-showall`);
|
|
102
|
+
void (0, ModelsVisibilityHandler_1.showAllModels)(props.models.map((model) => model.id), props.viewport);
|
|
103
|
+
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
|
|
101
104
|
}
|
|
102
105
|
function HideAllButton(props) {
|
|
103
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: () =>
|
|
106
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: () => {
|
|
107
|
+
props.onFeatureUsed?.(`${exports.ModelsTreeComponent.id}-hideall`);
|
|
108
|
+
void (0, ModelsVisibilityHandler_1.hideAllModels)(props.models.map((model) => model.id), props.viewport);
|
|
109
|
+
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
|
|
104
110
|
}
|
|
105
111
|
function InvertButton(props) {
|
|
106
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("invert"), onClick: () =>
|
|
112
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("invert"), onClick: () => {
|
|
113
|
+
props.onFeatureUsed?.(`${exports.ModelsTreeComponent.id}-invert`);
|
|
114
|
+
void (0, ModelsVisibilityHandler_1.invertAllModels)(props.models.map((model) => model.id), props.viewport);
|
|
115
|
+
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHalf, {}) }));
|
|
107
116
|
}
|
|
108
117
|
function View2DButton(props) {
|
|
109
118
|
const models2d = (0, react_1.useMemo)(() => {
|
|
@@ -114,7 +123,10 @@ function View2DButton(props) {
|
|
|
114
123
|
setIs2dToggleActive((0, ModelsVisibilityHandler_1.areAllModelsVisible)(models2d, props.viewport));
|
|
115
124
|
return props.viewport.onViewedModelsChanged.addListener((vp) => setIs2dToggleActive((0, ModelsVisibilityHandler_1.areAllModelsVisible)(models2d, vp)));
|
|
116
125
|
}, [models2d, props.viewport]);
|
|
117
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("toggle2DViews"), onClick: () =>
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("toggle2DViews"), onClick: () => {
|
|
127
|
+
props.onFeatureUsed?.(`${exports.ModelsTreeComponent.id}-view2d`);
|
|
128
|
+
void (0, ModelsVisibilityHandler_1.toggleModels)(models2d, is2dToggleActive, props.viewport);
|
|
129
|
+
}, disabled: models2d.length === 0, endIcon: is2dToggleActive ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}), children: TreeWidget_1.TreeWidget.translate("label2D") }));
|
|
118
130
|
}
|
|
119
131
|
function View3DButton(props) {
|
|
120
132
|
const models3d = (0, react_1.useMemo)(() => {
|
|
@@ -125,6 +137,9 @@ function View3DButton(props) {
|
|
|
125
137
|
setIs3dToggleActive((0, ModelsVisibilityHandler_1.areAllModelsVisible)(models3d, props.viewport));
|
|
126
138
|
return props.viewport.onViewedModelsChanged.addListener((vp) => setIs3dToggleActive((0, ModelsVisibilityHandler_1.areAllModelsVisible)(models3d, vp)));
|
|
127
139
|
}, [models3d, props.viewport]);
|
|
128
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("toggle3DViews"), onClick: () =>
|
|
140
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Button, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("toggle3DViews"), onClick: () => {
|
|
141
|
+
props.onFeatureUsed?.(`${exports.ModelsTreeComponent.id}-view3d`);
|
|
142
|
+
void (0, ModelsVisibilityHandler_1.toggleModels)(models3d, is3dToggleActive, props.viewport);
|
|
143
|
+
}, disabled: models3d.length === 0, endIcon: is3dToggleActive ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}), children: TreeWidget_1.TreeWidget.translate("label3D") }));
|
|
129
144
|
}
|
|
130
145
|
//# sourceMappingURL=ModelsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAA+D;AAC/D,oDAAkF;AAClF,oEAAqG;AACrG,wDAA0D;AAC1D,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,qDAAkD;AAClD,6CAA0C;AAC1C,uEAA6H;AAC7H,mCAAsD;AA4CtD;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA8B,EAAE,EAAE;IACpE,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,uBAAC,uBAAuB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACpF,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B;AAEF;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,aAAa,CAAC;AAElD;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,aAAa,CAAC;AAElD;;;GAGG;AACH,2BAAmB,CAAC,YAAY,GAAG,YAAY,CAAC;AAEhD;;;GAGG;AACH,2BAAm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AAmB,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpI,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,uBAAC,sBAAM,IACL,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,eAAe,CAAC,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,sCAAY,EAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAC5E,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,YAExE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to [[ModelsTreeComponent]] header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, models: availableModels })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() =>\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => void toggleModels(models2d, is2dToggleActive, props.viewport)}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => void toggleModels(models3d, is3dToggleActive, props.viewport)}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,sCAAoC;AACpC,4DAAoC;AACpC,iCAA+D;AAC/D,oDAAkF;AAClF,oEAAqG;AACrG,wDAA0D;AAC1D,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,qDAAkD;AAClD,6CAA0C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,WAAW,CAAC,CAAC,EAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAA,6CAAmB,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpI,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/B,OAAO,CACL,uBAAC,sBAAM,IACL,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,eAAe,CAAC,EAC5C,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,GAAG,2BAAmB,CAAC,EAAE,SAAS,CAAC,CAAC;YAC1D,KAAK,IAAA,sCAAY,EAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChE,CAAC,EACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,YAExE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACzB,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useMemo, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./ModelsVisibilityHandler\";\nimport { queryModelsForHeaderActions } from \"./Utils\";\n\nimport type { IModelConnection, ScreenViewport, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { ModelsTreeProps } from \"./ModelsTree\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to [[ModelsTreeComponent]] header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Props for [[ModelsTreeComponent]].\n * @public\n */\nexport interface ModelTreeComponentProps extends Omit<ModelsTreeProps, \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[ModelsTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.id = \"models-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"models\");\n\nfunction ModelsTreeComponentImpl(props: ModelTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n const { viewport, iModel } = props;\n const { searchOptions, filterString, onFilterApplied } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n queryModelsForHeaderActions(iModel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch((_e) => {\n setAvailableModels([]);\n });\n }, [iModel]);\n\n const filterInfo = useMemo(\n () => ({ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }),\n [filterString, searchOptions.activeMatchIndex],\n );\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => (\n <Fragment key={index}>{btn({ viewport, models: availableModels, density: props.density, onFeatureUsed: props.onFeatureUsed })}</Fragment>\n ))\n : [\n <ShowAllButton viewport={viewport} models={availableModels} key=\"show-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <HideAllButton viewport={viewport} models={availableModels} key=\"hide-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <InvertButton viewport={viewport} models={availableModels} key=\"invert-all-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <View2DButton viewport={viewport} models={availableModels} key=\"view-2d-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n <View3DButton viewport={viewport} models={availableModels} key=\"view-3d-btn\" density={props.density} onFeatureUsed={props.onFeatureUsed} />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <ModelsTree\n {...props}\n iModel={iModel}\n activeView={viewport}\n width={width}\n height={height}\n filterInfo={filterInfo}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nfunction ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-showall`);\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-hideall`);\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"invert\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-invert`);\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\nfunction View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle2DViews\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view2d`);\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label2D\")}\n </Button>\n );\n}\n\nfunction View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"toggle3DViews\")}\n onClick={() => {\n props.onFeatureUsed?.(`${ModelsTreeComponent.id}-view3d`);\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"label3D\")}\n </Button>\n );\n}\n"]}
|