@itwin/presentation-hierarchies-react 2.0.0-alpha.57 → 2.0.0-alpha.59
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 +184 -36
- package/README.md +46 -57
- package/lib/presentation-hierarchies-react/{stratakit/FlatTreeNode.d.ts → FlatTreeNode.d.ts} +2 -2
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/FlatTreeNode.js → FlatTreeNode.js} +2 -3
- package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/LocalizationContext.d.ts → LocalizationContext.d.ts} +1 -1
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/LocalizationContext.js → LocalizationContext.js} +3 -4
- package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts +2 -2
- package/lib/presentation-hierarchies-react/UseIModelTree.js +2 -3
- 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.d.ts +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +2 -3
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +2 -3
- 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.d.ts +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +2 -3
- 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 +2 -3
- 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 +2 -3
- 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 +2 -3
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +2 -3
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
- package/lib/presentation-hierarchies-react-extract.js +16 -0
- package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
- package/lib/presentation-hierarchies-react-stratakit.js +8 -0
- package/lib/presentation-hierarchies-react.d.ts +3 -10
- package/lib/presentation-hierarchies-react.js +3 -11
- package/package.json +20 -13
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.59
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1259](https://github.com/iTwin/presentation/pull/1259): Introduce separate import path for StrataKit based components. StrataKit based components have to be imported through `@itwin/presentation-hierarchies-react/stratakit`. This allows to use this package with or without StrataKit dependencies.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1256](https://github.com/iTwin/presentation/pull/1256): Fix `alpha` dependencies being specified with a range (`^`), allowing package manager to use higher versions, possibly with breaking changes.
|
|
12
|
+
- Updated dependencies:
|
|
13
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.14
|
|
14
|
+
|
|
15
|
+
## 2.0.0-alpha.58
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [#1236](https://github.com/iTwin/presentation/pull/1236): Start using tree structure for defining hierarchy search paths.
|
|
20
|
+
|
|
21
|
+
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:`
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { HierarchySearchTree } from "@itwin/presentation-hierarchies";
|
|
25
|
+
|
|
26
|
+
function MyTree() {
|
|
27
|
+
const [searchText, setSearchText] = useState("");
|
|
28
|
+
const treeProps = useIModelUnifiedSelectionTree({
|
|
29
|
+
// ...
|
|
30
|
+
getSearchPaths: useMemo<UseIModelTreeProps["getSearchPaths"]>(() => {
|
|
31
|
+
return async () => {
|
|
32
|
+
// before
|
|
33
|
+
return getSearchTargetPaths({ searchText }),
|
|
34
|
+
// after
|
|
35
|
+
return HierarchySearchTree.createFromPathsList(await getSearchTargetPaths({ searchText }));
|
|
36
|
+
};
|
|
37
|
+
}, [searchText]),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// ...
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<StrataKitTreeRenderer
|
|
44
|
+
{...treeProps.treeRendererProps}
|
|
45
|
+
// ...
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies:
|
|
54
|
+
- @itwin/unified-selection@1.6.9-alpha.0
|
|
55
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.13
|
|
56
|
+
- @itwin/presentation-shared@2.0.0-alpha.9
|
|
57
|
+
|
|
3
58
|
## 2.0.0-alpha.57
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
|
@@ -19,6 +74,7 @@
|
|
|
19
74
|
- [#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.
|
|
20
75
|
|
|
21
76
|
**Breaking changes**
|
|
77
|
+
|
|
22
78
|
- `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).
|
|
23
79
|
- `LOCALIZATION_NAMESPACES` must be registered with your localization provider during app initialization to make localized strings available.
|
|
24
80
|
|
|
@@ -80,6 +136,7 @@
|
|
|
80
136
|
- [#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.
|
|
81
137
|
|
|
82
138
|
**Breaking changes**
|
|
139
|
+
|
|
83
140
|
- `useSelectionHandler` is no longer exported. This function is an internal implementation detail of `StrataKitTreeRenderer` and should not be used directly.
|
|
84
141
|
|
|
85
142
|
- [#1181](https://github.com/iTwin/presentation/pull/1181): **Breaking change:** Rename `PresentationHierarchyNode` to `TreeNode` for clarity.
|
|
@@ -89,6 +146,7 @@
|
|
|
89
146
|
- [#1183](https://github.com/iTwin/presentation/pull/1183): Clean up `TreeErrorRenderer` and `ErrorItemRenderer`.
|
|
90
147
|
|
|
91
148
|
**Breaking changes:**
|
|
149
|
+
|
|
92
150
|
- 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:
|
|
93
151
|
- Renamed `errorItem` -> `errorNode` in `ErrorItemRenderer` component and changed the type from removed `ErrorItem` to `TreeNode`.
|
|
94
152
|
- Renamed `errorList` -> `errorNodes` in `TreeErrorRenderer` component and changed the type from `ErrorItem[]` to `TreeNode[]`.
|
|
@@ -105,7 +163,10 @@
|
|
|
105
163
|
Example:
|
|
106
164
|
|
|
107
165
|
```tsx
|
|
108
|
-
import {
|
|
166
|
+
import {
|
|
167
|
+
StrataKitTreeRenderer,
|
|
168
|
+
StrataKitTreeRendererAttributes,
|
|
169
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
109
170
|
|
|
110
171
|
function MyTree() {
|
|
111
172
|
const treeRef = useRef<StrataKitTreeRendererAttributes>(null);
|
|
@@ -115,7 +176,9 @@
|
|
|
115
176
|
<div className="tree-header">
|
|
116
177
|
<button
|
|
117
178
|
onClick={() => {
|
|
118
|
-
treeRef.current?.renameNode(
|
|
179
|
+
treeRef.current?.renameNode(
|
|
180
|
+
(node) => node.label === "Node to rename"
|
|
181
|
+
);
|
|
119
182
|
}}
|
|
120
183
|
>
|
|
121
184
|
Rename node
|
|
@@ -128,11 +191,13 @@
|
|
|
128
191
|
```
|
|
129
192
|
|
|
130
193
|
**Breaking changes**
|
|
194
|
+
|
|
131
195
|
- `StrataKitTreeNodeRenderer` is no longer exported.
|
|
132
196
|
- `RenameContextProvider` is no longer exported. It is not necessary when using `StrataKitTreeRenderer`.
|
|
133
197
|
- `RenameAction` now requires a `node` prop.
|
|
134
198
|
|
|
135
199
|
- [#1179](https://github.com/iTwin/presentation/pull/1179): **Breaking change:** Rename tree node action components for clarity.
|
|
200
|
+
|
|
136
201
|
- `FilterAction` -> `TreeNodeFilterAction`
|
|
137
202
|
- `RenameAction` -> `TreeNodeRenameAction`
|
|
138
203
|
|
|
@@ -143,7 +208,9 @@
|
|
|
143
208
|
```tsx
|
|
144
209
|
type TreeRendererProps = ComponentProps<typeof StrataKitTreeRenderer>;
|
|
145
210
|
|
|
146
|
-
const getEditingProps = useCallback<
|
|
211
|
+
const getEditingProps = useCallback<
|
|
212
|
+
Required<TreeRendererProps>["getEditingProps"]
|
|
213
|
+
>((node) => {
|
|
147
214
|
return {
|
|
148
215
|
onLabelChanged: (newLabel: string) => {
|
|
149
216
|
// Handle label change
|
|
@@ -153,10 +220,13 @@
|
|
|
153
220
|
};
|
|
154
221
|
}, []);
|
|
155
222
|
|
|
156
|
-
return
|
|
223
|
+
return (
|
|
224
|
+
<StrataKitTreeRenderer {...treeProps} getEditingProps={getEditingProps} />
|
|
225
|
+
);
|
|
157
226
|
```
|
|
158
227
|
|
|
159
228
|
**Breaking changes**
|
|
229
|
+
|
|
160
230
|
- `getEditingProps` callback was changed to require `onLabelChanged`. If node does not support renaming `getEditingProps` should return `undefined`.
|
|
161
231
|
|
|
162
232
|
### Patch Changes
|
|
@@ -175,6 +245,7 @@
|
|
|
175
245
|
**Breaking changes**
|
|
176
246
|
|
|
177
247
|
`StrataKitTreeNodeRenderer` props changes:
|
|
248
|
+
|
|
178
249
|
- `getMenuActions` callback changed to `menuActions` prop (type: `ReactNode[]`)
|
|
179
250
|
- `getInlineActions` callback changed to `inlineActions` prop (type: `ReactNode[]`)
|
|
180
251
|
- `getContextMenuActions` callback changed to `contextMenuActions` prop (type: `ReactNode[]`)
|
|
@@ -185,6 +256,7 @@
|
|
|
185
256
|
- `onNodeClick` and `onNodeKeyDown` callbacks removed - use `onClick` and `onKeyDown` props instead
|
|
186
257
|
|
|
187
258
|
`StrataKitTreeRenderer` props changes:
|
|
259
|
+
|
|
188
260
|
- Props previously passed to `StrataKitTreeNodeRenderer` are no longer accepted
|
|
189
261
|
- Use `getTreeItemProps` callback to provide props to specific `Tree.Item` components
|
|
190
262
|
- Use `getMenuActions`, `getInlineActions`, and `getContextMenuActions` on `StrataKitTreeRenderer` to provide actions for nodes
|
|
@@ -250,13 +322,19 @@
|
|
|
250
322
|
- [#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.
|
|
251
323
|
|
|
252
324
|
**Breaking changes**
|
|
325
|
+
|
|
253
326
|
- `StrataKitTreeRenderer.getInlineActions` callback receives `{ targetNode: PresentationHierarchyNode; selectedNodes: PresentationHierarchyNode[] }` props instead of `PresentationHierarchyNode`.
|
|
254
327
|
- `StrataKitTreeRenderer.getMenuActions` callback receives `{ targetNode: PresentationHierarchyNode; selectedNodes: PresentationHierarchyNode[] }` props instead of `PresentationHierarchyNode`.
|
|
255
328
|
|
|
256
329
|
Before
|
|
257
330
|
|
|
258
331
|
```tsx
|
|
259
|
-
return
|
|
332
|
+
return (
|
|
333
|
+
<StrataKitTreeRenderer
|
|
334
|
+
getInlineActions={(node) => [<InlineAction node={node} />]}
|
|
335
|
+
getMenuActions={(node) => [<MenuAction node={node} />]}
|
|
336
|
+
/>
|
|
337
|
+
);
|
|
260
338
|
```
|
|
261
339
|
|
|
262
340
|
After
|
|
@@ -264,7 +342,9 @@
|
|
|
264
342
|
```tsx
|
|
265
343
|
return (
|
|
266
344
|
<StrataKitTreeRenderer
|
|
267
|
-
getInlineActions={({ targetNode }) => [
|
|
345
|
+
getInlineActions={({ targetNode }) => [
|
|
346
|
+
<InlineAction node={targetNode} />,
|
|
347
|
+
]}
|
|
268
348
|
getMenuActions={({ targetNode }) => [<MenuAction node={targetNode} />]}
|
|
269
349
|
/>
|
|
270
350
|
);
|
|
@@ -273,6 +353,7 @@
|
|
|
273
353
|
- [#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.
|
|
274
354
|
|
|
275
355
|
**Breaking changes**
|
|
356
|
+
|
|
276
357
|
- Removed `reserveSpace` property from `<RenameAction />` and `<FilterAction />`. These actions now automatically infer the context they're used in.
|
|
277
358
|
- Added requirement to render newly introduced `<TreeActionBase />` component instead of `<Tree.ItemAction />` when rendering custom tree actions.
|
|
278
359
|
|
|
@@ -322,6 +403,7 @@
|
|
|
322
403
|
### Major Changes
|
|
323
404
|
|
|
324
405
|
- [#1094](https://github.com/iTwin/presentation/pull/1094): Improve custom errors rendering API:
|
|
406
|
+
|
|
325
407
|
- 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.
|
|
326
408
|
- Exposed `ErrorItemRenderer` that renders all error types supported by the tree.
|
|
327
409
|
- Updated `TreeErrorRenderer` to pass all props necessary to render `ErrorItemRenderer` into `renderError` callback.
|
|
@@ -339,7 +421,12 @@
|
|
|
339
421
|
{...errorProps}
|
|
340
422
|
renderError={(errorItemProps) => {
|
|
341
423
|
if (errorItemProps.errorItem.errorNode.error.type === "Unknown") {
|
|
342
|
-
return
|
|
424
|
+
return (
|
|
425
|
+
<ErrorRegion.Item
|
|
426
|
+
message="Custom error"
|
|
427
|
+
messageId={errorItemProps.errorItem.errorNode.id}
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
343
430
|
}
|
|
344
431
|
return <ErrorItemRenderer {...errorItemProps} />;
|
|
345
432
|
}}
|
|
@@ -356,6 +443,7 @@
|
|
|
356
443
|
- [#1075](https://github.com/iTwin/presentation/pull/1075): Fix accessibility issues in `<TreeErrorRenderer />`.
|
|
357
444
|
|
|
358
445
|
This involves a few localized string changes:
|
|
446
|
+
|
|
359
447
|
- Added `issuesForTree`, defaulting to "Issues for {{tree_label}}.", used as a region landmark label for the error message container.
|
|
360
448
|
- Added `noIssuesFound`, defaulting to "No issues found.", used as a label for errors' list when there are no issues.
|
|
361
449
|
- 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.
|
|
@@ -390,13 +478,19 @@
|
|
|
390
478
|
Example usage:
|
|
391
479
|
|
|
392
480
|
```ts
|
|
393
|
-
import {
|
|
481
|
+
import {
|
|
482
|
+
StrataKitTreeRenderer,
|
|
483
|
+
useNodeHighlighting,
|
|
484
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
394
485
|
|
|
395
|
-
type BaseTreeRendererProps = React.ComponentPropsWithoutRef<
|
|
486
|
+
type BaseTreeRendererProps = React.ComponentPropsWithoutRef<
|
|
487
|
+
typeof StrataKitTreeRenderer
|
|
488
|
+
>;
|
|
396
489
|
|
|
397
490
|
function MyComponent(props: BaseTreeRendererProps & { searchText: string }) {
|
|
398
491
|
// Create highlight based on searchText
|
|
399
|
-
const highlightText =
|
|
492
|
+
const highlightText =
|
|
493
|
+
props.searchText !== "" ? props.searchText : undefined;
|
|
400
494
|
const { getLabel } = useNodeHighlighting({ highlightText });
|
|
401
495
|
|
|
402
496
|
// Provide getLabel function to tree renderer
|
|
@@ -443,6 +537,7 @@
|
|
|
443
537
|
- [#1023](https://github.com/iTwin/presentation/pull/1023): Split `getActions` into `getMenuActions` & `getInlineActions` for `StrataKitTreeRenderer` and `StrataKitTreeNodeRenderer`.
|
|
444
538
|
|
|
445
539
|
Updated peer dependencies:
|
|
540
|
+
|
|
446
541
|
- @stratakit/bricks@0.3.3
|
|
447
542
|
- @stratakit/foundations@0.2.2
|
|
448
543
|
- @stratakit/structures@0.3.1
|
|
@@ -497,12 +592,14 @@
|
|
|
497
592
|
### Major Changes
|
|
498
593
|
|
|
499
594
|
- [#961](https://github.com/iTwin/presentation/pull/961): **Breaking changes** to tree state hooks `useTree`, `useUnifiedSelectionTree`, `useIModelTree`, `useIModelUnifiedSelectionTree`:
|
|
595
|
+
|
|
500
596
|
- All tree rendering props have been moved under `treeRendererProps`. The value can be passed to `<StrataKitTreeRenderer />` component.
|
|
501
597
|
- 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.
|
|
502
598
|
- The `isLoading` attribute has been renamed to `isReloading`.
|
|
503
599
|
- Errors are no longer defined as children of `PresentationHierarchyNode` and instead are now included as `error` attribute for more fluent API.
|
|
504
600
|
|
|
505
601
|
When rendering tree state, the recommended order of checks is:
|
|
602
|
+
|
|
506
603
|
1. If `rootErrorRendererProps` is defined, there was an error - render error state.
|
|
507
604
|
2. If `treeRendererProps` is not defined, the component is doing the initial load - render loading state.
|
|
508
605
|
3. If `treeRendererProps` is defined, the hierarchy is loaded - render the tree component.
|
|
@@ -541,6 +638,7 @@
|
|
|
541
638
|
### Major Changes
|
|
542
639
|
|
|
543
640
|
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
641
|
+
|
|
544
642
|
- `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.
|
|
545
643
|
- `EC.Class` now additionally has these members:
|
|
546
644
|
- `baseClass: Promise<Class | undefined>`
|
|
@@ -581,6 +679,7 @@
|
|
|
581
679
|
### Major Changes
|
|
582
680
|
|
|
583
681
|
- [#942](https://github.com/iTwin/presentation/pull/942): Unified selection API cleanup.
|
|
682
|
+
|
|
584
683
|
- Remove deprecated `UnifiedSelectionProvider`.
|
|
585
684
|
- Make `selectionStorage` prop required for unified selection - enabled tree state hooks (`useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree`).
|
|
586
685
|
|
|
@@ -593,7 +692,10 @@
|
|
|
593
692
|
Before:
|
|
594
693
|
|
|
595
694
|
```tsx
|
|
596
|
-
import {
|
|
695
|
+
import {
|
|
696
|
+
TreeNodeRenderer,
|
|
697
|
+
useFilterAction,
|
|
698
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
597
699
|
|
|
598
700
|
const filterAction = useFilterAction({ onFilter, getHierarchyLevelDetails });
|
|
599
701
|
return (
|
|
@@ -607,7 +709,7 @@
|
|
|
607
709
|
icon: customIconHref,
|
|
608
710
|
}),
|
|
609
711
|
],
|
|
610
|
-
[filterAction]
|
|
712
|
+
[filterAction]
|
|
611
713
|
)}
|
|
612
714
|
/>
|
|
613
715
|
);
|
|
@@ -617,16 +719,29 @@
|
|
|
617
719
|
|
|
618
720
|
```tsx
|
|
619
721
|
import { Icon, Tree } from "@itwin/itwinui-react";
|
|
620
|
-
import {
|
|
722
|
+
import {
|
|
723
|
+
FilterAction,
|
|
724
|
+
TreeNodeRenderer,
|
|
725
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
621
726
|
|
|
622
727
|
return (
|
|
623
728
|
<TreeNodeRenderer
|
|
624
729
|
getActions={useCallback(
|
|
625
730
|
(node) => [
|
|
626
|
-
<FilterAction
|
|
627
|
-
|
|
731
|
+
<FilterAction
|
|
732
|
+
key="filter"
|
|
733
|
+
node={node}
|
|
734
|
+
onFilter={onFilter}
|
|
735
|
+
getHierarchyLevelDetails={getHierarchyLevelDetails}
|
|
736
|
+
/>,
|
|
737
|
+
<Tree.ItemAction
|
|
738
|
+
key="customAction"
|
|
739
|
+
label="Custom action"
|
|
740
|
+
onClick={() => log(node.label)}
|
|
741
|
+
icon={<Icon href={customIconHref} />}
|
|
742
|
+
/>,
|
|
628
743
|
],
|
|
629
|
-
[onFilter, getHierarchyLevelDetails]
|
|
744
|
+
[onFilter, getHierarchyLevelDetails]
|
|
630
745
|
)}
|
|
631
746
|
/>
|
|
632
747
|
);
|
|
@@ -641,10 +756,10 @@
|
|
|
641
756
|
|
|
642
757
|
```ts
|
|
643
758
|
<TreeRenderer
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
759
|
+
{...treeProps}
|
|
760
|
+
errorRenderer={(errorsRendererProps) => (
|
|
761
|
+
<MyErrorRenderer {...errorsRendererProps} />
|
|
762
|
+
)}
|
|
648
763
|
/>
|
|
649
764
|
```
|
|
650
765
|
|
|
@@ -670,10 +785,10 @@
|
|
|
670
785
|
|
|
671
786
|
```ts
|
|
672
787
|
<TreeRenderer
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
788
|
+
{...treeProps}
|
|
789
|
+
rootErrorRenderer={(rootErrorRendererProps) => (
|
|
790
|
+
<MyRootErrorRenderer {...rootErrorRendererProps} />
|
|
791
|
+
)}
|
|
677
792
|
/>
|
|
678
793
|
```
|
|
679
794
|
|
|
@@ -777,11 +892,13 @@
|
|
|
777
892
|
### Minor Changes
|
|
778
893
|
|
|
779
894
|
- [#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:
|
|
895
|
+
|
|
780
896
|
- `undefined` - visible on hover/focus,
|
|
781
897
|
- `true` - visible at all times,
|
|
782
898
|
- `false` - hidden at all times.
|
|
783
899
|
|
|
784
900
|
Updated peer dependencies:
|
|
901
|
+
|
|
785
902
|
- itwinui-icons to 5.0.0-alpha.3,
|
|
786
903
|
- itwinui-react to 5.0.0-alpha.6,
|
|
787
904
|
|
|
@@ -811,6 +928,7 @@
|
|
|
811
928
|
- [#862](https://github.com/iTwin/presentation/pull/862): Update `@itwin/itwinui-react` dependency to `5.0.0-alpha.3`.
|
|
812
929
|
|
|
813
930
|
This fixes the following issues:
|
|
931
|
+
|
|
814
932
|
- nodes being selected on expand,
|
|
815
933
|
- node action buttons being rendered incorrectly.
|
|
816
934
|
|
|
@@ -820,6 +938,17 @@
|
|
|
820
938
|
|
|
821
939
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
822
940
|
|
|
941
|
+
## 1.9.13
|
|
942
|
+
|
|
943
|
+
### Patch Changes
|
|
944
|
+
|
|
945
|
+
- [#1242](https://github.com/iTwin/presentation/pull/1242): Bump dependencies.
|
|
946
|
+
- [#1252](https://github.com/iTwin/presentation/pull/1252): Fix tree node outline not appearing on touch devices.
|
|
947
|
+
- Updated dependencies:
|
|
948
|
+
- @itwin/presentation-hierarchies@1.7.11
|
|
949
|
+
- @itwin/presentation-shared@1.2.10
|
|
950
|
+
- @itwin/unified-selection@1.6.8
|
|
951
|
+
|
|
823
952
|
## 1.9.12
|
|
824
953
|
|
|
825
954
|
### Patch Changes
|
|
@@ -948,9 +1077,17 @@
|
|
|
948
1077
|
|
|
949
1078
|
const treeState = useUnifiedSelectionTree({
|
|
950
1079
|
selectionStorage,
|
|
951
|
-
createSelectableForGenericNode: useCallback<
|
|
952
|
-
|
|
953
|
-
|
|
1080
|
+
createSelectableForGenericNode: useCallback<
|
|
1081
|
+
NonNullable<
|
|
1082
|
+
Props<typeof useUnifiedSelectionTree>["createSelectableForGenericNode"]
|
|
1083
|
+
>
|
|
1084
|
+
>(
|
|
1085
|
+
(node, uniqueId) => ({
|
|
1086
|
+
identifier: node.key.id,
|
|
1087
|
+
data: node,
|
|
1088
|
+
async *loadInstanceKeys() {},
|
|
1089
|
+
}),
|
|
1090
|
+
[]
|
|
954
1091
|
),
|
|
955
1092
|
// ...other options
|
|
956
1093
|
});
|
|
@@ -1057,6 +1194,7 @@
|
|
|
1057
1194
|
### Minor Changes
|
|
1058
1195
|
|
|
1059
1196
|
- [#841](https://github.com/iTwin/presentation/pull/841): Changed how tree state hooks access unified selection storage.
|
|
1197
|
+
|
|
1060
1198
|
- 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.
|
|
1061
1199
|
- 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.
|
|
1062
1200
|
|
|
@@ -1132,7 +1270,11 @@
|
|
|
1132
1270
|
Example usage:
|
|
1133
1271
|
|
|
1134
1272
|
```tsx
|
|
1135
|
-
function MyTreeComponentInternal({
|
|
1273
|
+
function MyTreeComponentInternal({
|
|
1274
|
+
imodelAccess,
|
|
1275
|
+
}: {
|
|
1276
|
+
imodelAccess: IModelAccess;
|
|
1277
|
+
}) {
|
|
1136
1278
|
const {
|
|
1137
1279
|
rootNodes,
|
|
1138
1280
|
getNode,
|
|
@@ -1147,18 +1289,22 @@
|
|
|
1147
1289
|
async (nodeId: string, isExpanded: boolean) => {
|
|
1148
1290
|
const node = getNode(nodeId);
|
|
1149
1291
|
if (node) {
|
|
1150
|
-
console.log(
|
|
1292
|
+
console.log(
|
|
1293
|
+
`${isExpanded ? "Expanding" : "Collapsing"} node: ${node.label}`
|
|
1294
|
+
);
|
|
1151
1295
|
}
|
|
1152
1296
|
doExpandNode(nodeId, isExpanded);
|
|
1153
1297
|
},
|
|
1154
|
-
[getNode, doExpandNode]
|
|
1298
|
+
[getNode, doExpandNode]
|
|
1155
1299
|
);
|
|
1156
1300
|
|
|
1157
1301
|
// render the tree
|
|
1158
1302
|
if (!rootNodes || !rootNodes.length) {
|
|
1159
1303
|
return "No data to display";
|
|
1160
1304
|
}
|
|
1161
|
-
return
|
|
1305
|
+
return (
|
|
1306
|
+
<TreeRenderer {...state} expandNode={expandNode} rootNodes={rootNodes} />
|
|
1307
|
+
);
|
|
1162
1308
|
}
|
|
1163
1309
|
```
|
|
1164
1310
|
|
|
@@ -1312,6 +1458,7 @@
|
|
|
1312
1458
|
See "Basic example" section in README learning page for the full example.
|
|
1313
1459
|
|
|
1314
1460
|
- [#717](https://github.com/iTwin/presentation/pull/717): **BREAKING:** Add support for non-iModel-driven trees.
|
|
1461
|
+
|
|
1315
1462
|
- `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.
|
|
1316
1463
|
- 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.
|
|
1317
1464
|
|
|
@@ -1504,11 +1651,12 @@
|
|
|
1504
1651
|
const hierarchyLevelDetails = getHierarchyLevelDetails(nodeId);
|
|
1505
1652
|
someFunc(hierarchyLevelDetails);
|
|
1506
1653
|
}}
|
|
1507
|
-
|
|
1508
1654
|
// After the change
|
|
1509
1655
|
onNodeClick={(node, isSelected, event) => someFunc(node.id)}
|
|
1510
1656
|
onNodeKeyDown={(node, isSelected, event) => someFunc(node.id)}
|
|
1511
|
-
onFilterClick={(hierarchyLevelDetails) =>
|
|
1657
|
+
onFilterClick={(hierarchyLevelDetails) =>
|
|
1658
|
+
someFunc(hierarchyLevelDetails)
|
|
1659
|
+
}
|
|
1512
1660
|
/>
|
|
1513
1661
|
);
|
|
1514
1662
|
}
|
|
@@ -1541,7 +1689,7 @@
|
|
|
1541
1689
|
...props,
|
|
1542
1690
|
onHierarchyLimitExceeded: ({ nodeId, filter, limit }) => {
|
|
1543
1691
|
console.log(`Hierarchy limit of ${limit} exceeded for node ${nodeId}.`);
|
|
1544
|
-
}
|
|
1692
|
+
},
|
|
1545
1693
|
});
|
|
1546
1694
|
return <TreeRenderer {...state} />;
|
|
1547
1695
|
}
|
|
@@ -1552,7 +1700,7 @@
|
|
|
1552
1700
|
```ts
|
|
1553
1701
|
import { registerTxnListeners } from "@itwin/presentation-core-interop";
|
|
1554
1702
|
|
|
1555
|
-
function MyTree({ imodel, ...props}: Props) {
|
|
1703
|
+
function MyTree({ imodel, ...props }: Props) {
|
|
1556
1704
|
const { reloadTree, treeProps } = useTree(props);
|
|
1557
1705
|
useEffect(() => {
|
|
1558
1706
|
// listen for changes in iModel and reload tree
|
|
@@ -1578,7 +1726,7 @@
|
|
|
1578
1726
|
...props,
|
|
1579
1727
|
onPerformanceMeasured: (action, duration) => {
|
|
1580
1728
|
telemetryClient.log(`MyTree [${feature}] took ${duration} ms`);
|
|
1581
|
-
}
|
|
1729
|
+
},
|
|
1582
1730
|
});
|
|
1583
1731
|
return <TreeRenderer {...state} />;
|
|
1584
1732
|
}
|