@itwin/presentation-hierarchies-react 2.0.0-alpha.54 → 2.0.0-alpha.56
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 +38 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +2 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +1 -1
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.js +43 -48
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.d.ts +8 -3
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.js +21 -21
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -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.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/ErrorItemRenderer.d.ts +3 -3
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/ErrorItemRenderer.js +158 -128
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.js +7 -4
- 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.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/RootErrorRenderer.js +64 -46
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeErrorRenderer.d.ts +3 -3
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeErrorRenderer.js +19 -20
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeFilterAction.js +43 -30
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenameAction.js +37 -31
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.js +227 -192
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeRenderer.d.ts +3 -6
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeRenderer.js +39 -45
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react.d.ts → presentation-hierarchies-react.d.ts} +3 -2
- package/lib/{esm/presentation-hierarchies-react.js → presentation-hierarchies-react.js} +3 -2
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +19 -15
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- 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.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 -67
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/Renderers.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseNodeHighlighting.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseNodeHighlighting.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseSelectionHandler.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseSelectionHandler.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/Utils.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/DisposePolyfill.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeActions.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeLoader.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeModel.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeModel.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/UseUnifiedSelection.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/UseUnifiedSelection.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/Utils.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/RootErrorRenderer.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeAction.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeFilterAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenameAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.56
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1230](https://github.com/iTwin/presentation/pull/1230): Added `isNodeExpandable` property to `GenericErrorInfo`, allowing nodes with generic errors to remain expandable.
|
|
8
|
+
|
|
9
|
+
## 2.0.0-alpha.55
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
|
|
15
|
+
**Breaking changes**
|
|
16
|
+
- `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).
|
|
17
|
+
- `LOCALIZATION_NAMESPACES` must be registered with your localization provider during app initialization to make localized strings available.
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#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.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#1219](https://github.com/iTwin/presentation/pull/1219): Fix component documentation mentioning iTwinUI
|
|
26
|
+
- Updated dependencies:
|
|
27
|
+
- @itwin/presentation-shared@2.0.0-alpha.8
|
|
28
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.12
|
|
29
|
+
- @itwin/unified-selection@1.6.8-alpha.0
|
|
30
|
+
|
|
3
31
|
## 2.0.0-alpha.54
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -786,6 +814,16 @@
|
|
|
786
814
|
|
|
787
815
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
788
816
|
|
|
817
|
+
## 1.9.12
|
|
818
|
+
|
|
819
|
+
### Patch Changes
|
|
820
|
+
|
|
821
|
+
- [#1215](https://github.com/iTwin/presentation/pull/1215): Update dependencies.
|
|
822
|
+
- Updated dependencies:
|
|
823
|
+
- @itwin/presentation-hierarchies@1.7.10
|
|
824
|
+
- @itwin/presentation-shared@1.2.9
|
|
825
|
+
- @itwin/unified-selection@1.6.7
|
|
826
|
+
|
|
789
827
|
## 1.9.11
|
|
790
828
|
|
|
791
829
|
### 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 @@
|
|
|
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"}
|
|
@@ -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;EAYsB;EAVtB,gBAAA;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
|
@@ -12,7 +12,7 @@ type IModelAccess = IModelHierarchyProviderProps["imodelAccess"];
|
|
|
12
12
|
* Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearchPaths"> & Pick<IModelHierarchyProviderProps, "
|
|
15
|
+
type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearchPaths"> & Pick<IModelHierarchyProviderProps, "imodelAccess" | "imodelChanged"> & {
|
|
16
16
|
/**
|
|
17
17
|
* Provides the hierarchy definition for the tree.
|
|
18
18
|
*/
|
|
@@ -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"}
|
package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.js
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
|
|
2
|
+
import { useTranslation } from "./stratakit/LocalizationContext.js";
|
|
2
3
|
import { c } from "react-compiler-runtime";
|
|
3
4
|
import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
4
5
|
|
|
@@ -17,57 +18,52 @@ import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
20
|
function useIModelTree(props) {
|
|
20
|
-
const $ = c(
|
|
21
|
+
const $ = c(14);
|
|
21
22
|
let getHierarchyDefinition;
|
|
22
23
|
let getSearchPaths;
|
|
23
24
|
let imodelAccess;
|
|
24
25
|
let imodelChanged;
|
|
25
|
-
let localizedStrings;
|
|
26
26
|
let rest;
|
|
27
27
|
if ($[0] !== props) {
|
|
28
|
-
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths,
|
|
28
|
+
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
|
|
29
29
|
$[0] = props;
|
|
30
30
|
$[1] = getHierarchyDefinition;
|
|
31
31
|
$[2] = getSearchPaths;
|
|
32
32
|
$[3] = imodelAccess;
|
|
33
33
|
$[4] = imodelChanged;
|
|
34
|
-
$[5] =
|
|
35
|
-
$[6] = rest;
|
|
34
|
+
$[5] = rest;
|
|
36
35
|
} else {
|
|
37
36
|
getHierarchyDefinition = $[1];
|
|
38
37
|
getSearchPaths = $[2];
|
|
39
38
|
imodelAccess = $[3];
|
|
40
39
|
imodelChanged = $[4];
|
|
41
|
-
|
|
42
|
-
rest = $[6];
|
|
40
|
+
rest = $[5];
|
|
43
41
|
}
|
|
44
42
|
let t0;
|
|
45
|
-
if ($[
|
|
43
|
+
if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
|
|
46
44
|
t0 = {
|
|
47
45
|
imodelAccess,
|
|
48
46
|
imodelChanged,
|
|
49
47
|
getHierarchyDefinition,
|
|
50
|
-
getSearchPaths
|
|
51
|
-
localizedStrings
|
|
48
|
+
getSearchPaths
|
|
52
49
|
};
|
|
53
|
-
$[
|
|
54
|
-
$[
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
|
|
59
|
-
} else t0 = $[12];
|
|
50
|
+
$[6] = getHierarchyDefinition;
|
|
51
|
+
$[7] = getSearchPaths;
|
|
52
|
+
$[8] = imodelAccess;
|
|
53
|
+
$[9] = imodelChanged;
|
|
54
|
+
$[10] = t0;
|
|
55
|
+
} else t0 = $[10];
|
|
60
56
|
const t1 = useIModelTreeProps(t0);
|
|
61
57
|
let t2;
|
|
62
|
-
if ($[
|
|
58
|
+
if ($[11] !== rest || $[12] !== t1) {
|
|
63
59
|
t2 = {
|
|
64
60
|
...rest,
|
|
65
61
|
...t1
|
|
66
62
|
};
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
} else t2 = $[
|
|
63
|
+
$[11] = rest;
|
|
64
|
+
$[12] = t1;
|
|
65
|
+
$[13] = t2;
|
|
66
|
+
} else t2 = $[13];
|
|
71
67
|
return useTree(t2);
|
|
72
68
|
}
|
|
73
69
|
/**
|
|
@@ -86,74 +82,73 @@ function useIModelTree(props) {
|
|
|
86
82
|
* @public
|
|
87
83
|
*/
|
|
88
84
|
function useIModelUnifiedSelectionTree(props) {
|
|
89
|
-
const $ = c(
|
|
85
|
+
const $ = c(14);
|
|
90
86
|
let getHierarchyDefinition;
|
|
91
87
|
let getSearchPaths;
|
|
92
88
|
let imodelAccess;
|
|
93
89
|
let imodelChanged;
|
|
94
|
-
let localizedStrings;
|
|
95
90
|
let rest;
|
|
96
91
|
if ($[0] !== props) {
|
|
97
|
-
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths,
|
|
92
|
+
({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
|
|
98
93
|
$[0] = props;
|
|
99
94
|
$[1] = getHierarchyDefinition;
|
|
100
95
|
$[2] = getSearchPaths;
|
|
101
96
|
$[3] = imodelAccess;
|
|
102
97
|
$[4] = imodelChanged;
|
|
103
|
-
$[5] =
|
|
104
|
-
$[6] = rest;
|
|
98
|
+
$[5] = rest;
|
|
105
99
|
} else {
|
|
106
100
|
getHierarchyDefinition = $[1];
|
|
107
101
|
getSearchPaths = $[2];
|
|
108
102
|
imodelAccess = $[3];
|
|
109
103
|
imodelChanged = $[4];
|
|
110
|
-
|
|
111
|
-
rest = $[6];
|
|
104
|
+
rest = $[5];
|
|
112
105
|
}
|
|
113
106
|
let t0;
|
|
114
|
-
if ($[
|
|
107
|
+
if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
|
|
115
108
|
t0 = {
|
|
116
109
|
imodelAccess,
|
|
117
110
|
imodelChanged,
|
|
118
111
|
getHierarchyDefinition,
|
|
119
|
-
getSearchPaths
|
|
120
|
-
localizedStrings
|
|
112
|
+
getSearchPaths
|
|
121
113
|
};
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
|
|
128
|
-
} else t0 = $[12];
|
|
114
|
+
$[6] = getHierarchyDefinition;
|
|
115
|
+
$[7] = getSearchPaths;
|
|
116
|
+
$[8] = imodelAccess;
|
|
117
|
+
$[9] = imodelChanged;
|
|
118
|
+
$[10] = t0;
|
|
119
|
+
} else t0 = $[10];
|
|
129
120
|
const t1 = useIModelTreeProps(t0);
|
|
130
121
|
let t2;
|
|
131
|
-
if ($[
|
|
122
|
+
if ($[11] !== rest || $[12] !== t1) {
|
|
132
123
|
t2 = {
|
|
133
124
|
...rest,
|
|
134
125
|
...t1
|
|
135
126
|
};
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else t2 = $[
|
|
127
|
+
$[11] = rest;
|
|
128
|
+
$[12] = t1;
|
|
129
|
+
$[13] = t2;
|
|
130
|
+
} else t2 = $[13];
|
|
140
131
|
return useUnifiedSelectionTree(t2);
|
|
141
132
|
}
|
|
142
133
|
function useIModelTreeProps(props) {
|
|
143
134
|
const $ = c(11);
|
|
144
|
-
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths
|
|
135
|
+
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;
|
|
136
|
+
const translate = useTranslation();
|
|
145
137
|
let t0;
|
|
146
|
-
if ($[0] !== getHierarchyDefinition || $[1] !== imodelAccess || $[2] !== imodelChanged || $[3] !==
|
|
138
|
+
if ($[0] !== getHierarchyDefinition || $[1] !== imodelAccess || $[2] !== imodelChanged || $[3] !== translate) {
|
|
147
139
|
t0 = () => createIModelHierarchyProvider({
|
|
148
140
|
imodelAccess,
|
|
149
141
|
imodelChanged,
|
|
150
142
|
hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),
|
|
151
|
-
localizedStrings
|
|
143
|
+
localizedStrings: {
|
|
144
|
+
other: translate("other"),
|
|
145
|
+
unspecified: translate("unspecified")
|
|
146
|
+
}
|
|
152
147
|
});
|
|
153
148
|
$[0] = getHierarchyDefinition;
|
|
154
149
|
$[1] = imodelAccess;
|
|
155
150
|
$[2] = imodelChanged;
|
|
156
|
-
$[3] =
|
|
151
|
+
$[3] = translate;
|
|
157
152
|
$[4] = t0;
|
|
158
153
|
} else t0 = $[4];
|
|
159
154
|
const t1 = t0;
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;AA4DA,SAAOuB,cAAAN,OAAA;CAAA,MAAAO,IAAAC,EAAA,GAAA;CAAA,IAAAT;CAAA,IAAAG;CAAA,IAAAD;CAAA,IAAAQ;CAAA,IAAAC;AAAA,KAAAH,EAAA,OAAAP,OA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AAAK,KAAAD;CAYrB,IAAAG;AAAA,KAAAP,EAAA,OAAAL,kBAAAK,EAAA,OAAAN,cAAA;AAECa,OAAA,OAAAO,OAAA;GAAO,MAAA,EAAAlB,gBAAAkB;AAA6C,UAAKnB,iBAAiB;IAAAD;IAAAE;IAA6B,CAAC;;AAAAI,IAAA,KAAAL;AAAAK,IAAA,KAAAN;AAAAM,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAD1F,MAAAc,KAAAP;CAGf,IAAAQ;AAAA,KAAAf,EAAA,OAAAK,MAAAL,EAAA,OAAAc,IAAA;AAjBIC,OAAA;GAAAC,sBACiBX;GAYrBV,gBACemB;GAIjB;AAAAd,IAAA,KAAAK;AAAAL,IAAA,KAAAc;AAAAd,IAAA,MAAAe;OAAAA,MAAAf,EAAA;AAAA,QAlBMe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseNodeHighlighting.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"mappings":";;;;;;AAS8C;;UAMpC,wBAAA;EAER;EAAA,aAAA;AAAA;;;;;UAOQ,yBAAA;EAEG;EAAX,QAAA,GAAW,IAAA,EAAM,QAAA,KAAa,YAAA;AAAA;;AAOhC;;;iBAAgB,mBAAA,CAAA;EAAsB;AAAA,GAAiB,wBAAA,GAA2B,yBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseNodeHighlighting.js","names":["useCallback","HierarchyNode","JSX","ReactElement","TreeNode","UseNodeHighlightingProps","highlightText","UseNodeHighlightingResult","getLabel","node","useNodeHighlighting","t0","$","_c","t1","isGroupingNode","nodeData","search","isSearchTarget","label","matchedIndexes","Array","nodeLabel","toLocaleLowerCase","searchText","fromPosition","foundIndex","indexOf","push","length","finalLabel","lastAddedPosition","i","matchedIndex","substring","endingPlace","t2"],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * Props for `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingProps {\n /** Text that should be highlighted */\n highlightText?: string;\n}\n\n/**\n * Result of `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingResult {\n /** Function that creates highlighted node labels. */\n getLabel: (node: TreeNode) => ReactElement;\n}\n\n/**\n * A react hook that helps create highlighted node labels based on provided highlight.\n * @alpha\n */\nexport function useNodeHighlighting({ highlightText }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const getLabel = useCallback(\n (node: TreeNode) => {\n if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) {\n return <span>{node.label}</span>;\n }\n\n const matchedIndexes = new Array<number>();\n const nodeLabel = node.label.toLocaleLowerCase();\n const searchText = highlightText.toLocaleLowerCase();\n let fromPosition = 0;\n // Find all occurrences of the search text in the node label\n while (true) {\n const foundIndex = nodeLabel.indexOf(searchText, fromPosition);\n if (foundIndex === -1) {\n break;\n }\n matchedIndexes.push(foundIndex);\n fromPosition = foundIndex + searchText.length;\n }\n\n if (matchedIndexes.length === 0) {\n return <span>{node.label}</span>;\n }\n\n // Create the final label with highlighted parts\n const finalLabel = new Array<JSX.Element>();\n let lastAddedPosition = 0;\n for (let i = 0; i < matchedIndexes.length; ++i) {\n const matchedIndex = matchedIndexes[i];\n if (matchedIndex > lastAddedPosition) {\n finalLabel.push(<span key={`normal-${i}`}>{node.label.substring(lastAddedPosition, matchedIndex)}</span>);\n lastAddedPosition = matchedIndex;\n }\n const endingPlace = matchedIndex + highlightText.length;\n finalLabel.push(<mark key={`marked-${i}`}>{node.label.substring(lastAddedPosition, endingPlace)}</mark>);\n lastAddedPosition = endingPlace;\n }\n if (lastAddedPosition < node.label.length) {\n finalLabel.push(<span key={`normal-${matchedIndexes.length + 1}`}>{node.label.substring(lastAddedPosition)}</span>);\n }\n\n return <>{finalLabel}</>;\n },\n [highlightText],\n );\n\n return { getLabel };\n}\n"],"mappings":";;;;;;;;;AAiCA,SAAOU,oBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA6B,MAAA,EAAAP,kBAAAK;CAA2C,IAAAG;AAAA,KAAAF,EAAA,OAAAN,eAAA;AAE3EQ,QAAAL,SAAA;AACE,OAAI,CAACH,iBAAiBL,cAAac,eAAgBN,KAAIO,SAAmD,IAAtG,CAAkEP,KAAIO,SAASC,QAAuBC,eAAA,QACjG,oBAAA,oBAAOT,KAAIU,QAAc;GAGlC,MAAAC,iBAAuB,IAAIC,OAAe;GAC1C,MAAAC,YAAkBb,KAAIU,MAAMI,mBAAoB;GAChD,MAAAC,aAAmBlB,cAAaiB,mBAAoB;GACpD,IAAAE,eAAmB;AAEnB,UAAO,MAAI;IACT,MAAAC,aAAmBJ,UAASK,QAASH,YAAYC,aAAa;AAC9D,QAAIC,eAAe,GACjB;AAEFN,mBAAcQ,KAAMF,WAAW;AAC/BD,mBAAeC,aAAaF,WAAUK;;AAGxC,OAAIT,eAAcS,WAAY,EAAC,QACtB,oBAAA,oBAAOpB,KAAIU,QAAc;GAIlC,MAAAW,aAAmB,IAAIT,OAAoB;GAC3C,IAAAU,oBAAwB;AACxB,QAAA,IAAAC,IAAa,GAAGA,IAAIZ,eAAcS,QAAS,EAAEG,GAAC;IAC5C,MAAAC,eAAqBb,eAAeY;AACpC,QAAIC,eAAeF,mBAAiB;AAClCD,gBAAUF,KAAM,oBAAA,oBAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBE,aAAY,IAApE,UAAUD,IAAmE,CAAC;AACzGD,yBAAoBE;;IAEtB,MAAAE,cAAoBF,eAAe3B,cAAauB;AAChDC,eAAUF,KAAM,oBAAA,oBAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBI,YAAW,IAAnE,UAAUH,IAAkE,CAAC;AACxGD,wBAAoBI;;AAEtB,OAAIJ,oBAAoBtB,KAAIU,MAAMU,OAChCC,YAAUF,KAAM,oBAAA,oBAAmDnB,KAAIU,MAAMe,UAAWH,kBAAiB,IAA9E,UAAUX,eAAcS,SAAU,IAAqD,CAAC;AACpH,UAEM,0CAAGC,aAAc;;AACzBlB,IAAA,KAAAN;AAAAM,IAAA,KAAAE;OAAAA,MAAAF,EAAA;CA1CH,MAAAJ,WAAiBM;CA4Cf,IAAAsB;AAAA,KAAAxB,EAAA,OAAAJ,UAAA;AAEK4B,OAAA,EAAA5B,UAAY;AAAAI,IAAA,KAAAJ;AAAAI,IAAA,KAAAwB;OAAAA,MAAAxB,EAAA;AAAA,QAAZwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseSelectionHandler.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"mappings":";;;;;AAmBA;;;;;AAUA;;KAVY,aAAA;;;;;;;;;KAUA,mBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseSelectionHandler.js","names":["useCallback","useEffect","useRef","TreeRendererProps","TreeNode","SelectionMode","SelectionChangeType","UseSelectionHandlerProps","Pick","selectionMode","UseSelectionHandlerResult","handleNodeSelect","props","nodeId","isSelected","shiftDown","ctrlDown","FlatTreeState","flatNodeList","Array","nodeIdToIndexMap","Map","useSelectionHandler","$","_c","rootNodes","selectNodes","previousSelectionRef","undefined","t0","Symbol","for","state","t1","t2","current","computeFlatNodeList","t3","firstId","secondId","getIndex","get","firstIndex","secondIndex","startingIndex","Math","min","endIndex","max","slice","getNodeRange","t4","t5","nodeId_0","selection","getSelectionAction","type","nodes","select","length","SelectionAction","getExtendedSelectionAction","flattenNodeRecursively","forEach","node","set","id","push","isExpanded","children"],"sources":["../../src/presentation-hierarchies-react/UseSelectionHandler.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, useEffect, useRef } from \"react\";\n\nimport type { TreeRendererProps } from \"./Renderers.js\";\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * A union of different supported selection modes in a tree component:\n * - `none` - no selection is allowed,\n * - `single` - only one node can be selected at a time,\n * - `extended` - multiple nodes can be selected using shift and ctrl keys,\n * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.\n *\n * @public\n */\nexport type SelectionMode = \"none\" | \"single\" | \"extended\" | \"multiple\";\n\n/**\n * Type of selection change.\n * - `add` - a node was added to the selection,\n * - `replace` - a selected node was replaced with a different one,\n * - `remove` - a node was removed from the selection.\n *\n * @public\n */\nexport type SelectionChangeType = \"add\" | \"replace\" | \"remove\";\n\n/**\n * Props for `useSelectionHandler` hook.\n * @alpha\n */\ntype UseSelectionHandlerProps = Pick<TreeRendererProps, \"selectNodes\" | \"rootNodes\"> & {\n /**\n * Selection mode that the component is working in.\n */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @internal\n */\ninterface UseSelectionHandlerResult {\n /** Updates nodes selection based on current node state and modifier keys used. */\n handleNodeSelect: (props: { nodeId: string; isSelected: boolean; shiftDown: boolean; ctrlDown: boolean }) => void;\n}\n\ninterface FlatTreeState {\n flatNodeList: Array<string>;\n nodeIdToIndexMap: Map<string, number>;\n}\n\n/**\n * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.\n * @internal\n */\nexport function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult {\n const { rootNodes, selectionMode, selectNodes } = props;\n const previousSelectionRef = useRef<string | undefined>(undefined);\n const state = useRef<FlatTreeState>({\n flatNodeList: [],\n nodeIdToIndexMap: new Map(),\n });\n\n useEffect(() => {\n state.current = computeFlatNodeList(rootNodes);\n }, [rootNodes]);\n\n const getNodeRange = (firstId?: string, secondId?: string) => {\n const getIndex = (nodeId?: string) => {\n return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;\n };\n const firstIndex = getIndex(firstId);\n const secondIndex = getIndex(secondId);\n if (firstIndex === undefined || secondIndex === undefined) {\n return [];\n }\n\n const startingIndex = Math.min(firstIndex, secondIndex);\n const endIndex = Math.max(firstIndex, secondIndex);\n return state.current.flatNodeList.slice(startingIndex, endIndex + 1);\n };\n\n const handleNodeSelect = useCallback<UseSelectionHandlerResult[\"handleNodeSelect\"]>(\n ({ nodeId, isSelected, shiftDown, ctrlDown }) => {\n const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);\n if (selection.type === \"disabled\") {\n return;\n }\n\n const nodes = selection.select === \"range\" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];\n if (!nodes.length) {\n return;\n }\n\n selection.select !== \"range\" && (previousSelectionRef.current = nodeId);\n selectNodes(nodes, selection.type);\n },\n [selectionMode, selectNodes],\n );\n\n return { handleNodeSelect };\n}\n\ninterface SelectionAction {\n select: \"node\" | \"range\";\n type: SelectionChangeType | \"disabled\";\n}\n\nfunction getSelectionAction(selectionMode: SelectionMode, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n switch (selectionMode) {\n case \"none\":\n return { select: \"node\", type: \"disabled\" };\n case \"single\":\n return { select: \"node\", type: isSelected ? \"remove\" : \"replace\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"remove\" : \"add\" };\n case \"extended\":\n return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);\n }\n}\n\nfunction getExtendedSelectionAction(isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n if (shiftDown) {\n return { select: \"range\", type: \"replace\" };\n }\n if (ctrlDown) {\n return { select: \"node\", type: isSelected ? \"remove\" : \"add\" };\n }\n return { select: \"node\", type: \"replace\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<TreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<TreeNode>) => {\n nodes.forEach((node) => {\n nodeIdToIndexMap.set(node.id, flatNodeList.length);\n flatNodeList.push(node.id);\n if (node.isExpanded && typeof node.children !== \"boolean\") {\n flattenNodeRecursively(node.children);\n }\n });\n };\n\n flattenNodeRecursively(rootNodes);\n return { flatNodeList, nodeIdToIndexMap };\n}\n"],"mappings":";;;;;;;;AA4DA,SAAOsB,oBAAAV,OAAA;CAAA,MAAAW,IAAAC,EAAA,GAAA;CACL,MAAA,EAAAC,WAAAhB,eAAAiB,gBAAkDd;CAClD,MAAAe,uBAA6BzB,OAA2B0B,OAAU;CAAC,IAAAC;AAAA,KAAAN,EAAA,OAAAO,OAAAC,IAAA,4BAAA,EAAA;AAC/BF,OAAA;GAAAX,cACpB,EAAE;GAAAE,kCACE,IAAIC,KAAI;GAC3B;AAAAE,IAAA,KAAAM;OAAAA,MAAAN,EAAA;CAHD,MAAAS,QAAc9B,OAAsB2B,GAGlC;CAAC,IAAAI;CAAA,IAAAC;AAAA,KAAAX,EAAA,OAAAE,WAAA;AAEOQ,aAAA;AACRD,SAAKG,UAAWC,oBAAoBX,UAAvB;;AACZS,OAAA,CAACT,UAAU;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAU;AAAAV,IAAA,KAAAW;QAAA;AAAAD,OAAAV,EAAA;AAAAW,OAAAX,EAAA;;AAFdtB,WAAUgC,IAEPC,GAAY;CAAA,IAAAG;AAAA,KAAAd,EAAA,OAAAO,OAAAC,IAAA,4BAAA,EAAA;AAEMM,QAAAC,SAAAC,aAAA;GACnB,MAAAC,YAAiB3B,WACRA,SAASmB,MAAKG,QAAQf,iBAAiBqB,IAAK5B,OAAW,GAAvD;GAET,MAAA6B,aAAmBF,SAASF,QAAQ;GACpC,MAAAK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W;GAAW;EACpE,KAAK,WACH,QAAO;GAAE4C,QAAQ;GAAQF,MAAM1C,aAAa,WAAW;GAAO;EAChE,KAAK,WACH,QAAO+C,2BAA2B/C,YAAYC,WAAWC,SAAS;;;AAIxE,SAAS6C,2BAA2B/C,YAAqBC,WAAoBC,UAAoC;AAC/G,KAAID,UACF,QAAO;EAAE2C,QAAQ;EAASF,MAAM;EAAW;AAE7C,KAAIxC,SACF,QAAO;EAAE0C,QAAQ;EAAQF,MAAM1C,aAAa,WAAW;EAAO;AAEhE,QAAO;EAAE4C,QAAQ;EAAQF,MAAM;EAAW;;AAG5C,SAASpB,oBAAoBX,WAA2C;CACtE,MAAMP,eAA8B,EAAE;CACtC,MAAME,mCAAwC,IAAIC,KAAK;CAEvD,MAAMyC,0BAA0BL,UAA2B;AACzDA,QAAMM,SAASC,SAAS;AACtB5C,oBAAiB6C,IAAID,KAAKE,IAAIhD,aAAayC,OAAO;AAClDzC,gBAAaiD,KAAKH,KAAKE,GAAG;AAC1B,OAAIF,KAAKI,cAAc,OAAOJ,KAAKK,aAAa,UAC9CP,wBAAuBE,KAAKK,SAAS;IAEvC;;AAGJP,wBAAuBrC,UAAU;AACjC,QAAO;EAAEP;EAAcE;EAAkB"}
|
package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TreeNode } from "./TreeNode.js";
|
|
1
|
+
import { ErrorInfo, TreeNode } from "./TreeNode.js";
|
|
2
2
|
import { RootErrorRendererProps, TreeRendererProps } from "./Renderers.js";
|
|
3
3
|
import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
|
|
4
|
-
import { GenericInstanceFilter, HierarchyProvider, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
4
|
+
import { GenericInstanceFilter, HierarchyNode, HierarchyProvider, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
5
5
|
import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
6
6
|
|
|
7
7
|
//#region src/presentation-hierarchies-react/UseTree.d.ts
|
|
@@ -66,6 +66,11 @@ interface UseTreeProps {
|
|
|
66
66
|
type: "timeout" | "unknown";
|
|
67
67
|
error: unknown;
|
|
68
68
|
}) => void;
|
|
69
|
+
/** Callback to set custom TreeNode errors.
|
|
70
|
+
*
|
|
71
|
+
* **Note:** Internal errors take precedence over custom ones.
|
|
72
|
+
*/
|
|
73
|
+
getTreeNodeError?: (node: HierarchyNode) => ErrorInfo | undefined;
|
|
69
74
|
}
|
|
70
75
|
/** @public */
|
|
71
76
|
type UseTreeResult = {
|
|
@@ -94,7 +99,7 @@ type RendererProps = {
|
|
|
94
99
|
*/
|
|
95
100
|
rootErrorRendererProps: RootErrorRendererProps;
|
|
96
101
|
} | {
|
|
97
|
-
/** Is undefined when rootNodes
|
|
102
|
+
/** Is undefined when rootNodes were successfully loaded or are in initial loading process. */rootErrorRendererProps: undefined;
|
|
98
103
|
/**
|
|
99
104
|
* An object containing information used to render tree.
|
|
100
105
|
* Use with `TreeRenderer` or your custom implementation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseTree.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseTree.ts"],"mappings":";;;;;;;;AAiCA;;;;;;;;;AAoBA;;iBApBgB,OAAA,CAAQ,KAAA,EAAO,YAAA,GAAe,aAAA;;;;;;;;;;;;;;;;iBAoB9B,uBAAA,CAAA;EACd,UAAA;EACA,gBAAA;EACA,8BAAA;EAAA,GACG;AAAA,GACF,YAAA,GAAe,4BAAA,GAA+B,aAAA;;UAgBhC,YAAA;EAhB6C;EAkB5D,oBAAA,QAA4B,iBAAA;EAFb;EAIf,cAAA;IAAoB;EAAA;IAAiB,WAAA,EAAa,WAAA;EAAA,MAAkB,OAAA,CAAQ,mBAAA;EAAxD;;;;EAKpB,qBAAA,IAAyB,MAAA,sDAA4D,QAAA;EAS3D;EAP1B,wBAAA,IAA4B,KAAA;IAAS,QAAA;IAAmB,MAAA,GAAS,qBAAA;IAAuB,KAAA;EAAA;EAPxF;EASA,oBAAA,IAAwB,KAAA;IAAS,QAAA;IAAmB,IAAA;IAA6B,KAAA;EAAA;EATL;;;;EAc5E,gBAAA,IAAoB,IAAA,EAAM,aAAA,KAAkB,SAAA;AAAA;;KAIlC,aAAA;EAX8E;;;;EAgBxF,WAAA;EAdiF;;;EAkBjF,OAAA,GAAU,MAAA,aAAmB,QAAA;EAbT;;;EAiBpB,YAAA,GAAe,SAAA,EAAW,wBAAA;AAAA,IACxB,aAAA;;;;KAKC,aAAA;EALD;;;;;EAYE,sBAAA,EAAwB,sBAAA;AAAA;EAb5B,8FAiBI,sBAAA;EAjBW;;;;AACC;EAsBZ,iBAAA,GAAoB,iBAAA;AAAA"}
|
package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.js
RENAMED
|
@@ -118,7 +118,7 @@ function useUnifiedSelectionTree(t0) {
|
|
|
118
118
|
}
|
|
119
119
|
return rest;
|
|
120
120
|
}
|
|
121
|
-
function useTreeInternal({ getHierarchyProvider, getSearchPaths, onPerformanceMeasured, onHierarchyLimitExceeded, onHierarchyLoadError }) {
|
|
121
|
+
function useTreeInternal({ getHierarchyProvider, getSearchPaths, onPerformanceMeasured, onHierarchyLimitExceeded, onHierarchyLoadError, getTreeNodeError }) {
|
|
122
122
|
const [state, setState] = useState({
|
|
123
123
|
model: {
|
|
124
124
|
idToNode: /* @__PURE__ */ new Map(),
|
|
@@ -133,10 +133,11 @@ function useTreeInternal({ getHierarchyProvider, getSearchPaths, onPerformanceMe
|
|
|
133
133
|
const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);
|
|
134
134
|
const onHierarchyLimitExceededRef = useLatest(onHierarchyLimitExceeded);
|
|
135
135
|
const onHierarchyLoadErrorRef = useLatest(onHierarchyLoadError);
|
|
136
|
+
const getTreeNodeErrorRef = useLatest(getTreeNodeError);
|
|
136
137
|
const [actions] = useState(() => new TreeActions((model) => {
|
|
137
138
|
setState({
|
|
138
139
|
model,
|
|
139
|
-
rootNodes: model.parentChildMap.get(void 0) !== void 0 ? generateTreeStructure(void 0, model) : void 0
|
|
140
|
+
rootNodes: model.parentChildMap.get(void 0) !== void 0 ? generateTreeStructure(void 0, model, getTreeNodeErrorRef.current) : void 0
|
|
140
141
|
});
|
|
141
142
|
}, (actionType, duration) => onPerformanceMeasuredRef.current?.(actionType, duration), (props) => onHierarchyLimitExceededRef.current?.(props), (props_0) => onHierarchyLoadErrorRef.current?.(props_0)));
|
|
142
143
|
const currentFormatter = useRef();
|
|
@@ -194,8 +195,12 @@ function useTreeInternal({ getHierarchyProvider, getSearchPaths, onPerformanceMe
|
|
|
194
195
|
const getNode = useCallback((nodeId_0) => {
|
|
195
196
|
const node = actions.getNode(nodeId_0);
|
|
196
197
|
if (!node || node.id === void 0) return;
|
|
197
|
-
return createTreeNode(node, state.model);
|
|
198
|
-
}, [
|
|
198
|
+
return createTreeNode(node, state.model, getTreeNodeErrorRef.current);
|
|
199
|
+
}, [
|
|
200
|
+
actions,
|
|
201
|
+
getTreeNodeErrorRef,
|
|
202
|
+
state.model
|
|
203
|
+
]);
|
|
199
204
|
const expandNode = useCallback((nodeId_1, isExpanded) => {
|
|
200
205
|
actions.expandNode(nodeId_1, isExpanded);
|
|
201
206
|
}, [actions]);
|
|
@@ -263,35 +268,30 @@ function useTreeInternal({ getHierarchyProvider, getSearchPaths, onPerformanceMe
|
|
|
263
268
|
setFormatter
|
|
264
269
|
};
|
|
265
270
|
}
|
|
266
|
-
function generateTreeStructure(parentNodeId, model) {
|
|
271
|
+
function generateTreeStructure(parentNodeId, model, getTreeNodeError) {
|
|
267
272
|
const currentChildren = model.parentChildMap.get(parentNodeId);
|
|
268
273
|
if (!currentChildren) return;
|
|
269
274
|
return currentChildren.map((childId) => model.idToNode.get(childId)).filter((node) => !!node).map((node) => {
|
|
270
|
-
return createTreeNode(node, model);
|
|
275
|
+
return createTreeNode(node, model, getTreeNodeError);
|
|
271
276
|
});
|
|
272
277
|
}
|
|
273
|
-
function createTreeNode(modelNode, model) {
|
|
278
|
+
function createTreeNode(modelNode, model, getTreeNodeError) {
|
|
274
279
|
let children;
|
|
275
280
|
return {
|
|
276
|
-
|
|
281
|
+
id: modelNode.id,
|
|
282
|
+
label: modelNode.label,
|
|
283
|
+
nodeData: modelNode.nodeData,
|
|
284
|
+
isLoading: !!modelNode.isLoading,
|
|
285
|
+
isExpanded: !!modelNode.isExpanded,
|
|
286
|
+
isFilterable: !HierarchyNode.isGroupingNode(modelNode.nodeData) && !!modelNode.nodeData.supportsFiltering && modelNode.children,
|
|
287
|
+
isFiltered: !!modelNode.instanceFilter,
|
|
288
|
+
error: modelNode.error ?? getTreeNodeError?.(modelNode.nodeData),
|
|
277
289
|
get children() {
|
|
278
|
-
if (!children) children = generateTreeStructure(modelNode.id, model);
|
|
290
|
+
if (!children) children = generateTreeStructure(modelNode.id, model, getTreeNodeError);
|
|
279
291
|
return children ? children : modelNode.children === true ? true : [];
|
|
280
292
|
}
|
|
281
293
|
};
|
|
282
294
|
}
|
|
283
|
-
function toTreeNodeBase(node) {
|
|
284
|
-
return {
|
|
285
|
-
id: node.id,
|
|
286
|
-
label: node.label,
|
|
287
|
-
nodeData: node.nodeData,
|
|
288
|
-
isLoading: !!node.isLoading,
|
|
289
|
-
isExpanded: !!node.isExpanded,
|
|
290
|
-
isFilterable: !HierarchyNode.isGroupingNode(node.nodeData) && !!node.nodeData.supportsFiltering && node.children,
|
|
291
|
-
isFiltered: !!node.instanceFilter,
|
|
292
|
-
error: node.error
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
295
|
|
|
296
296
|
//#endregion
|
|
297
297
|
export { useTree, useUnifiedSelectionTree };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseTree.js","names":["useCallback","useEffect","useMemo","useRef","useState","HierarchyNode","TreeActions","TreeModel","useUnifiedTreeSelection","safeDispose","useLatest","GenericInstanceFilter","HierarchyProvider","HierarchySearchPath","IPrimitiveValueFormatter","TreeModelHierarchyNode","TreeModelRootNode","UseUnifiedTreeSelectionProps","RootErrorRendererProps","TreeRendererProps","ErrorInfo","TreeNode","SelectionChangeType","useTree","props","$","_c","t0","useTreeInternal","rest","getTreeModelNode","_","t1","useUnifiedSelectionTree","createSelectableForGenericNode","selectionStorage","sourceName","t2","selectionProps","rootErrorRendererProps","undefined","treeRendererProps","rootNodes","t3","t4","UseTreeProps","getHierarchyProvider","getSearchPaths","abortSignal","AbortSignal","Promise","onPerformanceMeasured","action","duration","onHierarchyLimitExceeded","parentId","filter","limit","onHierarchyLoadError","type","error","getTreeNodeError","node","UseTreeResult","isReloading","getNode","nodeId","setFormatter","formatter","RendererProps","TreeState","model","Array","state","setState","idToNode","Map","parentChildMap","rootNode","id","nodeData","onPerformanceMeasuredRef","onHierarchyLimitExceededRef","onHierarchyLoadErrorRef","getTreeNodeErrorRef","actions","get","generateTreeStructure","current","actionType","currentFormatter","hierarchyProvider","setHierarchyProvider","provider","removeHierarchyChangedListener","hierarchyChanged","addListener","hierarchyChangeArgs","shouldDiscardState","searchChange","newSearch","reloadTree","reset","isSearching","setIsSearching","disposed","controller","AbortController","setHierarchySearch","paths","signal","abort","createTreeNode","expandNode","isExpanded","options","selectNodes","nodeIds","changeType","isNodeSelected","getHierarchyLevelDetails","hierarchyNode","isGroupingNode","getInstanceKeysIterator","getNodeInstanceKeys","parentNode","instanceFilter","hierarchyLevelSizeLimit","setInstanceFilter","sizeLimit","hierarchyLimit","setSizeLimit","value","setHierarchyLimit","renderProps","isLoading","parentNodeId","currentChildren","map","childId","modelNode","children","label","isFilterable","supportsFiltering","isFiltered"],"sources":["../../src/presentation-hierarchies-react/UseTree.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, useEffect, useMemo, useRef, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { TreeActions } from \"./internal/TreeActions.js\";\nimport { TreeModel } from \"./internal/TreeModel.js\";\nimport { useUnifiedTreeSelection } from \"./internal/UseUnifiedSelection.js\";\nimport { safeDispose } from \"./internal/Utils.js\";\nimport { useLatest } from \"./Utils.js\";\n\nimport type { GenericInstanceFilter, HierarchyProvider, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { IPrimitiveValueFormatter } from \"@itwin/presentation-shared\";\nimport type { TreeModelHierarchyNode, TreeModelRootNode } from \"./internal/TreeModel.js\";\nimport type { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport type { RootErrorRendererProps, TreeRendererProps } from \"./Renderers.js\";\nimport type { ErrorInfo, TreeNode } from \"./TreeNode.js\";\nimport type { SelectionChangeType } from \"./UseSelectionHandler.js\";\n\n/**\n * A React hook that creates state for a tree component.\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 `useUnifiedSelectionTree`\n * @see `useIModelTree`\n * @public\n */\nexport function useTree(props: UseTreeProps): UseTreeResult {\n const { getTreeModelNode: _, ...rest } = useTreeInternal(props);\n return rest;\n}\n\n/**\n * A React hook that creates state for a tree component, that is integrated with unified selection\n * through the given selection storage (previously the storage was provided through the, now\n * 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 `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @public\n */\nexport function useUnifiedSelectionTree({\n sourceName,\n selectionStorage,\n createSelectableForGenericNode,\n ...props\n}: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { getTreeModelNode, ...rest } = useTreeInternal(props);\n const selectionProps = useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, createSelectableForGenericNode });\n if (rest.rootErrorRendererProps === undefined && rest.treeRendererProps?.rootNodes) {\n return {\n ...rest,\n treeRendererProps: {\n ...rest.treeRendererProps,\n ...selectionProps,\n },\n };\n }\n return rest;\n}\n\n/** @public */\nexport interface UseTreeProps {\n /** Provides the hierarchy provider for the tree. */\n getHierarchyProvider: () => HierarchyProvider;\n /** Provides paths to search nodes. */\n getSearchPaths?: ({ abortSignal }: { abortSignal: AbortSignal }) => Promise<HierarchySearchPath[] | undefined>;\n /**\n * Callback that is called just after a certain action is finished.\n * Can be used for performance tracking.\n */\n onPerformanceMeasured?: (action: \"initial-load\" | \"hierarchy-level-load\" | \"reload\", duration: number) => void;\n /** Action to perform when hierarchy level contains more items that the specified limit. */\n onHierarchyLimitExceeded?: (props: { parentId?: string; filter?: GenericInstanceFilter; limit?: number | \"unbounded\" }) => void;\n /** Action to perform when an error occurs while loading hierarchy. */\n onHierarchyLoadError?: (props: { parentId?: string; type: \"timeout\" | \"unknown\"; error: unknown }) => void;\n /** Callback to set custom TreeNode errors.\n *\n * **Note:** Internal errors take precedence over custom ones.\n */\n getTreeNodeError?: (node: HierarchyNode) => ErrorInfo | undefined;\n}\n\n/** @public */\nexport type UseTreeResult = {\n /**\n * Specifies whether tree is reloading or not. It is set to `false` when initial tree load is in progress to check if\n * or tree is reloading.\n */\n isReloading: boolean;\n /**\n * Get a tree node by id\n */\n getNode: (nodeId: string) => TreeNode | undefined;\n /**\n * Sets a formatter for the primitive values that are displayed in the hierarchy.\n */\n setFormatter: (formatter: IPrimitiveValueFormatter | undefined) => void;\n} & RendererProps;\n\n/**.\n * @alpha\n */\ntype RendererProps =\n | {\n /**\n * An object containing information used to render root error handling UI.\n * Use in combination with `RootErrorRenderer` or your custom implementation.\n * Defined when root nodes fail to load.\n */\n rootErrorRendererProps: RootErrorRendererProps;\n }\n | {\n /** Is undefined when rootNodes were successfully loaded or are in initial loading process. */\n rootErrorRendererProps: undefined;\n /**\n * An object containing information used to render tree.\n * Use with `TreeRenderer` or your custom implementation.\n * Is undefined on initial loading process.\n */\n treeRendererProps?: TreeRendererProps;\n };\n\ninterface TreeState {\n model: TreeModel;\n rootNodes: Array<TreeNode> | undefined;\n}\n\nfunction useTreeInternal({\n getHierarchyProvider,\n getSearchPaths,\n onPerformanceMeasured,\n onHierarchyLimitExceeded,\n onHierarchyLoadError,\n getTreeNodeError,\n}: UseTreeProps): UseTreeResult & {\n getTreeModelNode: (nodeId: string) => TreeModelRootNode | TreeModelHierarchyNode | undefined;\n} {\n const [state, setState] = useState<TreeState>({\n model: { idToNode: new Map(), parentChildMap: new Map(), rootNode: { id: undefined, nodeData: undefined } },\n rootNodes: undefined,\n });\n const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);\n const onHierarchyLimitExceededRef = useLatest(onHierarchyLimitExceeded);\n const onHierarchyLoadErrorRef = useLatest(onHierarchyLoadError);\n const getTreeNodeErrorRef = useLatest(getTreeNodeError);\n\n const [actions] = useState<TreeActions>(\n () =>\n new TreeActions(\n (model) => {\n const rootNodes =\n model.parentChildMap.get(undefined) !== undefined ? generateTreeStructure(undefined, model, getTreeNodeErrorRef.current) : undefined;\n setState({\n model,\n rootNodes,\n });\n },\n (actionType, duration) => onPerformanceMeasuredRef.current?.(actionType, duration),\n (props) => onHierarchyLimitExceededRef.current?.(props),\n (props) => onHierarchyLoadErrorRef.current?.(props),\n ),\n );\n const currentFormatter = useRef<IPrimitiveValueFormatter>();\n\n const [hierarchyProvider, setHierarchyProvider] = useState<HierarchyProvider | undefined>();\n useEffect(() => {\n const provider = getHierarchyProvider();\n provider.setFormatter(currentFormatter.current);\n const removeHierarchyChangedListener = provider.hierarchyChanged.addListener((hierarchyChangeArgs) => {\n const shouldDiscardState = hierarchyChangeArgs.searchChange?.newSearch !== undefined;\n actions.reloadTree({ state: shouldDiscardState ? \"discard\" : \"keep\" });\n });\n actions.setHierarchyProvider(provider);\n setHierarchyProvider(provider);\n return () => {\n removeHierarchyChangedListener();\n actions.reset();\n safeDispose(provider);\n };\n }, [actions, getHierarchyProvider]);\n\n const [isSearching, setIsSearching] = useState(false);\n useEffect(() => {\n let disposed = false as boolean;\n const controller = new AbortController();\n void (async () => {\n if (!hierarchyProvider) {\n return;\n }\n\n if (!getSearchPaths) {\n hierarchyProvider.setHierarchySearch(undefined);\n // reload tree in case hierarchy provider does not use hierarchy search to load initial nodes\n actions.reloadTree({ state: \"keep\" });\n setIsSearching(false);\n return;\n }\n\n setIsSearching(true);\n let paths: HierarchySearchPath[] | undefined;\n try {\n paths = await getSearchPaths({ abortSignal: controller.signal });\n } catch {\n } finally {\n if (!disposed) {\n hierarchyProvider.setHierarchySearch(paths ? { paths } : undefined);\n setIsSearching(false);\n }\n }\n })();\n return () => {\n controller.abort();\n disposed = true;\n };\n }, [hierarchyProvider, getSearchPaths, actions]);\n\n const getTreeModelNode = useCallback<(nodeId: string) => TreeModelRootNode | TreeModelHierarchyNode | undefined>(\n (nodeId: string) => {\n return actions.getNode(nodeId);\n },\n [actions],\n );\n\n const getNode = useCallback(\n (nodeId: string): TreeNode | undefined => {\n const node = actions.getNode(nodeId);\n if (!node || node.id === undefined) {\n return undefined;\n }\n return createTreeNode(node, state.model, getTreeNodeErrorRef.current);\n },\n [actions, getTreeNodeErrorRef, state.model],\n );\n\n const expandNode = useCallback<TreeRendererProps[\"expandNode\"]>(\n (nodeId: string, isExpanded: boolean) => {\n actions.expandNode(nodeId, isExpanded);\n },\n [actions],\n );\n\n const reloadTree = useCallback<TreeRendererProps[\"reloadTree\"]>(\n (options) => {\n actions.reloadTree(options);\n },\n [actions],\n );\n\n const selectNodes = useCallback<TreeRendererProps[\"selectNodes\"]>(\n (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n actions.selectNodes(nodeIds, changeType);\n },\n [actions],\n );\n\n const isNodeSelected = useCallback<TreeRendererProps[\"isNodeSelected\"]>((nodeId: string) => TreeModel.isNodeSelected(state.model, nodeId), [state]);\n\n const setFormatter = useCallback<UseTreeResult[\"setFormatter\"]>(\n (formatter: IPrimitiveValueFormatter | undefined) => {\n currentFormatter.current = formatter;\n /* c8 ignore next 3 */\n if (!hierarchyProvider) {\n return;\n }\n\n hierarchyProvider.setFormatter(formatter);\n },\n [hierarchyProvider],\n );\n\n const getHierarchyLevelDetails = useCallback<TreeRendererProps[\"getHierarchyLevelDetails\"]>(\n (nodeId) => {\n const node = actions.getNode(nodeId);\n if (!hierarchyProvider || !node) {\n return undefined;\n }\n const hierarchyNode = node.nodeData;\n if (hierarchyNode && HierarchyNode.isGroupingNode(hierarchyNode)) {\n return undefined;\n }\n\n return {\n hierarchyNode,\n getInstanceKeysIterator: (props) =>\n hierarchyProvider.getNodeInstanceKeys({\n parentNode: hierarchyNode,\n instanceFilter: props?.instanceFilter,\n hierarchyLevelSizeLimit: props?.hierarchyLevelSizeLimit,\n }),\n instanceFilter: node.instanceFilter,\n setInstanceFilter: (filter) => actions.setInstanceFilter(nodeId, filter),\n sizeLimit: node.hierarchyLimit,\n setSizeLimit: (value) => actions.setHierarchyLimit(nodeId, value),\n };\n },\n [actions, hierarchyProvider],\n );\n\n const renderProps: RendererProps = useMemo(() => {\n if (state.model.rootNode.error) {\n return {\n rootErrorRendererProps: {\n error: state.model.rootNode.error,\n reloadTree,\n getHierarchyLevelDetails,\n },\n };\n }\n return {\n rootErrorRendererProps: undefined,\n treeRendererProps: state.rootNodes\n ? {\n rootNodes: state.rootNodes,\n expandNode,\n selectNodes,\n isNodeSelected,\n reloadTree,\n getHierarchyLevelDetails,\n }\n : undefined,\n };\n }, [expandNode, getHierarchyLevelDetails, isNodeSelected, reloadTree, selectNodes, state.model.rootNode.error, state.rootNodes]);\n\n return {\n ...renderProps,\n isReloading: !!state.model.rootNode.isLoading || isSearching,\n getTreeModelNode,\n getNode,\n setFormatter,\n };\n}\n\nfunction generateTreeStructure(\n parentNodeId: string | undefined,\n model: TreeModel,\n getTreeNodeError?: (node: HierarchyNode) => ErrorInfo | undefined,\n): Array<TreeNode> | undefined {\n const currentChildren = model.parentChildMap.get(parentNodeId);\n if (!currentChildren) {\n return undefined;\n }\n\n return currentChildren\n .map((childId) => model.idToNode.get(childId))\n .filter((node): node is TreeModelHierarchyNode => !!node)\n .map<TreeNode>((node) => {\n return createTreeNode(node, model, getTreeNodeError);\n });\n}\n\nfunction createTreeNode(modelNode: TreeModelHierarchyNode, model: TreeModel, getTreeNodeError?: (node: HierarchyNode) => ErrorInfo | undefined): TreeNode {\n let children: Array<TreeNode> | undefined;\n return {\n id: modelNode.id,\n label: modelNode.label,\n nodeData: modelNode.nodeData,\n isLoading: !!modelNode.isLoading,\n isExpanded: !!modelNode.isExpanded,\n isFilterable: !HierarchyNode.isGroupingNode(modelNode.nodeData) && !!modelNode.nodeData.supportsFiltering && modelNode.children,\n isFiltered: !!modelNode.instanceFilter,\n error: modelNode.error ?? getTreeNodeError?.(modelNode.nodeData),\n get children() {\n if (!children) {\n children = generateTreeStructure(modelNode.id, model, getTreeNodeError);\n }\n return children ? children : modelNode.children === true ? true : [];\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAOuB,QAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACoC,MAAAC,KAAAC,gBAAgBJ,MAAM;CAAA,IAAAK;AAAA,KAAAJ,EAAA,OAAAE,IAAA;EAA/D,MAAA,EAAAG,kBAAAC,GAAA,GAAAC,OAAyCL;AAAzCE,SAAAG;AAAgEP,IAAA,KAAAE;AAAAF,IAAA,KAAAI;OAAAA,QAAAJ,EAAA;AAAA,QACzDI;;;;;;;;;;;;;;;;;AAkBT,SAAOI,wBAAAN,IAAA;CAAA,MAAAF,IAAAC,EAAA,GAAA;CAAA,IAAAQ;CAAA,IAAAV;CAAA,IAAAW;CAAA,IAAAC;AAAA,KAAAX,EAAA,OAAAE,IAAA;AAAiC,GAAA,CAAAS,YAAAD,kBAAAD,mCAAAV,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MutableRefObject","Ref","useLatest","value","$","_c","ref","t0","t1","current","useEvent","callback","latestCallback","args","useMergedRefs","refs","ReadonlyArray","T","instance","forEach"],"sources":["../../src/presentation-hierarchies-react/Utils.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, useInsertionEffect, useRef } from \"react\";\n\nimport type { LegacyRef, MutableRefObject, Ref } from \"react\";\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n\n useInsertionEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\n/* c8 ignore start */\n/** @internal */\nexport function useEvent<TCallback extends (...args: any[]) => void>(callback: TCallback) {\n const latestCallback = useLatest(callback);\n\n return useCallback(\n (...args: Parameters<TCallback>) => {\n latestCallback.current(...args);\n },\n [latestCallback],\n );\n}\n/* c8 ignore end */\n\n/* c8 ignore start */\n/** @internal */\nexport function useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n/* c8 ignore end */\n"],"mappings":";;;;;AAUA,SAAOM,UAAAC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACL,MAAAC,MAAYR,OAAOK,MAAM;CAAC,IAAAI;CAAA,IAAAC;AAAA,KAAAJ,EAAA,OAAAD,OAAA;AAEPI,aAAA;AACjBD,OAAGG,UAAWN;;AACbK,OAAA,CAACL,MAAM;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAG;AAAAH,IAAA,KAAAI;QAAA;AAAAD,OAAAH,EAAA;AAAAI,OAAAJ,EAAA;;AAFVP,oBAAmBU,IAEhBC,GAAQ;AAAA,QAEJF;;;;AAKT,SAAOI,SAAAC,UAAA;CAAA,MAAAP,IAAAC,EAAA,EAAA;CACL,MAAAO,iBAAuBV,UAAUS,SAAS;CAAC,IAAAJ;AAAA,KAAAH,EAAA,OAAAQ,gBAAA;AAGzCL,QAAA,GAAAC,OAAA;GAAC,MAAAK,OAAAL;AACCI,kBAAcH,QAAQ,GAAII,KAAK;;AAChCT,IAAA,KAAAQ;AAAAR,IAAA,KAAAG;OAAAA,MAAAH,EAAA;AAAA,QAHIG;;;;;AAWT,SAAgBO,cAAiB,GAAGC,MAA+D;AACjG,QAAOnB,aACJsB,aAAuB;AACtBH,OAAKI,SAASb,QAAQ;AACpB,OAAI,OAAOA,QAAQ,WACjBA,KAAIY,SAAS;YACJZ,IACT,CAACA,IAAmCG,UAAUS;IAEhD;IAEJ,CAAC,GAAGH,KACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisposePolyfill.js","names":["Symbol","dispose","asyncDispose"],"sources":["../../../src/presentation-hierarchies-react/internal/DisposePolyfill.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\n/**\n * Polyfill for upcoming resource management feature: https://github.com/tc39/proposal-explicit-resource-management\n */\n(Symbol as any).dispose ??= Symbol(\"Symbol.dispose\");\n(Symbol as any).asyncDispose ??= Symbol(\"Symbol.asyncDispose\");\n"],"mappings":";;;;AAQA,AAACA,OAAeC,YAAYD,OAAO,iBAAiB;AACpD,AAACA,OAAeE,iBAAiBF,OAAO,sBAAsB"}
|