@itwin/presentation-hierarchies-react 2.0.0-alpha.53 → 2.0.0-alpha.55
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 +58 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +33 -29
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -17
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +184 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +58 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +25 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +125 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +294 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +295 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +99 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +37 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +142 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +43 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +381 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +41 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +186 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +89 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +64 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +92 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +33 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +156 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +18 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +535 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +418 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react.d.ts +18 -0
- package/lib/presentation-hierarchies-react.js +16 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +27 -21
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +0 -85
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +0 -24
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +0 -53
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -48
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -83
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -94
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -241
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js +0 -39
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -322
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -90
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -157
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -42
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -115
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +0 -27
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +0 -74
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +0 -73
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +0 -138
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +0 -47
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +0 -16
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +0 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +0 -45
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +0 -36
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -20
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +0 -29
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -57
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +0 -71
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +0 -133
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +0 -193
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -17
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -18
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.55
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1223](https://github.com/iTwin/presentation/pull/1223): Reworked `localization` to use `i18next`-compatible approach. Instead of passing a `localizedStrings` object into `LocalizationContextProvider`, the package now delivers an English locale JSON file and resolves strings through a `getLocalizedString` function at runtime.
|
|
8
|
+
|
|
9
|
+
**Breaking changes**
|
|
10
|
+
- `LocalizationContextProvider` no longer accepts a `localizedStrings` object. It now requires a `localization` prop — an object with a `getLocalizedString(key: string): string` method (compatible with `Localization` from @itwin/core-common).
|
|
11
|
+
- `LOCALIZATION_NAMESPACES` must be registered with your localization provider during app initialization to make localized strings available.
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#1221](https://github.com/iTwin/presentation/pull/1221): Add `getTreeNodeError` callback prop to `useTree` hook and its derivatives, providing a way to set custom errors on tree nodes.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#1219](https://github.com/iTwin/presentation/pull/1219): Fix component documentation mentioning iTwinUI
|
|
20
|
+
- Updated dependencies:
|
|
21
|
+
- @itwin/presentation-shared@2.0.0-alpha.8
|
|
22
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.12
|
|
23
|
+
- @itwin/unified-selection@1.6.8-alpha.0
|
|
24
|
+
|
|
25
|
+
## 2.0.0-alpha.54
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#1198](https://github.com/iTwin/presentation/pull/1198): Change `HierarchyProvider.hierarchyChanged` argument to be required.
|
|
30
|
+
|
|
31
|
+
This simplifies the API for users of `HierarchyProvider`, as they no longer need to check for `undefined` when handling hierarchy changes.
|
|
32
|
+
|
|
33
|
+
For implementors of custom `HierarchyProvider`, this change means that they must always provide an even argument when raising the `hierarchyChanged` event. Since all members of the argument type are optional, it's okay to raise the even with an empty object, e.g.: `this.hierarchyChanged.raiseEvent({})`.
|
|
34
|
+
|
|
35
|
+
- [#1200](https://github.com/iTwin/presentation/pull/1200): Removed unnecessary, always-truthy condition checks.
|
|
36
|
+
- [#1193](https://github.com/iTwin/presentation/pull/1193): Process package output with [React Compiler](https://react.dev/reference/react-compiler/compiling-libraries).
|
|
37
|
+
- Updated dependencies:
|
|
38
|
+
- @itwin/presentation-shared@2.0.0-alpha.7
|
|
39
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.11
|
|
40
|
+
|
|
3
41
|
## 2.0.0-alpha.53
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -770,6 +808,26 @@
|
|
|
770
808
|
|
|
771
809
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
772
810
|
|
|
811
|
+
## 1.9.12
|
|
812
|
+
|
|
813
|
+
### Patch Changes
|
|
814
|
+
|
|
815
|
+
- [#1215](https://github.com/iTwin/presentation/pull/1215): Update dependencies.
|
|
816
|
+
- Updated dependencies:
|
|
817
|
+
- @itwin/presentation-hierarchies@1.7.10
|
|
818
|
+
- @itwin/presentation-shared@1.2.9
|
|
819
|
+
- @itwin/unified-selection@1.6.7
|
|
820
|
+
|
|
821
|
+
## 1.9.11
|
|
822
|
+
|
|
823
|
+
### Patch Changes
|
|
824
|
+
|
|
825
|
+
- [#1208](https://github.com/iTwin/presentation/pull/1208): Bump dependencies.
|
|
826
|
+
- Updated dependencies:
|
|
827
|
+
- @itwin/presentation-hierarchies@1.7.9
|
|
828
|
+
- @itwin/presentation-shared@1.2.8
|
|
829
|
+
- @itwin/unified-selection@1.6.6
|
|
830
|
+
|
|
773
831
|
## 1.9.10
|
|
774
832
|
|
|
775
833
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -214,79 +214,41 @@ function MyTreeComponentInternal({ imodelAccess, selectionStorage }: { imodelAcc
|
|
|
214
214
|
|
|
215
215
|
## Localization
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Example:
|
|
217
|
+
This package delivers a locale JSON file with English strings that follows the [`i18next JSON format`](https://www.i18next.com/misc/json-format). To enable localization, register `LOCALIZATION_NAMESPACES` during initialization and wrap components in `LocalizationContextProvider`:
|
|
220
218
|
|
|
221
219
|
```tsx
|
|
222
|
-
import {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
import {
|
|
221
|
+
LocalizationContextProvider,
|
|
222
|
+
LOCALIZATION_NAMESPACES,
|
|
223
|
+
StrataKitTreeRenderer,
|
|
224
|
+
useIModelUnifiedSelectionTree,
|
|
225
|
+
} from "@itwin/presentation-hierarchies-react";
|
|
226
|
+
|
|
227
|
+
// Register localization namespaces with `i18next` based localization provider.
|
|
228
|
+
for (const namespace of LOCALIZATION_NAMESPACES) {
|
|
229
|
+
await localization.registerNamespace(namespace);
|
|
230
|
+
}
|
|
227
231
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
clearHierarchyLevelFilter: "Clear active filter",
|
|
237
|
-
noFilteredChildren: "No child nodes match current filter",
|
|
238
|
-
resultLimitExceeded: "There are more items than allowed limit of {{limit}}.",
|
|
239
|
-
resultLimitExceededWithFiltering: "Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.",
|
|
240
|
-
increaseHierarchyLimit: "<link>Increase the hierarchy level size limit to {{limit}}.</link>",
|
|
241
|
-
increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>",
|
|
242
|
-
};
|
|
232
|
+
// Wrap components with LocalizationContextProvider
|
|
233
|
+
function Tree() {
|
|
234
|
+
return (
|
|
235
|
+
<LocalizationContextProvider localization={localization}>
|
|
236
|
+
<MyTreeComponent imodelAccess={imodelAccess} />
|
|
237
|
+
</LocalizationContextProvider>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
243
240
|
|
|
244
241
|
function MyTreeComponent({ imodelAccess }: { imodelAccess: IModelAccess }) {
|
|
245
242
|
const { rootNodes, expandNode } = useIModelUnifiedSelectionTree({
|
|
246
243
|
sourceName: "MyTreeComponent",
|
|
247
244
|
imodelAccess,
|
|
248
|
-
localizedStrings,
|
|
249
245
|
getHierarchyDefinition,
|
|
250
246
|
});
|
|
251
247
|
if (!rootNodes) {
|
|
252
|
-
return
|
|
248
|
+
return <Spinner />;
|
|
253
249
|
}
|
|
254
|
-
return <
|
|
250
|
+
return <StrataKitTreeRenderer rootNodes={rootNodes} expandNode={expandNode} />;
|
|
255
251
|
}
|
|
256
252
|
```
|
|
257
253
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
```tsx
|
|
261
|
-
import { Props } from "@itwin/presentation-shared";
|
|
262
|
-
|
|
263
|
-
import { ComponentPropsWithoutRef, useCallback } from "react";
|
|
264
|
-
import { Tree } from "@stratakit/bricks";
|
|
265
|
-
import { LocalizationContextProvider, TreeRenderer, useFlatTreeNodeList } from "@itwin/presentation-hierarchies-react";
|
|
266
|
-
|
|
267
|
-
type TreeRendererProps = Props<typeof TreeRenderer>;
|
|
268
|
-
|
|
269
|
-
function MyTreeRenderer({ rootNodes }: TreeRendererProps) {
|
|
270
|
-
const flatNodes = useFlatTreeNodeList(rootNodes);
|
|
271
|
-
|
|
272
|
-
return (
|
|
273
|
-
<LocalizationContextProvider localizedStrings={localizedStrings}>
|
|
274
|
-
<Tree.Root>
|
|
275
|
-
{flatNodes.map((flatNode) =>
|
|
276
|
-
isPlaceholderNode(flatNode) ? (
|
|
277
|
-
<Tree.Item key={flatNode.id} aria-level={flatNode.level} aria-posinset={1} aria-setsize={1} label="Loading" />
|
|
278
|
-
) : (
|
|
279
|
-
<Tree.Item
|
|
280
|
-
key={flatNode.id}
|
|
281
|
-
aria-level={flatNode.level}
|
|
282
|
-
aria-posinset={flatNode.posInLevel}
|
|
283
|
-
aria-setsize={flatNode.levelSize}
|
|
284
|
-
label={flatNode.label}
|
|
285
|
-
/>
|
|
286
|
-
),
|
|
287
|
-
)}
|
|
288
|
-
</Tree.Root>
|
|
289
|
-
</LocalizationContextProvider>
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
```
|
|
254
|
+
`LocalizationContextProvider` accepts a `localization` prop — an object with a `getLocalizedString(key: string): string` method. It is designed to work with the `Localization` interface from `@itwin/core-common`, but a custom implementation can be used as well by providing an object with a custom `getLocalizedString` function. The provider uses it internally to resolve translation keys prefixed with localization namespace.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ErrorInfo, TreeNode } from "./TreeNode.js";
|
|
2
|
+
import { SelectionChangeType } from "./UseSelectionHandler.js";
|
|
3
|
+
import { GenericInstanceFilter, HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
|
+
import { InstanceKey } from "@itwin/presentation-shared";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/Renderers.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Type definition used to render tree rendering UI component.
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
type TreeRendererProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Array containing root tree nodes.
|
|
14
|
+
*/
|
|
15
|
+
rootNodes: TreeNode[];
|
|
16
|
+
/**
|
|
17
|
+
* A function that should be called to either expand or collapse the given node.
|
|
18
|
+
*/
|
|
19
|
+
expandNode: (nodeId: string, isExpanded: boolean) => void;
|
|
20
|
+
/**
|
|
21
|
+
* A function that should be called to select nodes in the tree.
|
|
22
|
+
* @param nodeIds Ids of the nodes that are selected.
|
|
23
|
+
* @param changeType Type of change that occurred for the selection.
|
|
24
|
+
*/
|
|
25
|
+
selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether a given node is selected.
|
|
28
|
+
*/
|
|
29
|
+
isNodeSelected: (nodeId: string) => boolean;
|
|
30
|
+
} & CommonRendererProps;
|
|
31
|
+
/**
|
|
32
|
+
* Type definition used to render root error handling UI component.
|
|
33
|
+
* @alpha
|
|
34
|
+
*/
|
|
35
|
+
type RootErrorRendererProps = {
|
|
36
|
+
/**
|
|
37
|
+
* Object containing root error information
|
|
38
|
+
*/
|
|
39
|
+
error: ErrorInfo;
|
|
40
|
+
} & CommonRendererProps;
|
|
41
|
+
/**
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
interface CommonRendererProps {
|
|
45
|
+
/**
|
|
46
|
+
* A function that should be called to reload the tree.
|
|
47
|
+
*/
|
|
48
|
+
reloadTree: (options?: ReloadTreeOptions) => void;
|
|
49
|
+
/** Returns hierarchy level details for a given node ID. */
|
|
50
|
+
getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for doing either full or a sub tree reload.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
interface ReloadTreeOptions {
|
|
57
|
+
/** Specifies parent node under which sub tree should be reloaded. */
|
|
58
|
+
parentNodeId: string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Specifies how current tree state should be handled:
|
|
61
|
+
* - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).
|
|
62
|
+
* - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.
|
|
63
|
+
* - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.
|
|
64
|
+
*
|
|
65
|
+
* Defaults to `"keep"`.
|
|
66
|
+
*/
|
|
67
|
+
state?: "keep" | "discard" | "reset";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A data structure that contains information about a single hierarchy level.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
interface HierarchyLevelDetails {
|
|
74
|
+
/** The parent node whose hierarchy level's information is contained in this data structure */
|
|
75
|
+
hierarchyNode: HierarchyNode | undefined;
|
|
76
|
+
/** A function to get instance keys of the hierarchy level. */
|
|
77
|
+
getInstanceKeysIterator: (props?: {
|
|
78
|
+
instanceFilter?: GenericInstanceFilter;
|
|
79
|
+
hierarchyLevelSizeLimit?: number | "unbounded";
|
|
80
|
+
}) => AsyncIterableIterator<InstanceKey>;
|
|
81
|
+
/** Get the limit of how many nodes can be loaded in this hierarchy level. */
|
|
82
|
+
sizeLimit?: number | "unbounded";
|
|
83
|
+
/** Set the limit of how many nodes can be loaded in this hierarchy level. */
|
|
84
|
+
setSizeLimit: (value: undefined | number | "unbounded") => void;
|
|
85
|
+
/** Get the active instance filter applied to this hierarchy level. */
|
|
86
|
+
instanceFilter?: GenericInstanceFilter;
|
|
87
|
+
/** Set the instance filter to apply to this hierarchy level */
|
|
88
|
+
setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { HierarchyLevelDetails, RootErrorRendererProps, TreeRendererProps };
|
|
92
|
+
//# sourceMappingURL=Renderers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderers.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/Renderers.ts"],"mappings":";;;;;;;;AAcA;;KAAY,iBAAA;EAIC;;;EAAX,SAAA,EAAW,QAAA;EAeU;;;EAXrB,UAAA,GAAa,MAAA,UAAgB,UAAA;EAA7B;;;;;EAMA,WAAA,GAAc,OAAA,EAAS,KAAA,UAAe,UAAA,EAAY,mBAAA;EAAA;;;EAIlD,cAAA,GAAiB,MAAA;AAAA,IACf,mBAAA;;;AAMJ;;KAAY,sBAAA;EAKW;;;EADrB,KAAA,EAAO,SAAA;AAAA,IACL,mBAAA;;AAAoB;;UAKd,mBAAA;EAMuE;;;EAF/E,UAAA,GAAa,OAAA,GAAU,iBAAA;EAEvB;EAAA,wBAAA,GAA2B,MAAA,yBAA+B,qBAAA;AAAA;;;AAAqB;;UAOvE,iBAAA;EAER;EAAA,YAAA;EAiBe;;;;;;;;EAPf,KAAA;AAAA;;;;;UAOe,qBAAA;EAMI;EAJnB,aAAA,EAAe,aAAA;EAGW;EAA1B,uBAAA,GAA0B,KAAA;IACxB,cAAA,GAAiB,qBAAA;IACjB,uBAAA;EAAA,MACI,qBAAA,CAAsB,WAAA;EAKb;EAFf,SAAA;EAKiB;EAHjB,YAAA,GAAe,KAAA;EAKa;EAF5B,cAAA,GAAiB,qBAAA;EAE4C;EAA7D,iBAAA,GAAoB,MAAA,EAAQ,qBAAA;AAAA"}
|
package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts
RENAMED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
|
+
|
|
3
|
+
//#region src/presentation-hierarchies-react/TreeNode.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* A type that defines an node in a UI tree component, built with `useTree` hook.
|
|
4
6
|
* @public
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
interface TreeNode {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
children: true | Array<TreeNode>;
|
|
12
|
+
isExpanded: boolean;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
isFilterable: boolean;
|
|
15
|
+
isFiltered: boolean;
|
|
16
|
+
/** UI-agnostic source of this node object. */
|
|
17
|
+
nodeData: HierarchyNode;
|
|
18
|
+
/** Contains error encountered from expanding the node */
|
|
19
|
+
error?: ErrorInfo;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* A type of `ErrorInfo` that is returned,
|
|
@@ -22,9 +24,9 @@ export interface TreeNode {
|
|
|
22
24
|
*
|
|
23
25
|
* @public
|
|
24
26
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
interface NoFilterMatchesErrorInfo {
|
|
28
|
+
id: string;
|
|
29
|
+
type: "NoFilterMatches";
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* A type of `ErrorInfo` that is returned, when the
|
|
@@ -33,10 +35,10 @@ export interface NoFilterMatchesErrorInfo {
|
|
|
33
35
|
*
|
|
34
36
|
* @public
|
|
35
37
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
interface ResultSetTooLargeErrorInfo {
|
|
39
|
+
id: string;
|
|
40
|
+
type: "ResultSetTooLarge";
|
|
41
|
+
resultSetSizeLimit: number;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* A type of `ErrorInfo` that contains a user-friendly message to be displayed in the UI.
|
|
@@ -45,10 +47,10 @@ export interface ResultSetTooLargeErrorInfo {
|
|
|
45
47
|
*
|
|
46
48
|
* @public
|
|
47
49
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
interface ChildrenLoadErrorInfo {
|
|
51
|
+
id: string;
|
|
52
|
+
type: "ChildrenLoad";
|
|
53
|
+
message: string;
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* A type of `ErrorInfo` that can be used to show/handle generic errors,
|
|
@@ -58,11 +60,11 @@ export interface ChildrenLoadErrorInfo {
|
|
|
58
60
|
*
|
|
59
61
|
* @public
|
|
60
62
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
interface GenericErrorInfo {
|
|
64
|
+
id: string;
|
|
65
|
+
type: "Unknown";
|
|
66
|
+
message: string;
|
|
67
|
+
additionalData?: unknown;
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* A collection of types that defines an error state for `TreeNode` node in a UI tree component, built
|
|
@@ -70,5 +72,7 @@ export interface GenericErrorInfo {
|
|
|
70
72
|
*
|
|
71
73
|
* @public
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
type ErrorInfo = GenericErrorInfo | ResultSetTooLargeErrorInfo | NoFilterMatchesErrorInfo | ChildrenLoadErrorInfo;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { ErrorInfo, GenericErrorInfo, ResultSetTooLargeErrorInfo, TreeNode };
|
|
74
78
|
//# sourceMappingURL=TreeNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNode.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/TreeNode.ts"],"mappings":";;;;;AAWA;;UAAiB,QAAA;EACf,EAAA;EACA,KAAA;EACA,QAAA,SAAiB,KAAA,CAAM,QAAA;EACvB,UAAA;EACA,SAAA;EACA,YAAA;EACA,UAAA;EALA;EAOA,QAAA,EAAU,aAAA;EANO;EAQjB,KAAA,GAAQ,SAAA;AAAA;;;;;;;UASO,wBAAA;EACf,EAAA;EACA,IAAA;AAAA;;;;;AAUF;;;UAAiB,0BAAA;EACf,EAAA;EACA,IAAA;EACA,kBAAA;AAAA;;AAUF;;;;;;UAAiB,qBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;AAAA;;;;;;;;;UAWe,gBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,cAAA;AAAA;;;;;;;KASU,SAAA,GAAY,gBAAA,GAAmB,0BAAA,GAA6B,wBAAA,GAA2B,qBAAA"}
|
package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts
RENAMED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { createIModelHierarchyProvider, HierarchyDefinition, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
2
|
-
import { Props } from "@itwin/presentation-shared";
|
|
3
1
|
import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
|
|
4
2
|
import { UseTreeProps, UseTreeResult } from "./UseTree.js";
|
|
3
|
+
import { HierarchyDefinition, HierarchySearchPath, createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
4
|
+
import { Props } from "@itwin/presentation-shared";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/UseIModelTree.d.ts
|
|
5
7
|
/** @public */
|
|
6
8
|
type IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;
|
|
7
9
|
/** @public */
|
|
@@ -10,18 +12,26 @@ type IModelAccess = IModelHierarchyProviderProps["imodelAccess"];
|
|
|
10
12
|
* Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.
|
|
11
13
|
* @public
|
|
12
14
|
*/
|
|
13
|
-
type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearchPaths"> & Pick<IModelHierarchyProviderProps, "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearchPaths"> & Pick<IModelHierarchyProviderProps, "imodelAccess" | "imodelChanged"> & {
|
|
16
|
+
/**
|
|
17
|
+
* Provides the hierarchy definition for the tree.
|
|
18
|
+
*/
|
|
19
|
+
getHierarchyDefinition: (props: {
|
|
20
|
+
imodelAccess: IModelAccess;
|
|
21
|
+
}) => HierarchyDefinition;
|
|
22
|
+
/**
|
|
23
|
+
* Provides paths to target nodes.
|
|
24
|
+
*/
|
|
25
|
+
getSearchPaths?: (props: {
|
|
26
|
+
/**
|
|
27
|
+
* Object that provides access to the iModel schema and can run queries against the iModel.
|
|
28
|
+
*/
|
|
29
|
+
imodelAccess: IModelAccess;
|
|
30
|
+
/**
|
|
31
|
+
* Signal indicating that that the request was canceled
|
|
32
|
+
*/
|
|
33
|
+
abortSignal: AbortSignal;
|
|
34
|
+
}) => Promise<HierarchySearchPath[] | undefined>;
|
|
25
35
|
};
|
|
26
36
|
/**
|
|
27
37
|
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
@@ -36,7 +46,7 @@ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearch
|
|
|
36
46
|
* @see `useIModelUnifiedSelectionTree`
|
|
37
47
|
* @public
|
|
38
48
|
*/
|
|
39
|
-
|
|
49
|
+
declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
|
|
40
50
|
/**
|
|
41
51
|
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
42
52
|
* iModel data and that is integrated with unified selection through the given selection
|
|
@@ -52,6 +62,7 @@ export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
|
|
|
52
62
|
* @see `UnifiedSelectionProvider`
|
|
53
63
|
* @public
|
|
54
64
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
declare function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { useIModelTree, useIModelUnifiedSelectionTree };
|
|
57
68
|
//# sourceMappingURL=UseIModelTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseIModelTree.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseIModelTree.ts"],"mappings":";;;;;;;KAgBK,4BAAA,GAA+B,KAAA,QAAa,6BAAA;;KAG5C,YAAA,GAAe,4BAAA;;;AAH0D;;KASzE,kBAAA,GAAqB,IAAA,CAAK,YAAA,+CAC7B,IAAA,CAAK,4BAAA;EAPa;;AAA4B;EAW5C,sBAAA,GAAyB,KAAA;IAAS,YAAA,EAAc,YAAA;EAAA,MAAmB,mBAAA;EAL7C;;;EAUtB,cAAA,IAAkB,KAAA;IALiD;;;IASjE,YAAA,EAAc,YAAA;IAKV;;;IADJ,WAAA,EAAa,WAAA;EAAA,MACT,OAAA,CAAQ,mBAAA;AAAA;;;;;;;;;;;;;;iBAgBF,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAqB,aAAA;;;AAA1D;;;;;;;;;AAuBA;;;;iBAAgB,6BAAA,CAA8B,KAAA,EAAO,kBAAA,GAAqB,4BAAA,GAA+B,aAAA"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
|
|
2
|
+
import { useTranslation } from "./stratakit/LocalizationContext.js";
|
|
3
|
+
import { c } from "react-compiler-runtime";
|
|
4
|
+
import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/UseIModelTree.ts
|
|
7
|
+
/**
|
|
8
|
+
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
9
|
+
* iModel data.
|
|
10
|
+
*
|
|
11
|
+
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
12
|
+
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
13
|
+
*
|
|
14
|
+
* See `README.md` for an example
|
|
15
|
+
*
|
|
16
|
+
* @see `useTree`
|
|
17
|
+
* @see `useIModelUnifiedSelectionTree`
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
function useIModelTree(props) {
|
|
21
|
+
const $ = c(14);
|
|
22
|
+
let getHierarchyDefinition;
|
|
23
|
+
let getSearchPaths;
|
|
24
|
+
let imodelAccess;
|
|
25
|
+
let imodelChanged;
|
|
26
|
+
let rest;
|
|
27
|
+
if ($[0] !== props) {
|
|
28
|
+
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
|
|
29
|
+
$[0] = props;
|
|
30
|
+
$[1] = getHierarchyDefinition;
|
|
31
|
+
$[2] = getSearchPaths;
|
|
32
|
+
$[3] = imodelAccess;
|
|
33
|
+
$[4] = imodelChanged;
|
|
34
|
+
$[5] = rest;
|
|
35
|
+
} else {
|
|
36
|
+
getHierarchyDefinition = $[1];
|
|
37
|
+
getSearchPaths = $[2];
|
|
38
|
+
imodelAccess = $[3];
|
|
39
|
+
imodelChanged = $[4];
|
|
40
|
+
rest = $[5];
|
|
41
|
+
}
|
|
42
|
+
let t0;
|
|
43
|
+
if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
|
|
44
|
+
t0 = {
|
|
45
|
+
imodelAccess,
|
|
46
|
+
imodelChanged,
|
|
47
|
+
getHierarchyDefinition,
|
|
48
|
+
getSearchPaths
|
|
49
|
+
};
|
|
50
|
+
$[6] = getHierarchyDefinition;
|
|
51
|
+
$[7] = getSearchPaths;
|
|
52
|
+
$[8] = imodelAccess;
|
|
53
|
+
$[9] = imodelChanged;
|
|
54
|
+
$[10] = t0;
|
|
55
|
+
} else t0 = $[10];
|
|
56
|
+
const t1 = useIModelTreeProps(t0);
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[11] !== rest || $[12] !== t1) {
|
|
59
|
+
t2 = {
|
|
60
|
+
...rest,
|
|
61
|
+
...t1
|
|
62
|
+
};
|
|
63
|
+
$[11] = rest;
|
|
64
|
+
$[12] = t1;
|
|
65
|
+
$[13] = t2;
|
|
66
|
+
} else t2 = $[13];
|
|
67
|
+
return useTree(t2);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
71
|
+
* iModel data and that is integrated with unified selection through the given selection
|
|
72
|
+
* storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).
|
|
73
|
+
*
|
|
74
|
+
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
75
|
+
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
76
|
+
*
|
|
77
|
+
* See `README.md` for an example
|
|
78
|
+
*
|
|
79
|
+
* @see `useIModelTree`
|
|
80
|
+
* @see `useUnifiedSelectionTree`
|
|
81
|
+
* @see `UnifiedSelectionProvider`
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
function useIModelUnifiedSelectionTree(props) {
|
|
85
|
+
const $ = c(14);
|
|
86
|
+
let getHierarchyDefinition;
|
|
87
|
+
let getSearchPaths;
|
|
88
|
+
let imodelAccess;
|
|
89
|
+
let imodelChanged;
|
|
90
|
+
let rest;
|
|
91
|
+
if ($[0] !== props) {
|
|
92
|
+
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
|
|
93
|
+
$[0] = props;
|
|
94
|
+
$[1] = getHierarchyDefinition;
|
|
95
|
+
$[2] = getSearchPaths;
|
|
96
|
+
$[3] = imodelAccess;
|
|
97
|
+
$[4] = imodelChanged;
|
|
98
|
+
$[5] = rest;
|
|
99
|
+
} else {
|
|
100
|
+
getHierarchyDefinition = $[1];
|
|
101
|
+
getSearchPaths = $[2];
|
|
102
|
+
imodelAccess = $[3];
|
|
103
|
+
imodelChanged = $[4];
|
|
104
|
+
rest = $[5];
|
|
105
|
+
}
|
|
106
|
+
let t0;
|
|
107
|
+
if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
|
|
108
|
+
t0 = {
|
|
109
|
+
imodelAccess,
|
|
110
|
+
imodelChanged,
|
|
111
|
+
getHierarchyDefinition,
|
|
112
|
+
getSearchPaths
|
|
113
|
+
};
|
|
114
|
+
$[6] = getHierarchyDefinition;
|
|
115
|
+
$[7] = getSearchPaths;
|
|
116
|
+
$[8] = imodelAccess;
|
|
117
|
+
$[9] = imodelChanged;
|
|
118
|
+
$[10] = t0;
|
|
119
|
+
} else t0 = $[10];
|
|
120
|
+
const t1 = useIModelTreeProps(t0);
|
|
121
|
+
let t2;
|
|
122
|
+
if ($[11] !== rest || $[12] !== t1) {
|
|
123
|
+
t2 = {
|
|
124
|
+
...rest,
|
|
125
|
+
...t1
|
|
126
|
+
};
|
|
127
|
+
$[11] = rest;
|
|
128
|
+
$[12] = t1;
|
|
129
|
+
$[13] = t2;
|
|
130
|
+
} else t2 = $[13];
|
|
131
|
+
return useUnifiedSelectionTree(t2);
|
|
132
|
+
}
|
|
133
|
+
function useIModelTreeProps(props) {
|
|
134
|
+
const $ = c(11);
|
|
135
|
+
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;
|
|
136
|
+
const translate = useTranslation();
|
|
137
|
+
let t0;
|
|
138
|
+
if ($[0] !== getHierarchyDefinition || $[1] !== imodelAccess || $[2] !== imodelChanged || $[3] !== translate) {
|
|
139
|
+
t0 = () => createIModelHierarchyProvider({
|
|
140
|
+
imodelAccess,
|
|
141
|
+
imodelChanged,
|
|
142
|
+
hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),
|
|
143
|
+
localizedStrings: {
|
|
144
|
+
other: translate("other"),
|
|
145
|
+
unspecified: translate("unspecified")
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
$[0] = getHierarchyDefinition;
|
|
149
|
+
$[1] = imodelAccess;
|
|
150
|
+
$[2] = imodelChanged;
|
|
151
|
+
$[3] = translate;
|
|
152
|
+
$[4] = t0;
|
|
153
|
+
} else t0 = $[4];
|
|
154
|
+
const t1 = t0;
|
|
155
|
+
let t2;
|
|
156
|
+
if ($[5] !== getSearchPaths || $[6] !== imodelAccess) {
|
|
157
|
+
t2 = async (t3) => {
|
|
158
|
+
const { abortSignal } = t3;
|
|
159
|
+
return getSearchPaths?.({
|
|
160
|
+
imodelAccess,
|
|
161
|
+
abortSignal
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
$[5] = getSearchPaths;
|
|
165
|
+
$[6] = imodelAccess;
|
|
166
|
+
$[7] = t2;
|
|
167
|
+
} else t2 = $[7];
|
|
168
|
+
const t3 = t2;
|
|
169
|
+
let t4;
|
|
170
|
+
if ($[8] !== t1 || $[9] !== t3) {
|
|
171
|
+
t4 = {
|
|
172
|
+
getHierarchyProvider: t1,
|
|
173
|
+
getSearchPaths: t3
|
|
174
|
+
};
|
|
175
|
+
$[8] = t1;
|
|
176
|
+
$[9] = t3;
|
|
177
|
+
$[10] = t4;
|
|
178
|
+
} else t4 = $[10];
|
|
179
|
+
return t4;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
export { useIModelTree, useIModelUnifiedSelectionTree };
|
|
184
|
+
//# sourceMappingURL=UseIModelTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","HierarchySearchPath","Props","UseUnifiedTreeSelectionProps","UseTreeProps","UseTreeResult","IModelHierarchyProviderProps","IModelAccess","UseIModelTreeProps","Omit","Pick","getHierarchyDefinition","props","imodelAccess","getSearchPaths","abortSignal","AbortSignal","Promise","useIModelTree","$","_c","imodelChanged","rest","t0","t1","useIModelTreeProps","t2","useIModelUnifiedSelectionTree","translate","hierarchyDefinition","localizedStrings","other","unspecified","t3","t4","getHierarchyProvider"],"sources":["../../src/presentation-hierarchies-react/UseIModelTree.ts"],"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 } from \"@itwin/presentation-hierarchies\";\nimport { useTranslation } from \"./stratakit/LocalizationContext.js\";\nimport { useTree, useUnifiedSelectionTree } from \"./UseTree.js\";\n\nimport type { HierarchyDefinition, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { Props } from \"@itwin/presentation-shared\";\nimport type { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport type { UseTreeProps, UseTreeResult } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> &\n Pick<IModelHierarchyProviderProps, \"imodelAccess\" | \"imodelChanged\"> & {\n /**\n * Provides the hierarchy definition for the tree.\n */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /**\n * Provides paths to target nodes.\n */\n getSearchPaths?: (props: {\n /**\n * Object that provides access to the iModel schema and can run queries against the iModel.\n */\n imodelAccess: IModelAccess;\n /**\n * Signal indicating that that the request was canceled\n */\n abortSignal: AbortSignal;\n }) => Promise<HierarchySearchPath[] | 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 * @public\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\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 the given selection\n * storage (previously the storage was provided through the, now deprecated, `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 * @public\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getSearchPaths\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;\n const translate = useTranslation();\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings: {\n other: translate(\"other\"),\n unspecified: translate(\"unspecified\"),\n },\n }),\n [imodelAccess, imodelChanged, translate, getHierarchyDefinition],\n ),\n getSearchPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getSearchPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getSearchPaths],\n ),\n };\n}\n"],"mappings":"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"}
|