@itwin/presentation-hierarchies-react 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +353 -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/Renderers.js +6 -0
- 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/UseSelectionHandler.d.ts +2 -2
- 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 +28 -68
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +43 -44
- 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 +3 -7
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +2 -14
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts +18 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js +32 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +56 -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 +37 -7
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.js +11 -5
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.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 +42 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +72 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +30 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +91 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react.d.ts +11 -9
- package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react.js +8 -8
- 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/TreeActionButtons.d.ts +0 -12
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.js +0 -19
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButtons.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 -42
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -56
- 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,316 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.21
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#961](https://github.com/iTwin/presentation/pull/961): **Breaking changes** to tree state hooks `useTree`, `useUnifiedSelectionTree`, `useIModelTree`, `useIModelUnifiedSelectionTree`:
|
|
8
|
+
|
|
9
|
+
- All tree rendering props have been moved under `treeRendererProps`. The value can be passed to `<StrataKitTreeRenderer />` component.
|
|
10
|
+
- 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.
|
|
11
|
+
- The `isLoading` attribute has been renamed to `isReloading`.
|
|
12
|
+
- Errors are no longer defined as children of `PresentationHierarchyNode` and instead are now included as `error` attribute for more fluent API.
|
|
13
|
+
|
|
14
|
+
When rendering tree state, the recommended order of checks is:
|
|
15
|
+
|
|
16
|
+
1. If `rootErrorRendererProps` is defined, there was an error - render error state.
|
|
17
|
+
2. If `treeRendererProps` is not defined, the component is doing the initial load - render loading state.
|
|
18
|
+
3. If `treeRendererProps` is defined, the hierarchy is loaded - render the tree component.
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
function MyComponent () {
|
|
26
|
+
const useTreeResult = useIModelUnifiedSelectionTree({...});
|
|
27
|
+
|
|
28
|
+
// handle possible root errors with our provided component or your own custom implementation
|
|
29
|
+
if (treeProps.rootErrorRendererProps) {
|
|
30
|
+
return <StrataKitRootErrorRenderer {...useTreeResult.rootErrorRendererProps} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// handle loading state
|
|
34
|
+
if (!treeProps.treeRendererProps) {
|
|
35
|
+
return <MyLoadingComponent />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// handle loaded hierarchy
|
|
39
|
+
return <StrataKitTreeRenderer {...useTreeResult.treeProps} />;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 2.0.0-alpha.20
|
|
44
|
+
|
|
45
|
+
### Major Changes
|
|
46
|
+
|
|
47
|
+
- [#965](https://github.com/iTwin/presentation/pull/965): Added `@stratakit/structures` as a peer dependency.
|
|
48
|
+
|
|
49
|
+
## 2.0.0-alpha.19
|
|
50
|
+
|
|
51
|
+
### Major Changes
|
|
52
|
+
|
|
53
|
+
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
54
|
+
|
|
55
|
+
- `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.
|
|
56
|
+
- `EC.Class` now additionally has these members:
|
|
57
|
+
- `baseClass: Promise<Class | undefined>`
|
|
58
|
+
- `getDerivedClasses(): Promise<Class[]>`
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
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`.
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- [#957](https://github.com/iTwin/presentation/pull/957): Avoid leaking custom props to the `PlaceholderNode` that are causing console errors.
|
|
67
|
+
- Updated dependencies:
|
|
68
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.0
|
|
69
|
+
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
70
|
+
- @itwin/unified-selection@1.4.2-alpha.0
|
|
71
|
+
|
|
72
|
+
## 2.0.0-alpha.18
|
|
73
|
+
|
|
74
|
+
### Major Changes
|
|
75
|
+
|
|
76
|
+
- [#951](https://github.com/iTwin/presentation/pull/951): Move from `@itwin/itwinui-react@5.0.0-alpha` to `@stratakit/*` packages.
|
|
77
|
+
|
|
78
|
+
## 2.0.0-alpha.17
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- [#949](https://github.com/iTwin/presentation/pull/949): Use default imports instead of `URL` constructor for icons.
|
|
83
|
+
|
|
84
|
+
## 2.0.0-alpha.16
|
|
85
|
+
|
|
86
|
+
### Minor Changes
|
|
87
|
+
|
|
88
|
+
- [#945](https://github.com/iTwin/presentation/pull/945): Re-export `getLogger` and `setLogger` functions from `@itwin/presentation-hierarchies` to allow setting a logger.
|
|
89
|
+
|
|
90
|
+
## 2.0.0-alpha.15
|
|
91
|
+
|
|
92
|
+
### Major Changes
|
|
93
|
+
|
|
94
|
+
- [#942](https://github.com/iTwin/presentation/pull/942): Unified selection API cleanup.
|
|
95
|
+
|
|
96
|
+
- Remove deprecated `UnifiedSelectionProvider`.
|
|
97
|
+
- Make `selectionStorage` prop required for unified selection - enabled tree state hooks (`useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree`).
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
|
|
103
|
+
- [#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.
|
|
104
|
+
|
|
105
|
+
Before:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { TreeNodeRenderer, useFilterAction } from "@itwin/presentation-hierarchies-react";
|
|
109
|
+
|
|
110
|
+
const filterAction = useFilterAction({ onFilter, getHierarchyLevelDetails });
|
|
111
|
+
return (
|
|
112
|
+
<TreeNodeRenderer
|
|
113
|
+
actions={useMemo(
|
|
114
|
+
() => [
|
|
115
|
+
filterAction,
|
|
116
|
+
(node) => ({
|
|
117
|
+
label: "Custom Action",
|
|
118
|
+
actions: () => log(node.label),
|
|
119
|
+
icon: customIconHref,
|
|
120
|
+
}),
|
|
121
|
+
],
|
|
122
|
+
[filterAction],
|
|
123
|
+
)}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
After:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { Icon, Tree } from "@itwin/itwinui-react";
|
|
132
|
+
import { FilterAction, TreeNodeRenderer } from "@itwin/presentation-hierarchies-react";
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<TreeNodeRenderer
|
|
136
|
+
getActions={useCallback(
|
|
137
|
+
(node) => [
|
|
138
|
+
<FilterAction key="filter" node={node} onFilter={onFilter} getHierarchyLevelDetails={getHierarchyLevelDetails} />,
|
|
139
|
+
<Tree.ItemAction key="customAction" label="Custom action" onClick={() => log(node.label)} icon={<Icon href={customIconHref} />} />,
|
|
140
|
+
],
|
|
141
|
+
[onFilter, getHierarchyLevelDetails],
|
|
142
|
+
)}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Minor Changes
|
|
148
|
+
|
|
149
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Exposed `TreeErrorRenderer`, which takes `renderError` property to render custom error messages.
|
|
150
|
+
`TreeRenderer` now takes `errorRenderer` to render a custom error display component.
|
|
151
|
+
|
|
152
|
+
Custom error display component example:
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
<TreeRenderer
|
|
156
|
+
{...treeProps}
|
|
157
|
+
errorRenderer={(errorsRendererProps) => (
|
|
158
|
+
<MyErrorRenderer {...errorsRendererProps} />
|
|
159
|
+
)}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Custom error message example:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
<TreeRenderer
|
|
167
|
+
{...treeProps}
|
|
168
|
+
errorRenderer={(errorsRendererProps) => (
|
|
169
|
+
<TreeErrorRenderer
|
|
170
|
+
{...errorsRendererProps}
|
|
171
|
+
renderError={(errorProps) => {
|
|
172
|
+
return <unstable_ErrorRegion.Item message={...} />;
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
)}
|
|
176
|
+
/>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- [#937](https://github.com/iTwin/presentation/pull/937): `TreeRenderer` now takes `rootErrorRenderer` to render a custom root error display component.
|
|
180
|
+
|
|
181
|
+
Custom error display component example:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
<TreeRenderer
|
|
185
|
+
{...treeProps}
|
|
186
|
+
rootErrorRenderer={(rootErrorRendererProps) => (
|
|
187
|
+
<MyRootErrorRenderer {...rootErrorRendererProps} />
|
|
188
|
+
)}
|
|
189
|
+
/>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Changed flat tree building functions to hooks:
|
|
193
|
+
|
|
194
|
+
- `flattenNodes` => `useFlatTreeNodeList`.
|
|
195
|
+
- `getErrors` => `useErrorList`.
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- [#930](https://github.com/iTwin/presentation/pull/930): Fix `ResultSetTooLarge` error suggesting filtering when parent node is not filterable.
|
|
200
|
+
|
|
201
|
+
## 2.0.0-alpha.14
|
|
202
|
+
|
|
203
|
+
### Patch Changes
|
|
204
|
+
|
|
205
|
+
- [#928](https://github.com/iTwin/presentation/pull/928): Memoize tree components to reduce the amount of renders.
|
|
206
|
+
|
|
207
|
+
## 2.0.0-alpha.13
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- [#924](https://github.com/iTwin/presentation/pull/924): Fix tree error dropdown not applying actions.
|
|
212
|
+
|
|
213
|
+
## 2.0.0-alpha.12
|
|
214
|
+
|
|
215
|
+
### Patch Changes
|
|
216
|
+
|
|
217
|
+
- [#922](https://github.com/iTwin/presentation/pull/922): Fix tree displaying aditional scrollbars, when scrolling to the last element with low tree width.
|
|
218
|
+
|
|
219
|
+
## 2.0.0-alpha.11
|
|
220
|
+
|
|
221
|
+
### Patch Changes
|
|
222
|
+
|
|
223
|
+
- [#916](https://github.com/iTwin/presentation/pull/916): Fix tree nodes overlapping when nodes with and without sublabel are rendered alongside.
|
|
224
|
+
- [#920](https://github.com/iTwin/presentation/pull/920): Changed error display for node errors to match new design system.
|
|
225
|
+
|
|
226
|
+
## 2.0.0-alpha.10
|
|
227
|
+
|
|
228
|
+
### Patch Changes
|
|
229
|
+
|
|
230
|
+
- [#913](https://github.com/iTwin/presentation/pull/913): Removed outline showed after node expander is clicked.
|
|
231
|
+
|
|
232
|
+
## 2.0.0-alpha.9
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- [#906](https://github.com/iTwin/presentation/pull/906): Replaced `TreeNodeRenderer.getIcon` prop with `getDecorations` prop.
|
|
237
|
+
|
|
238
|
+
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:
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
// previously, when `getIcon` returned a `ReactElement`:
|
|
242
|
+
function myGetIcon(node: PresentationHierarchyNode): React.ReactElement {
|
|
243
|
+
// implementation...
|
|
244
|
+
}
|
|
245
|
+
<TreeNodeRenderer getIcon={myGetIcon} />
|
|
246
|
+
|
|
247
|
+
// now:
|
|
248
|
+
<TreeNodeRenderer getDecorations={myGetIcon} />
|
|
249
|
+
|
|
250
|
+
// previously, when `getIcon` returned an icon URI:
|
|
251
|
+
function myGetIconUri(node: PresentationHierarchyNode): string {
|
|
252
|
+
// implementation...
|
|
253
|
+
}
|
|
254
|
+
<TreeNodeRenderer getIcon={myGetIconUri} />
|
|
255
|
+
|
|
256
|
+
// now:
|
|
257
|
+
<TreeNodeRenderer getDecorations={(node) => <Icon href={myGetIconUri(node)} />} />
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- [#911](https://github.com/iTwin/presentation/pull/911): Fix incorrect left padding on tree items
|
|
261
|
+
|
|
262
|
+
## 2.0.0-alpha.8
|
|
263
|
+
|
|
264
|
+
### Patch Changes
|
|
265
|
+
|
|
266
|
+
- [#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.
|
|
267
|
+
- [#903](https://github.com/iTwin/presentation/pull/903): Changed `createFilterAction` function to a React hook and renamed it to `useFilterAction`.
|
|
268
|
+
|
|
269
|
+
## 2.0.0-alpha.7
|
|
270
|
+
|
|
271
|
+
### Patch Changes
|
|
272
|
+
|
|
273
|
+
- [#892](https://github.com/iTwin/presentation/pull/892): Fix focus outline for tree items not being visible on action items click.
|
|
274
|
+
- [#894](https://github.com/iTwin/presentation/pull/894): Fix `treeRenderer` property `getSublabel` not being used.
|
|
275
|
+
|
|
276
|
+
## 2.0.0-alpha.6
|
|
277
|
+
|
|
278
|
+
### Patch Changes
|
|
279
|
+
|
|
280
|
+
- [#890](https://github.com/iTwin/presentation/pull/890): Fix alpha peer dependencies to no longer have caret.
|
|
281
|
+
|
|
282
|
+
## 2.0.0-alpha.5
|
|
283
|
+
|
|
284
|
+
### Minor Changes
|
|
285
|
+
|
|
286
|
+
- [#883](https://github.com/iTwin/presentation/pull/883): Trees rendered with `TreeRenderer` will now be virtualized.
|
|
287
|
+
|
|
288
|
+
## 2.0.0-alpha.4
|
|
289
|
+
|
|
290
|
+
### Minor Changes
|
|
291
|
+
|
|
292
|
+
- [#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:
|
|
293
|
+
|
|
294
|
+
- `undefined` - visible on hover/focus,
|
|
295
|
+
- `true` - visible at all times,
|
|
296
|
+
- `false` - hidden at all times.
|
|
297
|
+
|
|
298
|
+
Updated peer dependencies:
|
|
299
|
+
|
|
300
|
+
- itwinui-icons to 5.0.0-alpha.3,
|
|
301
|
+
- itwinui-react to 5.0.0-alpha.6,
|
|
302
|
+
|
|
303
|
+
## 2.0.0-alpha.3
|
|
304
|
+
|
|
305
|
+
### Patch Changes
|
|
306
|
+
|
|
307
|
+
- [#870](https://github.com/iTwin/presentation/pull/870): `TreeRenderer` and `TreeNodeRenderer` now take actions as specification function array.
|
|
308
|
+
|
|
309
|
+
- `label`: Action item's label.
|
|
310
|
+
- `action`: The action performed when the button is clicked.
|
|
311
|
+
- `show` A boolean determining whether the button should be displayed.
|
|
312
|
+
- `icon`: The button's icon.
|
|
313
|
+
|
|
3
314
|
## 2.0.0-alpha.2
|
|
4
315
|
|
|
5
316
|
### Major Changes
|
|
@@ -26,6 +337,48 @@
|
|
|
26
337
|
|
|
27
338
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
28
339
|
|
|
340
|
+
## 1.6.6
|
|
341
|
+
|
|
342
|
+
### Patch Changes
|
|
343
|
+
|
|
344
|
+
- [#944](https://github.com/iTwin/presentation/pull/944): Fixed `extended` selection mode not replacing existing selection when selected node is clicked.
|
|
345
|
+
|
|
346
|
+
## 1.6.5
|
|
347
|
+
|
|
348
|
+
### Patch Changes
|
|
349
|
+
|
|
350
|
+
- [#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.
|
|
351
|
+
|
|
352
|
+
## 1.6.4
|
|
353
|
+
|
|
354
|
+
### Patch Changes
|
|
355
|
+
|
|
356
|
+
- [#909](https://github.com/iTwin/presentation/pull/909): Do not use `dev` versions of `@itwin/*` packages.
|
|
357
|
+
- Updated dependencies:
|
|
358
|
+
- @itwin/unified-selection@1.4.1
|
|
359
|
+
- @itwin/presentation-hierarchies@1.4.2
|
|
360
|
+
- @itwin/presentation-shared@1.2.1
|
|
361
|
+
|
|
362
|
+
## 1.6.3
|
|
363
|
+
|
|
364
|
+
### Patch Changes
|
|
365
|
+
|
|
366
|
+
- Updated dependencies:
|
|
367
|
+
- @itwin/unified-selection@1.4.0
|
|
368
|
+
|
|
369
|
+
## 1.6.2
|
|
370
|
+
|
|
371
|
+
### Patch Changes
|
|
372
|
+
|
|
373
|
+
- [#873](https://github.com/iTwin/presentation/pull/873): Fix hierarchy level size exceeds limit info message wrapping in narrow Tree on Safari browser.
|
|
374
|
+
- [#873](https://github.com/iTwin/presentation/pull/873): Do not require two clicks to expand node with filter buttons on touch devices.
|
|
375
|
+
|
|
376
|
+
## 1.6.1
|
|
377
|
+
|
|
378
|
+
### Patch Changes
|
|
379
|
+
|
|
380
|
+
- [#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.
|
|
381
|
+
|
|
29
382
|
## 1.6.0
|
|
30
383
|
|
|
31
384
|
### 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
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { GenericInstanceFilter, HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
|
+
import { InstanceKey } from "@itwin/presentation-shared";
|
|
3
|
+
import { ErrorInfo, PresentationHierarchyNode } from "./TreeNode.js";
|
|
4
|
+
import { SelectionChangeType } from "./UseSelectionHandler.js";
|
|
5
|
+
/**
|
|
6
|
+
* Type definition used to render tree rendering UI component.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export type TreeRendererProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Array containing root tree nodes.
|
|
12
|
+
*/
|
|
13
|
+
rootNodes: PresentationHierarchyNode[];
|
|
14
|
+
/**
|
|
15
|
+
* A function that should be called to either expand or collapse the given node.
|
|
16
|
+
*/
|
|
17
|
+
expandNode: (nodeId: string, isExpanded: boolean) => void;
|
|
18
|
+
/**
|
|
19
|
+
* A function that should be called to select nodes in the tree.
|
|
20
|
+
* @param nodeIds Ids of the nodes that are selected.
|
|
21
|
+
* @param changeType Type of change that occurred for the selection.
|
|
22
|
+
*/
|
|
23
|
+
selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;
|
|
24
|
+
/** Determines whether a given node is selected. */
|
|
25
|
+
isNodeSelected: (nodeId: string) => boolean;
|
|
26
|
+
} & CommonRendererProps;
|
|
27
|
+
/**
|
|
28
|
+
* Type definition used to render root error handling UI component.
|
|
29
|
+
* @alpha
|
|
30
|
+
*/
|
|
31
|
+
export type RootErrorRendererProps = {
|
|
32
|
+
/** Object containing root error information */
|
|
33
|
+
error: ErrorInfo;
|
|
34
|
+
} & CommonRendererProps;
|
|
35
|
+
/**
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
interface CommonRendererProps {
|
|
39
|
+
/**
|
|
40
|
+
* A function that should be called to reload the tree.
|
|
41
|
+
*/
|
|
42
|
+
reloadTree: (options?: ReloadTreeOptions) => void;
|
|
43
|
+
/** Returns hierarchy level details for a given node ID. */
|
|
44
|
+
getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for doing either full or a sub tree reload.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
interface ReloadTreeOptions {
|
|
51
|
+
/** Specifies parent node under which sub tree should be reloaded. */
|
|
52
|
+
parentNodeId: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies how current tree state should be handled:
|
|
55
|
+
* - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).
|
|
56
|
+
* - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.
|
|
57
|
+
* - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.
|
|
58
|
+
*
|
|
59
|
+
* Defaults to `"keep"`.
|
|
60
|
+
*/
|
|
61
|
+
state?: "keep" | "discard" | "reset";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A data structure that contains information about a single hierarchy level.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface HierarchyLevelDetails {
|
|
68
|
+
/** The parent node whose hierarchy level's information is contained in this data structure */
|
|
69
|
+
hierarchyNode: HierarchyNode | undefined;
|
|
70
|
+
/** A function to get instance keys of the hierarchy level. */
|
|
71
|
+
getInstanceKeysIterator: (props?: {
|
|
72
|
+
instanceFilter?: GenericInstanceFilter;
|
|
73
|
+
hierarchyLevelSizeLimit?: number | "unbounded";
|
|
74
|
+
}) => AsyncIterableIterator<InstanceKey>;
|
|
75
|
+
/** Get the limit of how many nodes can be loaded in this hierarchy level. */
|
|
76
|
+
sizeLimit?: number | "unbounded";
|
|
77
|
+
/** Set the limit of how many nodes can be loaded in this hierarchy level. */
|
|
78
|
+
setSizeLimit: (value: undefined | number | "unbounded") => void;
|
|
79
|
+
/** Get the active instance filter applied to this hierarchy level. */
|
|
80
|
+
instanceFilter?: GenericInstanceFilter;
|
|
81
|
+
/** Set the instance filter to apply to this hierarchy level */
|
|
82
|
+
setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=Renderers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderers.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Renderers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,SAAS,EAAE,yBAAyB,EAAE,CAAC;IACvC;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D;;;;OAIG;IACH,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/E,mDAAmD;IACnD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C,GAAG,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,+CAA+C;IAC/C,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,mBAAmB,CAAC;AAExB;;GAEG;AACH,UAAU,mBAAmB;IAC3B;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,2DAA2D;IAC3D,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,qBAAqB,GAAG,SAAS,CAAC;CAC7F;AAED;;;GAGG;AACH,UAAU,iBAAiB;IACzB,qEAAqE;IACrE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,8DAA8D;IAC9D,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE;QAChC,cAAc,CAAC,EAAE,qBAAqB,CAAC;QACvC,uBAAuB,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;KAChD,KAAK,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,6EAA6E;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAEhE,sEAAsE;IACtE,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,KAAK,IAAI,CAAC;CACxE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=Renderers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderers.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Renderers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { ErrorInfo, PresentationHierarchyNode } from \"./TreeNode.js\";\nimport { SelectionChangeType } from \"./UseSelectionHandler.js\";\n\n/**\n * Type definition used to render tree rendering UI component.\n * @alpha\n */\nexport type TreeRendererProps = {\n /**\n * Array containing root tree nodes.\n */\n rootNodes: PresentationHierarchyNode[];\n /**\n * A function that should be called to either expand or collapse the given node.\n */\n expandNode: (nodeId: string, isExpanded: boolean) => void;\n /**\n * A function that should be called to select nodes in the tree.\n * @param nodeIds Ids of the nodes that are selected.\n * @param changeType Type of change that occurred for the selection.\n */\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n /** Determines whether a given node is selected. */\n isNodeSelected: (nodeId: string) => boolean;\n} & CommonRendererProps;\n\n/**\n * Type definition used to render root error handling UI component.\n * @alpha\n */\nexport type RootErrorRendererProps = {\n /** Object containing root error information */\n error: ErrorInfo;\n} & CommonRendererProps;\n\n/**\n * @alpha\n */\ninterface CommonRendererProps {\n /**\n * A function that should be called to reload the tree.\n */\n reloadTree: (options?: ReloadTreeOptions) => void;\n /** Returns hierarchy level details for a given node ID. */\n getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;\n}\n\n/**\n * Options for doing either full or a sub tree reload.\n * @public\n */\ninterface ReloadTreeOptions {\n /** Specifies parent node under which sub tree should be reloaded. */\n parentNodeId: string | undefined;\n\n /**\n * Specifies how current tree state should be handled:\n * - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).\n * - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.\n * - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.\n *\n * Defaults to `\"keep\"`.\n */\n state?: \"keep\" | \"discard\" | \"reset\";\n}\n\n/**\n * A data structure that contains information about a single hierarchy level.\n * @public\n */\nexport interface HierarchyLevelDetails {\n /** The parent node whose hierarchy level's information is contained in this data structure */\n hierarchyNode: HierarchyNode | undefined;\n\n /** A function to get instance keys of the hierarchy level. */\n getInstanceKeysIterator: (props?: {\n instanceFilter?: GenericInstanceFilter;\n hierarchyLevelSizeLimit?: number | \"unbounded\";\n }) => AsyncIterableIterator<InstanceKey>;\n\n /** Get the limit of how many nodes can be loaded in this hierarchy level. */\n sizeLimit?: number | \"unbounded\";\n /** Set the limit of how many nodes can be loaded in this hierarchy level. */\n setSizeLimit: (value: undefined | number | \"unbounded\") => void;\n\n /** Get the active instance filter applied to this hierarchy level. */\n instanceFilter?: GenericInstanceFilter;\n /** Set the instance filter to apply to this hierarchy level */\n setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;\n}\n"]}
|
|
@@ -1,75 +1,60 @@
|
|
|
1
1
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
2
|
/**
|
|
3
|
-
* A type that defines an
|
|
3
|
+
* A type that defines an node in a UI tree component, built with `useTree` hook.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export interface PresentationHierarchyNode {
|
|
7
7
|
id: string;
|
|
8
8
|
label: string;
|
|
9
|
-
children: true | Array<
|
|
9
|
+
children: true | Array<PresentationHierarchyNode>;
|
|
10
10
|
isExpanded: boolean;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
isFilterable: boolean;
|
|
13
13
|
isFiltered: boolean;
|
|
14
14
|
/** UI-agnostic source of this node object. */
|
|
15
15
|
nodeData: HierarchyNode;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
16
|
+
/** Contains error encountered from expanding the node */
|
|
17
|
+
error?: ErrorInfo;
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
22
|
-
* A type of `
|
|
20
|
+
* A type of `ErrorInfo` that is returned,
|
|
23
21
|
* when none of the child nodes match the filter.
|
|
24
22
|
*
|
|
25
23
|
* @public
|
|
26
24
|
*/
|
|
27
|
-
export interface
|
|
25
|
+
export interface NoFilterMatchesErrorInfo {
|
|
28
26
|
id: string;
|
|
29
|
-
parentNodeId: string | undefined;
|
|
30
27
|
type: "NoFilterMatches";
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
|
-
* A type of `
|
|
30
|
+
* A type of `ErrorInfo` that is returned, when the
|
|
34
31
|
* number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included
|
|
35
|
-
* on this
|
|
32
|
+
* on this error as `resultSetSizeLimit` attribute.
|
|
36
33
|
*
|
|
37
34
|
* @public
|
|
38
35
|
*/
|
|
39
|
-
export interface
|
|
36
|
+
export interface ResultSetTooLargeErrorInfo {
|
|
40
37
|
id: string;
|
|
41
|
-
parentNodeId: string | undefined;
|
|
42
38
|
type: "ResultSetTooLarge";
|
|
43
39
|
resultSetSizeLimit: number;
|
|
44
40
|
}
|
|
45
41
|
/**
|
|
46
|
-
* A type of `
|
|
47
|
-
*
|
|
42
|
+
* A type of `ErrorInfo` that contains a user-friendly message to be displayed in the UI.
|
|
43
|
+
* Created in cases like an error loading children. The
|
|
48
44
|
* renderer may offer users to re-load the children or the whole component in such cases.
|
|
49
45
|
*
|
|
50
46
|
* @public
|
|
51
47
|
*/
|
|
52
|
-
export interface
|
|
48
|
+
export interface GenericErrorInfo {
|
|
53
49
|
id: string;
|
|
54
|
-
parentNodeId: string | undefined;
|
|
55
50
|
type: "Unknown";
|
|
56
51
|
message: string;
|
|
57
52
|
}
|
|
58
53
|
/**
|
|
59
|
-
* A
|
|
54
|
+
* A collection of types that defines an error state for `PresentationHierarchyNode` node in a UI tree component, built
|
|
60
55
|
* with `useTree` hook.
|
|
61
56
|
*
|
|
62
57
|
* @public
|
|
63
58
|
*/
|
|
64
|
-
export type
|
|
65
|
-
/**
|
|
66
|
-
* A type that defines a node in a UI tree component, built with `useTree` hook.
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;
|
|
70
|
-
/**
|
|
71
|
-
* An utility function to check if a node is a `PresentationHierarchyNode`.
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
export declare function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode;
|
|
59
|
+
export type ErrorInfo = GenericErrorInfo | ResultSetTooLargeErrorInfo | NoFilterMatchesErrorInfo;
|
|
75
60
|
//# sourceMappingURL=TreeNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAClD,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,aAAa,CAAC;IACxB,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,wBAAwB,CAAC"}
|
|
@@ -2,11 +2,5 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
* An utility function to check if a node is a `PresentationHierarchyNode`.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export function isPresentationHierarchyNode(node) {
|
|
10
|
-
return "children" in node;
|
|
11
|
-
}
|
|
5
|
+
export {};
|
|
12
6
|
//# sourceMappingURL=TreeNode.js.map
|