@itwin/presentation-hierarchies-react 2.0.0-alpha.3 → 2.0.0-alpha.31

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +559 -0
  2. package/README.md +24 -24
  3. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +85 -0
  4. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
  5. package/lib/esm/presentation-hierarchies-react/{itwinui/TreeActionButton.css → Renderers.js} +2 -4
  6. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +1 -0
  7. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +14 -29
  8. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  9. package/lib/esm/presentation-hierarchies-react/TreeNode.js +1 -7
  10. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
  11. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +2 -0
  12. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  13. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +1 -1
  14. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  15. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +24 -0
  16. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
  17. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +39 -0
  18. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
  19. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +3 -3
  20. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  21. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +1 -8
  22. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  23. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +32 -70
  24. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  25. package/lib/esm/presentation-hierarchies-react/UseTree.js +48 -49
  26. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  27. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +5 -0
  28. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +1 -0
  29. package/lib/esm/presentation-hierarchies-react/Utils.js +23 -0
  30. package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -0
  31. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
  32. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  33. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +31 -16
  34. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +24 -6
  36. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +28 -32
  38. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +6 -29
  40. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +31 -27
  42. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +23 -9
  44. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +16 -29
  46. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts +34 -0
  48. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +1 -0
  49. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js +26 -0
  50. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +1 -0
  51. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +58 -0
  52. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
  53. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +74 -0
  54. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
  55. package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.d.ts +47 -7
  56. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
  57. package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.js +13 -5
  58. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
  59. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts +33 -0
  60. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts.map +1 -0
  61. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js +39 -0
  62. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js.map +1 -0
  63. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -0
  64. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
  65. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +42 -0
  66. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
  67. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +43 -0
  68. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
  69. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +70 -0
  70. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
  71. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +49 -0
  72. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
  73. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +116 -0
  74. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
  75. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +40 -0
  76. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
  77. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +93 -0
  78. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
  79. package/lib/esm/presentation-hierarchies-react.d.ts +13 -10
  80. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  81. package/lib/esm/presentation-hierarchies-react.js +10 -9
  82. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  83. package/package.json +46 -38
  84. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
  85. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
  86. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
  87. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
  88. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
  89. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -21
  91. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
  92. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -29
  93. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
  94. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -12
  95. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
  96. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
  97. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
  98. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts +0 -12
  99. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts.map +0 -1
  100. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js +0 -10
  101. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js.map +0 -1
  102. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -45
  103. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
  104. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -71
  105. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
  106. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
  107. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
  108. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -22
  109. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,418 @@
1
1
  # @itwin/presentation-hierarchies-react
2
2
 
3
+ ## 2.0.0-alpha.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1042](https://github.com/iTwin/presentation/pull/1042): Version bump
8
+ - [#1040](https://github.com/iTwin/presentation/pull/1040): Added a react hook `useNodeHighlighting` that helps create highlighted node labels based on provided text that should be highlighted.
9
+
10
+ Example usage:
11
+
12
+ ```ts
13
+ import { StrataKitTreeRenderer, useNodeHighlighting } from "@itwin/presentation-hierarchies-react";
14
+
15
+ type BaseTreeRendererProps = React.ComponentPropsWithoutRef<typeof StrataKitTreeRenderer>;
16
+
17
+ function MyComponent(props: BaseTreeRendererProps & { searchText: string }) {
18
+ // Create highlight based on searchText
19
+ const highlightText = props.searchText !== "" ? props.searchText : undefined;
20
+ const { getLabel } = useNodeHighlighting({ highlightText });
21
+
22
+ // Provide getLabel function to tree renderer
23
+ return <StrataKitTreeRenderer {...props} getLabel={getLabel} />;
24
+ }
25
+ ```
26
+
27
+ - Updated dependencies:
28
+ - @itwin/presentation-hierarchies@2.0.0-alpha.4
29
+ - @itwin/presentation-shared@2.0.0-alpha.2
30
+ - @itwin/unified-selection@1.5.1-alpha.1
31
+
32
+ ## 2.0.0-alpha.30
33
+
34
+ ### Patch Changes
35
+
36
+ - [#1037](https://github.com/iTwin/presentation/pull/1037): Added additional documentation for `RenameAction`
37
+
38
+ ## 2.0.0-alpha.29
39
+
40
+ ### Patch Changes
41
+
42
+ - [#1035](https://github.com/iTwin/presentation/pull/1035): Version bump after merge from `master`.
43
+
44
+ ## 2.0.0-alpha.28
45
+
46
+ ### Patch Changes
47
+
48
+ - [#1031](https://github.com/iTwin/presentation/pull/1031): Version bump
49
+ - Updated dependencies:
50
+ - @itwin/presentation-hierarchies@2.0.0-alpha.3
51
+ - @itwin/unified-selection@1.5.1-alpha.0
52
+
53
+ ## 2.0.0-alpha.27
54
+
55
+ ### Patch Changes
56
+
57
+ - [#1026](https://github.com/iTwin/presentation/pull/1026): Fix `reserveSpace` property being required instead of optional for `FilterAction` and `RenameAction`.
58
+
59
+ ## 2.0.0-alpha.26
60
+
61
+ ### Major Changes
62
+
63
+ - [#1023](https://github.com/iTwin/presentation/pull/1023): Split `getActions` into `getMenuActions` & `getInlineActions` for `StrataKitTreeRenderer` and `StrataKitTreeNodeRenderer`.
64
+
65
+ Updated peer dependencies:
66
+
67
+ - @stratakit/bricks@0.3.3
68
+ - @stratakit/foundations@0.2.2
69
+ - @stratakit/structures@0.3.1
70
+
71
+ Added `reserveSpace` property to `FilterAction` and `RenameAction`, which reserves space for the action when it is not available
72
+
73
+ ### Minor Changes
74
+
75
+ - [#1007](https://github.com/iTwin/presentation/pull/1007): Renames:
76
+ `FlatNode` => `FlatTreeNodeItem`
77
+ `FlatTreeNode` => `FlatTreeItem`
78
+ `PlaceholderNode` => `PlaceholderItem`
79
+ `useFlatTreeNodeList` => `useFlatTreeItems`
80
+
81
+ Changed `FlatTreeNodeItem` (previously `FlatNode`) to have property `node: PresentationHierarchyNode` instead of extending `PresentationHierarchyNode`.
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies:
86
+ - @itwin/presentation-hierarchies@2.0.0-alpha.2
87
+
88
+ ## 2.0.0-alpha.25
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies:
93
+ - @itwin/presentation-hierarchies@2.0.0-alpha.1
94
+ - @itwin/presentation-shared@2.0.0-alpha.1
95
+ - @itwin/unified-selection@1.4.3-alpha.0
96
+
97
+ ## 2.0.0-alpha.24
98
+
99
+ ### Patch Changes
100
+
101
+ - [#975](https://github.com/iTwin/presentation/pull/975): Associate tree nodes rendered by `<StrataKitTreeNodeRenderer />` component with error messages rendered in `<TreeErrorRenderer />`. This improves accessibility by linking error information to the node.
102
+ - [#979](https://github.com/iTwin/presentation/pull/979): Adjust how `useTree` and other variants of it determines `isReloading` value. `isReloading` is now set to `true` if root nodes are being loaded.
103
+
104
+ ## 2.0.0-alpha.23
105
+
106
+ ### Minor Changes
107
+
108
+ - [#972](https://github.com/iTwin/presentation/pull/972): Added `getEditingProps` prop to `<StrataKitTreeRenderer />` component that allows to make node labels editable. In order to enter label editing mode `<RenameAction />` component was added.
109
+
110
+ ## 2.0.0-alpha.22
111
+
112
+ ### Minor Changes
113
+
114
+ - [#970](https://github.com/iTwin/presentation/pull/970): Exposed the type of tree state hooks' result `treeRendererProps` attribute - `TreeRendererProps`. The type can be useful when creating custom tree renderers.
115
+
116
+ ## 2.0.0-alpha.21
117
+
118
+ ### Major Changes
119
+
120
+ - [#961](https://github.com/iTwin/presentation/pull/961): **Breaking changes** to tree state hooks `useTree`, `useUnifiedSelectionTree`, `useIModelTree`, `useIModelUnifiedSelectionTree`:
121
+
122
+ - All tree rendering props have been moved under `treeRendererProps`. The value can be passed to `<StrataKitTreeRenderer />` component.
123
+ - 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.
124
+ - The `isLoading` attribute has been renamed to `isReloading`.
125
+ - Errors are no longer defined as children of `PresentationHierarchyNode` and instead are now included as `error` attribute for more fluent API.
126
+
127
+ When rendering tree state, the recommended order of checks is:
128
+
129
+ 1. If `rootErrorRendererProps` is defined, there was an error - render error state.
130
+ 2. If `treeRendererProps` is not defined, the component is doing the initial load - render loading state.
131
+ 3. If `treeRendererProps` is defined, the hierarchy is loaded - render the tree component.
132
+
133
+ The `isReloading` attribute may also be set at the same time, indicating that the hierarchy is being reloaded in the background. Consumers may want to render an overlay in this case, or not render the tree at all.
134
+
135
+ Example:
136
+
137
+ ```ts
138
+ function MyComponent () {
139
+ const useTreeResult = useIModelUnifiedSelectionTree({...});
140
+
141
+ // handle possible root errors with our provided component or your own custom implementation
142
+ if (treeProps.rootErrorRendererProps) {
143
+ return <StrataKitRootErrorRenderer {...useTreeResult.rootErrorRendererProps} />;
144
+ }
145
+
146
+ // handle loading state
147
+ if (!treeProps.treeRendererProps) {
148
+ return <MyLoadingComponent />;
149
+ }
150
+
151
+ // handle loaded hierarchy
152
+ return <StrataKitTreeRenderer {...useTreeResult.treeProps} />;
153
+ }
154
+ ```
155
+
156
+ ## 2.0.0-alpha.20
157
+
158
+ ### Major Changes
159
+
160
+ - [#965](https://github.com/iTwin/presentation/pull/965): Added `@stratakit/structures` as a peer dependency.
161
+
162
+ ## 2.0.0-alpha.19
163
+
164
+ ### Major Changes
165
+
166
+ - [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
167
+
168
+ - `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.
169
+ - `EC.Class` now additionally has these members:
170
+ - `baseClass: Promise<Class | undefined>`
171
+ - `getDerivedClasses(): Promise<Class[]>`
172
+
173
+ While this is an addition, it's considered a breaking change, because objects of the updated types are expected to be supplied to us by consumers.
174
+
175
+ In reality, consumers will likely use `@itwin/presentation-core-interop` package for creating them, and the package has been updated to handle the change, so reacting to the breaking change is as simple as bumping the version of `@itwin/presentation-core-interop` package in the consumer's `package.json`.
176
+
177
+ ### Patch Changes
178
+
179
+ - [#957](https://github.com/iTwin/presentation/pull/957): Avoid leaking custom props to the `PlaceholderNode` that are causing console errors.
180
+ - Updated dependencies:
181
+ - @itwin/presentation-hierarchies@2.0.0-alpha.0
182
+ - @itwin/presentation-shared@2.0.0-alpha.0
183
+ - @itwin/unified-selection@1.4.2-alpha.0
184
+
185
+ ## 2.0.0-alpha.18
186
+
187
+ ### Major Changes
188
+
189
+ - [#951](https://github.com/iTwin/presentation/pull/951): Move from `@itwin/itwinui-react@5.0.0-alpha` to `@stratakit/*` packages.
190
+
191
+ ## 2.0.0-alpha.17
192
+
193
+ ### Patch Changes
194
+
195
+ - [#949](https://github.com/iTwin/presentation/pull/949): Use default imports instead of `URL` constructor for icons.
196
+
197
+ ## 2.0.0-alpha.16
198
+
199
+ ### Minor Changes
200
+
201
+ - [#945](https://github.com/iTwin/presentation/pull/945): Re-export `getLogger` and `setLogger` functions from `@itwin/presentation-hierarchies` to allow setting a logger.
202
+
203
+ ## 2.0.0-alpha.15
204
+
205
+ ### Major Changes
206
+
207
+ - [#942](https://github.com/iTwin/presentation/pull/942): Unified selection API cleanup.
208
+
209
+ - Remove deprecated `UnifiedSelectionProvider`.
210
+ - Make `selectionStorage` prop required for unified selection - enabled tree state hooks (`useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree`).
211
+
212
+ Previously, the `selectionStorage` prop was optional, and if not provided, the hooks used unified selection React context (provided by `UnifiedSelectionProvider`) as fallback. Finally, if the context was not provided either, the hooks acted as regular non-unified selection hooks.
213
+
214
+ This didn't make much sense, as the hooks were designed to work with unified selection, as their name suggests. So it makes sense to require the selection storage to be provided to them, and at that point the context becomes redundant.
215
+
216
+ - [#936](https://github.com/iTwin/presentation/pull/936): Replaced `actions` property on `TreeNodeRenderer` with `getActions` to match how decorations are handled. Removed `useFilterAction` hook and replaced it with `FilterAction` component.
217
+
218
+ Before:
219
+
220
+ ```tsx
221
+ import { TreeNodeRenderer, useFilterAction } from "@itwin/presentation-hierarchies-react";
222
+
223
+ const filterAction = useFilterAction({ onFilter, getHierarchyLevelDetails });
224
+ return (
225
+ <TreeNodeRenderer
226
+ actions={useMemo(
227
+ () => [
228
+ filterAction,
229
+ (node) => ({
230
+ label: "Custom Action",
231
+ actions: () => log(node.label),
232
+ icon: customIconHref,
233
+ }),
234
+ ],
235
+ [filterAction],
236
+ )}
237
+ />
238
+ );
239
+ ```
240
+
241
+ After:
242
+
243
+ ```tsx
244
+ import { Icon, Tree } from "@itwin/itwinui-react";
245
+ import { FilterAction, TreeNodeRenderer } from "@itwin/presentation-hierarchies-react";
246
+
247
+ return (
248
+ <TreeNodeRenderer
249
+ getActions={useCallback(
250
+ (node) => [
251
+ <FilterAction key="filter" node={node} onFilter={onFilter} getHierarchyLevelDetails={getHierarchyLevelDetails} />,
252
+ <Tree.ItemAction key="customAction" label="Custom action" onClick={() => log(node.label)} icon={<Icon href={customIconHref} />} />,
253
+ ],
254
+ [onFilter, getHierarchyLevelDetails],
255
+ )}
256
+ />
257
+ );
258
+ ```
259
+
260
+ ### Minor Changes
261
+
262
+ - [#930](https://github.com/iTwin/presentation/pull/930): Exposed `TreeErrorRenderer`, which takes `renderError` property to render custom error messages.
263
+ `TreeRenderer` now takes `errorRenderer` to render a custom error display component.
264
+
265
+ Custom error display component example:
266
+
267
+ ```ts
268
+ <TreeRenderer
269
+ {...treeProps}
270
+ errorRenderer={(errorsRendererProps) => (
271
+ <MyErrorRenderer {...errorsRendererProps} />
272
+ )}
273
+ />
274
+ ```
275
+
276
+ Custom error message example:
277
+
278
+ ```ts
279
+ <TreeRenderer
280
+ {...treeProps}
281
+ errorRenderer={(errorsRendererProps) => (
282
+ <TreeErrorRenderer
283
+ {...errorsRendererProps}
284
+ renderError={(errorProps) => {
285
+ return <unstable_ErrorRegion.Item message={...} />;
286
+ }}
287
+ />
288
+ )}
289
+ />
290
+ ```
291
+
292
+ - [#937](https://github.com/iTwin/presentation/pull/937): `TreeRenderer` now takes `rootErrorRenderer` to render a custom root error display component.
293
+
294
+ Custom error display component example:
295
+
296
+ ```ts
297
+ <TreeRenderer
298
+ {...treeProps}
299
+ rootErrorRenderer={(rootErrorRendererProps) => (
300
+ <MyRootErrorRenderer {...rootErrorRendererProps} />
301
+ )}
302
+ />
303
+ ```
304
+
305
+ - [#930](https://github.com/iTwin/presentation/pull/930): Changed flat tree building functions to hooks:
306
+
307
+ - `flattenNodes` => `useFlatTreeNodeList`.
308
+ - `getErrors` => `useErrorList`.
309
+
310
+ ### Patch Changes
311
+
312
+ - [#930](https://github.com/iTwin/presentation/pull/930): Fix `ResultSetTooLarge` error suggesting filtering when parent node is not filterable.
313
+
314
+ ## 2.0.0-alpha.14
315
+
316
+ ### Patch Changes
317
+
318
+ - [#928](https://github.com/iTwin/presentation/pull/928): Memoize tree components to reduce the amount of renders.
319
+
320
+ ## 2.0.0-alpha.13
321
+
322
+ ### Patch Changes
323
+
324
+ - [#924](https://github.com/iTwin/presentation/pull/924): Fix tree error dropdown not applying actions.
325
+
326
+ ## 2.0.0-alpha.12
327
+
328
+ ### Patch Changes
329
+
330
+ - [#922](https://github.com/iTwin/presentation/pull/922): Fix tree displaying aditional scrollbars, when scrolling to the last element with low tree width.
331
+
332
+ ## 2.0.0-alpha.11
333
+
334
+ ### Patch Changes
335
+
336
+ - [#916](https://github.com/iTwin/presentation/pull/916): Fix tree nodes overlapping when nodes with and without sublabel are rendered alongside.
337
+ - [#920](https://github.com/iTwin/presentation/pull/920): Changed error display for node errors to match new design system.
338
+
339
+ ## 2.0.0-alpha.10
340
+
341
+ ### Patch Changes
342
+
343
+ - [#913](https://github.com/iTwin/presentation/pull/913): Removed outline showed after node expander is clicked.
344
+
345
+ ## 2.0.0-alpha.9
346
+
347
+ ### Patch Changes
348
+
349
+ - [#906](https://github.com/iTwin/presentation/pull/906): Replaced `TreeNodeRenderer.getIcon` prop with `getDecorations` prop.
350
+
351
+ The `getIcon` prop took either an icon URI, or a `ReactElement`. The new `getDecorations` prop allows passing multiple React elements, allowing consumers to render not just the icon, but also addition components like a tag or a color swatch. Migration:
352
+
353
+ ```ts
354
+ // previously, when `getIcon` returned a `ReactElement`:
355
+ function myGetIcon(node: PresentationHierarchyNode): React.ReactElement {
356
+ // implementation...
357
+ }
358
+ <TreeNodeRenderer getIcon={myGetIcon} />
359
+
360
+ // now:
361
+ <TreeNodeRenderer getDecorations={myGetIcon} />
362
+
363
+ // previously, when `getIcon` returned an icon URI:
364
+ function myGetIconUri(node: PresentationHierarchyNode): string {
365
+ // implementation...
366
+ }
367
+ <TreeNodeRenderer getIcon={myGetIconUri} />
368
+
369
+ // now:
370
+ <TreeNodeRenderer getDecorations={(node) => <Icon href={myGetIconUri(node)} />} />
371
+ ```
372
+
373
+ - [#911](https://github.com/iTwin/presentation/pull/911): Fix incorrect left padding on tree items
374
+
375
+ ## 2.0.0-alpha.8
376
+
377
+ ### Patch Changes
378
+
379
+ - [#903](https://github.com/iTwin/presentation/pull/903): Added `activeDescription` optional property to TreeItemAction interface, which when provided a value will display a dot above the button indicating an active state. The provided value is used to set accesible description and should explain why the action item is active.
380
+ - [#903](https://github.com/iTwin/presentation/pull/903): Changed `createFilterAction` function to a React hook and renamed it to `useFilterAction`.
381
+
382
+ ## 2.0.0-alpha.7
383
+
384
+ ### Patch Changes
385
+
386
+ - [#892](https://github.com/iTwin/presentation/pull/892): Fix focus outline for tree items not being visible on action items click.
387
+ - [#894](https://github.com/iTwin/presentation/pull/894): Fix `treeRenderer` property `getSublabel` not being used.
388
+
389
+ ## 2.0.0-alpha.6
390
+
391
+ ### Patch Changes
392
+
393
+ - [#890](https://github.com/iTwin/presentation/pull/890): Fix alpha peer dependencies to no longer have caret.
394
+
395
+ ## 2.0.0-alpha.5
396
+
397
+ ### Minor Changes
398
+
399
+ - [#883](https://github.com/iTwin/presentation/pull/883): Trees rendered with `TreeRenderer` will now be virtualized.
400
+
401
+ ## 2.0.0-alpha.4
402
+
403
+ ### Minor Changes
404
+
405
+ - [#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:
406
+
407
+ - `undefined` - visible on hover/focus,
408
+ - `true` - visible at all times,
409
+ - `false` - hidden at all times.
410
+
411
+ Updated peer dependencies:
412
+
413
+ - itwinui-icons to 5.0.0-alpha.3,
414
+ - itwinui-react to 5.0.0-alpha.6,
415
+
3
416
  ## 2.0.0-alpha.3
4
417
 
5
418
  ### Patch Changes
@@ -37,6 +450,152 @@
37
450
 
38
451
  - [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
39
452
 
453
+ ## 1.9.2
454
+
455
+ ### Patch Changes
456
+
457
+ - [#1039](https://github.com/iTwin/presentation/pull/1039): Bump iTwin.js core dependencies to `^5.1.1`.
458
+ - Updated dependencies:
459
+ - @itwin/presentation-hierarchies@1.7.2
460
+ - @itwin/presentation-shared@1.2.3
461
+ - @itwin/unified-selection@1.5.1
462
+
463
+ ## 1.9.1
464
+
465
+ ### Patch Changes
466
+
467
+ - [#1033](https://github.com/iTwin/presentation/pull/1033): Fix unified selection tree state hooks `useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree` not handling the recently added `createSelectableForGenericNode` prop.
468
+
469
+ ## 1.9.0
470
+
471
+ ### Minor Changes
472
+
473
+ - [#1027](https://github.com/iTwin/presentation/pull/1027): Added `getActions` property to `TreeRenderer` and `TreeNodeRenderer` to allow providing custom actions for tree nodes.
474
+
475
+ ## 1.8.1
476
+
477
+ ### Patch Changes
478
+
479
+ - Updated dependencies:
480
+ - @itwin/presentation-hierarchies@1.7.1
481
+
482
+ ## 1.8.0
483
+
484
+ ### Minor Changes
485
+
486
+ - [#1019](https://github.com/iTwin/presentation/pull/1019): Add ability to customize `Selectable` objects that are added to unified selection, when a generic node in a unified selection-driven tree component is selected.
487
+
488
+ By default, when a generic node is selected in a unified selection-driven tree component, the `Selectable` that is created for it gets a per-tree unique identifier. This means that a similar generic node somewhere else in the tree or a different tree will not be considered the same. However, in some cases we do want generic nodes to be treated as the same, and for that matter unified selection-enabling tree state hooks now have a new `createSelectableForGenericNode` option:
489
+
490
+ ```tsx
491
+ import { useUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
492
+
493
+ const treeState = useUnifiedSelectionTree({
494
+ selectionStorage,
495
+ createSelectableForGenericNode: useCallback<NonNullable<Props<typeof useUnifiedSelectionTree>["createSelectableForGenericNode"]>>(
496
+ (node, uniqueId) => ({ identifier: node.key.id, data: node, async *loadInstanceKeys() {} }),
497
+ [],
498
+ ),
499
+ // ...other options
500
+ });
501
+ ```
502
+
503
+ ### Patch Changes
504
+
505
+ - Updated dependencies:
506
+ - @itwin/unified-selection@1.5.0
507
+
508
+ ## 1.7.2
509
+
510
+ ### Patch Changes
511
+
512
+ - Updated dependencies:
513
+ - @itwin/presentation-hierarchies@1.7.0
514
+
515
+ ## 1.7.1
516
+
517
+ ### Patch Changes
518
+
519
+ - Updated dependencies:
520
+ - @itwin/presentation-hierarchies@1.6.1
521
+
522
+ ## 1.7.0
523
+
524
+ ### Minor Changes
525
+
526
+ - 64e80beaeb87e5797d8238c14fa9cd8dbfcee7c3: Added `abortSignal` to `getFilteredPaths` callback used by `UseTree` hook. This allows to cancel ongoing requests when component is unmounted or new request is started.
527
+
528
+ ### Patch Changes
529
+
530
+ - Updated dependencies:
531
+ - @itwin/presentation-hierarchies@1.6.0
532
+
533
+ ## 1.6.9
534
+
535
+ ### Patch Changes
536
+
537
+ - [#1000](https://github.com/iTwin/presentation/pull/1000): Made sure `Apply filter` button becomes focused after hierarchy level filter is applied.
538
+
539
+ ## 1.6.8
540
+
541
+ ### Patch Changes
542
+
543
+ - [#982](https://github.com/iTwin/presentation/pull/982): Update itwinjs-core dependencies to v5.0.0
544
+ - Updated dependencies:
545
+ - @itwin/presentation-hierarchies@1.5.1
546
+ - @itwin/presentation-shared@1.2.2
547
+ - @itwin/unified-selection@1.4.2
548
+
549
+ ## 1.6.7
550
+
551
+ ### Patch Changes
552
+
553
+ - [#974](https://github.com/iTwin/presentation/pull/974): Removed tree node outline on mobile devices.
554
+ - Updated dependencies:
555
+ - @itwin/presentation-hierarchies@1.5.0
556
+
557
+ ## 1.6.6
558
+
559
+ ### Patch Changes
560
+
561
+ - [#944](https://github.com/iTwin/presentation/pull/944): Fixed `extended` selection mode not replacing existing selection when selected node is clicked.
562
+
563
+ ## 1.6.5
564
+
565
+ ### Patch Changes
566
+
567
+ - [#938](https://github.com/iTwin/presentation/pull/938): Fixed hierarchy level size exceeded message that suggest applying filtering on hierarchy levels that do not support filtering.
568
+
569
+ ## 1.6.4
570
+
571
+ ### Patch Changes
572
+
573
+ - [#909](https://github.com/iTwin/presentation/pull/909): Do not use `dev` versions of `@itwin/*` packages.
574
+ - Updated dependencies:
575
+ - @itwin/unified-selection@1.4.1
576
+ - @itwin/presentation-hierarchies@1.4.2
577
+ - @itwin/presentation-shared@1.2.1
578
+
579
+ ## 1.6.3
580
+
581
+ ### Patch Changes
582
+
583
+ - Updated dependencies:
584
+ - @itwin/unified-selection@1.4.0
585
+
586
+ ## 1.6.2
587
+
588
+ ### Patch Changes
589
+
590
+ - [#873](https://github.com/iTwin/presentation/pull/873): Fix hierarchy level size exceeds limit info message wrapping in narrow Tree on Safari browser.
591
+ - [#873](https://github.com/iTwin/presentation/pull/873): Do not require two clicks to expand node with filter buttons on touch devices.
592
+
593
+ ## 1.6.1
594
+
595
+ ### Patch Changes
596
+
597
+ - [#866](https://github.com/iTwin/presentation/pull/866): Updated hierarchy level size exceeded info message styling in narrow tree component to avoid cutting out text.
598
+
40
599
  ## 1.6.0
41
600
 
42
601
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
4
4
 
5
- The `@itwin/presentation-hierarchies-react` package provides APIs for building a headless UI for rendering tree components based on data in an [iTwin.js iModel](https://www.itwinjs.org/learning/imodels/#imodel-overview). In addition, it delivers a set of [iTwinUI](https://itwinui.bentley.com/)-based components for rendering the tree.
5
+ The `@itwin/presentation-hierarchies-react` package provides APIs for building a headless UI for rendering tree components based on data in an [iTwin.js iModel](https://www.itwinjs.org/learning/imodels/#imodel-overview). In addition, it delivers a set of [StrataKit](https://www.npmjs.com/package/@stratakit/bricks)-based components for rendering the tree.
6
6
 
7
7
  ## Headless UI
8
8
 
@@ -125,21 +125,18 @@ The returned object contains 2 functions, that should be called by the node rend
125
125
 
126
126
  Our [tree renderer implementation](#treerenderer) calls this hook and passes the callbacks to the [node renderer](#treenoderenderer), so there's no need to use it unless implementing a custom tree renderer.
127
127
 
128
- ## iTwinUI components
128
+ ## StrataKit components
129
129
 
130
- While the package provides a headless UI, it also delivers a set of [iTwinUI](https://itwinui.bentley.com/)-based components for rendering the tree, which should cover majority of use cases. Consumers using the below components are required to provide a compatible `@itwin/itwinui-react` package, which is an optional peer dependency to this package.
130
+ While the package provides a headless UI, it also delivers a set of [StrataKit](https://www.npmjs.com/package/@stratakit/bricks)-based components for rendering the tree, which should cover majority of use cases. Consumers using the below components are required to provide compatible `@stratakit/bricks`/`@stratakit/icons`/`@stratakit/foundations` packages, which are optional peer dependencies to this package.
131
131
 
132
132
  ### `TreeRenderer`
133
133
 
134
- The component is based on [iTwinUI Tree component](https://itwinui.bentley.com/docs/tree) and uses our [`TreeNodeRenderer`](#treenoderenderer) to render the nodes. In addition, it makes use of the [`useSelectionHandler` hook](#useselectionhandler-hook) to add selection modes' support.
135
-
136
- The iTwinUI Tree component requires a `getNode` function that maps nodes to `NodeData<TNode>` objects. Our `TreeRenderer` uses `createRenderedTreeNodeData` function for this purpose, and it's available for consumers as well, in case a custom iTwinUI Tree component implementation is being written.
134
+ The component is based on StrataKit `Tree` component and uses our [`TreeNodeRenderer`](#treenoderenderer) to render the nodes. In addition, it makes use of the [`useSelectionHandler` hook](#useselectionhandler-hook) to add selection modes' support.
137
135
 
138
136
  ### `TreeNodeRenderer`
139
137
 
140
- The component is based on `TreeNode` component from iTwinUI library and supports the following features:
138
+ The component is based on `Tree.Item` component from StrataKit library and supports the following features:
141
139
 
142
- - Rendering informational type of nodes (e.g. "No filter matches", "Too many nodes in a hierarchy level", etc.).
143
140
  - Reporting click and key down events for use with [`useSelectionHandler` hook](#useselectionhandler-hook).
144
141
  - Icons, selection, expand / collapse.
145
142
  - Action buttons to clear / set hierarchy level instance filter.
@@ -306,28 +303,31 @@ In case the `TreeNodeRenderer` component is used within a custom tree renderer,
306
303
  import { Props } from "@itwin/presentation-shared";
307
304
 
308
305
  import { ComponentPropsWithoutRef, useCallback } from "react";
309
- import { Tree } from "@itwin/itwinui-react";
310
- import {
311
- createRenderedTreeNodeData,
312
- LocalizationContextProvider,
313
- RenderedTreeNode,
314
- TreeNodeRenderer,
315
- TreeRenderer,
316
- } from "@itwin/presentation-hierarchies-react";
317
-
318
- type TreeProps = ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>;
306
+ import { Tree } from "@stratakit/bricks";
307
+ import { LocalizationContextProvider, TreeRenderer, useFlatTreeNodeList } from "@itwin/presentation-hierarchies-react";
308
+
319
309
  type TreeRendererProps = Props<typeof TreeRenderer>;
320
310
 
321
311
  function MyTreeRenderer({ rootNodes }: TreeRendererProps) {
322
- const nodeRenderer = useCallback<TreeProps["nodeRenderer"]>((nodeProps) => {
323
- return <TreeNodeRenderer {...nodeProps} onFilterClick={() => {}} expandNode={() => {}} />;
324
- }, []);
325
-
326
- const getNode = useCallback<TreeProps["getNode"]>((node) => createRenderedTreeNodeData(node, () => false), []);
312
+ const flatNodes = useFlatTreeNodeList(rootNodes);
327
313
 
328
314
  return (
329
315
  <LocalizationContextProvider localizedStrings={localizedStrings}>
330
- <Tree<RenderedTreeNode> data={rootNodes} nodeRenderer={nodeRenderer} getNode={getNode} enableVirtualization={true} />
316
+ <Tree.Root>
317
+ {flatNodes.map((flatNode) =>
318
+ isPlaceholderNode(flatNode) ? (
319
+ <Tree.Item key={flatNode.id} aria-level={flatNode.level} aria-posinset={1} aria-setsize={1} label="Loading" />
320
+ ) : (
321
+ <Tree.Item
322
+ key={flatNode.id}
323
+ aria-level={flatNode.level}
324
+ aria-posinset={flatNode.posInLevel}
325
+ aria-setsize={flatNode.levelSize}
326
+ label={flatNode.label}
327
+ />
328
+ ),
329
+ )}
330
+ </Tree.Root>
331
331
  </LocalizationContextProvider>
332
332
  );
333
333
  }