@itwin/tree-widget-react 3.0.0-dev.3 → 3.0.0-dev.4
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/README.md +95 -6
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +10 -8
- package/lib/cjs/components/tree-header/TreeHeader.js +4 -6
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js +20 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +3 -7
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +24 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +15 -18
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +89 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +32 -78
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/cjs/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/cjs/components/trees/common/components/Tree.js +5 -4
- package/lib/cjs/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/index.d.ts +4 -0
- package/lib/cjs/components/trees/index.js +9 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +4 -4
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +4 -203
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +13 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +0 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +27 -20
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +29 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +233 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react.d.ts +1 -0
- package/lib/cjs/tree-widget-react.js +3 -1
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +10 -8
- package/lib/esm/components/tree-header/TreeHeader.js +4 -6
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +3 -7
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +22 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +16 -16
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +85 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +33 -79
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/esm/components/trees/common/components/Tree.js +5 -4
- package/lib/esm/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/index.d.ts +4 -0
- package/lib/esm/components/trees/index.js +4 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +4 -4
- package/lib/esm/components/trees/models-tree/ModelsTree.js +5 -204
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +12 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +0 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +29 -19
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +29 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +229 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +2 -2
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react.d.ts +1 -0
- package/lib/esm/tree-widget-react.js +1 -0
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/package.json +11 -15
- package/lib/cjs/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/cjs/components/trees/categories-tree/UseCategories.js +0 -22
- package/lib/cjs/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/cjs/components/utils/AutoSizer.d.ts +0 -13
- package/lib/cjs/components/utils/AutoSizer.js +0 -21
- package/lib/cjs/components/utils/AutoSizer.js.map +0 -1
- package/lib/esm/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/esm/components/trees/categories-tree/UseCategories.js +0 -18
- package/lib/esm/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/esm/components/utils/AutoSizer.d.ts +0 -13
- package/lib/esm/components/utils/AutoSizer.js +0 -17
- package/lib/esm/components/utils/AutoSizer.js.map +0 -1
- /package/lib/cjs/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
- /package/lib/esm/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
|
@@ -6,212 +6,13 @@ 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");
|
|
10
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
11
|
-
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
12
|
-
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
13
|
-
const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
|
|
14
|
-
const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
|
|
15
|
-
const TreeWidget_1 = require("../../../TreeWidget");
|
|
16
9
|
const VisibilityTree_1 = require("../common/components/VisibilityTree");
|
|
17
10
|
const VisibilityTreeRenderer_1 = require("../common/components/VisibilityTreeRenderer");
|
|
18
|
-
const
|
|
19
|
-
const UseIModelChangeListener_1 = require("../common/UseIModelChangeListener");
|
|
20
|
-
const UseTelemetryContext_1 = require("../common/UseTelemetryContext");
|
|
21
|
-
const ModelsTreeIdsCache_1 = require("./internal/ModelsTreeIdsCache");
|
|
22
|
-
const ModelsTreeVisibilityHandler_1 = require("./internal/ModelsTreeVisibilityHandler");
|
|
23
|
-
const ModelsTreeComponent_1 = require("./ModelsTreeComponent");
|
|
24
|
-
const ModelsTreeDefinition_1 = require("./ModelsTreeDefinition");
|
|
11
|
+
const UseModelsTree_1 = require("./UseModelsTree");
|
|
25
12
|
/** @beta */
|
|
26
|
-
function ModelsTree({ imodel, getSchemaContext, selectionStorage,
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
...ModelsTreeDefinition_1.defaultHierarchyConfiguration,
|
|
30
|
-
...hierarchyConfig,
|
|
31
|
-
}),
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
Object.values(hierarchyConfig ?? {}));
|
|
34
|
-
const { onFeatureUsed } = (0, UseTelemetryContext_1.useTelemetryContext)();
|
|
35
|
-
const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration, visibilityHandlerOverrides);
|
|
36
|
-
const { loadInstanceKeys: loadFocusedInstancesKeys } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
|
|
37
|
-
const getHierarchyDefinition = (0, react_1.useCallback)(({ imodelAccess }) => new ModelsTreeDefinition_1.ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }), [getModelsTreeIdsCache, hierarchyConfiguration]);
|
|
38
|
-
const onNodeDoubleClick = (0, react_1.useCallback)(async ({ nodeData, extendedData }) => {
|
|
39
|
-
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);
|
|
43
|
-
await core_frontend_1.IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);
|
|
44
|
-
onFeatureUsed({ featureId: "zoom-to-node", reportInteraction: false });
|
|
45
|
-
}, [onFeatureUsed]);
|
|
46
|
-
const getFocusedFilteredPaths = (0, react_1.useMemo)(() => {
|
|
47
|
-
setFilteringError(undefined);
|
|
48
|
-
if (!loadFocusedInstancesKeys) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
return async ({ imodelAccess }) => {
|
|
52
|
-
try {
|
|
53
|
-
const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);
|
|
54
|
-
return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
|
|
55
|
-
imodelAccess,
|
|
56
|
-
idsCache: getModelsTreeIdsCache(),
|
|
57
|
-
keys: targetKeys,
|
|
58
|
-
hierarchyConfig: hierarchyConfiguration,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyInstancesFocused" : "unknownInstanceFocusError";
|
|
63
|
-
setFilteringError(newError);
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, [loadFocusedInstancesKeys, getModelsTreeIdsCache, hierarchyConfiguration]);
|
|
68
|
-
const getSearchFilteredPaths = (0, react_1.useMemo)(() => {
|
|
69
|
-
setFilteringError(undefined);
|
|
70
|
-
if (!filter) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
return async ({ imodelAccess }) => {
|
|
74
|
-
onFeatureUsed({ featureId: "filtering", reportInteraction: true });
|
|
75
|
-
try {
|
|
76
|
-
return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
|
|
77
|
-
imodelAccess,
|
|
78
|
-
label: filter,
|
|
79
|
-
idsCache: getModelsTreeIdsCache(),
|
|
80
|
-
hierarchyConfig: hierarchyConfiguration,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyFilterMatches" : "unknownFilterError";
|
|
85
|
-
setFilteringError(newError);
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}, [filter, getModelsTreeIdsCache, onFeatureUsed, hierarchyConfiguration]);
|
|
90
|
-
const getFilteredPaths = getFocusedFilteredPaths ?? getSearchFilteredPaths;
|
|
91
|
-
return ((0, jsx_runtime_1.jsx)(VisibilityTree_1.VisibilityTree, { height: height, width: width, imodel: imodel, treeName: ModelsTreeComponent_1.ModelsTreeComponent.id, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, visibilityHandlerFactory: visibilityHandlerFactory, getHierarchyDefinition: getHierarchyDefinition, getFilteredPaths: getFilteredPaths, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, noDataMessage: getNoDataMessage(filter, filteringError), selectionMode: selectionMode, highlight: filter === undefined ? undefined : { text: filter }, treeRenderer: (treeProps) => (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeRenderer, { ...treeProps, getIcon: getIcon, onNodeDoubleClick: onNodeDoubleClick }) }));
|
|
13
|
+
function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, }) {
|
|
14
|
+
const { modelsTreeProps, rendererProps } = (0, UseModelsTree_1.useModelsTree)({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides });
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(VisibilityTree_1.VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
|
|
92
16
|
}
|
|
93
17
|
exports.ModelsTree = ModelsTree;
|
|
94
|
-
function getNoDataMessage(filter, error) {
|
|
95
|
-
if (isInstanceFocusError(error)) {
|
|
96
|
-
return (0, jsx_runtime_1.jsx)(InstanceFocusError, { error: error });
|
|
97
|
-
}
|
|
98
|
-
if (isFilterError(error)) {
|
|
99
|
-
return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate(`modelsTree.filtering.${error}`) });
|
|
100
|
-
}
|
|
101
|
-
if (filter) {
|
|
102
|
-
return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate("modelsTree.filtering.noMatches", { filter }) });
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
function isFilterError(error) {
|
|
107
|
-
return error === "tooManyFilterMatches" || error === "unknownFilterError";
|
|
108
|
-
}
|
|
109
|
-
function isInstanceFocusError(error) {
|
|
110
|
-
return error === "tooManyInstancesFocused" || error === "unknownInstanceFocusError";
|
|
111
|
-
}
|
|
112
|
-
function InstanceFocusError({ error }) {
|
|
113
|
-
const { toggle } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
|
|
114
|
-
const localizedMessage = createLocalizedMessage(TreeWidget_1.TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());
|
|
115
|
-
return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: localizedMessage });
|
|
116
|
-
}
|
|
117
|
-
function getIcon(node) {
|
|
118
|
-
if (node.extendedData?.imageId === undefined) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
switch (node.extendedData.imageId) {
|
|
122
|
-
case "icon-layers":
|
|
123
|
-
return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgLayers, {});
|
|
124
|
-
case "icon-item":
|
|
125
|
-
return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgItem, {});
|
|
126
|
-
case "icon-ec-class":
|
|
127
|
-
return (0, jsx_runtime_1.jsx)(SvgClassGrouping, {});
|
|
128
|
-
case "icon-imodel-hollow-2":
|
|
129
|
-
return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgImodelHollow, {});
|
|
130
|
-
case "icon-folder":
|
|
131
|
-
return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgFolder, {});
|
|
132
|
-
case "icon-model":
|
|
133
|
-
return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgModel, {});
|
|
134
|
-
}
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
function createVisibilityHandlerFactory(activeView, idsCacheGetter, overrides) {
|
|
138
|
-
return ({ imodelAccess }) => (0, ModelsTreeVisibilityHandler_1.createModelsTreeVisibilityHandler)({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides });
|
|
139
|
-
}
|
|
140
|
-
function useCachedVisibility(activeView, hierarchyConfig, overrides) {
|
|
141
|
-
const cacheRef = (0, react_1.useRef)();
|
|
142
|
-
const currentIModelRef = (0, react_1.useRef)(activeView.iModel);
|
|
143
|
-
const getModelsTreeIdsCache = (0, react_1.useCallback)(() => {
|
|
144
|
-
if (!cacheRef.current) {
|
|
145
|
-
cacheRef.current = new ModelsTreeIdsCache_1.ModelsTreeIdsCache((0, presentation_core_interop_1.createECSqlQueryExecutor)(currentIModelRef.current), hierarchyConfig);
|
|
146
|
-
}
|
|
147
|
-
return cacheRef.current;
|
|
148
|
-
}, [hierarchyConfig]);
|
|
149
|
-
const [visibilityHandlerFactory, setVisibilityHandlerFactory] = (0, react_1.useState)(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));
|
|
150
|
-
(0, UseIModelChangeListener_1.useIModelChangeListener)({
|
|
151
|
-
imodel: activeView.iModel,
|
|
152
|
-
action: (0, react_1.useCallback)(() => {
|
|
153
|
-
cacheRef.current = undefined;
|
|
154
|
-
setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));
|
|
155
|
-
}, [activeView, getModelsTreeIdsCache, overrides]),
|
|
156
|
-
});
|
|
157
|
-
(0, react_1.useEffect)(() => {
|
|
158
|
-
currentIModelRef.current = activeView.iModel;
|
|
159
|
-
cacheRef.current = undefined;
|
|
160
|
-
setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));
|
|
161
|
-
}, [activeView, getModelsTreeIdsCache, overrides]);
|
|
162
|
-
return {
|
|
163
|
-
getModelsTreeIdsCache,
|
|
164
|
-
visibilityHandlerFactory,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function SvgClassGrouping() {
|
|
168
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Icon, { children: (0, jsx_runtime_1.jsx)("svg", { id: "Calque_1", "data-name": "Calque 1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", children: (0, jsx_runtime_1.jsx)("path", { d: "M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z" }) }) }));
|
|
169
|
-
}
|
|
170
|
-
async function collectTargetKeys(loadFocusedInstancesKeys) {
|
|
171
|
-
const targetKeys = [];
|
|
172
|
-
const groupingNodeInfos = [];
|
|
173
|
-
for await (const key of loadFocusedInstancesKeys()) {
|
|
174
|
-
if ("id" in key) {
|
|
175
|
-
targetKeys.push(key);
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (!presentation_hierarchies_1.HierarchyNodeKey.isClassGrouping(key.key)) {
|
|
179
|
-
targetKeys.push(...key.groupedInstanceKeys);
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
if (!key.nonGroupingAncestor || !presentation_hierarchies_1.HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
const parentKey = key.nonGroupingAncestor.key;
|
|
186
|
-
const type = key.nonGroupingAncestor.extendedData?.isCategory ? "category" : "element";
|
|
187
|
-
const modelIds = (key.nonGroupingAncestor.extendedData?.modelIds ?? []).flatMap((ids) => ids);
|
|
188
|
-
const groupInfo = groupingNodeInfos.find((group) => presentation_hierarchies_1.HierarchyNodeKey.equals(group.parentKey, parentKey));
|
|
189
|
-
if (groupInfo) {
|
|
190
|
-
groupInfo.classes.push(key.key.className);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
targetKeys.push(...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({
|
|
197
|
-
parent: parentType === "element"
|
|
198
|
-
? { type: "element", ids: parentKey.instanceKeys.map((key) => key.id) }
|
|
199
|
-
: { type: "category", ids: parentKey.instanceKeys.map((key) => key.id), modelIds },
|
|
200
|
-
classes,
|
|
201
|
-
})));
|
|
202
|
-
return targetKeys;
|
|
203
|
-
}
|
|
204
|
-
function createLocalizedMessage(message, onClick) {
|
|
205
|
-
const exp = new RegExp("<link>(.*)</link>");
|
|
206
|
-
const match = message.match(exp);
|
|
207
|
-
if (!match) {
|
|
208
|
-
return message;
|
|
209
|
-
}
|
|
210
|
-
const [fullText, innerText] = match;
|
|
211
|
-
const [textBefore, textAfter] = message.split(fullText);
|
|
212
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [textBefore ? textBefore : null, (0, jsx_runtime_1.jsx)(itwinui_react_1.Anchor, { underline: true, onClick: (e) => {
|
|
213
|
-
e.stopPropagation();
|
|
214
|
-
onClick?.();
|
|
215
|
-
}, children: innerText }), textAfter ? textAfter : null] }));
|
|
216
|
-
}
|
|
217
18
|
//# sourceMappingURL=ModelsTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAA0D;AAC1D,gFAA4E;AAC5E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C,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,OAAO,CACL,6DACG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAC/B,uBAAC,sBAAM,IACL,SAAS,QACT,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,OAAO,EAAE,EAAE,CAAC;gBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,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 { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Icon, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition\";\n\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ComponentPropsWithoutRef, ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\n/** @beta */\ninterface ModelsTreeOwnProps {\n activeView: Viewport;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n filter?: string;\n}\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ntype ModelsTreeProps = ModelsTreeOwnProps &\n Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"height\" | \"width\" | \"density\" | \"selectionMode\">;\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n height,\n width,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n visibilityHandlerOverrides,\n}: ModelsTreeProps) {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration, visibilityHandlerOverrides);\n const { loadInstanceKeys: loadFocusedInstancesKeys } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getFocusedFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (!loadFocusedInstancesKeys) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n try {\n const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n keys: targetKeys,\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n setFilteringError(newError);\n return [];\n }\n };\n }, [loadFocusedInstancesKeys, getModelsTreeIdsCache, hierarchyConfiguration]);\n\n const getSearchFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, getModelsTreeIdsCache, onFeatureUsed, hierarchyConfiguration]);\n\n const getFilteredPaths = getFocusedFilteredPaths ?? getSearchFilteredPaths;\n\n return (\n <VisibilityTree\n height={height}\n width={width}\n imodel={imodel}\n treeName={ModelsTreeComponent.id}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n visibilityHandlerFactory={visibilityHandlerFactory}\n getHierarchyDefinition={getHierarchyDefinition}\n getFilteredPaths={getFilteredPaths}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n noDataMessage={getNoDataMessage(filter, filteringError)}\n selectionMode={selectionMode}\n highlight={filter === undefined ? undefined : { text: filter }}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} getIcon={getIcon} onNodeDoubleClick={onNodeDoubleClick} />}\n />\n );\n}\n\nfunction getNoDataMessage(filter?: string, error?: ModelsTreeFilteringError) {\n if (isInstanceFocusError(error)) {\n return <InstanceFocusError error={error!} />;\n }\n if (isFilterError(error)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <Icon>\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n </Icon>\n );\n}\n\nasync function collectTargetKeys(loadFocusedInstancesKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const targetKeys: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{ parentKey: InstancesNodeKey; parentType: \"element\" | \"category\"; classes: string[]; modelIds: Id64String[] }> = [];\n for await (const key of loadFocusedInstancesKeys()) {\n if (\"id\" in key) {\n targetKeys.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n targetKeys.push(...key.groupedInstanceKeys);\n continue;\n }\n\n if (!key.nonGroupingAncestor || !HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = key.nonGroupingAncestor.key;\n const type = key.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((key.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n const groupInfo = groupingNodeInfos.find((group) => HierarchyNodeKey.equals(group.parentKey, parentKey));\n if (groupInfo) {\n groupInfo.classes.push(key.key.className);\n } else {\n groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });\n }\n }\n targetKeys.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n classes,\n })),\n );\n return targetKeys;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,wEAAqE;AACrE,wFAAqF;AACrF,mDAAgD;AAwBhD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,0BAA0B,GACV;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,6BAAa,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,0BAA0B,EAAE,CAAC,CAAC;IAE9H,OAAO,CACL,uBAAC,+BAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,+CAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC;AA1BD,gCA0BC","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 { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\nimport { useModelsTree } from \"./UseModelsTree\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition\";\n\n/** @beta */\ninterface ModelsTreeOwnProps {\n activeView: Viewport;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n filter?: string;\n}\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ntype ModelsTreeProps = ModelsTreeOwnProps & Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\">;\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n visibilityHandlerOverrides,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TreeHeaderButtonProps } from "../../tree-header/TreeHeader";
|
|
3
|
-
import type { IModelConnection } from "@itwin/core-frontend";
|
|
3
|
+
import type { IModelConnection, Viewport } from "@itwin/core-frontend";
|
|
4
4
|
/**
|
|
5
5
|
* Information about a single Model.
|
|
6
6
|
* @public
|
|
@@ -18,8 +18,14 @@ export interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {
|
|
|
18
18
|
/** A list of models available in the iModel. */
|
|
19
19
|
models: ModelInfo[];
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Custom hook that creates props required to render `ModelsTreeComponent` header button.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function useModelsTreeButtonProps({ imodel, viewport, }: {
|
|
26
|
+
imodel: IModelConnection;
|
|
27
|
+
viewport: Viewport;
|
|
28
|
+
}): Pick<ModelsTreeHeaderButtonProps, "models" | "viewport">;
|
|
23
29
|
/** @public */
|
|
24
30
|
export declare function ShowAllButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
|
|
25
31
|
/** @public */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToggleInstancesFocusButton = exports.View3DButton = exports.View2DButton = exports.InvertButton = exports.HideAllButton = exports.ShowAllButton = exports.
|
|
3
|
+
exports.ToggleInstancesFocusButton = exports.View3DButton = exports.View2DButton = exports.InvertButton = exports.HideAllButton = exports.ShowAllButton = exports.useModelsTreeButtonProps = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
/*---------------------------------------------------------------------------------------------
|
|
6
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -12,7 +12,18 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
12
12
|
const TreeWidget_1 = require("../../../TreeWidget");
|
|
13
13
|
const FocusedInstancesContext_1 = require("../common/FocusedInstancesContext");
|
|
14
14
|
const ModelsTreeVisibilityHandler_1 = require("./internal/ModelsTreeVisibilityHandler");
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Custom hook that creates props required to render `ModelsTreeComponent` header button.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
function useModelsTreeButtonProps({ imodel, viewport, }) {
|
|
20
|
+
const models = useAvailableModels(imodel);
|
|
21
|
+
return {
|
|
22
|
+
models,
|
|
23
|
+
viewport,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.useModelsTreeButtonProps = useModelsTreeButtonProps;
|
|
16
27
|
function useAvailableModels(imodel) {
|
|
17
28
|
const [availableModels, setAvailableModels] = (0, react_1.useState)([]);
|
|
18
29
|
(0, react_1.useEffect)(() => {
|
|
@@ -26,7 +37,6 @@ function useAvailableModels(imodel) {
|
|
|
26
37
|
}, [imodel]);
|
|
27
38
|
return availableModels;
|
|
28
39
|
}
|
|
29
|
-
exports.useAvailableModels = useAvailableModels;
|
|
30
40
|
async function queryModelsForHeaderActions(iModel) {
|
|
31
41
|
const queryParams = {
|
|
32
42
|
from: "BisCore.GeometricModel3d",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqH;AACrH,wDAA0D;AAC1D,oDAAiD;AACjD,+EAA+E;AAC/E,wFAA0I;AAwB1I,gBAAgB;AAChB,SAAgB,kBAAkB,CAAC,MAAwB;IACzD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAc,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,2BAA2B,CAAC,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,UAAuB,EAAE,EAAE;YAChC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,eAAe,CAAC;AACzB,CAAC;AAdD,gDAcC;AAED,KAAK,UAAU,2BAA2B,CAAC,MAAwB;IACjE,MAAM,WAAW,GAAqB;QACpC,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE;;;;;;;OAOJ;QACH,WAAW,EAAE,KAAK;KACnB,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,E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AAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,oDAA0B,GAAE,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO;QACnB,CAAC,CAAC,uBAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QAC5E,CAAC,CAAC,uBAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC9E,OAAO,CACL,uBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,EACtB,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAChD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,EACD,QAAQ,EAAE,OAAO,YAEjB,uBAAC,oCAAc,KAAG,GACP,CACd,CAAC;AACJ,CAAC;AAnBD,gEAmBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { SvgCursorClick, SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler\";\n\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\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/** @internal */\nexport function useAvailableModels(imodel: IModelConnection) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ density, onFeatureUsed }: { density?: \"default\" | \"enlarged\"; onFeatureUsed?: (feature: string) => void }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const title = enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n styleType=\"borderless\"\n size={density === \"enlarged\" ? \"large\" : \"small\"}\n title={title}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n isActive={enabled}\n >\n <SvgCursorClick />\n </IconButton>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqH;AACrH,wDAA0D;AAC1D,oDAAiD;AACjD,+EAA+E;AAC/E,wFAA0I;AAwB1I;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,QAAQ,GAIT;IACC,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO;QACL,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAZD,4DAYC;A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QACX,CAAC,EACD,QAAQ,EAAE,OAAO,YAEjB,uBAAC,oCAAc,KAAG,GACP,CACd,CAAC;AACJ,CAAC;AAnBD,gEAmBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { SvgCursorClick, SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler\";\n\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n * @public\n */\nexport function useModelsTreeButtonProps({\n imodel,\n viewport,\n}: {\n imodel: IModelConnection;\n viewport: Viewport;\n}): Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\"> {\n const models = useAvailableModels(imodel);\n return {\n models,\n viewport,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ density, onFeatureUsed }: { density?: \"default\" | \"enlarged\"; onFeatureUsed?: (feature: string) => void }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const title = enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n styleType=\"borderless\"\n size={density === \"enlarged\" ? \"large\" : \"small\"}\n title={title}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n isActive={enabled}\n >\n <SvgCursorClick />\n </IconButton>\n );\n}\n"]}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ModelsTreeComponent = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
7
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
6
|
/*---------------------------------------------------------------------------------------------
|
|
9
7
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
10
8
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
11
9
|
*--------------------------------------------------------------------------------------------*/
|
|
12
|
-
require("
|
|
13
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
-
const react_1 = require("react");
|
|
10
|
+
const react_2 = require("react");
|
|
15
11
|
const appui_react_1 = require("@itwin/appui-react");
|
|
16
12
|
const TreeWidget_1 = require("../../../TreeWidget");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
13
|
+
const TreeWithHeader_1 = require("../../tree-header/TreeWithHeader");
|
|
14
|
+
const FocusedInstancesContext_1 = require("../common/FocusedInstancesContext");
|
|
19
15
|
const FocusedInstancesContextProvider_1 = require("../common/FocusedInstancesContextProvider");
|
|
20
16
|
const UseFiltering_1 = require("../common/UseFiltering");
|
|
21
17
|
const UseTelemetryContext_1 = require("../common/UseTelemetryContext");
|
|
@@ -33,7 +29,7 @@ const ModelsTreeComponent = (props) => {
|
|
|
33
29
|
if (!iModel || !viewport) {
|
|
34
30
|
return null;
|
|
35
31
|
}
|
|
36
|
-
return (0, jsx_runtime_1.jsx)(ModelsTreeComponentImpl, { ...props, iModel: iModel, viewport: viewport });
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(FocusedInstancesContextProvider_1.FocusedInstancesContextProvider, { selectionStorage: props.selectionStorage, imodelKey: iModel.key, children: (0, jsx_runtime_1.jsx)(ModelsTreeComponentImpl, { ...props, iModel: iModel, viewport: viewport }) }));
|
|
37
33
|
};
|
|
38
34
|
exports.ModelsTreeComponent = ModelsTreeComponent;
|
|
39
35
|
/**
|
|
@@ -77,18 +73,29 @@ exports.ModelsTreeComponent.id = "models-tree-v2";
|
|
|
77
73
|
*/
|
|
78
74
|
exports.ModelsTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("modelsTree.label");
|
|
79
75
|
function ModelsTreeComponentImpl({ iModel, viewport, headerButtons, onFeatureUsed, onPerformanceMeasured, ...treeProps }) {
|
|
80
|
-
const
|
|
76
|
+
const buttonProps = (0, ModelsTreeButtons_1.useModelsTreeButtonProps)({ imodel: iModel, viewport });
|
|
81
77
|
const { filter, applyFilter, clearFilter } = (0, UseFiltering_1.useFiltering)();
|
|
78
|
+
const { enabled: instanceFocusEnabled } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
|
|
82
79
|
const density = treeProps.density;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
const buttons = headerButtons
|
|
81
|
+
? headerButtons.map((btn, index) => (0, jsx_runtime_1.jsx)(react_2.Fragment, { children: btn({ ...buttonProps, onFeatureUsed }) }, index))
|
|
82
|
+
: [
|
|
83
|
+
(0, react_1.createElement)(ModelsTreeButtons_1.ShowAllButton, { ...buttonProps, key: "show-all-btn", density: density, onFeatureUsed: onFeatureUsed }),
|
|
84
|
+
(0, react_1.createElement)(ModelsTreeButtons_1.HideAllButton, { ...buttonProps, key: "hide-all-btn", density: density, onFeatureUsed: onFeatureUsed }),
|
|
85
|
+
(0, react_1.createElement)(ModelsTreeButtons_1.InvertButton, { ...buttonProps, key: "invert-all-btn", density: density, onFeatureUsed: onFeatureUsed }),
|
|
86
|
+
(0, react_1.createElement)(ModelsTreeButtons_1.View2DButton, { ...buttonProps, key: "view-2d-btn", density: density, onFeatureUsed: onFeatureUsed }),
|
|
87
|
+
(0, react_1.createElement)(ModelsTreeButtons_1.View3DButton, { ...buttonProps, key: "view-3d-btn", density: density, onFeatureUsed: onFeatureUsed }),
|
|
88
|
+
(0, jsx_runtime_1.jsx)(ModelsTreeButtons_1.ToggleInstancesFocusButton, { density: density, onFeatureUsed: onFeatureUsed }, "toggle-instances-focus-btn"),
|
|
89
|
+
];
|
|
90
|
+
(0, react_2.useEffect)(() => {
|
|
91
|
+
if (instanceFocusEnabled) {
|
|
92
|
+
clearFilter();
|
|
93
|
+
}
|
|
94
|
+
}, [instanceFocusEnabled, clearFilter]);
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(UseTelemetryContext_1.TelemetryContextProvider, { componentIdentifier: exports.ModelsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: (0, jsx_runtime_1.jsx)(TreeWithHeader_1.TreeWithHeader, { filteringProps: {
|
|
96
|
+
onFilterStart: applyFilter,
|
|
97
|
+
onFilterClear: clearFilter,
|
|
98
|
+
isDisabled: instanceFocusEnabled,
|
|
99
|
+
}, buttons: buttons, density: density, children: (0, jsx_runtime_1.jsx)(ModelsTree_1.ModelsTree, { ...treeProps, imodel: iModel, activeView: viewport, filter: filter }) }) }));
|
|
93
100
|
}
|
|
94
101
|
//# sourceMappingURL=ModelsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,oDAAkF;AAClF,oDAAiD;AACjD,qEAAkE;AAClE,+EAA+E;AAC/E,+FAA4F;AAC5F,yDAAsD;AACtD,uEAAyE;AACzE,6CAA0C;AAC1C,2DAE6B;AA8B7B;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,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,CACL,uBAAC,iEAA+B,IAAC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,YAC9F,uBAAC,uBAAuB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,GAC1C,CACnC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,mBAAmB,uBAa9B;AAEF;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,iCAAa,CAAC;AAElD;;;GAGG;AACH,2BAAmB,CAAC,aAAa,GAAG,iCAAa,CAAC;AAElD;;;GAGG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AC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACrG,2BAAC,gCAAY,OAAK,WAAW,EAAE,GAAG,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACtG,2BAAC,gCAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,2BAAC,gCAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,uBAAC,8CAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE;YACxB,WAAW,EAAE,CAAC;SACf;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,uBAAC,8CAAwB,IAAC,mBAAmB,EAAE,2BAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,uBAAC,+BAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB;aACjC,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,uBAAC,uBAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAI,GACpE,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { FocusedInstancesContextProvider } from \"../common/FocusedInstancesContextProvider\";\nimport { useFiltering } from \"../common/UseFiltering\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport {\n HideAllButton, InvertButton, ShowAllButton, ToggleInstancesFocusButton, useModelsTreeButtonProps, View2DButton, View3DButton,\n} from \"./ModelsTreeButtons\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps } from \"./ModelsTreeButtons\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ComponentPropsWithoutRef<typeof ModelsTree>,\n \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\" | \"hierarchyConfig\" | \"visibilityHandlerOverrides\"\n > {\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 * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\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 * Renders a \"Enable/Disable instances focus\" button that enables/disables instances focusing mode.\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const buttonProps = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import type { Viewport } from "@itwin/core-frontend";
|
|
3
|
+
import type { ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
|
|
4
|
+
import type { ModelsTreeVisibilityHandlerOverrides } from "./internal/ModelsTreeVisibilityHandler";
|
|
5
|
+
import type { VisibilityTree } from "../common/components/VisibilityTree";
|
|
6
|
+
import type { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
|
|
7
|
+
/** @beta */
|
|
8
|
+
type VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;
|
|
9
|
+
/** @beta */
|
|
10
|
+
type VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;
|
|
11
|
+
/** @beta */
|
|
12
|
+
interface UseModelsTreeProps {
|
|
13
|
+
filter?: string;
|
|
14
|
+
activeView: Viewport;
|
|
15
|
+
hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
|
|
16
|
+
visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;
|
|
17
|
+
}
|
|
18
|
+
/** @beta */
|
|
19
|
+
interface UseModelsTreeResult {
|
|
20
|
+
modelsTreeProps: Pick<VisibilityTreeProps, "treeName" | "getHierarchyDefinition" | "getFilteredPaths" | "visibilityHandlerFactory" | "highlight" | "noDataMessage">;
|
|
21
|
+
rendererProps: Pick<Required<VisibilityTreeRendererProps>, "getIcon" | "onNodeDoubleClick">;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Custom hook to create and manage state for the models tree.
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides }: UseModelsTreeProps): UseModelsTreeResult;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=UseModelsTree.d.ts.map
|