@itwin/presentation-hierarchies-react 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +92 -74
  3. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts +53 -0
  4. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
  5. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js +65 -0
  6. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
  7. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts +16 -45
  8. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  9. package/lib/cjs/presentation-hierarchies-react/UseTree.js +46 -47
  10. package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +1 -1
  11. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts +3 -2
  12. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  13. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +8 -6
  14. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  15. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts +3 -2
  16. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  17. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +6 -4
  18. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  19. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +1 -3
  20. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  21. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +79 -43
  22. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  23. package/lib/cjs/presentation-hierarchies-react/internal/Utils.js +1 -1
  24. package/lib/cjs/presentation-hierarchies-react/internal/Utils.js.map +1 -1
  25. package/lib/cjs/presentation-hierarchies-react.d.ts +1 -0
  26. package/lib/cjs/presentation-hierarchies-react.d.ts.map +1 -1
  27. package/lib/cjs/presentation-hierarchies-react.js +4 -1
  28. package/lib/cjs/presentation-hierarchies-react.js.map +1 -1
  29. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +53 -0
  30. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
  31. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +61 -0
  32. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
  33. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +16 -45
  34. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/UseTree.js +47 -48
  36. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +3 -2
  38. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +8 -6
  40. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +3 -2
  42. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +6 -4
  44. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +1 -3
  46. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +79 -43
  48. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  49. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +1 -1
  50. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
  51. package/lib/esm/presentation-hierarchies-react.d.ts +1 -0
  52. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  53. package/lib/esm/presentation-hierarchies-react.js +1 -0
  54. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  55. package/package.json +7 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # @itwin/presentation-hierarchies-react
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#708](https://github.com/iTwin/presentation/pull/708): **BREAKING:** A new attribute - `imodelKey` - has been added to `imodelAccess` prop of "use tree" hooks. For the most common case when a hierarchy is built from an `IModelConnection`, it's recommended to use `key` attribute of the connection as this value.
8
+
9
+ Example:
10
+
11
+ ```ts
12
+ function createHierarchyProvider(imodel: IModelConnection) {
13
+ return createIModelHierarchyProvider({
14
+ imodelAccess: {
15
+ imodelKey: imodel.key, // set the newly introduced `imodelKey` attribute
16
+ // ... other iModel access props
17
+ },
18
+ // ... other provider props
19
+ });
20
+ }
21
+ ```
22
+
23
+ See "Basic example" section in README learning page for the full example.
24
+
25
+ - [#717](https://github.com/iTwin/presentation/pull/717): **BREAKING:** Add support for non-iModel-driven trees.
26
+
27
+ - `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.
28
+ - 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.
29
+
30
+ Reacting to this breaking change is as simple as renaming the calls to `useTree` and `useUnifiedSelectionTree` to `useIModelTree` and `useIModelUnifiedSelectionTree`, respectively.
31
+
32
+ - [#717](https://github.com/iTwin/presentation/pull/717): **BREAKING:** The `reloadTree` function attribute returned by "use tree" hooks has been changed to **not** accept a `dataSourceChanged` parameter.
33
+
34
+ The parameter was used to notify the tree component that the underlying data source has changed and the tree should be reloaded. For example, something like this was necessary:
35
+
36
+ ```tsx
37
+ const { reloadTree } = useIModelUnifiedSelectionTree({
38
+ // ...
39
+ });
40
+
41
+ useEffect(() => {
42
+ if (!imodel.isBriefcaseConnection()) {
43
+ return;
44
+ }
45
+
46
+ return registerTxnListeners(imodel.txns, () => {
47
+ reloadTree({ dataSourceChanged: true });
48
+ });
49
+ }, [imodel, reloadTree]);
50
+ ```
51
+
52
+ Now, the `HierarchyProvider` notifies the hook about hierarchy changes.
53
+
54
+ Note that iModel-based hierarchy providers require an `imodelChanged` event object to be provided and raised when the underlying iModel changes:
55
+
56
+ ```tsx
57
+ const [imodelChanged] = useState(new BeEvent<() => void>());
58
+ useEffect(() => {
59
+ if (imodel.isBriefcaseConnection()) {
60
+ return registerTxnListeners(imodel.txns, () => imodelChanged.raiseEvent());
61
+ }
62
+ return undefined;
63
+ }, [imodel, imodelChanged]);
64
+
65
+ const { ... } = useIModelUnifiedSelectionTree({
66
+ imodelChanged,
67
+ ...,
68
+ });
69
+ ```
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies:
74
+ - @itwin/presentation-hierarchies@0.7.0
75
+
3
76
  ## 0.7.2
4
77
 
5
78
  ### Patch Changes
package/README.md CHANGED
@@ -6,11 +6,55 @@ The `@itwin/presentation-hierarchies-react` package provides APIs for building a
6
6
 
7
7
  ## Headless UI
8
8
 
9
- ### `useTree`
9
+ ### Tree state hooks
10
10
 
11
- This is a React hook that creates state for a tree component.
11
+ The package provides different flavors of the same hook for creating and managing state of a tree component:
12
12
 
13
- It takes 2 required properties:
13
+ | Feature \ Hook | `useTree` | `useIModelTree` | `useUnifiedSelectionTree` | `useIModelUnifiedSelectionTree` |
14
+ | ---------------------------------------------------------------------------------------------------- | --------- | --------------- | ------------------------- | ------------------------------- |
15
+ | Supported data source | any | iModel | any | iModel |
16
+ | Integration with [Unified Selection](https://www.itwinjs.org/presentation/unified-selection/) system | ❌ | ❌ | ✔️ | ✔️ |
17
+
18
+ All these hooks return the same state object, which contains properties and functions to manage the tree component:
19
+
20
+ - `isLoading` is a boolean indicating whether the root tree nodes are being loaded. Set to `true` on initial load and on reload (e.g. when iModel data changes).
21
+
22
+ - `rootNodes` is an array of root tree nodes and is what the component should render. There are several types of nodes:
23
+
24
+ - A `PresentationHierarchyNode` is the primary type of node, created based on the hierarchy definition. The `isPresentationHierarchyNode` type guard utility may be used to check if a node is of this type.
25
+ - A `PresentationInfoNode` is a non-expandable, non-selectable informational type of node, generally created when for some reason we don't have any real nodes to show. There may be different reasons like filtered-out nodes, too large result set, a network error, etc. The `type` attribute of the node indicates that.
26
+
27
+ - `expandNode` function to expand or collapse a node.
28
+
29
+ - `isNodeSelected` and `selectNodes` function to inspect and change tree selection.
30
+
31
+ - `getHierarchyLevelDetails` function to access details of a specific hierarchy level. The returned object provides access to:
32
+
33
+ - hierarchy level size limit,
34
+ - hierarchy level instance filter,
35
+ - instance keys of the nodes in the hierarchy level.
36
+
37
+ - `reloadTree` function to reload part of the tree, optionally keeping its state.
38
+
39
+ - `setFormatter` function to set active node label formatter.
40
+
41
+ #### `useTree` props
42
+
43
+ The hook takes a single required prop:
44
+
45
+ - `getHierarchyProvider` is a factory function that creates a hierarchy provider, returning the hierarchy the tree component will render. The `@itwin/presentation-hierarchies` package describes the concept of hierarchy provider [in more detail](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md#hierarchy-providers).
46
+
47
+ #### `useUnifiedSelectionTree` props
48
+
49
+ In addition to [props required by `useTree`](#usetree-props), the hook additionally requires:
50
+
51
+ - `sourceName` - a string that distinguishes selection changes being made by different components. The value should be unique for each component.
52
+
53
+ The hook also relies on unified selection storage being provided to it through a React context. See [Providing unified selection context](#providing-unified-selection-context) example below for more details.
54
+
55
+ #### `useIModelTree` props
56
+
57
+ The hook takes 2 required properties:
14
58
 
15
59
  - `imodelAccess` provides access to iModel's data and metadata, required to build the hierarchy. Generally, `@itwin/presentation-core-interop` and `@itwin/presentation-shared` packages are used to create this object:
16
60
 
@@ -43,6 +87,7 @@ It takes 2 required properties:
43
87
  function createIModelAccess(imodel: IModelConnection) {
44
88
  const schemaProvider = createECSchemaProvider(getIModelSchemaContext(imodel));
45
89
  return {
90
+ imodelKey: imodel.key,
46
91
  ...schemaProvider,
47
92
  // while caching for hierarchy inspector is not mandatory, it's recommended to use it to improve performance
48
93
  ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
@@ -55,66 +100,25 @@ It takes 2 required properties:
55
100
 
56
101
  <!-- END EXTRACTION -->
57
102
 
58
- - `getHierarchyDefinition` is a factory function that creates a hierarchy definition, describing the hierarchy the tree component will render. The `@itwin/presentation-hierarchies` package describes the concept of hierarchy definitions [in more detail](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md#hierarchy-definition).
59
-
60
- The resulting state object contains the following properties:
103
+ - `getHierarchyDefinition` is a factory function that creates a hierarchy definition, describing the hierarchy the tree component will render. The `@itwin/presentation-hierarchies` package describes the concept of hierarchy definitions [in more detail](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/learning/imodel/HierarchyDefinition.md).
61
104
 
62
- - `isLoading` is a boolean indicating whether the root tree nodes are being loaded. Set to `true` on initial load and on reload (e.g. when iModel data changes).
105
+ #### `useIModelUnifiedSelectionTree` props
63
106
 
64
- - `rootNodes` is an array of root tree nodes and is what the component should render. There are several types of nodes:
107
+ In addition to [props required by `useIModelTree`](#useimodeltree-props), the hook additionally requires:
65
108
 
66
- - A `PresentationHierarchyNode` is the primary type of node, created based on the hierarchy definition. The `isPresentationHierarchyNode` type guard utility may be used to check if a node is of this type.
67
- - A `PresentationInfoNode` is a non-expandable, non-selectable informational type of node, generally created when for some reason we don't have any real nodes to show. There may be different reasons like filtered-out nodes, too large result set, a network error, etc. The `type` attribute of the node indicates that.
109
+ - `sourceName` - a string that distinguishes selection changes being made by different components. The value should be unique for each component.
68
110
 
69
- - `expandNode` function to expand or collapse a node.
111
+ The hook also relies on unified selection storage being provided to it through a React context. See [Providing unified selection context](#providing-unified-selection-context) example below for more details.
70
112
 
71
- - `isNodeSelected` and `selectNodes` function to inspect and change tree selection.
113
+ #### Providing unified selection context
72
114
 
73
- - `getHierarchyLevelDetails` function to access details of a specific hierarchy level. The returned object provides access to:
74
-
75
- - hierarchy level size limit,
76
- - hierarchy level instance filter,
77
- - instance keys of the nodes in the hierarchy level.
78
-
79
- - `reloadTree` function to reload the tree, optionally keeping its state, after an iModel data change.
80
-
81
- - `setFormatter` function to set active node label formatter.
82
-
83
- ### `useSelectionHandler`
84
-
85
- This is a React hook that helps implement different selection modes in a tree, whose state is managed through the `useTree` or `useUnifiedSelectionTree` hooks.
86
-
87
- It takes 3 required properties:
88
-
89
- - `rootNodes` and `selectNodes` are the corresponding properties from the tree state object, created using `useTree` or `useUnifiedSelectionTree` hook.
90
-
91
- - `selectionMode` is a string that defines the selection mode. It can be one of the following values:
92
- - `none` - no selection is allowed,
93
- - `single` - only one node can be selected at a time,
94
- - `extended` - multiple nodes can be selected using shift and ctrl keys,
95
- - `multiple` - multiple nodes can be selected without using shift or ctrl keys.
96
-
97
- The returned object contains 2 functions, that should be called by the node renderer: `onNodeClick` and `onNodeKeyDown`.
98
-
99
- 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.
100
-
101
- ### `useUnifiedSelectionTree` & `UnifiedSelectionProvider`
102
-
103
- The package delivers a variation of [`useTree`](#usetree), that automatically hooks tree selection into the [Unified Selection](https://www.itwinjs.org/learning/unified-selection/) system. It takes the same properties as [`useTree`](#usetree), plus a couple of additional ones:
104
-
105
- - `imodelKey` is a string that uniquely identifies the iModel the tree is associated with. It's used to distinguish selection changes between different iModels. Generally, the value is obtained using `IModelConnection.key` getter.
106
-
107
- - `sourceName` is a string that distinguishes selection changes being made by different components. It's used to avoid conflicts between different components that use the same iModel and the same selection storage. The value should be unique for each component.
108
-
109
- The returned result is identical to the one from [`useTree`](#usetree).
110
-
111
- The hook also relies on unified selection storage being provided to it through a React context. For that, the package delivers the `UnifiedSelectionProvider` component, that should wrap the tree component, using the `useUnifiedSelectionTree` hook:
115
+ The flavor of tree state hooks, that support unified selection integration, relies on unified selection storage being provided to it through a React context. For that, the package delivers the `UnifiedSelectionProvider` component, that should wrap the tree component, using the `useUnifiedSelectionTree` hook:
112
116
 
113
117
  <!-- [[include: [Presentation.HierarchiesReact.SelectionStorage.Imports, Presentation.HierarchiesReact.SelectionStorage], tsx]] -->
114
118
  <!-- BEGIN EXTRACTION -->
115
119
 
116
120
  ```tsx
117
- import { TreeRenderer, UnifiedSelectionProvider, useUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
121
+ import { TreeRenderer, UnifiedSelectionProvider, useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
118
122
  import { createStorage } from "@itwin/unified-selection";
119
123
  import { useEffect, useState } from "react";
120
124
 
@@ -134,7 +138,7 @@ function MyTreeComponent({ imodel }: { imodel: IModelConnection }) {
134
138
 
135
139
  return (
136
140
  <UnifiedSelectionProvider storage={selectionStorage}>
137
- <MyTreeComponentInternal imodelKey={imodel.key} imodelAccess={imodelAccess} />
141
+ <MyTreeComponentInternal imodelAccess={imodelAccess} />
138
142
  </UnifiedSelectionProvider>
139
143
  );
140
144
  }
@@ -142,18 +146,16 @@ function MyTreeComponent({ imodel }: { imodel: IModelConnection }) {
142
146
 
143
147
  <!-- END EXTRACTION -->
144
148
 
145
- After providing the unified selection storage through the context, the `useUnifiedSelectionTree` hook can be used inside the component as follows:
149
+ After providing the unified selection storage through the context, the `useUnifiedSelectionTree` and `useIModelUnifiedSelectionTree` hooks can be used inside the component as follows:
146
150
 
147
151
  <!-- [[include: Presentation.HierarchiesReact.UseUnifiedSelectionTree, tsx]] -->
148
152
  <!-- BEGIN EXTRACTION -->
149
153
 
150
154
  ```tsx
151
- function MyTreeComponentInternal({ imodelAccess, imodelKey }: { imodelAccess: IModelAccess; imodelKey: string }) {
152
- const { rootNodes, ...state } = useUnifiedSelectionTree({
155
+ function MyTreeComponentInternal({ imodelAccess }: { imodelAccess: IModelAccess }) {
156
+ const { rootNodes, ...state } = useIModelUnifiedSelectionTree({
153
157
  // the source name is used to distinguish selection changes being made by different components
154
158
  sourceName: "MyTreeComponent",
155
- // the iModel key is required for unified selection system to distinguish selection changes between different iModels
156
- imodelKey,
157
159
  // iModel access is used to build the hierarchy
158
160
  imodelAccess,
159
161
  // the hierarchy definition describes the hierarchy using ECSQL queries
@@ -168,13 +170,31 @@ function MyTreeComponentInternal({ imodelAccess, imodelKey }: { imodelAccess: IM
168
170
 
169
171
  <!-- END EXTRACTION -->
170
172
 
173
+ ### `useSelectionHandler` hook
174
+
175
+ This is a React hook that helps implement different selection modes in a tree, whose state is managed through one of the [tree state hooks](#tree-state-hooks).
176
+
177
+ It takes 3 required properties:
178
+
179
+ - `rootNodes` and `selectNodes` are the corresponding properties from the tree state object, created using one of the [tree state hooks](#tree-state-hooks).
180
+
181
+ - `selectionMode` is a string that defines the selection mode. It can be one of the following values:
182
+ - `none` - no selection is allowed,
183
+ - `single` - only one node can be selected at a time,
184
+ - `extended` - multiple nodes can be selected using shift and ctrl keys,
185
+ - `multiple` - multiple nodes can be selected without using shift or ctrl keys.
186
+
187
+ The returned object contains 2 functions, that should be called by the node renderer: `onNodeClick` and `onNodeKeyDown`.
188
+
189
+ 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.
190
+
171
191
  ## iTwinUI components
172
192
 
173
193
  While the package provides a headless UI, it also delivers a set of [iTwinUI](https://itwinui.bentley.com/)-based components for rendering the tree, which should cover majority of use cases. Consumers using the below components are required to provide a compatible `@itwin/itwinui-react` package, which is an optional peer dependency to this package.
174
194
 
175
195
  ### `TreeRenderer`
176
196
 
177
- The component is based on [iTwinUI Tree component](https://itwinui.bentley.com/docs/tree) and uses our [`TreeNodeRenderer`](#treenoderenderer) to render the nodes. In addition, it makes use of the [`useSelectionHandler` hook](#useselectionhandler) to add selection modes' support.
197
+ The component is based on [iTwinUI Tree component](https://itwinui.bentley.com/docs/tree) and uses our [`TreeNodeRenderer`](#treenoderenderer) to render the nodes. In addition, it makes use of the [`useSelectionHandler` hook](#useselectionhandler-hook) to add selection modes' support.
178
198
 
179
199
  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.
180
200
 
@@ -183,7 +203,7 @@ The iTwinUI Tree component requires a `getNode` function that maps nodes to `Nod
183
203
  The component is based on `TreeNode` component from iTwinUI library and supports the following features:
184
204
 
185
205
  - Rendering informational type of nodes (e.g. "No filter matches", "Too many nodes in a hierarchy level", etc.).
186
- - Reporting click and key down events for use with [`useSelectionHandler` hook](#useselectionhandler).
206
+ - Reporting click and key down events for use with [`useSelectionHandler` hook](#useselectionhandler-hook).
187
207
  - Icons, selection, expand / collapse.
188
208
  - Action buttons to clear / set hierarchy level instance filter.
189
209
 
@@ -199,7 +219,7 @@ import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
199
219
  import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
200
220
  import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, HierarchyDefinition } from "@itwin/presentation-hierarchies";
201
221
 
202
- import { TreeRenderer, UnifiedSelectionProvider, useUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
222
+ import { TreeRenderer, UnifiedSelectionProvider, useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
203
223
  import { createStorage } from "@itwin/unified-selection";
204
224
  import { useEffect, useState } from "react";
205
225
 
@@ -224,6 +244,7 @@ function getIModelSchemaContext(imodel: IModelConnection) {
224
244
  function createIModelAccess(imodel: IModelConnection) {
225
245
  const schemaProvider = createECSchemaProvider(getIModelSchemaContext(imodel));
226
246
  return {
247
+ imodelKey: imodel.key,
227
248
  ...schemaProvider,
228
249
  // while caching for hierarchy inspector is not mandatory, it's recommended to use it to improve performance
229
250
  ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
@@ -249,12 +270,12 @@ function MyTreeComponent({ imodel }: { imodel: IModelConnection }) {
249
270
 
250
271
  return (
251
272
  <UnifiedSelectionProvider storage={selectionStorage}>
252
- <MyTreeComponentInternal imodelKey={imodel.key} imodelAccess={imodelAccess} />
273
+ <MyTreeComponentInternal imodelAccess={imodelAccess} />
253
274
  </UnifiedSelectionProvider>
254
275
  );
255
276
  }
256
277
 
257
- type IModelAccess = Parameters<typeof useUnifiedSelectionTree>[0]["imodelAccess"];
278
+ type IModelAccess = Parameters<typeof useIModelUnifiedSelectionTree>[0]["imodelAccess"];
258
279
 
259
280
  // The hierarchy definition describes the hierarchy using ECSQL queries; here it just returns all `BisCore.PhysicalModel` instances
260
281
  function getHierarchyDefinition({ imodelAccess }: { imodelAccess: IModelAccess }): HierarchyDefinition {
@@ -286,12 +307,10 @@ function getHierarchyDefinition({ imodelAccess }: { imodelAccess: IModelAccess }
286
307
  }
287
308
 
288
309
  /** Internal component that creates and renders tree state. */
289
- function MyTreeComponentInternal({ imodelAccess, imodelKey }: { imodelAccess: IModelAccess; imodelKey: string }) {
290
- const { rootNodes, setFormatter, isLoading, ...state } = useUnifiedSelectionTree({
310
+ function MyTreeComponentInternal({ imodelAccess }: { imodelAccess: IModelAccess }) {
311
+ const { rootNodes, setFormatter, isLoading, ...state } = useIModelUnifiedSelectionTree({
291
312
  // the source name is used to distinguish selection changes being made by different components
292
313
  sourceName: "MyTreeComponent",
293
- // the iModel key is required for unified selection system to distinguish selection changes between different iModels
294
- imodelKey,
295
314
  // iModel access is used to build the hierarchy
296
315
  imodelAccess,
297
316
  // supply the hierarchy definition
@@ -308,7 +327,7 @@ function MyTreeComponentInternal({ imodelAccess, imodelKey }: { imodelAccess: IM
308
327
 
309
328
  ## Localization
310
329
 
311
- Localization can be enabled for `TreeRenderer` component and `useTree` and `useUnifiedSelectionTree` hooks by providing an object with localized strings that will be used instead of the default English ones.
330
+ Localization can be enabled for `TreeRenderer` component and [tree state hooks](#tree-state-hooks) by providing an object with localized strings that will be used instead of the default English ones.
312
331
 
313
332
  Example:
314
333
 
@@ -316,12 +335,12 @@ Example:
316
335
  <!-- BEGIN EXTRACTION -->
317
336
 
318
337
  ```tsx
319
- import { useUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
338
+ import { useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
320
339
 
321
- type IModelAccess = Parameters<typeof useUnifiedSelectionTree>[0]["imodelAccess"];
340
+ type IModelAccess = Parameters<typeof useIModelUnifiedSelectionTree>[0]["imodelAccess"];
322
341
 
323
342
  const localizedStrings = {
324
- // strings for the `useUnifiedSelectionTree` hook
343
+ // strings for the `useIModelUnifiedSelectionTree` hook
325
344
  unspecified: "Unspecified",
326
345
  other: "Other",
327
346
 
@@ -336,10 +355,9 @@ const localizedStrings = {
336
355
  increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>",
337
356
  };
338
357
 
339
- function MyTreeComponent({ imodelAccess, imodelKey }: { imodelAccess: IModelAccess; imodelKey: string }) {
340
- const { rootNodes, expandNode } = useUnifiedSelectionTree({
358
+ function MyTreeComponent({ imodelAccess }: { imodelAccess: IModelAccess }) {
359
+ const { rootNodes, expandNode } = useIModelUnifiedSelectionTree({
341
360
  sourceName: "MyTreeComponent",
342
- imodelKey,
343
361
  imodelAccess,
344
362
  localizedStrings,
345
363
  getHierarchyDefinition,
@@ -0,0 +1,53 @@
1
+ import { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
2
+ import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection";
3
+ import { UseTreeProps, UseTreeResult } from "./UseTree";
4
+ /** @beta */
5
+ type IModelHierarchyProviderProps = Parameters<typeof createIModelHierarchyProvider>[0];
6
+ /** @beta */
7
+ type IModelAccess = IModelHierarchyProviderProps["imodelAccess"];
8
+ /**
9
+ * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.
10
+ * @beta
11
+ */
12
+ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getFilteredPaths"> & Pick<IModelHierarchyProviderProps, "localizedStrings" | "imodelAccess" | "imodelChanged"> & {
13
+ /** Provides the hierarchy definition for the tree. */
14
+ getHierarchyDefinition: (props: {
15
+ imodelAccess: IModelAccess;
16
+ }) => HierarchyDefinition;
17
+ /** Provides paths to filtered nodes. */
18
+ getFilteredPaths?: (props: {
19
+ /** Object that provides access to the iModel schema and can run queries against the iModel. */
20
+ imodelAccess: IModelAccess;
21
+ }) => Promise<HierarchyFilteringPath[] | undefined>;
22
+ };
23
+ /**
24
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
25
+ * iModel data.
26
+ *
27
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
28
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
29
+ *
30
+ * See `README.md` for an example
31
+ *
32
+ * @see `useTree`
33
+ * @see `useIModelUnifiedSelectionTree`
34
+ * @beta
35
+ */
36
+ export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
37
+ /**
38
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
39
+ * iModel data and that is integrated with unified selection through context provided by `UnifiedSelectionProvider`.
40
+ *
41
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
42
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
43
+ *
44
+ * See `README.md` for an example
45
+ *
46
+ * @see `useIModelTree`
47
+ * @see `useUnifiedSelectionTree`
48
+ * @see `UnifiedSelectionProvider`
49
+ * @beta
50
+ */
51
+ export declare function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
52
+ export {};
53
+ //# sourceMappingURL=UseIModelTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseIModelTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAW,YAAY,EAAE,aAAa,EAA2B,MAAM,WAAW,CAAC;AAE1F,YAAY;AACZ,KAAK,4BAA4B,GAAG,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;AAExF,YAAY;AACZ,KAAK,YAAY,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;AAEjE;;;GAGG;AACH,KAAK,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,sBAAsB,GAAG,kBAAkB,CAAC,GACvF,IAAI,CAAC,4BAA4B,EAAE,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC,GAAG;IAC1F,sDAAsD;IACtD,sBAAsB,EAAE,CAAC,KAAK,EAAE;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,KAAK,mBAAmB,CAAC;IAEvF,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QACzB,+FAA+F;QAC/F,YAAY,EAAE,YAAY,CAAC;KAC5B,KAAK,OAAO,CAAC,sBAAsB,EAAE,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAMtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,GAAG,4BAA4B,GAAG,aAAa,CAMrH"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useIModelTree = useIModelTree;
8
+ exports.useIModelUnifiedSelectionTree = useIModelUnifiedSelectionTree;
9
+ const react_1 = require("react");
10
+ const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
11
+ const UseTree_1 = require("./UseTree");
12
+ /**
13
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
14
+ * iModel data.
15
+ *
16
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
17
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
18
+ *
19
+ * See `README.md` for an example
20
+ *
21
+ * @see `useTree`
22
+ * @see `useIModelUnifiedSelectionTree`
23
+ * @beta
24
+ */
25
+ function useIModelTree(props) {
26
+ const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;
27
+ return (0, UseTree_1.useTree)({
28
+ ...rest,
29
+ ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),
30
+ });
31
+ }
32
+ /**
33
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
34
+ * iModel data and that is integrated with unified selection through context provided by `UnifiedSelectionProvider`.
35
+ *
36
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
37
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
38
+ *
39
+ * See `README.md` for an example
40
+ *
41
+ * @see `useIModelTree`
42
+ * @see `useUnifiedSelectionTree`
43
+ * @see `UnifiedSelectionProvider`
44
+ * @beta
45
+ */
46
+ function useIModelUnifiedSelectionTree(props) {
47
+ const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;
48
+ return (0, UseTree_1.useUnifiedSelectionTree)({
49
+ ...rest,
50
+ ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),
51
+ });
52
+ }
53
+ function useIModelTreeProps(props) {
54
+ const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;
55
+ return {
56
+ getHierarchyProvider: (0, react_1.useCallback)(() => (0, presentation_hierarchies_1.createIModelHierarchyProvider)({
57
+ imodelAccess,
58
+ imodelChanged,
59
+ hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),
60
+ localizedStrings,
61
+ }), [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings]),
62
+ getFilteredPaths: (0, react_1.useCallback)(async () => getFilteredPaths?.({ imodelAccess }), [imodelAccess, getFilteredPaths]),
63
+ };
64
+ }
65
+ //# sourceMappingURL=UseIModelTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseIModelTree.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0ChG,sCAMC;AAgBD,sEAMC;AApED,iCAAoC;AACpC,8EAA6H;AAE7H,uCAA0F;AAwB1F;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,iBAAO,EAAC;QACb,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,6BAA6B,CAAC,KAAwD;IACpG,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,iCAAuB,EAAC;QAC7B,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAsI;IAEtI,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC1G,OAAO;QACL,oBAAoB,EAAE,IAAA,mBAAW,EAC/B,GAAG,EAAE,CACH,IAAA,wDAA6B,EAAC;YAC5B,YAAY;YACZ,aAAa;YACb,mBAAmB,EAAE,sBAAsB,CAAC,EAAE,YAAY,EAAE,CAAC;YAC7D,gBAAgB;SACjB,CAAC,EACJ,CAAC,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,CACxE;QACD,gBAAgB,EAAE,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAClH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } from \"./UseTree\";\n\n/** @beta */\ntype IModelHierarchyProviderProps = Parameters<typeof createIModelHierarchyProvider>[0];\n\n/** @beta */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @beta\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> &\n Pick<IModelHierarchyProviderProps, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to filtered nodes. */\n getFilteredPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @beta\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through context provided by `UnifiedSelectionProvider`.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @beta\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"localizedStrings\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings,\n }),\n [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings],\n ),\n getFilteredPaths: useCallback(async () => getFilteredPaths?.({ imodelAccess }), [imodelAccess, getFilteredPaths]),\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { createHierarchyProvider, GenericInstanceFilter, HierarchyDefinition, HierarchyNode, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
2
- import { ECClassHierarchyInspector, ECSchemaProvider, InstanceKey, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
1
+ import { GenericInstanceFilter, HierarchyFilteringPath, HierarchyNode, HierarchyProvider } from "@itwin/presentation-hierarchies";
2
+ import { InstanceKey, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
3
3
  import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection";
4
4
  import { PresentationTreeNode } from "./TreeNode";
5
5
  import { SelectionChangeType } from "./UseSelectionHandler";
@@ -33,6 +33,7 @@ export interface HierarchyLevelDetails {
33
33
  * See `README.md` for an example
34
34
  *
35
35
  * @see `useUnifiedSelectionTree`
36
+ * @see `useIModelTree`
36
37
  * @beta
37
38
  */
38
39
  export declare function useTree(props: UseTreeProps): UseTreeResult;
@@ -46,31 +47,17 @@ export declare function useTree(props: UseTreeProps): UseTreeResult;
46
47
  * See `README.md` for an example
47
48
  *
48
49
  * @see `useTree`
50
+ * @see `useIModelUnifiedSelectionTree`
49
51
  * @see `UnifiedSelectionProvider`
50
52
  * @beta
51
53
  */
52
- export declare function useUnifiedSelectionTree({ imodelKey, sourceName, ...props }: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
54
+ export declare function useUnifiedSelectionTree({ sourceName, ...props }: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
53
55
  /** @beta */
54
- type IModelAccess = ECSchemaProvider & LimitingECSqlQueryExecutor & ECClassHierarchyInspector;
55
- /** @beta */
56
- interface GetFilteredPathsProps {
57
- /** Object that provides access to the iModel schema and can run queries against the iModel. */
58
- imodelAccess: IModelAccess;
59
- }
60
- /** @beta */
61
- type HierarchyProviderProps = Parameters<typeof createHierarchyProvider>[0];
62
- /** @beta */
63
- type HierarchyFilteringPaths = NonNullable<NonNullable<HierarchyProviderProps["filtering"]>["paths"]>;
64
- /** @beta */
65
- interface UseTreeProps extends Pick<HierarchyProviderProps, "localizedStrings"> {
66
- /** Object that provides access to the iModel schema and can run queries against the iModel. */
67
- imodelAccess: ECSchemaProvider & LimitingECSqlQueryExecutor & ECClassHierarchyInspector;
68
- /** Provides the hierarchy definition for the tree. */
69
- getHierarchyDefinition: (props: {
70
- imodelAccess: IModelAccess;
71
- }) => HierarchyDefinition;
56
+ export interface UseTreeProps {
57
+ /** Provides the hierarchy provider for the tree. */
58
+ getHierarchyProvider: () => HierarchyProvider;
72
59
  /** Provides paths to filtered nodes. */
73
- getFilteredPaths?: (props: GetFilteredPathsProps) => Promise<HierarchyFilteringPaths | undefined>;
60
+ getFilteredPaths?: () => Promise<HierarchyFilteringPath[] | undefined>;
74
61
  /**
75
62
  * Callback that is called just after a certain action is finished.
76
63
  * Can be used for performance tracking.
@@ -88,8 +75,13 @@ interface UseTreeProps extends Pick<HierarchyProviderProps, "localizedStrings">
88
75
  type: "timeout" | "unknown";
89
76
  }) => void;
90
77
  }
91
- /** @beta */
92
- interface ReloadTreeCommonOptions {
78
+ /**
79
+ * Options for doing either full or a sub tree reload.
80
+ * @beta
81
+ */
82
+ interface ReloadTreeOptions {
83
+ /** Specifies parent node under which sub tree should be reloaded. */
84
+ parentNodeId: string | undefined;
93
85
  /**
94
86
  * Specifies how current tree state should be handled:
95
87
  * - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).
@@ -100,27 +92,6 @@ interface ReloadTreeCommonOptions {
100
92
  */
101
93
  state?: "keep" | "discard" | "reset";
102
94
  }
103
- /**
104
- * Options for full tree reload.
105
- * @beta
106
- */
107
- type FullTreeReloadOptions = {
108
- /** Specifies that data source changed and caches should be cleared before reloading tree. */
109
- dataSourceChanged?: true;
110
- } & ReloadTreeCommonOptions;
111
- /**
112
- * Options for subtree reload.
113
- * @beta
114
- */
115
- type SubtreeReloadOptions = {
116
- /** Specifies parent node under which sub tree should be reloaded. */
117
- parentNodeId: string;
118
- } & ReloadTreeCommonOptions;
119
- /**
120
- * Options for doing either full or a sub tree reload.
121
- * @beta
122
- */
123
- type ReloadTreeOptions = FullTreeReloadOptions | SubtreeReloadOptions;
124
95
  /** @beta */
125
96
  export interface UseTreeResult {
126
97
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"UseTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseTree.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EAEb,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGhI,OAAO,EAA2B,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACvG,OAAO,EAA6B,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,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