@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
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
# Change Log - @itwin/tree-widget-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 21 May 2024 13:26:08 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.3.0
|
|
8
|
+
|
|
9
|
+
Tue, 21 May 2024 13:26:08 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Added support for custom start icons in `TreeSelector`. ([#830](https://github.com/iTwin/viewer-components-react/pull/830))
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Fixed `ModelsTree` not changing visibility for child elements. ([#828](https://github.com/iTwin/viewer-components-react/pull/828))
|
|
18
|
+
|
|
19
|
+
## 2.2.0
|
|
20
|
+
|
|
21
|
+
Mon, 29 Apr 2024 14:59:26 GMT
|
|
22
|
+
|
|
23
|
+
### Minor changes
|
|
24
|
+
|
|
25
|
+
- Added ability to track usage of `TreeWidget` features. ([#820](https://github.com/iTwin/viewer-components-react/pull/820))
|
|
26
|
+
|
|
7
27
|
## 2.1.0
|
|
8
28
|
|
|
9
|
-
Wed, 17 Apr 2024
|
|
29
|
+
Wed, 17 Apr 2024 15:50:19 GMT
|
|
10
30
|
|
|
11
31
|
### Minor changes
|
|
12
32
|
|
|
13
|
-
- Added ability to track performance of `TreeWidget` component features. Requires `@itwin/presentation-components` version `5.1` or higher ([#813](https://github.com
|
|
33
|
+
- Added ability to track performance of `TreeWidget` component features. Requires `@itwin/presentation-components` version `5.1` or higher ([#813](https://github.com:iTwin/viewer-components-react.git/pull/813))
|
|
14
34
|
|
|
15
35
|
### Patches
|
|
16
36
|
|
|
17
|
-
- ModelsTree: Improved performance when changing visibility of multiple element nodes at the same time. ([#810](https://github.com
|
|
37
|
+
- ModelsTree: Improved performance when changing visibility of multiple element nodes at the same time. ([#810](https://github.com:iTwin/viewer-components-react.git/pull/810))
|
|
18
38
|
|
|
19
39
|
## 2.0.2
|
|
20
40
|
|
package/README.md
CHANGED
|
@@ -223,3 +223,88 @@ return (
|
|
|
223
223
|
/>
|
|
224
224
|
);
|
|
225
225
|
```
|
|
226
|
+
|
|
227
|
+
## Usage tracking
|
|
228
|
+
|
|
229
|
+
Components from this package allows consumers to track the usage of specific features.
|
|
230
|
+
|
|
231
|
+
This can be achieved by passing `onFeatureUsed` function to `CategoriesTreeComponent`, `ModelsTreeComponent`, `IModelContentTreeComponent` or `TreeWidgetUiItemsProvider`. The function is invoked with feature id as the component is being used. List of tracked features:
|
|
232
|
+
|
|
233
|
+
- `"choose-{tree}"` - when a tree is selected in the tree selector.
|
|
234
|
+
- `"use-{tree}"` - when an interaction with a tree hierarchy happens.
|
|
235
|
+
- `"{tree}-visibility-change"` - when visibility is toggled using an "eye" button.
|
|
236
|
+
- `"models-tree-showall"` - when "Show All" button is used in `ModelsTreeComponent`.
|
|
237
|
+
- `"models-tree-hideall"` - when "Hide All" button is used in `ModelsTreeComponent`.
|
|
238
|
+
- `"models-tree-invert"` - when "Invert" button is used in `ModelsTreeComponent`.
|
|
239
|
+
- `"models-tree-view2d"` - when "Toggle 2D Views" button is used in `ModelsTreeComponent`.
|
|
240
|
+
- `"models-tree-view3d"` - when "Toggle 3D Views" button is used in `ModelsTreeComponent`.
|
|
241
|
+
- `"models-tree-zoom-to-node"` - when node is zoomed to in `ModelsTree`.
|
|
242
|
+
- `"models-tree-filtering"` - when a filter is applied in `ModelsTree`.
|
|
243
|
+
- `"models-tree-hierarchy-level-filtering"` - when a hierarchy level filter is applied in `ModelsTree`.
|
|
244
|
+
- `"models-tree-hierarchy-level-size-limit-hit"` - when hierarchy limit is exceeded while loading nodes in `ModelsTree`.
|
|
245
|
+
- `"categories-tree-showall"` - when "Show All" button is used in `CategoriesTreeComponent`.
|
|
246
|
+
- `"categories-tree-hideall"` - when "Hide All" button is used in `CategoriesTreeComponent`.
|
|
247
|
+
- `"categories-tree-invert"` - when "Invert" button is used in `CategoriesTreeComponent`.
|
|
248
|
+
|
|
249
|
+
Where `{tree}` specifies which tree component the feature is of.
|
|
250
|
+
|
|
251
|
+
Example:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import { UiItemsManager } from "@itwin/appui-react";
|
|
255
|
+
import { TreeWidgetUiItemsProvider, ModelsTreeComponent } from "@itwin/tree-widget-react";
|
|
256
|
+
...
|
|
257
|
+
UiItemsManager.register(
|
|
258
|
+
new TreeWidgetUiItemsProvider({
|
|
259
|
+
defaultPanelLocation: StagePanelLocation.Left,
|
|
260
|
+
defaultPanelSection: StagePanelSection.End,
|
|
261
|
+
defaultTreeWidgetPriority: 1000,
|
|
262
|
+
onFeatureUsed={(feature) => {
|
|
263
|
+
telemetryClient.log(`TreeWidget [${feature}] used`);
|
|
264
|
+
}},
|
|
265
|
+
trees: [{
|
|
266
|
+
id: ModelsTreeComponent.id,
|
|
267
|
+
getLabel: ModelsTreeComponent.getLabel,
|
|
268
|
+
render: (props) => <ModelsTreeComponent { ...props } />,
|
|
269
|
+
}];
|
|
270
|
+
})
|
|
271
|
+
);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
For individual tree components the `onFeatureUsed` callback should be supplied through props:
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
return (
|
|
278
|
+
<ModelsTreeComponent
|
|
279
|
+
onFeatureUsed={(feature) => {
|
|
280
|
+
console.log(`TreeWidget [${feature}] used`)
|
|
281
|
+
}}
|
|
282
|
+
/>
|
|
283
|
+
);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Tree selector icons
|
|
287
|
+
|
|
288
|
+
Provided trees to `TreeWidgetUiItemsProvider` can define a `startIcon` property that will be shown next to the tree label in tree selector.
|
|
289
|
+
|
|
290
|
+
Example:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import { UiItemsManager } from "@itwin/appui-react";
|
|
294
|
+
import { TreeWidgetUiItemsProvider, ModelsTreeComponent } from "@itwin/tree-widget-react";
|
|
295
|
+
import { SvgTechnicalPreviewMiniBw } from "@itwin/itwinui-icons-react";
|
|
296
|
+
...
|
|
297
|
+
UiItemsManager.register(
|
|
298
|
+
new TreeWidgetUiItemsProvider({
|
|
299
|
+
defaultPanelLocation: StagePanelLocation.Left,
|
|
300
|
+
defaultPanelSection: StagePanelSection.End,
|
|
301
|
+
defaultTreeWidgetPriority: 1000,
|
|
302
|
+
trees: [{
|
|
303
|
+
id: ModelsTreeComponent.id,
|
|
304
|
+
getLabel: ModelsTreeComponent.getLabel,
|
|
305
|
+
render: (props) => <ModelsTreeComponent { ...props } />,
|
|
306
|
+
startIcon: <SvgTechnicalPreviewMiniBw />,
|
|
307
|
+
}];
|
|
308
|
+
})
|
|
309
|
+
);
|
|
310
|
+
```
|
|
@@ -8,6 +8,7 @@ import type { IModelConnection } from "@itwin/core-frontend";
|
|
|
8
8
|
export interface TreeRenderProps {
|
|
9
9
|
density?: "enlarged" | "default";
|
|
10
10
|
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
11
|
+
onFeatureUsed?: (feature: string) => void;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Definition of a tree component displayed in [[SelectableTree]]
|
|
@@ -25,6 +26,8 @@ export interface TreeDefinition {
|
|
|
25
26
|
* If callback is `undefined` tree is shown for all iModel connections.
|
|
26
27
|
*/
|
|
27
28
|
shouldShow?: (imodel: IModelConnection) => Promise<boolean>;
|
|
29
|
+
/** Icon to render before tree label in tree selector */
|
|
30
|
+
startIcon?: React.ReactNode;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Props for [[SelectableTree]]
|
|
@@ -34,6 +37,7 @@ export interface SelectableTreeProps {
|
|
|
34
37
|
trees: TreeDefinition[];
|
|
35
38
|
density?: "enlarged" | "default";
|
|
36
39
|
onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;
|
|
40
|
+
onFeatureUsed?: (feature: string) => void;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* A component that renders a tree (combo box) selector and the selected tree component.
|
|
@@ -28,7 +28,7 @@ exports.SelectableTree = SelectableTree;
|
|
|
28
28
|
function SelectableTreeContent(props) {
|
|
29
29
|
const { trees: treeDefinitions, imodel } = props;
|
|
30
30
|
const trees = useActiveTrees(treeDefinitions, imodel);
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "tree-widget-selectable-tree", children: (0, jsx_runtime_1.jsx)(TreeSelector_1.TreeSelector, { ...getTreeSelectorProps(trees), density: props.density, onPerformanceMeasured: props.onPerformanceMeasured }) }));
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "tree-widget-selectable-tree", children: (0, jsx_runtime_1.jsx)(TreeSelector_1.TreeSelector, { ...getTreeSelectorProps(trees), density: props.density, onPerformanceMeasured: props.onPerformanceMeasured, onFeatureUsed: props.onFeatureUsed }) }));
|
|
32
32
|
}
|
|
33
33
|
function useActiveTrees(treeDefinitions, imodel) {
|
|
34
34
|
const [trees, setTrees] = (0, react_1.useState)();
|
|
@@ -56,6 +56,7 @@ async function getActiveTrees(treeDefinitions, imodel) {
|
|
|
56
56
|
id: treeDef.id,
|
|
57
57
|
label: treeDef.getLabel(),
|
|
58
58
|
render: treeDef.render,
|
|
59
|
+
startIcon: treeDef.startIcon,
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectableTree.js","sourceRoot":"","sources":["../../../src/components/SelectableTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA+B;AAC/B,iCAA4C;AAC5C,oDAA+D;AAC/D,kDAAiD;AACjD,wDAAsD;AACtD,8CAA2C;AAC3C,iDAA8C;
|
|
1
|
+
{"version":3,"file":"SelectableTree.js","sourceRoot":"","sources":["../../../src/components/SelectableTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA+B;AAC/B,iCAA4C;AAC5C,oDAA+D;AAC/D,kDAAiD;AACjD,wDAAsD;AACtD,8CAA2C;AAC3C,iDAA8C;AA8C9C;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,uBAAC,qBAAqB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AAC9D,CAAC;AARD,wCAQC;AAED,SAAS,qBA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,EAAC,KAAK,CAAC,CAAC;IAExC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,EAAE,KAAK,CAAC,CAAC;QACV,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAO,2DAAG,QAAQ,GAAI,CAAC;AACzB,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 \"./SelectableTree.scss\";\nimport { useEffect, useState } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { ProgressLinear } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../TreeWidget\";\nimport { TreeSelector } from \"./TreeSelector\";\n\nimport type { PropsWithChildren } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeContentDefinition, TreeSelectorProps } from \"./TreeSelector\";\n/**\n * Props for rendering trees\n * @public\n */\nexport interface TreeRenderProps {\n density?: \"enlarged\" | \"default\";\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Definition of a tree component displayed in [[SelectableTree]]\n * @public\n */\nexport interface TreeDefinition {\n /** Id of the tree */\n id: string;\n /** Callback that is used to get tree label */\n getLabel: () => string;\n /** Callback that is used to render tree component */\n render: (props: TreeRenderProps) => React.ReactNode;\n /**\n * Callback that is used to determine if tree should be shown for current active iModel connection.\n * If callback is `undefined` tree is shown for all iModel connections.\n */\n shouldShow?: (imodel: IModelConnection) => Promise<boolean>;\n /** Icon to render before tree label in tree selector */\n startIcon?: React.ReactNode;\n}\n\n/**\n * Props for [[SelectableTree]]\n * @public\n */\nexport interface SelectableTreeProps {\n trees: TreeDefinition[];\n density?: \"enlarged\" | \"default\";\n onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders a tree (combo box) selector and the selected tree component.\n * @public\n */\nexport function SelectableTree(props: SelectableTreeProps) {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return <SelectableTreeContent {...props} imodel={imodel} />;\n}\n\nfunction SelectableTreeContent(props: SelectableTreeProps & { imodel: IModelConnection }) {\n const { trees: treeDefinitions, imodel } = props;\n const trees = useActiveTrees(treeDefinitions, imodel);\n\n return (\n <div className=\"tree-widget-selectable-tree\">\n <TreeSelector\n {...getTreeSelectorProps(trees)}\n density={props.density}\n onPerformanceMeasured={props.onPerformanceMeasured}\n onFeatureUsed={props.onFeatureUsed}\n />\n </div>\n );\n}\n\nfunction useActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection) {\n const [trees, setTrees] = useState<TreeContentDefinition[]>();\n\n useEffect(() => {\n let disposed = false;\n void (async () => {\n const visibleTrees = await getActiveTrees(treeDefinitions, imodel);\n // istanbul ignore else\n if (!disposed) {\n setTrees(visibleTrees);\n }\n })();\n\n return () => {\n disposed = true;\n };\n }, [treeDefinitions, imodel]);\n\n return trees;\n}\n\nasync function getActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection): Promise<TreeContentDefinition[]> {\n const handleDefinition = async (treeDef: TreeDefinition) => {\n if (treeDef.shouldShow !== undefined && !(await treeDef.shouldShow(imodel))) {\n return undefined;\n }\n return {\n id: treeDef.id,\n label: treeDef.getLabel(),\n render: treeDef.render,\n startIcon: treeDef.startIcon,\n };\n };\n\n return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined) as TreeContentDefinition[];\n}\n\nfunction getTreeSelectorProps(trees?: TreeContentDefinition[]): TreeSelectorProps {\n if (trees === undefined) {\n return {\n defaultSelectedContentId: \"loading\",\n trees: [\n {\n id: \"loading\",\n label: \"\",\n render: () => (\n <Delayed>\n <ProgressLinear indeterminate={true} />\n </Delayed>\n ),\n },\n ],\n };\n }\n\n if (trees.length === 0) {\n return {\n defaultSelectedContentId: \"no-trees\",\n trees: [\n {\n id: \"no-trees\",\n label: \"\",\n render: () => <FillCentered>{TreeWidget.translate(\"noTrees\")}</FillCentered>,\n },\n ],\n };\n }\n\n return {\n defaultSelectedContentId: trees[0].id,\n trees,\n };\n}\n\nfunction Delayed({ delay = 200, children }: PropsWithChildren<{ delay?: number }>) {\n const [show, setShow] = useState(false);\n\n useEffect(() => {\n const id = setTimeout(() => {\n setShow(true);\n }, delay);\n return () => {\n clearTimeout(id);\n };\n }, [delay]);\n\n if (!show) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}
|
|
@@ -9,6 +9,7 @@ export interface TreeContentDefinition {
|
|
|
9
9
|
id: string;
|
|
10
10
|
label: string;
|
|
11
11
|
render: (props: TreeRenderProps) => React.ReactNode;
|
|
12
|
+
startIcon?: React.ReactNode;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Props for [[TreeSelector]]
|
|
@@ -19,6 +20,7 @@ export interface TreeSelectorProps {
|
|
|
19
20
|
trees: TreeContentDefinition[];
|
|
20
21
|
density?: "enlarged" | "default";
|
|
21
22
|
onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;
|
|
23
|
+
onFeatureUsed?: (feature: string) => void;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* A component that accepts a list of trees and renders a select box at the top,
|
|
@@ -19,9 +19,12 @@ function TreeSelector(props) {
|
|
|
19
19
|
const selectedContent = props.trees.find((c) => c.id === selectedContentId) ?? props.trees[0];
|
|
20
20
|
const isEnlarged = props.density === "enlarged";
|
|
21
21
|
const options = (0, react_1.useMemo)(() => {
|
|
22
|
-
return props.trees.map((c) => ({ label: c.label, value: c.id }));
|
|
22
|
+
return props.trees.map((c) => ({ label: c.label, value: c.id, startIcon: c.startIcon }));
|
|
23
23
|
}, [props.trees]);
|
|
24
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "presentation-components-tree-selector-content", children: [(0, jsx_runtime_1.jsx)("div", { className: "presentation-components-tree-selector-content-header", children: options.length > 0 && ((0, jsx_runtime_1.jsx)(itwinui_react_1.Select, {
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "presentation-components-tree-selector-content", children: [(0, jsx_runtime_1.jsx)("div", { className: "presentation-components-tree-selector-content-header", children: options.length > 0 && ((0, jsx_runtime_1.jsx)(itwinui_react_1.Select, { options: options, value: selectedContent.id, size: isEnlarged ? "large" : "small", onChange: (treeId) => {
|
|
25
|
+
props.onFeatureUsed?.(`choose-${treeId}`);
|
|
26
|
+
setSelectedContentId(treeId);
|
|
27
|
+
}, itemRenderer: (option, itemProps) => ((0, jsx_runtime_1.jsx)(itwinui_react_1.MenuItem, { ...option, isSelected: itemProps.isSelected, size: isEnlarged ? "large" : "default", children: option.label })) })) }), (0, jsx_runtime_1.jsx)("div", { className: "presentation-components-tree-selector-content-wrapper", children: selectedContent?.render({ density: props.density, onPerformanceMeasured: props.onPerformanceMeasured, onFeatureUsed: props.onFeatureUsed }) })] }));
|
|
25
28
|
}
|
|
26
29
|
exports.TreeSelector = TreeSelector;
|
|
27
30
|
//# sourceMappingURL=TreeSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelector.js","sourceRoot":"","sources":["../../../src/components/TreeSelector.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,+BAA6B;AAC7B,iCAA0C;AAC1C,wDAAwD;
|
|
1
|
+
{"version":3,"file":"TreeSelector.js","sourceRoot":"","sources":["../../../src/components/TreeSelector.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGg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AE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CACnC,uBAAC,wBAAQ,OAAK,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,YAC3F,MAAM,CAAC,KAAK,GACJ,CACZ,GACD,CACH,GACG,EACN,gCAAK,SAAS,EAAC,uDAAuD,YACnE,eAAe,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,GACxI,IACF,CACP,CAAC;AACJ,CAAC;AAlCD,oCAkCC","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 \"./TreeSelector.scss\";\nimport { useMemo, useState } from \"react\";\nimport { MenuItem, Select } from \"@itwin/itwinui-react\";\n\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport type { TreeRenderProps } from \"./SelectableTree\";\n\n/**\n * A definition for trees displayed in [[TreeSelector]]\n * @internal\n */\nexport interface TreeContentDefinition {\n id: string;\n label: string;\n render: (props: TreeRenderProps) => React.ReactNode;\n startIcon?: React.ReactNode;\n}\n\n/**\n * Props for [[TreeSelector]]\n * @internal\n */\nexport interface TreeSelectorProps {\n defaultSelectedContentId: string;\n trees: TreeContentDefinition[];\n density?: \"enlarged\" | \"default\";\n onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that accepts a list of trees and renders a select box at the top,\n * allowing to choose which of the provided tree components should be rendered at the bottom.\n * @internal\n */\nexport function TreeSelector(props: TreeSelectorProps) {\n const [selectedContentId, setSelectedContentId] = useState(props.defaultSelectedContentId);\n const selectedContent = props.trees.find((c) => c.id === selectedContentId) ?? props.trees[0];\n const isEnlarged = props.density === \"enlarged\";\n\n const options = useMemo(() => {\n return props.trees.map((c) => ({ label: c.label, value: c.id, startIcon: c.startIcon })) as SelectOption<string>[];\n }, [props.trees]);\n\n return (\n <div className=\"presentation-components-tree-selector-content\">\n <div className=\"presentation-components-tree-selector-content-header\">\n {options.length > 0 && (\n <Select\n options={options}\n value={selectedContent.id}\n size={isEnlarged ? \"large\" : \"small\"}\n onChange={(treeId: string) => {\n props.onFeatureUsed?.(`choose-${treeId}`);\n setSelectedContentId(treeId);\n }}\n itemRenderer={(option, itemProps) => (\n <MenuItem {...option} isSelected={itemProps.isSelected} size={isEnlarged ? \"large\" : \"default\"}>\n {option.label}\n </MenuItem>\n )}\n />\n )}\n </div>\n <div className=\"presentation-components-tree-selector-content-wrapper\">\n {selectedContent?.render({ density: props.density, onPerformanceMeasured: props.onPerformanceMeasured, onFeatureUsed: props.onFeatureUsed })}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -20,6 +20,8 @@ export interface TreeWidgetOptions {
|
|
|
20
20
|
density?: "enlarged" | "default";
|
|
21
21
|
/** Callback that is invoked when performance of tracked feature is measured. */
|
|
22
22
|
onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;
|
|
23
|
+
/** Callback that is invoked when a tracked feature is used. */
|
|
24
|
+
onFeatureUsed?: (feature: string) => void;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Id of the tree widget created by [[TreeWidgetUiItemsProvider]].
|
|
@@ -53,7 +53,7 @@ class TreeWidgetUiItemsProvider {
|
|
|
53
53
|
{
|
|
54
54
|
id: exports.TreeWidgetId,
|
|
55
55
|
label: TreeWidget_1.TreeWidget.translate("treeview"),
|
|
56
|
-
content: ((0, jsx_runtime_1.jsx)(TreeWidgetComponent, { trees: trees, density: this._treeWidgetOptions?.density, onPerformanceMeasured: this._treeWidgetOptions?.onPerformanceMeasured })),
|
|
56
|
+
content: ((0, jsx_runtime_1.jsx)(TreeWidgetComponent, { trees: trees, density: this._treeWidgetOptions?.density, onPerformanceMeasured: this._treeWidgetOptions?.onPerformanceMeasured, onFeatureUsed: this._treeWidgetOptions?.onFeatureUsed })),
|
|
57
57
|
icon: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgHierarchyTree, {}),
|
|
58
58
|
priority: this._treeWidgetOptions?.defaultTreeWidgetPriority,
|
|
59
59
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,4CAA0C;AAC1C,+DAAqD;AACrD,oDAAuF;AACvF,oEAA8D;AAC9D,oFAA8D;AAC9D,wDAA6D;AAC7D,8CAA2C;AAC3C,qDAAkD;AAClD,2FAAwF;AACxF,iFAA8E;AAC9E,yEAAsE;
|
|
1
|
+
{"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,4CAA0C;AAC1C,+DAAqD;AACrD,oDAAuF;AACvF,oEAA8D;AAC9D,oFAA8D;AAC9D,wDAA6D;AAC7D,8CAA2C;AAC3C,qDAAkD;AAClD,2FAAwF;AACxF,iFAA8E;AAC9E,yEAAsE;AA0BtE;;;GAGG;AACU,QAAA,YAAY,GAAG,yBAAyB,CAAC;AAEtD;;;GAGG;AACH,MAAa,yBAAyB;IAGpC,YAAoB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;QAF1C,OAAE,GAAG,2BAA2B,CAAC;IAEY,CAAC;IAEvD,cAAc,CAAC,QAAgB,EAAE,UAAkB,EAAE,QAA4B,EAAE,OAA2B;QACnH,MAAM,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,oBAAoB,IAAI,gCAAkB,CAAC,K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AAkB,CAAC;IAEpD,OAAO,CACL,gCAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,aAAa,YACpC,uBAAC,oCAAa,IAAC,iBAAiB,EAAE,UAAU,YAC1C,uBAAC,+BAAc,OAAK,KAAK,GAAI,GACf,GACZ,CACP,CAAC;AACJ,CAAC;AAVD,kDAUC;AAED,SAAS,UAAU,CAAC,EAAE,kBAAkB,EAAiB;IACvD,OAAO,CACL,uBAAC,6BAAa,IACZ,GAAG,EAAE,uBAAC,sCAAQ,KAAG,EACjB,OAAO,EAAE,uBAAU,CAAC,SAAS,CAAC,OAAO,CAAC,EACtC,WAAW,EAAE,uBAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,EAC9D,OAAO,EACL,uBAAC,sBAAM,IAAC,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,YAC9D,uBAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GACvB,GAEX,CACH,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 \"./TreeWidgetUiItemsProvider.scss\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport { StagePanelLocation, StagePanelSection, StageUsage } from \"@itwin/appui-react\";\nimport { SvgHierarchyTree } from \"@itwin/itwinui-icons-react\";\nimport { SvgError } from \"@itwin/itwinui-illustrations-react\";\nimport { Button, NonIdealState } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../TreeWidget\";\nimport { SelectableTree } from \"./SelectableTree\";\nimport { CategoriesTreeComponent } from \"./trees/category-tree/CategoriesTreeComponent\";\nimport { ModelsTreeComponent } from \"./trees/models-tree/ModelsTreeComponent\";\nimport { useTreeTransientState } from \"./utils/UseTreeTransientState\";\n\nimport type { UiItemsProvider, Widget } from \"@itwin/appui-react\";\nimport type { SelectableTreeProps, TreeDefinition } from \"./SelectableTree\";\nimport type { FallbackProps } from \"react-error-boundary\";\n/**\n * Parameters for creating a [[TreeWidgetUiItemsProvider]].\n * @public\n */\nexport interface TreeWidgetOptions {\n /** The stage panel to place the widget in. Defaults to `StagePanelLocation.Right`. */\n defaultPanelLocation?: StagePanelLocation;\n /** The stage panel section to place the widget in. Defaults to `StagePanelSection.Start`. */\n defaultPanelSection?: StagePanelSection;\n /** Widget priority in the stage panel. */\n defaultTreeWidgetPriority?: number;\n /** Trees to show in the widget. Defaults to [[ModelsTreeComponent]] and [[CategoriesTreeComponent]]. */\n trees?: TreeDefinition[];\n /** Modifies the density of the tree widget. `enlarged` widget contains larger content */\n density?: \"enlarged\" | \"default\";\n /** Callback that is invoked when performance of tracked feature is measured. */\n onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;\n /** Callback that is invoked when a tracked feature is used. */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Id of the tree widget created by [[TreeWidgetUiItemsProvider]].\n * @public\n */\nexport const TreeWidgetId = \"tree-widget-react:trees\";\n\n/**\n * A [[UiItemsProvider]] implementation that provides a [[SelectableTree]] into a stage panel.\n * @public\n */\nexport class TreeWidgetUiItemsProvider implements UiItemsProvider {\n public readonly id = \"TreeWidgetUiItemsProvider\";\n\n constructor(private _treeWidgetOptions?: TreeWidgetOptions) {}\n\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection): ReadonlyArray<Widget> {\n const preferredLocation = this._treeWidgetOptions?.defaultPanelLocation ?? StagePanelLocation.Right;\n const preferredPanelSection = this._treeWidgetOptions?.defaultPanelSection ?? StagePanelSection.Start;\n\n if (location !== preferredLocation || section !== preferredPanelSection || stageUsage !== StageUsage.General) {\n return [];\n }\n\n const trees: TreeDefinition[] = this._treeWidgetOptions?.trees ?? [\n {\n id: ModelsTreeComponent.id,\n getLabel: ModelsTreeComponent.getLabel,\n render: (props) => <ModelsTreeComponent {...props} />,\n },\n {\n id: CategoriesTreeComponent.id,\n getLabel: CategoriesTreeComponent.getLabel,\n render: (props) => <CategoriesTreeComponent {...props} />,\n },\n ];\n\n return [\n {\n id: TreeWidgetId,\n label: TreeWidget.translate(\"treeview\"),\n content: (\n <TreeWidgetComponent\n trees={trees}\n density={this._treeWidgetOptions?.density}\n onPerformanceMeasured={this._treeWidgetOptions?.onPerformanceMeasured}\n onFeatureUsed={this._treeWidgetOptions?.onFeatureUsed}\n />\n ),\n icon: <SvgHierarchyTree />,\n priority: this._treeWidgetOptions?.defaultTreeWidgetPriority,\n },\n ];\n }\n}\n\n/**\n * Tree widget component which allows selecting which tree to render.\n * @public\n */\nexport function TreeWidgetComponent(props: SelectableTreeProps) {\n const ref = useTreeTransientState<HTMLDivElement>();\n\n return (\n <div ref={ref} className=\"tree-widget\">\n <ErrorBoundary FallbackComponent={ErrorState}>\n <SelectableTree {...props} />\n </ErrorBoundary>\n </div>\n );\n}\n\nfunction ErrorState({ resetErrorBoundary }: FallbackProps) {\n return (\n <NonIdealState\n svg={<SvgError />}\n heading={TreeWidget.translate(\"error\")}\n description={TreeWidget.translate(\"generic-error-description\")}\n actions={\n <Button styleType={\"high-visibility\"} onClick={resetErrorBoundary}>\n {TreeWidget.translate(\"retry\")}\n </Button>\n }\n />\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
export interface TreeHeaderButtonProps {
|
|
7
7
|
viewport: Viewport;
|
|
8
8
|
density?: "default" | "enlarged";
|
|
9
|
+
onFeatureUsed?: (feature: string) => void;
|
|
9
10
|
}
|
|
10
11
|
/** @internal */
|
|
11
12
|
export interface TreeHeaderProps extends CommonProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeHeader.js","sourceRoot":"","sources":["../../../../src/components/tree-header/TreeHeader.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,6BAA2B;AAC3B,4DAAoC;AACpC,iCAA8D;AAC9D,oEAAyF;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AC,OAAO,YAC1H,uBAAC,6BAAO,KAAG,GACA,GACA,CAChB,YAEA,KAAK,CAAC,QAAQ,GACH,CACf,CAAC;AACJ,CAAC;AASD,SAAS,mBAAmB,CAAC,KAA+B;IAC1D,MAAM,EAAE,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,6DACE,iCAAM,SAAS,EAAC,0BAA0B,YAAE,GAAG,aAAa,IAAI,KAAK,EAAE,GAAQ,EAC/E,uBAAC,uBAAO,IAAC,WAAW,EAAC,UAAU,GAAG,EAClC,uBAAC,yBAAS,CAAC,MAAM,IACf,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,EACjD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,CAAC,EAAE;wBACrB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,uBAAC,qCAAe,KAAG,GACF,EACnB,uBAAC,yBAAS,CAAC,MAAM,IACf,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAC7C,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,KAAK,EAAE;wBACzB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,uBAAC,uCAAiB,KAAG,GACJ,IAClB,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 \"./TreeHeader.scss\";\nimport classnames from \"classnames\";\nimport { Children, useEffect, useRef, useState } from \"react\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { ButtonGroup, Divider, DropdownMenu, IconButton, SearchBox } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../TreeWidget\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n/** @internal */\nexport interface TreeHeaderButtonProps {\n viewport: Viewport;\n density?: \"default\" | \"enlarged\";\n}\n\n/** @internal */\nexport interface TreeHeaderProps extends CommonProps {\n /** Filtering is cleared after everything's loaded */\n onFilterStart: (newFilter: string) => void;\n /** listens for onClick event for Clear (x) icon */\n onFilterClear: () => void;\n /** Total number of results/entries */\n resultCount?: number;\n /** Current selected result index */\n selectedIndex?: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n /** Header buttons */\n children?: React.ReactNode;\n /** Modifies the density of tree header. `enlarged` header contains larger content */\n density?: \"default\" | \"enlarged\";\n}\n\n/** @internal */\nexport function TreeHeader(props: TreeHeaderProps) {\n const { onFilterStart, onFilterClear, resultCount, selectedIndex, onSelectedChanged, children, density, className } = props;\n const [isSearchOpen, setIsSearchOpen] = useState<boolean>(false);\n const isEnlarged = density === \"enlarged\";\n return (\n <div className={classnames(\"tree-widget-tree-header\", className, isEnlarged && \"enlarge\")}>\n <HeaderButtons contracted={isSearchOpen} isEnlarged={isEnlarged}>\n {children}\n </HeaderButtons>\n <DebouncedSearchBox\n isOpened={isSearchOpen}\n onOpen={() => setIsSearchOpen(true)}\n onClose={() => setIsSearchOpen(false)}\n onChange={(value) => (value ? onFilterStart(value) : onFilterClear())}\n delay={500}\n selectedResultIndex={selectedIndex}\n resultCount={resultCount}\n onSelectedResultChanged={onSelectedChanged}\n size={isEnlarged ? \"large\" : \"small\"}\n />\n </div>\n );\n}\n\ninterface DebouncedSearchBoxProps {\n isOpened: boolean;\n onOpen: () => void;\n onClose: () => void;\n onChange: (value: string) => void;\n delay: number;\n selectedResultIndex?: number;\n resultCount?: number;\n onSelectedResultChanged: (index: number) => void;\n size?: \"large\" | \"small\";\n}\n\nfunction DebouncedSearchBox({\n isOpened,\n selectedResultIndex,\n resultCount,\n onSelectedResultChanged,\n onChange,\n onOpen,\n onClose,\n delay,\n size,\n}: DebouncedSearchBoxProps) {\n const [inputValue, setInputValue] = useState<string>(\"\");\n const onChangeRef = useRef(onChange);\n // save latest `onChange` reference into `useRef` to avoid restarting timeout when `onChange` reference changes.\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!inputValue) {\n onChangeRef.current(\"\");\n return;\n }\n\n const timeoutId = setTimeout(() => {\n onChangeRef.current(inputValue);\n }, delay);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [inputValue, delay]);\n\n return (\n <SearchBox expandable onExpand={onOpen} onCollapse={onClose} size={size} className={classnames(\"tree-widget-search-box\", !isOpened && \"contracted\")}>\n <SearchBox.CollapsedState>\n <SearchBox.ExpandButton\n title={TreeWidget.translate(\"searchBox.searchForSomething\")}\n aria-label={TreeWidget.translate(\"searchBox.open\")}\n size={size}\n styleType=\"borderless\"\n />\n </SearchBox.CollapsedState>\n <SearchBox.ExpandedState>\n <SearchBox.Input placeholder={TreeWidget.translate(\"searchBox.search\")} onChange={(e) => setInputValue(e.currentTarget.value)} />\n <SearchResultStepper selectedIndex={selectedResultIndex} total={resultCount} onStep={onSelectedResultChanged} size={size} />\n <SearchBox.CollapseButton\n onClick={() => {\n setInputValue(\"\");\n onClose();\n }}\n size={size}\n aria-label={TreeWidget.translate(\"searchBox.close\")}\n />\n </SearchBox.ExpandedState>\n </SearchBox>\n );\n}\n\ninterface HeaderButtonsProps {\n contracted: boolean;\n children?: React.ReactNode;\n isEnlarged?: boolean;\n}\n\nfunction HeaderButtons(props: HeaderButtonsProps) {\n const className = classnames(\"button-container\", props.contracted && \"contracted\");\n const dropdownClassName = classnames(\"dropdown-item\", props.isEnlarged && \"enlarge\");\n\n return (\n <ButtonGroup\n className={className}\n overflowButton={(overflowStart) => (\n <DropdownMenu\n menuItems={() =>\n Children.toArray(props.children)\n .slice(overflowStart)\n .map((btn, index) => (\n <li key={index} className={dropdownClassName} role=\"menuitem\">\n {btn}\n </li>\n ))\n }\n className=\"tree-header-button-dropdown-container\"\n >\n <IconButton title={TreeWidget.translate(\"dropdownMore\")} styleType=\"borderless\" size={props.isEnlarged ? undefined : \"small\"}>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n )}\n >\n {props.children}\n </ButtonGroup>\n );\n}\n\ninterface SearchResultStepperProps {\n total?: number;\n onStep: (newIndex: number) => void;\n selectedIndex?: number;\n size?: \"large\" | \"small\";\n}\n\nfunction SearchResultStepper(props: SearchResultStepperProps) {\n const { selectedIndex = 1, total, onStep } = props;\n if (!total) {\n return null;\n }\n\n return (\n <>\n <span className=\"searchbox-stepping-count\">{`${selectedIndex}/${total}`}</span>\n <Divider orientation=\"vertical\" />\n <SearchBox.Button\n title={TreeWidget.translate(\"searchBox.previous\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex > 1) {\n onStep(selectedIndex - 1);\n }\n }}\n >\n <SvgCaretUpSmall />\n </SearchBox.Button>\n <SearchBox.Button\n title={TreeWidget.translate(\"searchBox.next\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex < total) {\n onStep(selectedIndex + 1);\n }\n }}\n >\n <SvgCaretDownSmall />\n </SearchBox.Button>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeHeader.js","sourceRoot":"","sources":["../../../../src/components/tree-header/TreeHeader.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,6BAA2B;AAC3B,4DAAoC;AACpC,iCAA8D;AAC9D,oEAAyF;AACzF,wDAAiG;AACjG,iDAA8C;AA8B9C,gBAAgB;AAChB,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ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AAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,6DACE,iCAAM,SAAS,EAAC,0BAA0B,YAAE,GAAG,aAAa,IAAI,KAAK,EAAE,GAAQ,EAC/E,uBAAC,uBAAO,IAAC,WAAW,EAAC,UAAU,GAAG,EAClC,uBAAC,yBAAS,CAAC,MAAM,IACf,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,EACjD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,CAAC,EAAE;wBACrB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,uBAAC,qCAAe,KAAG,GACF,EACnB,uBAAC,yBAAS,CAAC,MAAM,IACf,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAC7C,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,KAAK,EAAE;wBACzB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,uBAAC,uCAAiB,KAAG,GACJ,IAClB,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 \"./TreeHeader.scss\";\nimport classnames from \"classnames\";\nimport { Children, useEffect, useRef, useState } from \"react\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { ButtonGroup, Divider, DropdownMenu, IconButton, SearchBox } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../TreeWidget\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n/** @internal */\nexport interface TreeHeaderButtonProps {\n viewport: Viewport;\n density?: \"default\" | \"enlarged\";\n onFeatureUsed?: (feature: string) => void;\n}\n\n/** @internal */\nexport interface TreeHeaderProps extends CommonProps {\n /** Filtering is cleared after everything's loaded */\n onFilterStart: (newFilter: string) => void;\n /** listens for onClick event for Clear (x) icon */\n onFilterClear: () => void;\n /** Total number of results/entries */\n resultCount?: number;\n /** Current selected result index */\n selectedIndex?: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n /** Header buttons */\n children?: React.ReactNode;\n /** Modifies the density of tree header. `enlarged` header contains larger content */\n density?: \"default\" | \"enlarged\";\n}\n\n/** @internal */\nexport function TreeHeader(props: TreeHeaderProps) {\n const { onFilterStart, onFilterClear, resultCount, selectedIndex, onSelectedChanged, children, density, className } = props;\n const [isSearchOpen, setIsSearchOpen] = useState<boolean>(false);\n const isEnlarged = density === \"enlarged\";\n return (\n <div className={classnames(\"tree-widget-tree-header\", className, isEnlarged && \"enlarge\")}>\n <HeaderButtons contracted={isSearchOpen} isEnlarged={isEnlarged}>\n {children}\n </HeaderButtons>\n <DebouncedSearchBox\n isOpened={isSearchOpen}\n onOpen={() => setIsSearchOpen(true)}\n onClose={() => setIsSearchOpen(false)}\n onChange={(value) => (value ? onFilterStart(value) : onFilterClear())}\n delay={500}\n selectedResultIndex={selectedIndex}\n resultCount={resultCount}\n onSelectedResultChanged={onSelectedChanged}\n size={isEnlarged ? \"large\" : \"small\"}\n />\n </div>\n );\n}\n\ninterface DebouncedSearchBoxProps {\n isOpened: boolean;\n onOpen: () => void;\n onClose: () => void;\n onChange: (value: string) => void;\n delay: number;\n selectedResultIndex?: number;\n resultCount?: number;\n onSelectedResultChanged: (index: number) => void;\n size?: \"large\" | \"small\";\n}\n\nfunction DebouncedSearchBox({\n isOpened,\n selectedResultIndex,\n resultCount,\n onSelectedResultChanged,\n onChange,\n onOpen,\n onClose,\n delay,\n size,\n}: DebouncedSearchBoxProps) {\n const [inputValue, setInputValue] = useState<string>(\"\");\n const onChangeRef = useRef(onChange);\n // save latest `onChange` reference into `useRef` to avoid restarting timeout when `onChange` reference changes.\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!inputValue) {\n onChangeRef.current(\"\");\n return;\n }\n\n const timeoutId = setTimeout(() => {\n onChangeRef.current(inputValue);\n }, delay);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [inputValue, delay]);\n\n return (\n <SearchBox expandable onExpand={onOpen} onCollapse={onClose} size={size} className={classnames(\"tree-widget-search-box\", !isOpened && \"contracted\")}>\n <SearchBox.CollapsedState>\n <SearchBox.ExpandButton\n title={TreeWidget.translate(\"searchBox.searchForSomething\")}\n aria-label={TreeWidget.translate(\"searchBox.open\")}\n size={size}\n styleType=\"borderless\"\n />\n </SearchBox.CollapsedState>\n <SearchBox.ExpandedState>\n <SearchBox.Input placeholder={TreeWidget.translate(\"searchBox.search\")} onChange={(e) => setInputValue(e.currentTarget.value)} />\n <SearchResultStepper selectedIndex={selectedResultIndex} total={resultCount} onStep={onSelectedResultChanged} size={size} />\n <SearchBox.CollapseButton\n onClick={() => {\n setInputValue(\"\");\n onClose();\n }}\n size={size}\n aria-label={TreeWidget.translate(\"searchBox.close\")}\n />\n </SearchBox.ExpandedState>\n </SearchBox>\n );\n}\n\ninterface HeaderButtonsProps {\n contracted: boolean;\n children?: React.ReactNode;\n isEnlarged?: boolean;\n}\n\nfunction HeaderButtons(props: HeaderButtonsProps) {\n const className = classnames(\"button-container\", props.contracted && \"contracted\");\n const dropdownClassName = classnames(\"dropdown-item\", props.isEnlarged && \"enlarge\");\n\n return (\n <ButtonGroup\n className={className}\n overflowButton={(overflowStart) => (\n <DropdownMenu\n menuItems={() =>\n Children.toArray(props.children)\n .slice(overflowStart)\n .map((btn, index) => (\n <li key={index} className={dropdownClassName} role=\"menuitem\">\n {btn}\n </li>\n ))\n }\n className=\"tree-header-button-dropdown-container\"\n >\n <IconButton title={TreeWidget.translate(\"dropdownMore\")} styleType=\"borderless\" size={props.isEnlarged ? undefined : \"small\"}>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n )}\n >\n {props.children}\n </ButtonGroup>\n );\n}\n\ninterface SearchResultStepperProps {\n total?: number;\n onStep: (newIndex: number) => void;\n selectedIndex?: number;\n size?: \"large\" | \"small\";\n}\n\nfunction SearchResultStepper(props: SearchResultStepperProps) {\n const { selectedIndex = 1, total, onStep } = props;\n if (!total) {\n return null;\n }\n\n return (\n <>\n <span className=\"searchbox-stepping-count\">{`${selectedIndex}/${total}`}</span>\n <Divider orientation=\"vertical\" />\n <SearchBox.Button\n title={TreeWidget.translate(\"searchBox.previous\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex > 1) {\n onStep(selectedIndex - 1);\n }\n }}\n >\n <SvgCaretUpSmall />\n </SearchBox.Button>\n <SearchBox.Button\n title={TreeWidget.translate(\"searchBox.next\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex < total) {\n onStep(selectedIndex + 1);\n }\n }}\n >\n <SvgCaretDownSmall />\n </SearchBox.Button>\n </>\n );\n}\n"]}
|
|
@@ -40,6 +40,10 @@ export interface VisibilityTreeNodeRendererProps {
|
|
|
40
40
|
* Is `false` by default
|
|
41
41
|
*/
|
|
42
42
|
isEnlarged?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Callback called when visibility is toggled using a checkbox.
|
|
45
|
+
*/
|
|
46
|
+
onVisibilityToggled?: (enabled: boolean) => void;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
49
|
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
@@ -50,12 +54,15 @@ export declare function createVisibilityTreeRenderer({ nodeRendererProps, ...res
|
|
|
50
54
|
* Creates node renderer which renders node with eye checkbox.
|
|
51
55
|
* @public
|
|
52
56
|
*/
|
|
53
|
-
export declare function createVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, iconsEnabled, }: VisibilityTreeNodeRendererProps): (treeNodeProps: TreeNodeRendererProps) => JSX.Element;
|
|
57
|
+
export declare function createVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, iconsEnabled, onVisibilityToggled, }: VisibilityTreeNodeRendererProps): (treeNodeProps: TreeNodeRendererProps) => JSX.Element;
|
|
58
|
+
interface VisibilityTreeNodeCheckboxProps extends NodeCheckboxRenderProps {
|
|
59
|
+
onVisibilityToggled?: (enabled: boolean) => void;
|
|
60
|
+
}
|
|
54
61
|
/**
|
|
55
62
|
* Checkbox renderer that renders an eye.
|
|
56
63
|
* @public
|
|
57
64
|
*/
|
|
58
|
-
export declare function VisibilityTreeNodeCheckbox(props:
|
|
65
|
+
export declare function VisibilityTreeNodeCheckbox(props: VisibilityTreeNodeCheckboxProps): JSX.Element;
|
|
59
66
|
/**
|
|
60
67
|
* Props for [[FilterableVisibilityTreeNodeRenderer]].
|
|
61
68
|
* @beta
|
|
@@ -65,7 +72,7 @@ export type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNod
|
|
|
65
72
|
* Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.
|
|
66
73
|
* @beta
|
|
67
74
|
*/
|
|
68
|
-
export declare function FilterableVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, isEnlarged, ...restProps }: FilterableVisibilityTreeNodeRendererProps): JSX.Element;
|
|
75
|
+
export declare function FilterableVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, isEnlarged, onVisibilityToggled, ...restProps }: FilterableVisibilityTreeNodeRendererProps): JSX.Element;
|
|
69
76
|
/**
|
|
70
77
|
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
71
78
|
* @public
|
|
@@ -89,4 +96,5 @@ export interface VisibilityTreeNoFilteredDataProps {
|
|
|
89
96
|
* @public
|
|
90
97
|
*/
|
|
91
98
|
export declare function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps): JSX.Element;
|
|
99
|
+
export {};
|
|
92
100
|
//# sourceMappingURL=VisibilityTreeRenderer.d.ts.map
|
|
@@ -38,10 +38,10 @@ exports.createVisibilityTreeRenderer = createVisibilityTreeRenderer;
|
|
|
38
38
|
* Creates node renderer which renders node with eye checkbox.
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
41
|
-
function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, }) {
|
|
41
|
+
function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, onVisibilityToggled, }) {
|
|
42
42
|
return function VisibilityTreeNodeRenderer(treeNodeProps) {
|
|
43
43
|
const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);
|
|
44
|
-
return ((0, jsx_runtime_1.jsx)(components_react_1.TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: (0, classnames_1.default)("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(components_react_1.TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: (0, classnames_1.default)("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
|
|
@@ -50,17 +50,20 @@ exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
|
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
52
|
function VisibilityTreeNodeCheckbox(props) {
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { className: "visibility-tree-checkbox", variant: "eyeball", checked: props.checked, onChange: (e) =>
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { className: "visibility-tree-checkbox", variant: "eyeball", checked: props.checked, onChange: (e) => {
|
|
54
|
+
props.onVisibilityToggled?.(e.currentTarget.checked);
|
|
55
|
+
props.onChange(e.currentTarget.checked);
|
|
56
|
+
}, onMouseDown: (e) => e.stopPropagation(), onClick: props.onClick, disabled: props.disabled, title: props.title }));
|
|
54
57
|
}
|
|
55
58
|
exports.VisibilityTreeNodeCheckbox = VisibilityTreeNodeCheckbox;
|
|
56
59
|
/**
|
|
57
60
|
* Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.
|
|
58
61
|
* @beta
|
|
59
62
|
*/
|
|
60
|
-
function FilterableVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse, descriptionEnabled, isEnlarged, ...restProps }) {
|
|
63
|
+
function FilterableVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse, descriptionEnabled, isEnlarged, onVisibilityToggled, ...restProps }) {
|
|
61
64
|
const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;
|
|
62
65
|
const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);
|
|
63
|
-
return ((0, jsx_runtime_1.jsx)(presentation_components_1.PresentationTreeNodeRenderer, { ...restProps, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps }) })), descriptionEnabled: descriptionEnabled, imageLoader: imageLoader, className: (0, classnames_1.default)("with-checkbox", (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && "disable-expander") }));
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(presentation_components_1.PresentationTreeNodeRenderer, { ...restProps, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: imageLoader, className: (0, classnames_1.default)("with-checkbox", (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && "disable-expander") }));
|
|
64
67
|
}
|
|
65
68
|
exports.FilterableVisibilityTreeNodeRenderer = FilterableVisibilityTreeNodeRenderer;
|
|
66
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,4DAAoC;AACpC,iCAAkC;AAClC,8DAA4E;AAC5E,wDAAgD;AAChD,4EAAsH;AACtH,wDAAqD;AAOrD;;;;;GAKG;AACH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AC3C,iCAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,iCAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: NodeCheckboxRenderProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => props.onChange(e.currentTarget.checked)}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function useVisibilityTreeFiltering(\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,4DAAoC;AACpC,iCAAkC;AAClC,8DAA4E;AAC5E,wDAAgD;AAChD,4EAAsH;AACtH,wDAAqD;AAOrD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,kCAAe,EAAE,CAAC;AA6C1C;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAA+B;IAC3G,OAAO,SAAS,sBAAsB,CAAC,S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,EAAC,8BAA8B,aAC3C,iCAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,iCAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n /**\n * Callback called when visibility is toggled using a checkbox.\n */\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n onVisibilityToggled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\ninterface VisibilityTreeNodeCheckboxProps extends NodeCheckboxRenderProps {\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: VisibilityTreeNodeCheckboxProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => {\n props.onVisibilityToggled?.(e.currentTarget.checked);\n props.onChange(e.currentTarget.checked);\n }}\n onMouseDown={(e) => e.stopPropagation()}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n onVisibilityToggled,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function useVisibilityTreeFiltering(\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
|
|
@@ -45,6 +45,12 @@ export interface CategoryTreeProps extends BaseFilterableTreeProps {
|
|
|
45
45
|
* @beta
|
|
46
46
|
*/
|
|
47
47
|
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Callback that is invoked when a tracked feature is used.
|
|
50
|
+
* @param featureId ID of the feature.
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
onFeatureUsed?: (feature: string) => void;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Tree which displays and manages display of categories contained in an iModel.
|