@itwin/presentation-hierarchies-react 2.0.0-alpha.3 → 2.0.0-alpha.30
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 +520 -0
- package/README.md +24 -24
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +85 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/{itwinui/TreeActionButton.css → Renderers.js} +2 -4
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +14 -29
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +1 -7
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +2 -0
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +3 -3
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +1 -8
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +32 -70
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +48 -49
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +5 -0
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/Utils.js +23 -0
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +31 -16
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +24 -6
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +28 -32
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +6 -29
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +31 -27
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +23 -9
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +16 -29
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts +34 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js +26 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +58 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +74 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.d.ts +47 -7
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.js +13 -5
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts +33 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js +39 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +42 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +43 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +70 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +49 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +116 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +40 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +93 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react.d.ts +12 -10
- package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react.js +9 -9
- package/lib/esm/presentation-hierarchies-react.js.map +1 -1
- package/package.json +46 -38
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -21
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -29
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -12
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts +0 -12
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js +0 -10
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -45
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -71
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -22
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,389 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1037](https://github.com/iTwin/presentation/pull/1037): Added additional documentation for `RenameAction`
|
|
8
|
+
|
|
9
|
+
## 2.0.0-alpha.29
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1035](https://github.com/iTwin/presentation/pull/1035): Version bump after merge from `master`.
|
|
14
|
+
|
|
15
|
+
## 2.0.0-alpha.28
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#1031](https://github.com/iTwin/presentation/pull/1031): Version bump
|
|
20
|
+
- Updated dependencies:
|
|
21
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.3
|
|
22
|
+
- @itwin/unified-selection@1.5.1-alpha.0
|
|
23
|
+
|
|
24
|
+
## 2.0.0-alpha.27
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#1026](https://github.com/iTwin/presentation/pull/1026): Fix `reserveSpace` property being required instead of optional for `FilterAction` and `RenameAction`.
|
|
29
|
+
|
|
30
|
+
## 2.0.0-alpha.26
|
|
31
|
+
|
|
32
|
+
### Major Changes
|
|
33
|
+
|
|
34
|
+
- [#1023](https://github.com/iTwin/presentation/pull/1023): Split `getActions` into `getMenuActions` & `getInlineActions` for `StrataKitTreeRenderer` and `StrataKitTreeNodeRenderer`.
|
|
35
|
+
|
|
36
|
+
Updated peer dependencies:
|
|
37
|
+
|
|
38
|
+
- @stratakit/bricks@0.3.3
|
|
39
|
+
- @stratakit/foundations@0.2.2
|
|
40
|
+
- @stratakit/structures@0.3.1
|
|
41
|
+
|
|
42
|
+
Added `reserveSpace` property to `FilterAction` and `RenameAction`, which reserves space for the action when it is not available
|
|
43
|
+
|
|
44
|
+
### Minor Changes
|
|
45
|
+
|
|
46
|
+
- [#1007](https://github.com/iTwin/presentation/pull/1007): Renames:
|
|
47
|
+
`FlatNode` => `FlatTreeNodeItem`
|
|
48
|
+
`FlatTreeNode` => `FlatTreeItem`
|
|
49
|
+
`PlaceholderNode` => `PlaceholderItem`
|
|
50
|
+
`useFlatTreeNodeList` => `useFlatTreeItems`
|
|
51
|
+
|
|
52
|
+
Changed `FlatTreeNodeItem` (previously `FlatNode`) to have property `node: PresentationHierarchyNode` instead of extending `PresentationHierarchyNode`.
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies:
|
|
57
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.2
|
|
58
|
+
|
|
59
|
+
## 2.0.0-alpha.25
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies:
|
|
64
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.1
|
|
65
|
+
- @itwin/presentation-shared@2.0.0-alpha.1
|
|
66
|
+
- @itwin/unified-selection@1.4.3-alpha.0
|
|
67
|
+
|
|
68
|
+
## 2.0.0-alpha.24
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- [#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.
|
|
73
|
+
- [#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.
|
|
74
|
+
|
|
75
|
+
## 2.0.0-alpha.23
|
|
76
|
+
|
|
77
|
+
### Minor Changes
|
|
78
|
+
|
|
79
|
+
- [#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.
|
|
80
|
+
|
|
81
|
+
## 2.0.0-alpha.22
|
|
82
|
+
|
|
83
|
+
### Minor Changes
|
|
84
|
+
|
|
85
|
+
- [#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.
|
|
86
|
+
|
|
87
|
+
## 2.0.0-alpha.21
|
|
88
|
+
|
|
89
|
+
### Major Changes
|
|
90
|
+
|
|
91
|
+
- [#961](https://github.com/iTwin/presentation/pull/961): **Breaking changes** to tree state hooks `useTree`, `useUnifiedSelectionTree`, `useIModelTree`, `useIModelUnifiedSelectionTree`:
|
|
92
|
+
|
|
93
|
+
- All tree rendering props have been moved under `treeRendererProps`. The value can be passed to `<StrataKitTreeRenderer />` component.
|
|
94
|
+
- 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.
|
|
95
|
+
- The `isLoading` attribute has been renamed to `isReloading`.
|
|
96
|
+
- Errors are no longer defined as children of `PresentationHierarchyNode` and instead are now included as `error` attribute for more fluent API.
|
|
97
|
+
|
|
98
|
+
When rendering tree state, the recommended order of checks is:
|
|
99
|
+
|
|
100
|
+
1. If `rootErrorRendererProps` is defined, there was an error - render error state.
|
|
101
|
+
2. If `treeRendererProps` is not defined, the component is doing the initial load - render loading state.
|
|
102
|
+
3. If `treeRendererProps` is defined, the hierarchy is loaded - render the tree component.
|
|
103
|
+
|
|
104
|
+
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.
|
|
105
|
+
|
|
106
|
+
Example:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
function MyComponent () {
|
|
110
|
+
const useTreeResult = useIModelUnifiedSelectionTree({...});
|
|
111
|
+
|
|
112
|
+
// handle possible root errors with our provided component or your own custom implementation
|
|
113
|
+
if (treeProps.rootErrorRendererProps) {
|
|
114
|
+
return <StrataKitRootErrorRenderer {...useTreeResult.rootErrorRendererProps} />;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// handle loading state
|
|
118
|
+
if (!treeProps.treeRendererProps) {
|
|
119
|
+
return <MyLoadingComponent />;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// handle loaded hierarchy
|
|
123
|
+
return <StrataKitTreeRenderer {...useTreeResult.treeProps} />;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 2.0.0-alpha.20
|
|
128
|
+
|
|
129
|
+
### Major Changes
|
|
130
|
+
|
|
131
|
+
- [#965](https://github.com/iTwin/presentation/pull/965): Added `@stratakit/structures` as a peer dependency.
|
|
132
|
+
|
|
133
|
+
## 2.0.0-alpha.19
|
|
134
|
+
|
|
135
|
+
### Major Changes
|
|
136
|
+
|
|
137
|
+
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
138
|
+
|
|
139
|
+
- `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.
|
|
140
|
+
- `EC.Class` now additionally has these members:
|
|
141
|
+
- `baseClass: Promise<Class | undefined>`
|
|
142
|
+
- `getDerivedClasses(): Promise<Class[]>`
|
|
143
|
+
|
|
144
|
+
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.
|
|
145
|
+
|
|
146
|
+
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`.
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- [#957](https://github.com/iTwin/presentation/pull/957): Avoid leaking custom props to the `PlaceholderNode` that are causing console errors.
|
|
151
|
+
- Updated dependencies:
|
|
152
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.0
|
|
153
|
+
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
154
|
+
- @itwin/unified-selection@1.4.2-alpha.0
|
|
155
|
+
|
|
156
|
+
## 2.0.0-alpha.18
|
|
157
|
+
|
|
158
|
+
### Major Changes
|
|
159
|
+
|
|
160
|
+
- [#951](https://github.com/iTwin/presentation/pull/951): Move from `@itwin/itwinui-react@5.0.0-alpha` to `@stratakit/*` packages.
|
|
161
|
+
|
|
162
|
+
## 2.0.0-alpha.17
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- [#949](https://github.com/iTwin/presentation/pull/949): Use default imports instead of `URL` constructor for icons.
|
|
167
|
+
|
|
168
|
+
## 2.0.0-alpha.16
|
|
169
|
+
|
|
170
|
+
### Minor Changes
|
|
171
|
+
|
|
172
|
+
- [#945](https://github.com/iTwin/presentation/pull/945): Re-export `getLogger` and `setLogger` functions from `@itwin/presentation-hierarchies` to allow setting a logger.
|
|
173
|
+
|
|
174
|
+
## 2.0.0-alpha.15
|
|
175
|
+
|
|
176
|
+
### Major Changes
|
|
177
|
+
|
|
178
|
+
- [#942](https://github.com/iTwin/presentation/pull/942): Unified selection API cleanup.
|
|
179
|
+
|
|
180
|
+
- Remove deprecated `UnifiedSelectionProvider`.
|
|
181
|
+
- Make `selectionStorage` prop required for unified selection - enabled tree state hooks (`useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree`).
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
- [#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.
|
|
188
|
+
|
|
189
|
+
Before:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { TreeNodeRenderer, useFilterAction } from "@itwin/presentation-hierarchies-react";
|
|
193
|
+
|
|
194
|
+
const filterAction = useFilterAction({ onFilter, getHierarchyLevelDetails });
|
|
195
|
+
return (
|
|
196
|
+
<TreeNodeRenderer
|
|
197
|
+
actions={useMemo(
|
|
198
|
+
() => [
|
|
199
|
+
filterAction,
|
|
200
|
+
(node) => ({
|
|
201
|
+
label: "Custom Action",
|
|
202
|
+
actions: () => log(node.label),
|
|
203
|
+
icon: customIconHref,
|
|
204
|
+
}),
|
|
205
|
+
],
|
|
206
|
+
[filterAction],
|
|
207
|
+
)}
|
|
208
|
+
/>
|
|
209
|
+
);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
After:
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { Icon, Tree } from "@itwin/itwinui-react";
|
|
216
|
+
import { FilterAction, TreeNodeRenderer } from "@itwin/presentation-hierarchies-react";
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<TreeNodeRenderer
|
|
220
|
+
getActions={useCallback(
|
|
221
|
+
(node) => [
|
|
222
|
+
<FilterAction key="filter" node={node} onFilter={onFilter} getHierarchyLevelDetails={getHierarchyLevelDetails} />,
|
|
223
|
+
<Tree.ItemAction key="customAction" label="Custom action" onClick={() => log(node.label)} icon={<Icon href={customIconHref} />} />,
|
|
224
|
+
],
|
|
225
|
+
[onFilter, getHierarchyLevelDetails],
|
|
226
|
+
)}
|
|
227
|
+
/>
|
|
228
|
+
);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Minor Changes
|
|
232
|
+
|
|
233
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Exposed `TreeErrorRenderer`, which takes `renderError` property to render custom error messages.
|
|
234
|
+
`TreeRenderer` now takes `errorRenderer` to render a custom error display component.
|
|
235
|
+
|
|
236
|
+
Custom error display component example:
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
<TreeRenderer
|
|
240
|
+
{...treeProps}
|
|
241
|
+
errorRenderer={(errorsRendererProps) => (
|
|
242
|
+
<MyErrorRenderer {...errorsRendererProps} />
|
|
243
|
+
)}
|
|
244
|
+
/>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Custom error message example:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
<TreeRenderer
|
|
251
|
+
{...treeProps}
|
|
252
|
+
errorRenderer={(errorsRendererProps) => (
|
|
253
|
+
<TreeErrorRenderer
|
|
254
|
+
{...errorsRendererProps}
|
|
255
|
+
renderError={(errorProps) => {
|
|
256
|
+
return <unstable_ErrorRegion.Item message={...} />;
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
260
|
+
/>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- [#937](https://github.com/iTwin/presentation/pull/937): `TreeRenderer` now takes `rootErrorRenderer` to render a custom root error display component.
|
|
264
|
+
|
|
265
|
+
Custom error display component example:
|
|
266
|
+
|
|
267
|
+
```ts
|
|
268
|
+
<TreeRenderer
|
|
269
|
+
{...treeProps}
|
|
270
|
+
rootErrorRenderer={(rootErrorRendererProps) => (
|
|
271
|
+
<MyRootErrorRenderer {...rootErrorRendererProps} />
|
|
272
|
+
)}
|
|
273
|
+
/>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Changed flat tree building functions to hooks:
|
|
277
|
+
|
|
278
|
+
- `flattenNodes` => `useFlatTreeNodeList`.
|
|
279
|
+
- `getErrors` => `useErrorList`.
|
|
280
|
+
|
|
281
|
+
### Patch Changes
|
|
282
|
+
|
|
283
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Fix `ResultSetTooLarge` error suggesting filtering when parent node is not filterable.
|
|
284
|
+
|
|
285
|
+
## 2.0.0-alpha.14
|
|
286
|
+
|
|
287
|
+
### Patch Changes
|
|
288
|
+
|
|
289
|
+
- [#928](https://github.com/iTwin/presentation/pull/928): Memoize tree components to reduce the amount of renders.
|
|
290
|
+
|
|
291
|
+
## 2.0.0-alpha.13
|
|
292
|
+
|
|
293
|
+
### Patch Changes
|
|
294
|
+
|
|
295
|
+
- [#924](https://github.com/iTwin/presentation/pull/924): Fix tree error dropdown not applying actions.
|
|
296
|
+
|
|
297
|
+
## 2.0.0-alpha.12
|
|
298
|
+
|
|
299
|
+
### Patch Changes
|
|
300
|
+
|
|
301
|
+
- [#922](https://github.com/iTwin/presentation/pull/922): Fix tree displaying aditional scrollbars, when scrolling to the last element with low tree width.
|
|
302
|
+
|
|
303
|
+
## 2.0.0-alpha.11
|
|
304
|
+
|
|
305
|
+
### Patch Changes
|
|
306
|
+
|
|
307
|
+
- [#916](https://github.com/iTwin/presentation/pull/916): Fix tree nodes overlapping when nodes with and without sublabel are rendered alongside.
|
|
308
|
+
- [#920](https://github.com/iTwin/presentation/pull/920): Changed error display for node errors to match new design system.
|
|
309
|
+
|
|
310
|
+
## 2.0.0-alpha.10
|
|
311
|
+
|
|
312
|
+
### Patch Changes
|
|
313
|
+
|
|
314
|
+
- [#913](https://github.com/iTwin/presentation/pull/913): Removed outline showed after node expander is clicked.
|
|
315
|
+
|
|
316
|
+
## 2.0.0-alpha.9
|
|
317
|
+
|
|
318
|
+
### Patch Changes
|
|
319
|
+
|
|
320
|
+
- [#906](https://github.com/iTwin/presentation/pull/906): Replaced `TreeNodeRenderer.getIcon` prop with `getDecorations` prop.
|
|
321
|
+
|
|
322
|
+
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:
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
// previously, when `getIcon` returned a `ReactElement`:
|
|
326
|
+
function myGetIcon(node: PresentationHierarchyNode): React.ReactElement {
|
|
327
|
+
// implementation...
|
|
328
|
+
}
|
|
329
|
+
<TreeNodeRenderer getIcon={myGetIcon} />
|
|
330
|
+
|
|
331
|
+
// now:
|
|
332
|
+
<TreeNodeRenderer getDecorations={myGetIcon} />
|
|
333
|
+
|
|
334
|
+
// previously, when `getIcon` returned an icon URI:
|
|
335
|
+
function myGetIconUri(node: PresentationHierarchyNode): string {
|
|
336
|
+
// implementation...
|
|
337
|
+
}
|
|
338
|
+
<TreeNodeRenderer getIcon={myGetIconUri} />
|
|
339
|
+
|
|
340
|
+
// now:
|
|
341
|
+
<TreeNodeRenderer getDecorations={(node) => <Icon href={myGetIconUri(node)} />} />
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
- [#911](https://github.com/iTwin/presentation/pull/911): Fix incorrect left padding on tree items
|
|
345
|
+
|
|
346
|
+
## 2.0.0-alpha.8
|
|
347
|
+
|
|
348
|
+
### Patch Changes
|
|
349
|
+
|
|
350
|
+
- [#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.
|
|
351
|
+
- [#903](https://github.com/iTwin/presentation/pull/903): Changed `createFilterAction` function to a React hook and renamed it to `useFilterAction`.
|
|
352
|
+
|
|
353
|
+
## 2.0.0-alpha.7
|
|
354
|
+
|
|
355
|
+
### Patch Changes
|
|
356
|
+
|
|
357
|
+
- [#892](https://github.com/iTwin/presentation/pull/892): Fix focus outline for tree items not being visible on action items click.
|
|
358
|
+
- [#894](https://github.com/iTwin/presentation/pull/894): Fix `treeRenderer` property `getSublabel` not being used.
|
|
359
|
+
|
|
360
|
+
## 2.0.0-alpha.6
|
|
361
|
+
|
|
362
|
+
### Patch Changes
|
|
363
|
+
|
|
364
|
+
- [#890](https://github.com/iTwin/presentation/pull/890): Fix alpha peer dependencies to no longer have caret.
|
|
365
|
+
|
|
366
|
+
## 2.0.0-alpha.5
|
|
367
|
+
|
|
368
|
+
### Minor Changes
|
|
369
|
+
|
|
370
|
+
- [#883](https://github.com/iTwin/presentation/pull/883): Trees rendered with `TreeRenderer` will now be virtualized.
|
|
371
|
+
|
|
372
|
+
## 2.0.0-alpha.4
|
|
373
|
+
|
|
374
|
+
### Minor Changes
|
|
375
|
+
|
|
376
|
+
- [#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:
|
|
377
|
+
|
|
378
|
+
- `undefined` - visible on hover/focus,
|
|
379
|
+
- `true` - visible at all times,
|
|
380
|
+
- `false` - hidden at all times.
|
|
381
|
+
|
|
382
|
+
Updated peer dependencies:
|
|
383
|
+
|
|
384
|
+
- itwinui-icons to 5.0.0-alpha.3,
|
|
385
|
+
- itwinui-react to 5.0.0-alpha.6,
|
|
386
|
+
|
|
3
387
|
## 2.0.0-alpha.3
|
|
4
388
|
|
|
5
389
|
### Patch Changes
|
|
@@ -37,6 +421,142 @@
|
|
|
37
421
|
|
|
38
422
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
39
423
|
|
|
424
|
+
## 1.9.1
|
|
425
|
+
|
|
426
|
+
### Patch Changes
|
|
427
|
+
|
|
428
|
+
- [#1033](https://github.com/iTwin/presentation/pull/1033): Fix unified selection tree state hooks `useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree` not handling the recently added `createSelectableForGenericNode` prop.
|
|
429
|
+
|
|
430
|
+
## 1.9.0
|
|
431
|
+
|
|
432
|
+
### Minor Changes
|
|
433
|
+
|
|
434
|
+
- [#1027](https://github.com/iTwin/presentation/pull/1027): Added `getActions` property to `TreeRenderer` and `TreeNodeRenderer` to allow providing custom actions for tree nodes.
|
|
435
|
+
|
|
436
|
+
## 1.8.1
|
|
437
|
+
|
|
438
|
+
### Patch Changes
|
|
439
|
+
|
|
440
|
+
- Updated dependencies:
|
|
441
|
+
- @itwin/presentation-hierarchies@1.7.1
|
|
442
|
+
|
|
443
|
+
## 1.8.0
|
|
444
|
+
|
|
445
|
+
### Minor Changes
|
|
446
|
+
|
|
447
|
+
- [#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.
|
|
448
|
+
|
|
449
|
+
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:
|
|
450
|
+
|
|
451
|
+
```tsx
|
|
452
|
+
import { useUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
|
|
453
|
+
|
|
454
|
+
const treeState = useUnifiedSelectionTree({
|
|
455
|
+
selectionStorage,
|
|
456
|
+
createSelectableForGenericNode: useCallback<NonNullable<Props<typeof useUnifiedSelectionTree>["createSelectableForGenericNode"]>>(
|
|
457
|
+
(node, uniqueId) => ({ identifier: node.key.id, data: node, async *loadInstanceKeys() {} }),
|
|
458
|
+
[],
|
|
459
|
+
),
|
|
460
|
+
// ...other options
|
|
461
|
+
});
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Patch Changes
|
|
465
|
+
|
|
466
|
+
- Updated dependencies:
|
|
467
|
+
- @itwin/unified-selection@1.5.0
|
|
468
|
+
|
|
469
|
+
## 1.7.2
|
|
470
|
+
|
|
471
|
+
### Patch Changes
|
|
472
|
+
|
|
473
|
+
- Updated dependencies:
|
|
474
|
+
- @itwin/presentation-hierarchies@1.7.0
|
|
475
|
+
|
|
476
|
+
## 1.7.1
|
|
477
|
+
|
|
478
|
+
### Patch Changes
|
|
479
|
+
|
|
480
|
+
- Updated dependencies:
|
|
481
|
+
- @itwin/presentation-hierarchies@1.6.1
|
|
482
|
+
|
|
483
|
+
## 1.7.0
|
|
484
|
+
|
|
485
|
+
### Minor Changes
|
|
486
|
+
|
|
487
|
+
- 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.
|
|
488
|
+
|
|
489
|
+
### Patch Changes
|
|
490
|
+
|
|
491
|
+
- Updated dependencies:
|
|
492
|
+
- @itwin/presentation-hierarchies@1.6.0
|
|
493
|
+
|
|
494
|
+
## 1.6.9
|
|
495
|
+
|
|
496
|
+
### Patch Changes
|
|
497
|
+
|
|
498
|
+
- [#1000](https://github.com/iTwin/presentation/pull/1000): Made sure `Apply filter` button becomes focused after hierarchy level filter is applied.
|
|
499
|
+
|
|
500
|
+
## 1.6.8
|
|
501
|
+
|
|
502
|
+
### Patch Changes
|
|
503
|
+
|
|
504
|
+
- [#982](https://github.com/iTwin/presentation/pull/982): Update itwinjs-core dependencies to v5.0.0
|
|
505
|
+
- Updated dependencies:
|
|
506
|
+
- @itwin/presentation-hierarchies@1.5.1
|
|
507
|
+
- @itwin/presentation-shared@1.2.2
|
|
508
|
+
- @itwin/unified-selection@1.4.2
|
|
509
|
+
|
|
510
|
+
## 1.6.7
|
|
511
|
+
|
|
512
|
+
### Patch Changes
|
|
513
|
+
|
|
514
|
+
- [#974](https://github.com/iTwin/presentation/pull/974): Removed tree node outline on mobile devices.
|
|
515
|
+
- Updated dependencies:
|
|
516
|
+
- @itwin/presentation-hierarchies@1.5.0
|
|
517
|
+
|
|
518
|
+
## 1.6.6
|
|
519
|
+
|
|
520
|
+
### Patch Changes
|
|
521
|
+
|
|
522
|
+
- [#944](https://github.com/iTwin/presentation/pull/944): Fixed `extended` selection mode not replacing existing selection when selected node is clicked.
|
|
523
|
+
|
|
524
|
+
## 1.6.5
|
|
525
|
+
|
|
526
|
+
### Patch Changes
|
|
527
|
+
|
|
528
|
+
- [#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.
|
|
529
|
+
|
|
530
|
+
## 1.6.4
|
|
531
|
+
|
|
532
|
+
### Patch Changes
|
|
533
|
+
|
|
534
|
+
- [#909](https://github.com/iTwin/presentation/pull/909): Do not use `dev` versions of `@itwin/*` packages.
|
|
535
|
+
- Updated dependencies:
|
|
536
|
+
- @itwin/unified-selection@1.4.1
|
|
537
|
+
- @itwin/presentation-hierarchies@1.4.2
|
|
538
|
+
- @itwin/presentation-shared@1.2.1
|
|
539
|
+
|
|
540
|
+
## 1.6.3
|
|
541
|
+
|
|
542
|
+
### Patch Changes
|
|
543
|
+
|
|
544
|
+
- Updated dependencies:
|
|
545
|
+
- @itwin/unified-selection@1.4.0
|
|
546
|
+
|
|
547
|
+
## 1.6.2
|
|
548
|
+
|
|
549
|
+
### Patch Changes
|
|
550
|
+
|
|
551
|
+
- [#873](https://github.com/iTwin/presentation/pull/873): Fix hierarchy level size exceeds limit info message wrapping in narrow Tree on Safari browser.
|
|
552
|
+
- [#873](https://github.com/iTwin/presentation/pull/873): Do not require two clicks to expand node with filter buttons on touch devices.
|
|
553
|
+
|
|
554
|
+
## 1.6.1
|
|
555
|
+
|
|
556
|
+
### Patch Changes
|
|
557
|
+
|
|
558
|
+
- [#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.
|
|
559
|
+
|
|
40
560
|
## 1.6.0
|
|
41
561
|
|
|
42
562
|
### 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 [
|
|
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
|
-
##
|
|
128
|
+
## StrataKit components
|
|
129
129
|
|
|
130
|
-
While the package provides a headless UI, it also delivers a set of [
|
|
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
|
|
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 `
|
|
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 "@
|
|
310
|
-
import {
|
|
311
|
-
|
|
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
|
|
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
|
|
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
|
}
|