@itwin/presentation-hierarchies-react 2.0.0-alpha.56 → 2.0.0-alpha.58
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 +178 -36
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts +2 -2
- package/lib/presentation-hierarchies-react/UseIModelTree.js +1 -2
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +1 -2
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -2
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +1 -2
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/presentation-hierarchies-react/UseTree.d.ts +2 -2
- package/lib/presentation-hierarchies-react/UseTree.js +1 -2
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/presentation-hierarchies-react/Utils.js +1 -1
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +2 -2
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +1 -1
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +1 -2
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +1 -2
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -2
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +1 -1
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -2
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +1 -2
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/presentation-hierarchies-react/internal/Utils.js +1 -2
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +2 -3
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -4
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +1 -2
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react.js +1 -2
- package/package.json +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.58
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1236](https://github.com/iTwin/presentation/pull/1236): Start using tree structure for defining hierarchy search paths.
|
|
8
|
+
|
|
9
|
+
The expected return type of `useTree` hooks' `getSearchPaths` callback prop has changed from `Promise<HierarchySearchPath[] | undefined>` to `Promise<HierarchySearchTree[] | undefined>`. The newly added `HierarchySearchTree.createFromPathsList` from `@itwin/presentation-hierarchies` can be used to do the conversion:`
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { HierarchySearchTree } from "@itwin/presentation-hierarchies";
|
|
13
|
+
|
|
14
|
+
function MyTree() {
|
|
15
|
+
const [searchText, setSearchText] = useState("");
|
|
16
|
+
const treeProps = useIModelUnifiedSelectionTree({
|
|
17
|
+
// ...
|
|
18
|
+
getSearchPaths: useMemo<UseIModelTreeProps["getSearchPaths"]>(() => {
|
|
19
|
+
return async () => {
|
|
20
|
+
// before
|
|
21
|
+
return getSearchTargetPaths({ searchText }),
|
|
22
|
+
// after
|
|
23
|
+
return HierarchySearchTree.createFromPathsList(await getSearchTargetPaths({ searchText }));
|
|
24
|
+
};
|
|
25
|
+
}, [searchText]),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// ...
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<StrataKitTreeRenderer
|
|
32
|
+
{...treeProps.treeRendererProps}
|
|
33
|
+
// ...
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies:
|
|
42
|
+
- @itwin/unified-selection@1.6.9-alpha.0
|
|
43
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.13
|
|
44
|
+
- @itwin/presentation-shared@2.0.0-alpha.9
|
|
45
|
+
|
|
46
|
+
## 2.0.0-alpha.57
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- [#1238](https://github.com/iTwin/presentation/pull/1238): Fix root nodes with errors not being counted when collapsed
|
|
51
|
+
|
|
3
52
|
## 2.0.0-alpha.56
|
|
4
53
|
|
|
5
54
|
### Minor Changes
|
|
@@ -13,6 +62,7 @@
|
|
|
13
62
|
- [#1223](https://github.com/iTwin/presentation/pull/1223): Reworked `localization` to use `i18next`-compatible approach. Instead of passing a `localizedStrings` object into `LocalizationContextProvider`, the package now delivers an English locale JSON file and resolves strings through a `getLocalizedString` function at runtime.
|
|
14
63
|
|
|
15
64
|
**Breaking changes**
|
|
65
|
+
|
|
16
66
|
- `LocalizationContextProvider` no longer accepts a `localizedStrings` object. It now requires a `localization` prop — an object with a `getLocalizedString(key: string): string` method (compatible with `Localization` from @itwin/core-common).
|
|
17
67
|
- `LOCALIZATION_NAMESPACES` must be registered with your localization provider during app initialization to make localized strings available.
|
|
18
68
|
|
|
@@ -74,6 +124,7 @@
|
|
|
74
124
|
- [#1184](https://github.com/iTwin/presentation/pull/1184): Fixed selection handling in `StrataKitTreeRenderer`. Mouse double clicks are now correctly ignored to prevent rapid selection toggling. Keyboard selection using `Space` and `Enter` keys is working.
|
|
75
125
|
|
|
76
126
|
**Breaking changes**
|
|
127
|
+
|
|
77
128
|
- `useSelectionHandler` is no longer exported. This function is an internal implementation detail of `StrataKitTreeRenderer` and should not be used directly.
|
|
78
129
|
|
|
79
130
|
- [#1181](https://github.com/iTwin/presentation/pull/1181): **Breaking change:** Rename `PresentationHierarchyNode` to `TreeNode` for clarity.
|
|
@@ -83,6 +134,7 @@
|
|
|
83
134
|
- [#1183](https://github.com/iTwin/presentation/pull/1183): Clean up `TreeErrorRenderer` and `ErrorItemRenderer`.
|
|
84
135
|
|
|
85
136
|
**Breaking changes:**
|
|
137
|
+
|
|
86
138
|
- Replaced `useErrorList` hook with `useErrorNodes` hook that returns error nodes (`TreeNode[]`) instead of error items. The `expandTo` function became unnecessary, because expanding to error nodes is now handled internally. As a result, the whole `ErrorItem` type (result of `useErrorList`) was removed. Reacting to this, the following other breaking changes were made:
|
|
87
139
|
- Renamed `errorItem` -> `errorNode` in `ErrorItemRenderer` component and changed the type from removed `ErrorItem` to `TreeNode`.
|
|
88
140
|
- Renamed `errorList` -> `errorNodes` in `TreeErrorRenderer` component and changed the type from `ErrorItem[]` to `TreeNode[]`.
|
|
@@ -99,7 +151,10 @@
|
|
|
99
151
|
Example:
|
|
100
152
|
|
|
101
153
|
```tsx
|
|
102
|
-
import {
|
|
154
|
+
import {
|
|
155
|
+
StrataKitTreeRenderer,
|
|
156
|
+
StrataKitTreeRendererAttributes,
|
|
157
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
103
158
|
|
|
104
159
|
function MyTree() {
|
|
105
160
|
const treeRef = useRef<StrataKitTreeRendererAttributes>(null);
|
|
@@ -109,7 +164,9 @@
|
|
|
109
164
|
<div className="tree-header">
|
|
110
165
|
<button
|
|
111
166
|
onClick={() => {
|
|
112
|
-
treeRef.current?.renameNode(
|
|
167
|
+
treeRef.current?.renameNode(
|
|
168
|
+
(node) => node.label === "Node to rename"
|
|
169
|
+
);
|
|
113
170
|
}}
|
|
114
171
|
>
|
|
115
172
|
Rename node
|
|
@@ -122,11 +179,13 @@
|
|
|
122
179
|
```
|
|
123
180
|
|
|
124
181
|
**Breaking changes**
|
|
182
|
+
|
|
125
183
|
- `StrataKitTreeNodeRenderer` is no longer exported.
|
|
126
184
|
- `RenameContextProvider` is no longer exported. It is not necessary when using `StrataKitTreeRenderer`.
|
|
127
185
|
- `RenameAction` now requires a `node` prop.
|
|
128
186
|
|
|
129
187
|
- [#1179](https://github.com/iTwin/presentation/pull/1179): **Breaking change:** Rename tree node action components for clarity.
|
|
188
|
+
|
|
130
189
|
- `FilterAction` -> `TreeNodeFilterAction`
|
|
131
190
|
- `RenameAction` -> `TreeNodeRenameAction`
|
|
132
191
|
|
|
@@ -137,7 +196,9 @@
|
|
|
137
196
|
```tsx
|
|
138
197
|
type TreeRendererProps = ComponentProps<typeof StrataKitTreeRenderer>;
|
|
139
198
|
|
|
140
|
-
const getEditingProps = useCallback<
|
|
199
|
+
const getEditingProps = useCallback<
|
|
200
|
+
Required<TreeRendererProps>["getEditingProps"]
|
|
201
|
+
>((node) => {
|
|
141
202
|
return {
|
|
142
203
|
onLabelChanged: (newLabel: string) => {
|
|
143
204
|
// Handle label change
|
|
@@ -147,10 +208,13 @@
|
|
|
147
208
|
};
|
|
148
209
|
}, []);
|
|
149
210
|
|
|
150
|
-
return
|
|
211
|
+
return (
|
|
212
|
+
<StrataKitTreeRenderer {...treeProps} getEditingProps={getEditingProps} />
|
|
213
|
+
);
|
|
151
214
|
```
|
|
152
215
|
|
|
153
216
|
**Breaking changes**
|
|
217
|
+
|
|
154
218
|
- `getEditingProps` callback was changed to require `onLabelChanged`. If node does not support renaming `getEditingProps` should return `undefined`.
|
|
155
219
|
|
|
156
220
|
### Patch Changes
|
|
@@ -169,6 +233,7 @@
|
|
|
169
233
|
**Breaking changes**
|
|
170
234
|
|
|
171
235
|
`StrataKitTreeNodeRenderer` props changes:
|
|
236
|
+
|
|
172
237
|
- `getMenuActions` callback changed to `menuActions` prop (type: `ReactNode[]`)
|
|
173
238
|
- `getInlineActions` callback changed to `inlineActions` prop (type: `ReactNode[]`)
|
|
174
239
|
- `getContextMenuActions` callback changed to `contextMenuActions` prop (type: `ReactNode[]`)
|
|
@@ -179,6 +244,7 @@
|
|
|
179
244
|
- `onNodeClick` and `onNodeKeyDown` callbacks removed - use `onClick` and `onKeyDown` props instead
|
|
180
245
|
|
|
181
246
|
`StrataKitTreeRenderer` props changes:
|
|
247
|
+
|
|
182
248
|
- Props previously passed to `StrataKitTreeNodeRenderer` are no longer accepted
|
|
183
249
|
- Use `getTreeItemProps` callback to provide props to specific `Tree.Item` components
|
|
184
250
|
- Use `getMenuActions`, `getInlineActions`, and `getContextMenuActions` on `StrataKitTreeRenderer` to provide actions for nodes
|
|
@@ -244,13 +310,19 @@
|
|
|
244
310
|
- [#1113](https://github.com/iTwin/presentation/pull/1113): Pass selected nodes to tree node action getters to support actions that should be applied on all selected nodes.
|
|
245
311
|
|
|
246
312
|
**Breaking changes**
|
|
313
|
+
|
|
247
314
|
- `StrataKitTreeRenderer.getInlineActions` callback receives `{ targetNode: PresentationHierarchyNode; selectedNodes: PresentationHierarchyNode[] }` props instead of `PresentationHierarchyNode`.
|
|
248
315
|
- `StrataKitTreeRenderer.getMenuActions` callback receives `{ targetNode: PresentationHierarchyNode; selectedNodes: PresentationHierarchyNode[] }` props instead of `PresentationHierarchyNode`.
|
|
249
316
|
|
|
250
317
|
Before
|
|
251
318
|
|
|
252
319
|
```tsx
|
|
253
|
-
return
|
|
320
|
+
return (
|
|
321
|
+
<StrataKitTreeRenderer
|
|
322
|
+
getInlineActions={(node) => [<InlineAction node={node} />]}
|
|
323
|
+
getMenuActions={(node) => [<MenuAction node={node} />]}
|
|
324
|
+
/>
|
|
325
|
+
);
|
|
254
326
|
```
|
|
255
327
|
|
|
256
328
|
After
|
|
@@ -258,7 +330,9 @@
|
|
|
258
330
|
```tsx
|
|
259
331
|
return (
|
|
260
332
|
<StrataKitTreeRenderer
|
|
261
|
-
getInlineActions={({ targetNode }) => [
|
|
333
|
+
getInlineActions={({ targetNode }) => [
|
|
334
|
+
<InlineAction node={targetNode} />,
|
|
335
|
+
]}
|
|
262
336
|
getMenuActions={({ targetNode }) => [<MenuAction node={targetNode} />]}
|
|
263
337
|
/>
|
|
264
338
|
);
|
|
@@ -267,6 +341,7 @@
|
|
|
267
341
|
- [#1115](https://github.com/iTwin/presentation/pull/1115): Unified tree actions handling to make it easier defining actions that could be reused in different contexts: inline, context menu and actions dropdown.
|
|
268
342
|
|
|
269
343
|
**Breaking changes**
|
|
344
|
+
|
|
270
345
|
- Removed `reserveSpace` property from `<RenameAction />` and `<FilterAction />`. These actions now automatically infer the context they're used in.
|
|
271
346
|
- Added requirement to render newly introduced `<TreeActionBase />` component instead of `<Tree.ItemAction />` when rendering custom tree actions.
|
|
272
347
|
|
|
@@ -316,6 +391,7 @@
|
|
|
316
391
|
### Major Changes
|
|
317
392
|
|
|
318
393
|
- [#1094](https://github.com/iTwin/presentation/pull/1094): Improve custom errors rendering API:
|
|
394
|
+
|
|
319
395
|
- Separated `ChildrenLoad` error from the `Unknown` error. All expected tree errors have dedicated type and `Unknown` error can be used to handle custom errors encountered outside of tree.
|
|
320
396
|
- Exposed `ErrorItemRenderer` that renders all error types supported by the tree.
|
|
321
397
|
- Updated `TreeErrorRenderer` to pass all props necessary to render `ErrorItemRenderer` into `renderError` callback.
|
|
@@ -333,7 +409,12 @@
|
|
|
333
409
|
{...errorProps}
|
|
334
410
|
renderError={(errorItemProps) => {
|
|
335
411
|
if (errorItemProps.errorItem.errorNode.error.type === "Unknown") {
|
|
336
|
-
return
|
|
412
|
+
return (
|
|
413
|
+
<ErrorRegion.Item
|
|
414
|
+
message="Custom error"
|
|
415
|
+
messageId={errorItemProps.errorItem.errorNode.id}
|
|
416
|
+
/>
|
|
417
|
+
);
|
|
337
418
|
}
|
|
338
419
|
return <ErrorItemRenderer {...errorItemProps} />;
|
|
339
420
|
}}
|
|
@@ -350,6 +431,7 @@
|
|
|
350
431
|
- [#1075](https://github.com/iTwin/presentation/pull/1075): Fix accessibility issues in `<TreeErrorRenderer />`.
|
|
351
432
|
|
|
352
433
|
This involves a few localized string changes:
|
|
434
|
+
|
|
353
435
|
- Added `issuesForTree`, defaulting to "Issues for {{tree_label}}.", used as a region landmark label for the error message container.
|
|
354
436
|
- Added `noIssuesFound`, defaulting to "No issues found.", used as a label for errors' list when there are no issues.
|
|
355
437
|
- Changed `issuesFound` to default to "{{number_of_issues}} issue(s) found.", and updated its usage to inject the number of issues found into the string instead of prefixing it before the string, which allows to place the number at any place in the string (may be a requirement for some languages). This is **a breaking change** for anyone, supplying their own localized strings.
|
|
@@ -384,13 +466,19 @@
|
|
|
384
466
|
Example usage:
|
|
385
467
|
|
|
386
468
|
```ts
|
|
387
|
-
import {
|
|
469
|
+
import {
|
|
470
|
+
StrataKitTreeRenderer,
|
|
471
|
+
useNodeHighlighting,
|
|
472
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
388
473
|
|
|
389
|
-
type BaseTreeRendererProps = React.ComponentPropsWithoutRef<
|
|
474
|
+
type BaseTreeRendererProps = React.ComponentPropsWithoutRef<
|
|
475
|
+
typeof StrataKitTreeRenderer
|
|
476
|
+
>;
|
|
390
477
|
|
|
391
478
|
function MyComponent(props: BaseTreeRendererProps & { searchText: string }) {
|
|
392
479
|
// Create highlight based on searchText
|
|
393
|
-
const highlightText =
|
|
480
|
+
const highlightText =
|
|
481
|
+
props.searchText !== "" ? props.searchText : undefined;
|
|
394
482
|
const { getLabel } = useNodeHighlighting({ highlightText });
|
|
395
483
|
|
|
396
484
|
// Provide getLabel function to tree renderer
|
|
@@ -437,6 +525,7 @@
|
|
|
437
525
|
- [#1023](https://github.com/iTwin/presentation/pull/1023): Split `getActions` into `getMenuActions` & `getInlineActions` for `StrataKitTreeRenderer` and `StrataKitTreeNodeRenderer`.
|
|
438
526
|
|
|
439
527
|
Updated peer dependencies:
|
|
528
|
+
|
|
440
529
|
- @stratakit/bricks@0.3.3
|
|
441
530
|
- @stratakit/foundations@0.2.2
|
|
442
531
|
- @stratakit/structures@0.3.1
|
|
@@ -491,12 +580,14 @@
|
|
|
491
580
|
### Major Changes
|
|
492
581
|
|
|
493
582
|
- [#961](https://github.com/iTwin/presentation/pull/961): **Breaking changes** to tree state hooks `useTree`, `useUnifiedSelectionTree`, `useIModelTree`, `useIModelUnifiedSelectionTree`:
|
|
583
|
+
|
|
494
584
|
- All tree rendering props have been moved under `treeRendererProps`. The value can be passed to `<StrataKitTreeRenderer />` component.
|
|
495
585
|
- In case an error occurs while loading the root hierarchy level, instead of `treeRendererProps`, the `rootErrorRendererProps` are set, which can be passed to `<StrataKitRootErrorRenderer />` component to render the error state.
|
|
496
586
|
- The `isLoading` attribute has been renamed to `isReloading`.
|
|
497
587
|
- Errors are no longer defined as children of `PresentationHierarchyNode` and instead are now included as `error` attribute for more fluent API.
|
|
498
588
|
|
|
499
589
|
When rendering tree state, the recommended order of checks is:
|
|
590
|
+
|
|
500
591
|
1. If `rootErrorRendererProps` is defined, there was an error - render error state.
|
|
501
592
|
2. If `treeRendererProps` is not defined, the component is doing the initial load - render loading state.
|
|
502
593
|
3. If `treeRendererProps` is defined, the hierarchy is loaded - render the tree component.
|
|
@@ -535,6 +626,7 @@
|
|
|
535
626
|
### Major Changes
|
|
536
627
|
|
|
537
628
|
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
629
|
+
|
|
538
630
|
- `EC.Schema`, `EC.Class` and `EC.Property` now all have an async `getCustomAttributes()` method that returns an `EC.CustomAttributeSet`, allowing consumers to access custom attributes of these schema items.
|
|
539
631
|
- `EC.Class` now additionally has these members:
|
|
540
632
|
- `baseClass: Promise<Class | undefined>`
|
|
@@ -575,6 +667,7 @@
|
|
|
575
667
|
### Major Changes
|
|
576
668
|
|
|
577
669
|
- [#942](https://github.com/iTwin/presentation/pull/942): Unified selection API cleanup.
|
|
670
|
+
|
|
578
671
|
- Remove deprecated `UnifiedSelectionProvider`.
|
|
579
672
|
- Make `selectionStorage` prop required for unified selection - enabled tree state hooks (`useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree`).
|
|
580
673
|
|
|
@@ -587,7 +680,10 @@
|
|
|
587
680
|
Before:
|
|
588
681
|
|
|
589
682
|
```tsx
|
|
590
|
-
import {
|
|
683
|
+
import {
|
|
684
|
+
TreeNodeRenderer,
|
|
685
|
+
useFilterAction,
|
|
686
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
591
687
|
|
|
592
688
|
const filterAction = useFilterAction({ onFilter, getHierarchyLevelDetails });
|
|
593
689
|
return (
|
|
@@ -601,7 +697,7 @@
|
|
|
601
697
|
icon: customIconHref,
|
|
602
698
|
}),
|
|
603
699
|
],
|
|
604
|
-
[filterAction]
|
|
700
|
+
[filterAction]
|
|
605
701
|
)}
|
|
606
702
|
/>
|
|
607
703
|
);
|
|
@@ -611,16 +707,29 @@
|
|
|
611
707
|
|
|
612
708
|
```tsx
|
|
613
709
|
import { Icon, Tree } from "@itwin/itwinui-react";
|
|
614
|
-
import {
|
|
710
|
+
import {
|
|
711
|
+
FilterAction,
|
|
712
|
+
TreeNodeRenderer,
|
|
713
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
615
714
|
|
|
616
715
|
return (
|
|
617
716
|
<TreeNodeRenderer
|
|
618
717
|
getActions={useCallback(
|
|
619
718
|
(node) => [
|
|
620
|
-
<FilterAction
|
|
621
|
-
|
|
719
|
+
<FilterAction
|
|
720
|
+
key="filter"
|
|
721
|
+
node={node}
|
|
722
|
+
onFilter={onFilter}
|
|
723
|
+
getHierarchyLevelDetails={getHierarchyLevelDetails}
|
|
724
|
+
/>,
|
|
725
|
+
<Tree.ItemAction
|
|
726
|
+
key="customAction"
|
|
727
|
+
label="Custom action"
|
|
728
|
+
onClick={() => log(node.label)}
|
|
729
|
+
icon={<Icon href={customIconHref} />}
|
|
730
|
+
/>,
|
|
622
731
|
],
|
|
623
|
-
[onFilter, getHierarchyLevelDetails]
|
|
732
|
+
[onFilter, getHierarchyLevelDetails]
|
|
624
733
|
)}
|
|
625
734
|
/>
|
|
626
735
|
);
|
|
@@ -635,10 +744,10 @@
|
|
|
635
744
|
|
|
636
745
|
```ts
|
|
637
746
|
<TreeRenderer
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
747
|
+
{...treeProps}
|
|
748
|
+
errorRenderer={(errorsRendererProps) => (
|
|
749
|
+
<MyErrorRenderer {...errorsRendererProps} />
|
|
750
|
+
)}
|
|
642
751
|
/>
|
|
643
752
|
```
|
|
644
753
|
|
|
@@ -664,10 +773,10 @@
|
|
|
664
773
|
|
|
665
774
|
```ts
|
|
666
775
|
<TreeRenderer
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
776
|
+
{...treeProps}
|
|
777
|
+
rootErrorRenderer={(rootErrorRendererProps) => (
|
|
778
|
+
<MyRootErrorRenderer {...rootErrorRendererProps} />
|
|
779
|
+
)}
|
|
671
780
|
/>
|
|
672
781
|
```
|
|
673
782
|
|
|
@@ -771,11 +880,13 @@
|
|
|
771
880
|
### Minor Changes
|
|
772
881
|
|
|
773
882
|
- [#878](https://github.com/iTwin/presentation/pull/878): Tree node renderer now uses `Tree.ItemAction`. `Show` property now takes in undefined values, values behave like this:
|
|
883
|
+
|
|
774
884
|
- `undefined` - visible on hover/focus,
|
|
775
885
|
- `true` - visible at all times,
|
|
776
886
|
- `false` - hidden at all times.
|
|
777
887
|
|
|
778
888
|
Updated peer dependencies:
|
|
889
|
+
|
|
779
890
|
- itwinui-icons to 5.0.0-alpha.3,
|
|
780
891
|
- itwinui-react to 5.0.0-alpha.6,
|
|
781
892
|
|
|
@@ -805,6 +916,7 @@
|
|
|
805
916
|
- [#862](https://github.com/iTwin/presentation/pull/862): Update `@itwin/itwinui-react` dependency to `5.0.0-alpha.3`.
|
|
806
917
|
|
|
807
918
|
This fixes the following issues:
|
|
919
|
+
|
|
808
920
|
- nodes being selected on expand,
|
|
809
921
|
- node action buttons being rendered incorrectly.
|
|
810
922
|
|
|
@@ -814,6 +926,17 @@
|
|
|
814
926
|
|
|
815
927
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
816
928
|
|
|
929
|
+
## 1.9.13
|
|
930
|
+
|
|
931
|
+
### Patch Changes
|
|
932
|
+
|
|
933
|
+
- [#1242](https://github.com/iTwin/presentation/pull/1242): Bump dependencies.
|
|
934
|
+
- [#1252](https://github.com/iTwin/presentation/pull/1252): Fix tree node outline not appearing on touch devices.
|
|
935
|
+
- Updated dependencies:
|
|
936
|
+
- @itwin/presentation-hierarchies@1.7.11
|
|
937
|
+
- @itwin/presentation-shared@1.2.10
|
|
938
|
+
- @itwin/unified-selection@1.6.8
|
|
939
|
+
|
|
817
940
|
## 1.9.12
|
|
818
941
|
|
|
819
942
|
### Patch Changes
|
|
@@ -942,9 +1065,17 @@
|
|
|
942
1065
|
|
|
943
1066
|
const treeState = useUnifiedSelectionTree({
|
|
944
1067
|
selectionStorage,
|
|
945
|
-
createSelectableForGenericNode: useCallback<
|
|
946
|
-
|
|
947
|
-
|
|
1068
|
+
createSelectableForGenericNode: useCallback<
|
|
1069
|
+
NonNullable<
|
|
1070
|
+
Props<typeof useUnifiedSelectionTree>["createSelectableForGenericNode"]
|
|
1071
|
+
>
|
|
1072
|
+
>(
|
|
1073
|
+
(node, uniqueId) => ({
|
|
1074
|
+
identifier: node.key.id,
|
|
1075
|
+
data: node,
|
|
1076
|
+
async *loadInstanceKeys() {},
|
|
1077
|
+
}),
|
|
1078
|
+
[]
|
|
948
1079
|
),
|
|
949
1080
|
// ...other options
|
|
950
1081
|
});
|
|
@@ -1051,6 +1182,7 @@
|
|
|
1051
1182
|
### Minor Changes
|
|
1052
1183
|
|
|
1053
1184
|
- [#841](https://github.com/iTwin/presentation/pull/841): Changed how tree state hooks access unified selection storage.
|
|
1185
|
+
|
|
1054
1186
|
- The tree state hooks that hook into unified selection system now accept a `selectionStorage` prop. At the moment the prop is optional, but will be made required in the next major release of the package.
|
|
1055
1187
|
- The `UnifiedSelectionProvider` React context provider is now deprecated. The context is still used by tree state hooks if the selection storage is not provided through prop.
|
|
1056
1188
|
|
|
@@ -1126,7 +1258,11 @@
|
|
|
1126
1258
|
Example usage:
|
|
1127
1259
|
|
|
1128
1260
|
```tsx
|
|
1129
|
-
function MyTreeComponentInternal({
|
|
1261
|
+
function MyTreeComponentInternal({
|
|
1262
|
+
imodelAccess,
|
|
1263
|
+
}: {
|
|
1264
|
+
imodelAccess: IModelAccess;
|
|
1265
|
+
}) {
|
|
1130
1266
|
const {
|
|
1131
1267
|
rootNodes,
|
|
1132
1268
|
getNode,
|
|
@@ -1141,18 +1277,22 @@
|
|
|
1141
1277
|
async (nodeId: string, isExpanded: boolean) => {
|
|
1142
1278
|
const node = getNode(nodeId);
|
|
1143
1279
|
if (node) {
|
|
1144
|
-
console.log(
|
|
1280
|
+
console.log(
|
|
1281
|
+
`${isExpanded ? "Expanding" : "Collapsing"} node: ${node.label}`
|
|
1282
|
+
);
|
|
1145
1283
|
}
|
|
1146
1284
|
doExpandNode(nodeId, isExpanded);
|
|
1147
1285
|
},
|
|
1148
|
-
[getNode, doExpandNode]
|
|
1286
|
+
[getNode, doExpandNode]
|
|
1149
1287
|
);
|
|
1150
1288
|
|
|
1151
1289
|
// render the tree
|
|
1152
1290
|
if (!rootNodes || !rootNodes.length) {
|
|
1153
1291
|
return "No data to display";
|
|
1154
1292
|
}
|
|
1155
|
-
return
|
|
1293
|
+
return (
|
|
1294
|
+
<TreeRenderer {...state} expandNode={expandNode} rootNodes={rootNodes} />
|
|
1295
|
+
);
|
|
1156
1296
|
}
|
|
1157
1297
|
```
|
|
1158
1298
|
|
|
@@ -1306,6 +1446,7 @@
|
|
|
1306
1446
|
See "Basic example" section in README learning page for the full example.
|
|
1307
1447
|
|
|
1308
1448
|
- [#717](https://github.com/iTwin/presentation/pull/717): **BREAKING:** Add support for non-iModel-driven trees.
|
|
1449
|
+
|
|
1309
1450
|
- `useTree` and `useUnifiedSelectionTree` hooks have been changed to support non-iModel-driven trees. The hooks take a `getHierarchyProvider` prop, which returns a `HierarchyProvider`. The provider can return data from any data source.
|
|
1310
1451
|
- New `useIModelTree` and `useIModelUnifiedSelectionTree` hooks have been added to cover the most common case, where a tree is created from a iModel's data. The API of these hooks is exactly the same as of the old `useTree` and `useUnifiedSelectionTree` hooks.
|
|
1311
1452
|
|
|
@@ -1498,11 +1639,12 @@
|
|
|
1498
1639
|
const hierarchyLevelDetails = getHierarchyLevelDetails(nodeId);
|
|
1499
1640
|
someFunc(hierarchyLevelDetails);
|
|
1500
1641
|
}}
|
|
1501
|
-
|
|
1502
1642
|
// After the change
|
|
1503
1643
|
onNodeClick={(node, isSelected, event) => someFunc(node.id)}
|
|
1504
1644
|
onNodeKeyDown={(node, isSelected, event) => someFunc(node.id)}
|
|
1505
|
-
onFilterClick={(hierarchyLevelDetails) =>
|
|
1645
|
+
onFilterClick={(hierarchyLevelDetails) =>
|
|
1646
|
+
someFunc(hierarchyLevelDetails)
|
|
1647
|
+
}
|
|
1506
1648
|
/>
|
|
1507
1649
|
);
|
|
1508
1650
|
}
|
|
@@ -1535,7 +1677,7 @@
|
|
|
1535
1677
|
...props,
|
|
1536
1678
|
onHierarchyLimitExceeded: ({ nodeId, filter, limit }) => {
|
|
1537
1679
|
console.log(`Hierarchy limit of ${limit} exceeded for node ${nodeId}.`);
|
|
1538
|
-
}
|
|
1680
|
+
},
|
|
1539
1681
|
});
|
|
1540
1682
|
return <TreeRenderer {...state} />;
|
|
1541
1683
|
}
|
|
@@ -1546,7 +1688,7 @@
|
|
|
1546
1688
|
```ts
|
|
1547
1689
|
import { registerTxnListeners } from "@itwin/presentation-core-interop";
|
|
1548
1690
|
|
|
1549
|
-
function MyTree({ imodel, ...props}: Props) {
|
|
1691
|
+
function MyTree({ imodel, ...props }: Props) {
|
|
1550
1692
|
const { reloadTree, treeProps } = useTree(props);
|
|
1551
1693
|
useEffect(() => {
|
|
1552
1694
|
// listen for changes in iModel and reload tree
|
|
@@ -1572,7 +1714,7 @@
|
|
|
1572
1714
|
...props,
|
|
1573
1715
|
onPerformanceMeasured: (action, duration) => {
|
|
1574
1716
|
telemetryClient.log(`MyTree [${feature}] took ${duration} ms`);
|
|
1575
|
-
}
|
|
1717
|
+
},
|
|
1576
1718
|
});
|
|
1577
1719
|
return <TreeRenderer {...state} />;
|
|
1578
1720
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
|
|
2
2
|
import { UseTreeProps, UseTreeResult } from "./UseTree.js";
|
|
3
|
-
import { HierarchyDefinition,
|
|
3
|
+
import { HierarchyDefinition, HierarchySearchTree, createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
4
4
|
import { Props } from "@itwin/presentation-shared";
|
|
5
5
|
|
|
6
6
|
//#region src/presentation-hierarchies-react/UseIModelTree.d.ts
|
|
@@ -31,7 +31,7 @@ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearch
|
|
|
31
31
|
* Signal indicating that that the request was canceled
|
|
32
32
|
*/
|
|
33
33
|
abortSignal: AbortSignal;
|
|
34
|
-
}) => Promise<
|
|
34
|
+
}) => Promise<HierarchySearchTree[] | undefined>;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
@@ -2,7 +2,6 @@ import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
|
|
|
2
2
|
import { useTranslation } from "./stratakit/LocalizationContext.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
5
|
-
|
|
6
5
|
//#region src/presentation-hierarchies-react/UseIModelTree.ts
|
|
7
6
|
/**
|
|
8
7
|
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
@@ -178,7 +177,7 @@ function useIModelTreeProps(props) {
|
|
|
178
177
|
} else t4 = $[10];
|
|
179
178
|
return t4;
|
|
180
179
|
}
|
|
181
|
-
|
|
182
180
|
//#endregion
|
|
183
181
|
export { useIModelTree, useIModelUnifiedSelectionTree };
|
|
182
|
+
|
|
184
183
|
//# sourceMappingURL=UseIModelTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","
|
|
1
|
+
{"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","HierarchySearchTree","Props","UseUnifiedTreeSelectionProps","UseTreeProps","UseTreeResult","IModelHierarchyProviderProps","IModelAccess","UseIModelTreeProps","Omit","Pick","getHierarchyDefinition","props","imodelAccess","getSearchPaths","abortSignal","AbortSignal","Promise","useIModelTree","$","_c","imodelChanged","rest","t0","t1","useIModelTreeProps","t2","useIModelUnifiedSelectionTree","translate","hierarchyDefinition","localizedStrings","other","unspecified","t3","t4","getHierarchyProvider"],"sources":["../../src/presentation-hierarchies-react/UseIModelTree.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { createIModelHierarchyProvider } from \"@itwin/presentation-hierarchies\";\nimport { useTranslation } from \"./stratakit/LocalizationContext.js\";\nimport { useTree, useUnifiedSelectionTree } from \"./UseTree.js\";\n\nimport type { HierarchyDefinition, HierarchySearchTree } from \"@itwin/presentation-hierarchies\";\nimport type { Props } from \"@itwin/presentation-shared\";\nimport type { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport type { UseTreeProps, UseTreeResult } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> &\n Pick<IModelHierarchyProviderProps, \"imodelAccess\" | \"imodelChanged\"> & {\n /**\n * Provides the hierarchy definition for the tree.\n */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /**\n * Provides paths to target nodes.\n */\n getSearchPaths?: (props: {\n /**\n * Object that provides access to the iModel schema and can run queries against the iModel.\n */\n imodelAccess: IModelAccess;\n /**\n * Signal indicating that that the request was canceled\n */\n abortSignal: AbortSignal;\n }) => Promise<HierarchySearchTree[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @public\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through the given selection\n * storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @public\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getSearchPaths\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;\n const translate = useTranslation();\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings: {\n other: translate(\"other\"),\n unspecified: translate(\"unspecified\"),\n },\n }),\n [imodelAccess, imodelChanged, translate, getHierarchyDefinition],\n ),\n getSearchPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getSearchPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getSearchPaths],\n ),\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { c } from "react-compiler-runtime";
|
|
2
2
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
4
|
//#region src/presentation-hierarchies-react/UseNodeHighlighting.tsx
|
|
6
5
|
/**
|
|
7
6
|
* A react hook that helps create highlighted node labels based on provided highlight.
|
|
@@ -52,7 +51,7 @@ function useNodeHighlighting(t0) {
|
|
|
52
51
|
} else t2 = $[3];
|
|
53
52
|
return t2;
|
|
54
53
|
}
|
|
55
|
-
|
|
56
54
|
//#endregion
|
|
57
55
|
export { useNodeHighlighting };
|
|
56
|
+
|
|
58
57
|
//# sourceMappingURL=UseNodeHighlighting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseNodeHighlighting.js","names":["useCallback","HierarchyNode","JSX","ReactElement","TreeNode","UseNodeHighlightingProps","highlightText","UseNodeHighlightingResult","getLabel","node","useNodeHighlighting","t0","$","_c","t1","isGroupingNode","nodeData","search","isSearchTarget","label","matchedIndexes","Array","nodeLabel","toLocaleLowerCase","searchText","fromPosition","foundIndex","indexOf","push","length","finalLabel","lastAddedPosition","i","matchedIndex","substring","endingPlace","t2"],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * Props for `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingProps {\n /** Text that should be highlighted */\n highlightText?: string;\n}\n\n/**\n * Result of `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingResult {\n /** Function that creates highlighted node labels. */\n getLabel: (node: TreeNode) => ReactElement;\n}\n\n/**\n * A react hook that helps create highlighted node labels based on provided highlight.\n * @alpha\n */\nexport function useNodeHighlighting({ highlightText }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const getLabel = useCallback(\n (node: TreeNode) => {\n if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) {\n return <span>{node.label}</span>;\n }\n\n const matchedIndexes = new Array<number>();\n const nodeLabel = node.label.toLocaleLowerCase();\n const searchText = highlightText.toLocaleLowerCase();\n let fromPosition = 0;\n // Find all occurrences of the search text in the node label\n while (true) {\n const foundIndex = nodeLabel.indexOf(searchText, fromPosition);\n if (foundIndex === -1) {\n break;\n }\n matchedIndexes.push(foundIndex);\n fromPosition = foundIndex + searchText.length;\n }\n\n if (matchedIndexes.length === 0) {\n return <span>{node.label}</span>;\n }\n\n // Create the final label with highlighted parts\n const finalLabel = new Array<JSX.Element>();\n let lastAddedPosition = 0;\n for (let i = 0; i < matchedIndexes.length; ++i) {\n const matchedIndex = matchedIndexes[i];\n if (matchedIndex > lastAddedPosition) {\n finalLabel.push(<span key={`normal-${i}`}>{node.label.substring(lastAddedPosition, matchedIndex)}</span>);\n lastAddedPosition = matchedIndex;\n }\n const endingPlace = matchedIndex + highlightText.length;\n finalLabel.push(<mark key={`marked-${i}`}>{node.label.substring(lastAddedPosition, endingPlace)}</mark>);\n lastAddedPosition = endingPlace;\n }\n if (lastAddedPosition < node.label.length) {\n finalLabel.push(<span key={`normal-${matchedIndexes.length + 1}`}>{node.label.substring(lastAddedPosition)}</span>);\n }\n\n return <>{finalLabel}</>;\n },\n [highlightText],\n );\n\n return { getLabel };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UseNodeHighlighting.js","names":["useCallback","HierarchyNode","JSX","ReactElement","TreeNode","UseNodeHighlightingProps","highlightText","UseNodeHighlightingResult","getLabel","node","useNodeHighlighting","t0","$","_c","t1","isGroupingNode","nodeData","search","isSearchTarget","label","matchedIndexes","Array","nodeLabel","toLocaleLowerCase","searchText","fromPosition","foundIndex","indexOf","push","length","finalLabel","lastAddedPosition","i","matchedIndex","substring","endingPlace","t2"],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * Props for `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingProps {\n /** Text that should be highlighted */\n highlightText?: string;\n}\n\n/**\n * Result of `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingResult {\n /** Function that creates highlighted node labels. */\n getLabel: (node: TreeNode) => ReactElement;\n}\n\n/**\n * A react hook that helps create highlighted node labels based on provided highlight.\n * @alpha\n */\nexport function useNodeHighlighting({ highlightText }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const getLabel = useCallback(\n (node: TreeNode) => {\n if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) {\n return <span>{node.label}</span>;\n }\n\n const matchedIndexes = new Array<number>();\n const nodeLabel = node.label.toLocaleLowerCase();\n const searchText = highlightText.toLocaleLowerCase();\n let fromPosition = 0;\n // Find all occurrences of the search text in the node label\n while (true) {\n const foundIndex = nodeLabel.indexOf(searchText, fromPosition);\n if (foundIndex === -1) {\n break;\n }\n matchedIndexes.push(foundIndex);\n fromPosition = foundIndex + searchText.length;\n }\n\n if (matchedIndexes.length === 0) {\n return <span>{node.label}</span>;\n }\n\n // Create the final label with highlighted parts\n const finalLabel = new Array<JSX.Element>();\n let lastAddedPosition = 0;\n for (let i = 0; i < matchedIndexes.length; ++i) {\n const matchedIndex = matchedIndexes[i];\n if (matchedIndex > lastAddedPosition) {\n finalLabel.push(<span key={`normal-${i}`}>{node.label.substring(lastAddedPosition, matchedIndex)}</span>);\n lastAddedPosition = matchedIndex;\n }\n const endingPlace = matchedIndex + highlightText.length;\n finalLabel.push(<mark key={`marked-${i}`}>{node.label.substring(lastAddedPosition, endingPlace)}</mark>);\n lastAddedPosition = endingPlace;\n }\n if (lastAddedPosition < node.label.length) {\n finalLabel.push(<span key={`normal-${matchedIndexes.length + 1}`}>{node.label.substring(lastAddedPosition)}</span>);\n }\n\n return <>{finalLabel}</>;\n },\n [highlightText],\n );\n\n return { getLabel };\n}\n"],"mappings":";;;;;;;;AAiCA,SAAOU,oBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA6B,MAAA,EAAAP,kBAAAK;CAA2C,IAAAG;AAAA,KAAAF,EAAA,OAAAN,eAAA;AAE3EQ,QAAAL,SAAA;AACE,OAAI,CAACH,iBAAiBL,cAAac,eAAgBN,KAAIO,SAAmD,IAAtG,CAAkEP,KAAIO,SAASC,QAAuBC,eAAA,QACjG,oBAAA,QAAA,EAAA,UAAOT,KAAIU,OAAc,CAAA;GAGlC,MAAAC,iBAAuB,IAAIC,OAAe;GAC1C,MAAAC,YAAkBb,KAAIU,MAAMI,mBAAoB;GAChD,MAAAC,aAAmBlB,cAAaiB,mBAAoB;GACpD,IAAAE,eAAmB;AAEnB,UAAO,MAAI;IACT,MAAAC,aAAmBJ,UAASK,QAASH,YAAYC,aAAa;AAC9D,QAAIC,eAAe,GACjB;AAEFN,mBAAcQ,KAAMF,WAAW;AAC/BD,mBAAeC,aAAaF,WAAUK;;AAGxC,OAAIT,eAAcS,WAAY,EAAC,QACtB,oBAAA,QAAA,EAAA,UAAOpB,KAAIU,OAAc,CAAA;GAIlC,MAAAW,aAAmB,IAAIT,OAAoB;GAC3C,IAAAU,oBAAwB;AACxB,QAAA,IAAAC,IAAa,GAAGA,IAAIZ,eAAcS,QAAS,EAAEG,GAAC;IAC5C,MAAAC,eAAqBb,eAAeY;AACpC,QAAIC,eAAeF,mBAAiB;AAClCD,gBAAUF,KAAM,oBAAA,QAAA,EAAA,UAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBE,aAAY,EAAS,EAA7E,UAAUD,IAAmE,CAAC;AACzGD,yBAAoBE;;IAEtB,MAAAE,cAAoBF,eAAe3B,cAAauB;AAChDC,eAAUF,KAAM,oBAAA,QAAA,EAAA,UAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBI,YAAW,EAAS,EAA5E,UAAUH,IAAkE,CAAC;AACxGD,wBAAoBI;;AAEtB,OAAIJ,oBAAoBtB,KAAIU,MAAMU,OAChCC,YAAUF,KAAM,oBAAA,QAAA,EAAA,UAAmDnB,KAAIU,MAAMe,UAAWH,kBAAiB,EAAS,EAAvF,UAAUX,eAAcS,SAAU,IAAqD,CAAC;AACpH,UAEM,oBAAA,UAAA,EAAA,UAAGC,YAAc,CAAA;;AACzBlB,IAAA,KAAAN;AAAAM,IAAA,KAAAE;OAAAA,MAAAF,EAAA;CA1CH,MAAAJ,WAAiBM;CA4Cf,IAAAsB;AAAA,KAAAxB,EAAA,OAAAJ,UAAA;AAEK4B,OAAA,EAAA5B,UAAY;AAAAI,IAAA,KAAAJ;AAAAI,IAAA,KAAAwB;OAAAA,MAAAxB,EAAA;AAAA,QAAZwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseSelectionHandler.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UseSelectionHandler.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"mappings":";;;AAmBA;;;;;AAUA;;KAVY,aAAA;;;;;;;;;KAUA,mBAAA"}
|