@itwin/presentation-hierarchies-react 2.0.0-alpha.58 → 2.0.0-alpha.59
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 +12 -0
- package/README.md +46 -57
- package/lib/presentation-hierarchies-react/{stratakit/FlatTreeNode.d.ts → FlatTreeNode.d.ts} +2 -2
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/FlatTreeNode.js → FlatTreeNode.js} +1 -1
- package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/LocalizationContext.d.ts → LocalizationContext.d.ts} +1 -1
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/{stratakit/LocalizationContext.js → LocalizationContext.js} +2 -2
- package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +1 -1
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +1 -1
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
- package/lib/presentation-hierarchies-react-extract.js +16 -0
- package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
- package/lib/presentation-hierarchies-react-stratakit.js +8 -0
- package/lib/presentation-hierarchies-react.d.ts +3 -10
- package/lib/presentation-hierarchies-react.js +3 -10
- package/package.json +12 -7
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.59
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1259](https://github.com/iTwin/presentation/pull/1259): Introduce separate import path for StrataKit based components. StrataKit based components have to be imported through `@itwin/presentation-hierarchies-react/stratakit`. This allows to use this package with or without StrataKit dependencies.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1256](https://github.com/iTwin/presentation/pull/1256): Fix `alpha` dependencies being specified with a range (`^`), allowing package manager to use higher versions, possibly with breaking changes.
|
|
12
|
+
- Updated dependencies:
|
|
13
|
+
- @itwin/presentation-hierarchies@2.0.0-alpha.14
|
|
14
|
+
|
|
3
15
|
## 2.0.0-alpha.58
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -4,6 +4,15 @@ Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md
|
|
|
4
4
|
|
|
5
5
|
The `@itwin/presentation-hierarchies-react` package provides APIs for building a headless UI for rendering tree components based on data in an [iTwin.js iModel](https://www.itwinjs.org/learning/imodels/#imodel-overview). In addition, it delivers a set of [StrataKit](https://www.npmjs.com/package/@stratakit/bricks)-based components for rendering the tree.
|
|
6
6
|
|
|
7
|
+
## Entry points
|
|
8
|
+
|
|
9
|
+
Because StrataKit packages are optional peer dependencies, the package exposes two entry points:
|
|
10
|
+
|
|
11
|
+
| Entry point | Requires StrataKit peer dependencies | Description |
|
|
12
|
+
| ------------------------------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `@itwin/presentation-hierarchies-react` | ❌ | Core API - headless hooks and utilities, including localization helpers. |
|
|
14
|
+
| `@itwin/presentation-hierarchies-react/stratakit` | ✔️ | StrataKit-based components and actions (`StrataKitTreeRenderer`, `TreeNodeFilterAction`, `TreeNodeRenameAction`). |
|
|
15
|
+
|
|
7
16
|
## Headless UI
|
|
8
17
|
|
|
9
18
|
### Tree state hooks
|
|
@@ -15,26 +24,22 @@ The package provides different flavors of the same hook for creating and managin
|
|
|
15
24
|
| Supported data source | any | iModel | any | iModel |
|
|
16
25
|
| Integration with [Unified Selection](https://www.itwinjs.org/presentation/unified-selection/) system | ❌ | ❌ | ✔️ | ✔️ |
|
|
17
26
|
|
|
18
|
-
All these hooks return
|
|
19
|
-
|
|
20
|
-
- `isLoading` is a boolean indicating whether the root tree nodes are being loaded. Set to `true` on initial load and on reload (e.g. when iModel data changes).
|
|
21
|
-
|
|
22
|
-
- `rootNodes` is an array of `TreeNode` and is what the component should render.
|
|
23
|
-
|
|
24
|
-
- `expandNode` function to expand or collapse a node.
|
|
27
|
+
All these hooks return a `UseTreeResult` object with top-level properties and two optional renderer prop bags:
|
|
25
28
|
|
|
26
|
-
- `
|
|
29
|
+
- `isReloading` is a boolean that is `true` while the tree is being reloaded (does not apply to the initial load).
|
|
27
30
|
|
|
28
|
-
- `getNode` function to get node by its id.
|
|
31
|
+
- `getNode` function to get a tree node by its id.
|
|
29
32
|
|
|
30
|
-
- `
|
|
31
|
-
- hierarchy level size limit,
|
|
32
|
-
- hierarchy level instance filter,
|
|
33
|
-
- instance keys of the nodes in the hierarchy level.
|
|
33
|
+
- `setFormatter` function to set the active node label formatter.
|
|
34
34
|
|
|
35
|
-
- `
|
|
35
|
+
- `rootErrorRendererProps` is defined (and `treeRendererProps` is `undefined`) when root nodes fail to load. Pass it directly to `StrataKitRootErrorRenderer` or use it to build a custom error UI.
|
|
36
36
|
|
|
37
|
-
- `
|
|
37
|
+
- `treeRendererProps` is defined once root nodes have loaded successfully. It is `undefined` during the initial load. Pass it directly to `StrataKitTreeRenderer` or use it to build a custom tree renderer. It contains:
|
|
38
|
+
- `rootNodes` — array of `TreeNode` items to render.
|
|
39
|
+
- `expandNode` — function to expand or collapse a node.
|
|
40
|
+
- `isNodeSelected` and `selectNodes` — functions to inspect and change tree selection.
|
|
41
|
+
- `getHierarchyLevelDetails` — function to get details of a specific hierarchy level (size limit, instance filter, instance key iterator).
|
|
42
|
+
- `reloadTree` — function to reload part of the tree, optionally keeping its state.
|
|
38
43
|
|
|
39
44
|
#### `useTree` props
|
|
40
45
|
|
|
@@ -84,39 +89,13 @@ In addition to [props required by `useIModelTree`](#useimodeltree-props), the ho
|
|
|
84
89
|
- `selectionStorage` - unified selection storage used across different app's components, allowing them all to share selection state.
|
|
85
90
|
- `sourceName` - a string that distinguishes selection changes being made by different components. The value should be unique for each component.
|
|
86
91
|
|
|
87
|
-
### `useSelectionHandler` hook
|
|
88
|
-
|
|
89
|
-
This is a React hook that helps implement different selection modes in a tree, whose state is managed through one of the [tree state hooks](#tree-state-hooks).
|
|
90
|
-
|
|
91
|
-
It takes 3 required properties:
|
|
92
|
-
|
|
93
|
-
- `rootNodes` and `selectNodes` are the corresponding properties from the tree state object, created using one of the [tree state hooks](#tree-state-hooks).
|
|
94
|
-
|
|
95
|
-
- `selectionMode` is a string that defines the selection mode. It can be one of the following values:
|
|
96
|
-
- `none` - no selection is allowed,
|
|
97
|
-
- `single` - only one node can be selected at a time,
|
|
98
|
-
- `extended` - multiple nodes can be selected using shift and ctrl keys,
|
|
99
|
-
- `multiple` - multiple nodes can be selected without using shift or ctrl keys.
|
|
100
|
-
|
|
101
|
-
The returned object contains 2 functions, that should be called by the node renderer: `onNodeClick` and `onNodeKeyDown`.
|
|
102
|
-
|
|
103
|
-
Our [tree renderer implementation](#treerenderer) calls this hook and passes the callbacks to the [node renderer](#treenoderenderer), so there's no need to use it unless implementing a custom tree renderer.
|
|
104
|
-
|
|
105
92
|
## StrataKit components
|
|
106
93
|
|
|
107
94
|
While the package provides a headless UI, it also delivers a set of [StrataKit](https://www.npmjs.com/package/@stratakit/bricks)-based components for rendering the tree, which should cover majority of use cases. Consumers using the below components are required to provide compatible `@stratakit/bricks`/`@stratakit/icons`/`@stratakit/foundations` packages, which are optional peer dependencies to this package.
|
|
108
95
|
|
|
109
|
-
### `
|
|
110
|
-
|
|
111
|
-
The component is based on StrataKit `Tree` component and uses our [`TreeNodeRenderer`](#treenoderenderer) to render the nodes. In addition, it makes use of the [`useSelectionHandler` hook](#useselectionhandler-hook) to add selection modes' support.
|
|
112
|
-
|
|
113
|
-
### `TreeNodeRenderer`
|
|
96
|
+
### `StrataKitTreeRenderer`
|
|
114
97
|
|
|
115
|
-
The component
|
|
116
|
-
|
|
117
|
-
- Reporting click and key down events for use with [`useSelectionHandler` hook](#useselectionhandler-hook).
|
|
118
|
-
- Icons, selection, expand / collapse.
|
|
119
|
-
- Action buttons to clear / set hierarchy level instance filter.
|
|
98
|
+
The component renders a virtualized tree using the `Tree` component from `@stratakit/structures`. It handles node selection modes, error display, and virtualized scrolling. It accepts a required `treeLabel` prop (used for accessibility) and spreads `treeRendererProps` returned by the tree state hooks.
|
|
120
99
|
|
|
121
100
|
## Full example
|
|
122
101
|
|
|
@@ -128,7 +107,8 @@ import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, Hierar
|
|
|
128
107
|
|
|
129
108
|
import { createBisInstanceLabelSelectClauseFactory, Props } from "@itwin/presentation-shared";
|
|
130
109
|
|
|
131
|
-
import {
|
|
110
|
+
import { useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
|
|
111
|
+
import { StrataKitTreeRenderer, StrataKitRootErrorRenderer } from "@itwin/presentation-hierarchies-react/stratakit";
|
|
132
112
|
import { createStorage, SelectionStorage } from "@itwin/unified-selection";
|
|
133
113
|
import { useEffect, useState } from "react";
|
|
134
114
|
|
|
@@ -195,7 +175,7 @@ function getHierarchyDefinition({ imodelAccess }: { imodelAccess: IModelAccess }
|
|
|
195
175
|
|
|
196
176
|
/** Internal component that creates and renders tree state. */
|
|
197
177
|
function MyTreeComponentInternal({ imodelAccess, selectionStorage }: { imodelAccess: IModelAccess; selectionStorage: SelectionStorage }) {
|
|
198
|
-
const
|
|
178
|
+
const treeProps = useIModelUnifiedSelectionTree({
|
|
199
179
|
// the unified selection storage used by all app components let them share selection state
|
|
200
180
|
selectionStorage,
|
|
201
181
|
// the source name is used to distinguish selection changes being made by different components
|
|
@@ -205,10 +185,17 @@ function MyTreeComponentInternal({ imodelAccess, selectionStorage }: { imodelAcc
|
|
|
205
185
|
// supply the hierarchy definition
|
|
206
186
|
getHierarchyDefinition,
|
|
207
187
|
});
|
|
208
|
-
|
|
188
|
+
|
|
189
|
+
if (treeProps.rootErrorRendererProps) {
|
|
190
|
+
// render error component if tree fails to load
|
|
191
|
+
return <StrataKitRootErrorRenderer {...treeProps.rootErrorRendererProps} />;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (treeProps.isReloading || treeProps.treeRendererProps === undefined) {
|
|
209
195
|
return "Loading...";
|
|
210
196
|
}
|
|
211
|
-
|
|
197
|
+
|
|
198
|
+
return <StrataKitTreeRenderer {...treeProps.treeRendererProps} treeLabel="My Tree" />;
|
|
212
199
|
}
|
|
213
200
|
```
|
|
214
201
|
|
|
@@ -217,12 +204,8 @@ function MyTreeComponentInternal({ imodelAccess, selectionStorage }: { imodelAcc
|
|
|
217
204
|
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`:
|
|
218
205
|
|
|
219
206
|
```tsx
|
|
220
|
-
import {
|
|
221
|
-
|
|
222
|
-
LOCALIZATION_NAMESPACES,
|
|
223
|
-
StrataKitTreeRenderer,
|
|
224
|
-
useIModelUnifiedSelectionTree,
|
|
225
|
-
} from "@itwin/presentation-hierarchies-react";
|
|
207
|
+
import { LocalizationContextProvider, LOCALIZATION_NAMESPACES, useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
|
|
208
|
+
import { StrataKitTreeRenderer } from "@itwin/presentation-hierarchies-react/stratakit";
|
|
226
209
|
|
|
227
210
|
// Register localization namespaces with `i18next` based localization provider.
|
|
228
211
|
for (const namespace of LOCALIZATION_NAMESPACES) {
|
|
@@ -239,15 +222,21 @@ function Tree() {
|
|
|
239
222
|
}
|
|
240
223
|
|
|
241
224
|
function MyTreeComponent({ imodelAccess }: { imodelAccess: IModelAccess }) {
|
|
242
|
-
const
|
|
225
|
+
const treeProps = useIModelUnifiedSelectionTree({
|
|
243
226
|
sourceName: "MyTreeComponent",
|
|
244
227
|
imodelAccess,
|
|
245
228
|
getHierarchyDefinition,
|
|
246
229
|
});
|
|
247
|
-
|
|
248
|
-
|
|
230
|
+
|
|
231
|
+
if (treeProps.rootErrorRendererProps) {
|
|
232
|
+
return <div>Error</div>;
|
|
249
233
|
}
|
|
250
|
-
|
|
234
|
+
|
|
235
|
+
if (treeProps.isReloading || treeProps.treeRendererProps === undefined) {
|
|
236
|
+
return <div>Loading...</div>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return <StrataKitTreeRenderer {...treeProps.treeRendererProps} treeLabel="My Tree" />;
|
|
251
240
|
}
|
|
252
241
|
```
|
|
253
242
|
|
package/lib/presentation-hierarchies-react/{stratakit/FlatTreeNode.d.ts → FlatTreeNode.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TreeNode } from "
|
|
1
|
+
import { TreeNode } from "./TreeNode.js";
|
|
2
2
|
|
|
3
|
-
//#region src/presentation-hierarchies-react/
|
|
3
|
+
//#region src/presentation-hierarchies-react/FlatTreeNode.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.
|
|
6
6
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/FlatTreeNode.ts"],"mappings":";;;;;AAO8C;;;UAOpC,mBAAA;EACR,EAAA;EACA,KAAA;EACA,WAAA;AAAA;;AAQF;;;;UAAiB,gBAAA;EACf,EAAA;EACA,KAAA;EACA,SAAA;EACA,UAAA;EACA,IAAA,EAAM,QAAA;AAAA;;AASR;;;;;KAAY,YAAA,GAAe,gBAAA,GAAmB,mBAAA;;;;;;;AA8C9C;iBAhCgB,gBAAA,CAAiB,SAAA,EAAW,QAAA,KAAU,YAAA;;;;;;iBAgCtC,aAAA,CAAc,SAAA,EAAW,QAAA,KAAa,KAAA,CAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.js","names":["useMemo","TreeNode","FlatPlaceholderItem","id","level","placeholder","FlatTreeNodeItem","levelSize","posInLevel","node","FlatTreeItem","isPlaceholderItem","item","useFlatTreeItems","rootNodes","$","_c","t0","getFlatItems","nodes","flatItems","forEach","index","push","length","isExpanded","error","type","isNodeExpandable","children","childNodes","useErrorNodes","flatMap","_temp","rootNode","errors","isErrorNode","getErrorNodes","parent","errorList","ReturnType","childErrorList","Pick","Required","undefined"],"sources":["../../src/presentation-hierarchies-react/FlatTreeNode.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 { useMemo } from \"react\";\n\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded) {\n return;\n }\n\n if (node.error && (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable)) {\n return;\n }\n\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n const errors = isErrorNode(rootNode) ? [rootNode] : [];\n if (rootNode.children === true) {\n return errors;\n }\n\n if (errors.length === 1 && (rootNode.error?.type !== \"Unknown\" || !rootNode.error.isNodeExpandable)) {\n return errors;\n }\n errors.push(...getErrorNodes(rootNode));\n return errors;\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n if (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable) {\n return;\n }\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"],"mappings":";;;AA0CA,SAAgBW,kBAAkBC,MAAiD;AACjF,QAAO,iBAAiBA;;;;;;;;;AAU1B,SAAOC,iBAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AACgBG,OAAAC,aAAaJ,WAAW,EAAE;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAA1BE;;AAGvB,SAASC,aAAaC,OAAmBf,OAAe;CACtD,MAAMgB,YAA4B,EAAE;AACpC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,KAAKd,KAAK;AACpB,OAAIA,KAAKiB,MAAMC,SAAS,aAAa,CAAClB,KAAKiB,MAAME,iBAC/C;;AAIJ,MAAInB,KAAKoB,aAAa,MAAM;GAC1B,MAAMY,iBAAiBJ,cAAc5B,KAAK;AAC1C8B,aAAUhB,KAAK,GAAGkB,eAAe;AACjC;;GAEF;AACF,QAAOF;;AAGT,SAASH,YAAY3B,MAAsE;AACzF,QAAOA,KAAKiB,UAAUkB,KAAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSX, PropsWithChildren } from "react";
|
|
2
2
|
|
|
3
|
-
//#region src/presentation-hierarchies-react/
|
|
3
|
+
//#region src/presentation-hierarchies-react/LocalizationContext.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Properties for `LocalizationContextProvider`.
|
|
6
6
|
* @public
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/LocalizationContext.tsx"],"mappings":";;;AAW0C;;;;AAAA,UAQhC,gCAAA;EAGN;EADF,YAAA;IACE,kBAAA,GAAqB,GAAA;EAAA;AAAA;;;;;iBAQT,2BAAA,CAAA;EAA8B,YAAA;EAAc;AAAA,GAAY,iBAAA,CAAkB,gCAAA,IAAoC,GAAA,CAAI,OAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LOCALIZATION_NAMESPACE } from "
|
|
1
|
+
import { LOCALIZATION_NAMESPACE } from "./internal/LocalizedStrings.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/presentation-hierarchies-react/
|
|
5
|
+
//#region src/presentation-hierarchies-react/LocalizationContext.tsx
|
|
6
6
|
const localizationContext = createContext((key) => key);
|
|
7
7
|
/**
|
|
8
8
|
* Context provider for localizing components.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.js","names":["createContext","useContext","useMemo","LOCALIZATION_NAMESPACE","JSX","PropsWithChildren","LocalizationKey","TranslateFunc","key","localizationContext","LocalizationContextProviderProps","localization","getLocalizedString","LocalizationContextProvider","t0","$","_c","children","t1","translate","t2","useTranslation"],"sources":["../../src/presentation-hierarchies-react/LocalizationContext.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 { createContext, useContext, useMemo } from \"react\";\nimport { LOCALIZATION_NAMESPACE } from \"./internal/LocalizedStrings.js\";\n\nimport type { JSX, PropsWithChildren } from \"react\";\nimport type { LocalizationKey } from \"./internal/LocalizedStrings.js\";\n\ntype TranslateFunc = (key: LocalizationKey) => string;\n\nconst localizationContext = createContext<TranslateFunc>((key) => key);\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localization object compatible with `@itwin/core-common` */\n localization: {\n getLocalizedString: (key: string) => string;\n };\n}\n\n/**\n * Context provider for localizing components.\n * @public\n */\nexport function LocalizationContextProvider({ localization, children }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element {\n const translate = useMemo<TranslateFunc>(() => {\n return (key: LocalizationKey) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);\n }, [localization]);\n return <localizationContext.Provider value={translate}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useTranslation() {\n return useContext(localizationContext);\n}\n"],"mappings":";;;;;AAaA,MAAMS,sBAAsBT,eAA8BQ,QAAQA,IAAI;;;;;AAiBtE,SAAOK,4BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqC,MAAA,EAAAL,cAAAM,aAAAH;CAA+E,IAAAI;AAAA,KAAAH,EAAA,OAAAJ,cAAA;AAEhHO,QAAAV,QAA0BG,aAAYC,mBAAoB,GAAGT,uBAAsB,GAAIK,MAAM;AAAAO,IAAA,KAAAJ;AAAAI,IAAA,KAAAG;OAAAA,MAAAH,EAAA;CADtG,MAAAI,YACED;CACiB,IAAAE;AAAA,KAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,WAAA;AACZC,OAAA,oBAAA,oBAAA,UAAA;GAAqCD,OAAAA;GAAYF;GAAwC,CAAA;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;AAAA,QAAzFK;;;AAIT,SAAOC,iBAAA;AAAA,QACEpB,WAAWQ,oBAAoB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
|
|
2
|
-
import { useTranslation } from "./
|
|
2
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
5
5
|
//#region src/presentation-hierarchies-react/UseIModelTree.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","HierarchySearchTree","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 \"./
|
|
1
|
+
{"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","HierarchySearchTree","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 \"./LocalizationContext.js\";\nimport { useTree, useUnifiedSelectionTree } from \"./UseTree.js\";\n\nimport type { HierarchyDefinition, HierarchySearchTree } 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<HierarchySearchTree[] | 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,OAAA;AACL,GAAA,CAAAC,cAAAQ,eAAAV,wBAAAG,mBAAAQ,QAAyFV;AAAMO,IAAA,KAAAP;AAAAO,IAAA,KAAAR;AAAAQ,IAAA,KAAAL;AAAAK,IAAA,KAAAN;AAAAM,IAAA,KAAAE;AAAAF,IAAA,KAAAG;QAAA;AAAAX,2BAAAQ,EAAA;AAAAL,mBAAAK,EAAA;AAAAN,iBAAAM,EAAA;AAAAE,kBAAAF,EAAA;AAAAG,SAAAH,EAAA;;CAAA,IAAAI;AAAA,KAAAJ,EAAA,OAAAR,0BAAAQ,EAAA,OAAAL,kBAAAK,EAAA,OAAAN,gBAAAM,EAAA,OAAAE,eAAA;AAGvEE,OAAA;GAAAV;GAAAQ;GAAAV;GAAAG;GAAuE;AAAAK,IAAA,KAAAR;AAAAQ,IAAA,KAAAL;AAAAK,IAAA,KAAAN;AAAAM,IAAA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
1
1
|
import { TreeNode } from "../TreeNode.js";
|
|
2
2
|
import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
|
|
3
|
-
import { useErrorNodes } from "
|
|
3
|
+
import { useErrorNodes } from "../FlatTreeNode.js";
|
|
4
4
|
import { JSX } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
|
|
2
|
-
import { useTranslation } from "
|
|
2
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { unstable_ErrorRegion } from "@stratakit/structures";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorItemRenderer.js","names":["Anchor","Text","unstable_ErrorRegion","ErrorRegion","MAX_LIMIT_OVERRIDE","useTranslation","JSX","HierarchyLevelDetails","TreeRendererProps","TreeNode","useErrorNodes","ErrorItemRendererProps","Pick","errorNode","ReturnType","reloadTree","options","parentNodeId","scrollToNode","filterHierarchyLevel","hierarchyLevelDetails","ErrorItemRenderer","t0","$","_c","getHierarchyLevelDetails","translate","error","type","limit","resultSetSizeLimit","t1","id","setSizeLimit","onOverrideLimit","t2","t3","replace","toString","t4","t5","action","label","condition","t6","t7","t8","isFilterable","t9","t10","t11","t12","t13","hierarchyLevelDetails_0","_temp","_temp2","message","ErrorItemContainerProps","actions","MessageWithLinkProps","ErrorItemContainer","scrollToElement","filter","_temp3","map","_temp4","linkLabel","MessageWithLink","split","splitMessage","Symbol","for","display","whiteSpace","flexWrap"],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.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 { Anchor, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useTranslation } from \"./LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { useErrorNodes } from \"./FlatTreeNode.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** A node containing an error. */\n errorNode: ReturnType<typeof useErrorNodes>[number];\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (errorNode: TreeNode) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({\n errorNode,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n scrollToNode,\n}: ErrorItemRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE);\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n onOverrideLimit();\n },\n label: translate(\"increaseHierarchyLimit\").replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"increaseHierarchyLimitWithFiltering\"),\n condition: () => !!filterHierarchyLevel && !!errorNode.isFilterable,\n },\n ]}\n message={translate(\"resultLimitExceeded\").replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"noFilteredChildrenChangeFilter\"),\n condition: () => true,\n },\n ]}\n message={translate(\"noFilteredChildren\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n message={translate(\"failedToCreateHierarchy\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToNode(errorNode)} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: TreeNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAOqB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAX,WAAAY,0BAAAN,sBAAAJ,YAAAG,iBAAAI;CAOhC,MAAAI,YAAkBrB,gBAAgB;AAElC,KAAIQ,UAASc,MAAMC,SAAU,qBAAmB;EAC9C,MAAAC,QAAchB,UAASc,MAAMG;EAAoB,IAAAC;AAAA,MAAAR,EAAA,OAAAV,UAAAmB,MAAAT,EAAA,OAAAE,0BAAA;AACzBM,cAAMN,yBAAyBZ,UAASmB,GAAkB,EAAAC,aAAC7B,mBAAmB;AAAAmB,KAAA,KAAAV,UAAAmB;AAAAT,KAAA,KAAAE;AAAAF,KAAA,KAAAQ;QAAAA,MAAAR,EAAA;EAAtG,MAAAW,kBAAwBH;EAA+E,IAAAI;AAAA,MAAAZ,EAAA,OAAAW,iBAAA;AAMvFC,cAAA;AACND,qBAAiB;;AAClBX,KAAA,KAAAW;AAAAX,KAAA,KAAAY;QAAAA,MAAAZ,EAAA;EAAA,IAAAa;AAAA,MAAAb,EAAA,OAAAG,WAAA;AACMU,QAAAV,UAAU,yBAAyB,CAAAW,QAAS,aAAajC,mBAAkBkC,UAAW,CAAC;AAAAf,KAAA,KAAAG;AAAAH,K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,IAAAgB;AAAA,KAAAhB,EAAA,OAAA2C,aAAA3C,EAAA,OAAAsC,iBAAA;AAApDtB,OAAA,oBAAC,QAAD;GAAiBsB,SAAAA;GAAyB,QAAAzB;aACvC8B;GACM,CAAA;AAAA3C,IAAA,KAAA2C;AAAA3C,IAAA,KAAAsC;AAAAtC,IAAA,KAAAgB;OAAAA,MAAAhB,EAAA;CACR,MAAAiB,KAAA6B,aAAY,KAAMA,aAAY,KAA9B;CAAwC,IAAAzB;AAAA,KAAArB,EAAA,OAAA8C,aAAA,MAAA9C,EAAA,OAAAgB,MAAAhB,EAAA,OAAAiB,IAAA;AAL3CI,OAAA,qBAAA,OAAA;GAAY,OAAAT;aAAZ;IACGkC,aAAY;IACb9B;IAGCC;IACG;;AAAAjB,IAAA,KAAA8C,aAAA;AAAA9C,IAAA,KAAAgB;AAAAhB,IAAA,KAAAiB;AAAAjB,IAAA,MAAAqB;OAAAA,MAAArB,EAAA;AAAA,QANNqB"}
|
|
1
|
+
{"version":3,"file":"ErrorItemRenderer.js","names":["Anchor","Text","unstable_ErrorRegion","ErrorRegion","MAX_LIMIT_OVERRIDE","useTranslation","JSX","useErrorNodes","HierarchyLevelDetails","TreeRendererProps","TreeNode","ErrorItemRendererProps","Pick","errorNode","ReturnType","reloadTree","options","parentNodeId","scrollToNode","filterHierarchyLevel","hierarchyLevelDetails","ErrorItemRenderer","t0","$","_c","getHierarchyLevelDetails","translate","error","type","limit","resultSetSizeLimit","t1","id","setSizeLimit","onOverrideLimit","t2","t3","replace","toString","t4","t5","action","label","condition","t6","t7","t8","isFilterable","t9","t10","t11","t12","t13","hierarchyLevelDetails_0","_temp","_temp2","message","ErrorItemContainerProps","actions","MessageWithLinkProps","ErrorItemContainer","scrollToElement","filter","_temp3","map","_temp4","linkLabel","MessageWithLink","split","splitMessage","Symbol","for","display","whiteSpace","flexWrap"],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.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 { Anchor, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { useErrorNodes } from \"../FlatTreeNode.js\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** A node containing an error. */\n errorNode: ReturnType<typeof useErrorNodes>[number];\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (errorNode: TreeNode) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({\n errorNode,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n scrollToNode,\n}: ErrorItemRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE);\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n onOverrideLimit();\n },\n label: translate(\"increaseHierarchyLimit\").replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"increaseHierarchyLimitWithFiltering\"),\n condition: () => !!filterHierarchyLevel && !!errorNode.isFilterable,\n },\n ]}\n message={translate(\"resultLimitExceeded\").replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"noFilteredChildrenChangeFilter\"),\n condition: () => true,\n },\n ]}\n message={translate(\"noFilteredChildren\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n message={translate(\"failedToCreateHierarchy\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToNode(errorNode)} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: TreeNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAOqB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAX,WAAAY,0BAAAN,sBAAAJ,YAAAG,iBAAAI;CAOhC,MAAAI,YAAkBrB,gBAAgB;AAElC,KAAIQ,UAASc,MAAMC,SAAU,qBAAmB;EAC9C,MAAAC,QAAchB,UAASc,MAAMG;EAAoB,IAAAC;AAAA,MAAAR,EAAA,OAAAV,UAAAmB,MAAAT,EAAA,OAAAE,0BAAA;AACzBM,cAAMN,yBAAyBZ,UAASmB,GAAkB,EAAAC,aAAC7B,mBAAmB;AAAAmB,KAAA,KAAAV,UAAAmB;AAAAT,KAAA,KAAAE;AAAAF,KAAA,KAAAQ;QAAAA,MAAAR,EAAA;EAAtG,MAAAW,kBAAwBH;EAA+E,IAAAI;AAAA,MAAAZ,EAAA,OAAAW,iBAAA;AAMvFC,cAAA;AACND,qBAAiB;;AAClBX,KAAA,KAAAW;AAAAX,KAAA,KAAAY;QAAAA,MAAAZ,EAAA;EAAA,IAAAa;AAAA,MAAAb,EAAA,OAAAG,WAAA;AACMU,QAAAV,UAAU,yBAAyB,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,oBAAA,UAAA,EAAU,CAAA;AAAAb,IAAA,KAAAa;OAAAA,MAAAb,EAAA;CAAA,IAAAgB;AAAA,KAAAhB,EAAA,OAAA2C,aAAA3C,EAAA,OAAAsC,iBAAA;AAApDtB,OAAA,oBAAC,QAAD;GAAiBsB,SAAAA;GAAyB,QAAAzB;aACvC8B;GACM,CAAA;AAAA3C,IAAA,KAAA2C;AAAA3C,IAAA,KAAAsC;AAAAtC,IAAA,KAAAgB;OAAAA,MAAAhB,EAAA;CACR,MAAAiB,KAAA6B,aAAY,KAAMA,aAAY,KAA9B;CAAwC,IAAAzB;AAAA,KAAArB,EAAA,OAAA8C,aAAA,MAAA9C,EAAA,OAAAgB,MAAAhB,EAAA,OAAAiB,IAAA;AAL3CI,OAAA,qBAAA,OAAA;GAAY,OAAAT;aAAZ;IACGkC,aAAY;IACb9B;IAGCC;IACG;;AAAAjB,IAAA,KAAA8C,aAAA;AAAA9C,IAAA,KAAAgB;AAAAhB,IAAA,KAAAiB;AAAAjB,IAAA,MAAAqB;OAAAA,MAAArB,EAAA;AAAA,QANNqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","useTranslation","errorSvg","JSX","RootErrorRendererProps","ErrorInfo","StrataKitRootErrorRendererProps","error","StrataKitRootErrorRenderer","t0","$","_c","getHierarchyLevelDetails","reloadTree","translate","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","replace","toString","t3","t4","action","label","condition","_temp","t5","parentNodeId","state","_temp2","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","filter","_temp3","map","_temp4","t6"],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.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 { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { useTranslation } from \"
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","useTranslation","errorSvg","JSX","RootErrorRendererProps","ErrorInfo","StrataKitRootErrorRendererProps","error","StrataKitRootErrorRenderer","t0","$","_c","getHierarchyLevelDetails","reloadTree","translate","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","replace","toString","t3","t4","action","label","condition","_temp","t5","parentNodeId","state","_temp2","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","filter","_temp3","map","_temp4","t6"],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.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 { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = {\n /**\n * Root error to be displayed\n */\n error: ErrorInfo;\n} & RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit(\"unbounded\");\n return (\n <RootErrorContainer\n message={translate(\"rootResultLimitExceeded\").replace(\"{{limit}}\", error.resultSetSizeLimit.toString())}\n actions={[\n {\n action: onOverrideLimit,\n label: translate(\"increaseHierarchyLimitToUnlimited\"),\n condition: () => true,\n },\n ]}\n />\n );\n }\n\n return (\n <RootErrorContainer\n message={translate(\"failedToCreateRootHierarchy\")}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: undefined, state: \"reset\" }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n />\n );\n}\n\ninterface RootErrorContainerProps {\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n}\n\nfunction RootErrorContainer({ actions, message }: RootErrorContainerProps) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\", justifyContent: \"center\", alignItems: \"center\", gap: \"0.5rem\" }}>\n <Icon href={errorSvg} size=\"large\" />\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {message}\n </Text>\n {actions\n ?.filter(({ condition }) => condition())\n .map((action) => {\n return (\n <Button key={action.label} onClick={() => action.action()}>\n {action.label}\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAOU,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAoC,MAAA,EAAAJ,OAAAK,0BAAAC,eAAAJ;CACzC,MAAAK,YAAkBb,gBAAgB;AAElC,KAAIM,MAAKQ,SAAU,qBAAmB;EAAA,IAAAC;AAAA,MAAAN,EAAA,OAAAE,0BAAA;AACZI,cAAMJ,yBAAyBK,KAAAA,EAAwB,EAAAC,aAAC,YAAY;AAAAR,KAAA,KAAAE;AAAAF,KAAA,KAAAM;QAAAA,MAAAN,EAAA;EAA5F,MAAAS,kBAAwBH;EAAqE,IAAAI;AAAA,MAAAV,EAAA,OAAAH,MAAAc,sBAAAX,EAAA,OAAAI,WAAA;AAGhFM,QAAAN,UAAU,0BAA0B,CAAAQ,QAAS,aAAaf,MAAKc,mBAAmBE,UAAW,CAAC;AAAAb,KAAA,KAAAH,MAAAc;AAAAX,KAAA,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OACGC,OACL,CAAAC,IAACC,OAMH;AAAAxC,IAAA,KAAA0B;AAAA1B,IAAA,KAAAoB;OAAAA,MAAApB,EAAA;CAAA,IAAAyC;AAAA,KAAAzC,EAAA,OAAAe,MAAAf,EAAA,OAAAoB,IAAA;AAbNqB,OAAA,qBAAA,OAAA;GAAY,OAAAnC;aAAZ;IACEI;IACAK;IAGCK;IASG;;AAAApB,IAAA,KAAAe;AAAAf,IAAA,KAAAoB;AAAApB,IAAA,KAAAyC;OAAAA,MAAAzC,EAAA;AAAA,QAdNyC;;AAFJ,SAAAD,OAAAxB,QAAA;AAAA,QAWY,oBAAC,QAAD;EAAoC,eAAMA,OAAMA,QAAQ;YACrDA,OAAMC;EACA,EAFID,OAAMC,MAEV;;AAbrB,SAAAqB,OAAAvC,IAAA;CAQkB,MAAA,EAAAmB,cAAAnB;AAAa,QAAKmB,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"mappings":";;;;;;;AAYqE;;;UAO3D,yBAAA;EAOI;;;;EAFZ,SAAA;EAAA;EAEA,UAAA,EAAY,UAAA,QAAkB,aAAA;EAAlB;EAEZ,WAAA,IAAe,KAAA,EAAO,sBAAA,KAA2B,YAAA;AAAA;;KAIvC,sBAAA,GAAyB,yBAAA,GAA4B,IAAA,CAAK,sBAAA;;;;AAAtE;;;iBAQgB,iBAAA,CAAA;EAAoB,SAAA;EAAW,UAAA;EAAY,WAAA;EAAA,GAAgB;AAAA,GAA0B,sBAAA,GAAyB,GAAA,CAAI,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.js","names":["cloneElement","unstable_ErrorRegion","ErrorRegion","
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.js","names":["cloneElement","unstable_ErrorRegion","ErrorRegion","useTranslation","ErrorItemRenderer","JSX","ReactElement","useErrorNodes","ErrorItemRendererProps","TreeErrorRendererOwnProps","treeLabel","errorNodes","ReturnType","renderError","props","TreeErrorRendererProps","Omit","TreeErrorRenderer","t0","$","_c","errorItemRendererProps","translate","errorItems","map","errorNode","errorRendererProps","key","id","t1","Symbol","for","width","t2","replace","t3","length","toString","t4"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.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 { cloneElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { ErrorItemRenderer } from \"./ErrorItemRenderer.js\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { useErrorNodes } from \"../FlatTreeNode.js\";\nimport type { ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\n\n/**\n * Interface containing building blocks for `TreeErrorRenderer`.\n *\n * @alpha\n */\ninterface TreeErrorRendererOwnProps {\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for creating a unique accessible label for the error region.\n */\n treeLabel: string;\n /** List of error nodes to render errors for. */\n errorNodes: ReturnType<typeof useErrorNodes>;\n /** Callback to render custom error messages. Component should be wrapped in `unstable_ErrorRegion.Item` from `@stratakit/structures` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, \"errorNode\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@stratakit/structures`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorNodes` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps): JSX.Element {\n const translate = useTranslation();\n const errorItems = errorNodes.map((errorNode) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorNode,\n ...errorItemRendererProps,\n };\n\n if (renderError) {\n return cloneElement(renderError(errorRendererProps), { key: errorNode.id });\n }\n\n return <ErrorItemRenderer key={errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={translate(\"issuesForTree\").replace(\"{{tree_label}}\", treeLabel)}\n label={errorNodes.length === 0 ? translate(\"noIssuesFound\") : translate(\"issuesFound\").replace(\"{{number_of_issues}}\", errorNodes.length.toString())}\n items={errorItems}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAwCA,SAAOiB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAV,WAAAC,YAAAE,aAAA,GAAAQ,2BAAAH;CAChC,MAAAI,YAAkBnB,gBAAgB;CAClC,MAAAoB,aAAmBZ,WAAUa,KAAKC,cAAA;EAChC,MAAAC,qBAAmD;GAAAD;GAAA,GAE9CJ;GACJ;AAED,MAAIR,YAAW,QACNb,aAAaa,YAAYa,mBAAmB,EAAE,EAAAC,KAAOF,UAASG,IAAK,CAAC;AAC5E,SAEM,oBAAC,mBAAD,EAAoC,GAAMF,oBAAsB,EAAxCD,UAASG,GAA+B;GACvE;CAAC,IAAAC;AAAA,KAAAV,EAAA,OAAAW,OAAAC,IAAA,4BAAA,EAAA;AAIQF,OAAA,EAAAG,OAAS,QAAQ;AAAAb,IAAA,KAAAU;OAAAA,MAAAV,EAAA;CAAA,IAAAc;AAAA,KAAAd,EAAA,OAAAG,aAAAH,EAAA,OAAAT,WAAA;AACZuB,OAAAX,UAAU,gBAAgB,CAAAY,QAAS,kBAAkBxB,UAAU;AAAAS,IAAA,KAAAG;AAAAH,IAAA,KAAAT;AAAAS,IAAA,KAAAc;OAAAA,MAAAd,EAAA;CAAA,IAAAgB;AAAA,KAAAhB,EAAA,OAAAR,WAAAyB,UAAAjB,EAAA,OAAAG,WAAA;AACpEa,OAAAxB,WAAUyB,WAAY,IAAId,UAAU,gBAAyG,GAAtFA,UAAU,cAAc,CAAAY,QAAS,wBAAwBvB,WAAUyB,OAAOC,UAAW,CAAC;AAAAlB,IAAA,KAAAR,WAAAyB;AAAAjB,IAAA,KAAAG;AAAAH,IAAA,KAAAgB;OAAAA,MAAAhB,EAAA;CAAA,IAAAmB;AAAA,KAAAnB,EAAA,OAAAI,cAAAJ,EAAA,OAAAc,MAAAd,EAAA,OAAAgB,IAAA;AAHtJG,OAAA,oBAAA,qBAAA,MAAA;GACS,OAAAT;GACK,cAAAI;GACL,OAAAE;GACAZ,OAAAA;GACP,CAAA;AAAAJ,IAAA,KAAAI;AAAAJ,IAAA,KAAAc;AAAAd,IAAA,KAAAgB;AAAAhB,IAAA,MAAAmB;OAAAA,MAAAnB,EAAA;AAAA,QALFmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","useTranslation","TreeActionBase","filterSvg","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","translate","t1","filterHierarchyLevel","t2","filterHierarchyLevelActiveDescription","t3","id","handleClick","t4","isFiltered","undefined","t5","t6","isFilterable","t7"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.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 { memo, useCallback } from \"react\";\nimport { useTranslation } from \"
|
|
1
|
+
{"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","useTranslation","TreeActionBase","filterSvg","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","translate","t1","filterHierarchyLevel","t2","filterHierarchyLevelActiveDescription","t3","id","handleClick","t4","isFiltered","undefined","t5","t6","isFilterable","t7"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.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 { memo, useCallback } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport filterSvg from \"@stratakit/icons/filter.svg\";\n\nimport type { NamedExoticComponent } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /**\n * Action to perform when the filter button is clicked for this node.\n */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction: NamedExoticComponent<TreeNodeFilterActionProps & { node: TreeNode }> = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: TreeNode }) {\n const translate = useTranslation();\n const filterHierarchyLevel = translate(\"filterHierarchyLevel\");\n const filterHierarchyLevelActiveDescription = translate(\"filterHierarchyLevelActiveDescription\");\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n hide={!onFilter || !node.isFilterable}\n />\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,MAAac,uBAA6Fd,KAAK,SAAAc,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAL;CAAA,IAAAJ;AAAA,KAAAM,EAAA,OAAAD,IAAA;AAA8B,GAAA,CAAAD,MAAAJ,UAAAS,6BAAAD,oBAAAH;AAK5FC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;AAAAF,IAAA,KAAAG;AAAAH,IAAA,KAAAF;AAAAE,IAAA,KAAAN;QAAA;AAAAQ,qBAAAF,EAAA;AAAAG,6BAAAH,EAAA;AAAAF,SAAAE,EAAA;AAAAN,aAAAM,EAAA;;CAC/C,MAAAI,YAAkBnB,gBAAgB;CAAC,IAAAoB;AAAA,KAAAL,EAAA,OAAAI,WAAA;AACNC,OAAAD,UAAU,uBAAuB;AAAAJ,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;CAA9D,MAAAM,uBAA6BD;CAAkC,IAAAE;AAAA,KAAAP,EAAA,OAAAI,WAAA;AACjBG,OAAAH,UAAU,wCAAwC;AAAAJ,IAAA,KAAAI;AAAAJ,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAAhG,MAAAQ,wCAA8CD;CAAmD,IAAAE;AAAA,KAAAT,EAAA,OAAAG,4BAAAH,EAAA,QAAAF,KAAAY,MAAAV,EAAA,QAAAN,UAAA;AAEjEe,aAAA;GAC9B,MAAAd,wBAA8BQ,yBAAyBL,KAAIY,GAAI;AAC/Df,4BAAyBD,WAAWC,sBAAsB;;AAC3DK,IAAA,KAAAG;AAAAH,IAAA,MAAAF,KAAAY;AAAAV,IAAA,MAAAN;AAAAM,IAAA,MAAAS;OAAAA,MAAAT,EAAA;CAHD,MAAAW,cAAoBF;CAWP,MAAAG,KAAAd,KAAIe,aAAJ,OAAAC,KAAAA;CACJ,MAAAC,KAAAjB,KAAIe,aAAJL,wCAAAM,KAAAA;CACC,MAAAE,KAAA,CAACtB,YAAD,CAAcI,KAAImB;CAAa,IAAAC;AAAA,KAAAlB,EAAA,QAAAE,oBAAAF,EAAA,QAAAM,wBAAAN,EAAA,QAAAW,eAAAX,EAAA,QAAAY,MAAAZ,EAAA,QAAAe,MAAAf,EAAA,QAAAgB,IAAA;AAPvCE,OAAA,oBAAC,gBAAD;GAAe,GACThB;GACGI,OAAAA;GACEK,SAAAA;GACHxB,MAAAA;GACG,SAAAyB;GACJ,KAAAG;GACC,MAAAC;GACN,CAAA;AAAAhB,IAAA,MAAAE;AAAAF,IAAA,MAAAM;AAAAN,IAAA,MAAAW;AAAAX,IAAA,MAAAY;AAAAZ,IAAA,MAAAe;AAAAf,IAAA,MAAAgB;AAAAhB,IAAA,MAAAkB;OAAAA,MAAAlB,EAAA;AAAA,QARFkB;EAUF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTranslation } from "
|
|
1
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
2
2
|
import { TreeActionBase } from "./TreeAction.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { createContext, memo, useContext, useState } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","useTranslation","TreeActionBase","renameSvg","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","translate","context","useTreeNodeRenameContext","t1","rename","t2","canRename","startRename","t3","handleClick","t4","t5","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.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 { createContext, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport { useTranslation } from \"
|
|
1
|
+
{"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","useTranslation","TreeActionBase","renameSvg","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","translate","context","useTreeNodeRenameContext","t1","rename","t2","canRename","startRename","t3","handleClick","t4","t5","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.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 { createContext, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport renameSvg from \"@stratakit/icons/rename.svg\";\n\nimport type { NamedExoticComponent, PropsWithChildren } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & { node: TreeNode }> = memo(function TreeNodeRenameAction({\n node,\n ...actionAttributes\n}: TreeActionBaseAttributes & { node: TreeNode }) {\n const translate = useTranslation();\n const context = useTreeNodeRenameContext();\n const rename = translate(\"rename\");\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />;\n});\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({ getEditingProps }: { getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined }) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({\n renameParameters,\n cancelRename,\n startRename,\n canRename,\n }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAaa,uBAA4FZ,KAAK,SAAAY,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAJ;AAAA,KAAAE,EAAA,OAAAD,IAAA;AAA8B,GAAA,CAAAD,SAAAI,oBAAAH;AAG5FC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;AAAAF,IAAA,KAAAF;QAAA;AAAAI,qBAAAF,EAAA;AAAAF,SAAAE,EAAA;;CAC9C,MAAAG,YAAkBb,gBAAgB;CAClC,MAAAc,UAAgBC,0BAA0B;CAAC,IAAAC;AAAA,KAAAN,EAAA,OAAAG,WAAA;AAC5BG,OAAAH,UAAU,SAAS;AAAAH,IA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,KAAAS;AAAAT,IAAA,KAAAwB;AAAAxB,IAAA,KAAAU;AAAAV,IAAA,KAAAa;OAAAA,MAAAb,EAAA;AAAA,QALMa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTranslation } from "
|
|
1
|
+
import { useTranslation } from "../LocalizationContext.js";
|
|
2
2
|
import { TreeActionBase } from "./TreeAction.js";
|
|
3
3
|
import { useTreeNodeRenameContext } from "./TreeNodeRenameAction.js";
|
|
4
4
|
import { c } from "react-compiler-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","names":["cloneElement","forwardRef","isValidElement","memo","useCallback","useEffect","useId","useMemo","useRef","useState","Description","IconButton","Spinner","Text","TextBox","DropdownMenu","unstable_Popover","Popover","Tree","useTranslation","TreeActionBase","useTreeNodeRenameContext","checkmarkSvg","dismissSvg","refreshSvg","ComponentPropsWithoutRef","FC","PropsWithRef","ReactNode","RefAttributes","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeRendererOwnProps","Pick","node","menuActions","inlineActions","contextMenuActions","StrataKitTreeItemProps","Omit","Item","decorations","TreeNodeRendererProps","StrataKitTreeNodeRenderer","HTMLElement","HierarchyNode","props","forwardedRef","$","_c","expandNode","reloadTree","treeItemProps","translate","renameContext","contextMenuProps","setContextMenuProps","undefined","label","t0","bb0","error","type","t1","t2","id","parentNodeId","state","t3","injectActionVariant","inlineActionItems","bb1","menuActionItems","bb2","isNodeExpandable","children","length","isExpanded","expanded","renameParameters","cancelRename","t4","commit","t5","labelValidationHint","t6","validate","t7","labelEditor","t8","nodeId","t9","t10","t11","t12","e","onContextMenu","preventDefault","actions","position","x","clientX","y","clientY","t13","t14","t15","t16","Symbol","for","open","t17","t18","top","left","t19","t20","t21","t22","PlaceholderNode","LabelEditor","initialLabel","onChange","onCancel","inputRef","newLabelValue","setNewLabelValue","hasError","setHasError","handleLabelChange","cancelLabelChange","current","focus","select","canRename","inputId","width","event","target","value","event_0","key","display","variant","filter","action","map"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.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 \"./TreeNodeRenderer.css\";\n\nimport { cloneElement, forwardRef, isValidElement, memo, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Description, IconButton, Spinner, Text, TextBox } from \"@stratakit/bricks\";\nimport { DropdownMenu, unstable_Popover as Popover, Tree } from \"@stratakit/structures\";\nimport { useTranslation } from \"./LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\nimport { useTreeNodeRenameContext } from \"./TreeNodeRenameAction.js\";\n\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\n\nimport type { ComponentPropsWithoutRef, FC, PropsWithRef, ReactNode, RefAttributes } from \"react\";\nimport type { TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @internal */\ninterface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, \"expandNode\" | \"reloadTree\"> {\n /** Node that is rendered. */\n node: TreeNode;\n /**\n * Menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n menuActions?: ReactNode[];\n /**\n * Inline actions for tree item.\n * Must be an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n inlineActions?: ReactNode[];\n /**\n * Context menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n contextMenuActions?: ReactNode[];\n}\n\n/** @alpha */\nexport type StrataKitTreeItemProps = Omit<\n ComponentPropsWithoutRef<typeof Tree.Item>,\n \"actions\" | \"inlineActions\" | \"expanded\" | \"onExpandedChange\" | \"icon\" | \"unstable_decorations\" | \"error\"\n> & {\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n decorations?: ReactNode;\n};\n\n/** @internal */\nexport type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;\n\n/**\n * A component that renders a given `TreeNode` using the `Tree.Item` component from `@stratakit/structures`.\n *\n * @internal\n */\nexport const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>> = memo(\n forwardRef<HTMLElement, TreeNodeRendererProps>(function HierarchyNode(props, forwardedRef) {\n const { node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps } = props;\n const translate = useTranslation();\n const renameContext = useTreeNodeRenameContext();\n const [contextMenuProps, setContextMenuProps] = useState<{ position: { x: number; y: number }; actions: ReactNode[] } | undefined>(undefined);\n\n const label = treeItemProps.label ?? node.label;\n const inlineActionItems = useMemo(() => {\n if (node.error !== undefined && node.error.type === \"ChildrenLoad\") {\n return [\n <TreeActionBase\n key=\"retry\"\n label={translate(\"retry\")}\n onClick={() => reloadTree({ parentNodeId: node.id, state: \"reset\" })}\n visible={true}\n icon={refreshSvg}\n variant=\"inline\"\n />,\n ];\n }\n if (!inlineActions) {\n return undefined;\n }\n return injectActionVariant(inlineActions, \"inline\");\n }, [node, inlineActions, translate, reloadTree]);\n\n const menuActionItems = useMemo(() => {\n if (!menuActions) {\n return undefined;\n }\n return injectActionVariant(menuActions, \"default\");\n }, [menuActions]);\n\n const expanded = useMemo(() => {\n if (node.error && (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable)) {\n return undefined;\n }\n\n // this is a leaf node\n if (node.children !== true && node.children.length === 0) {\n return undefined;\n }\n\n return node.isExpanded;\n }, [node]);\n\n const { renameParameters, cancelRename } = renameContext ?? {};\n const labelEditor = (\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters?.commit}\n onCancel={cancelRename}\n labelValidationHint={renameParameters?.labelValidationHint}\n validate={renameParameters?.validate}\n />\n );\n\n return (\n <>\n <Popover content={labelEditor} placement=\"bottom\" open={renameParameters?.nodeId === node.id} setOpen={cancelRename} unmountOnHide>\n <Tree.Item\n {...treeItemProps}\n ref={forwardedRef}\n label={label}\n expanded={expanded}\n onExpandedChange={useCallback(\n (isExpanded: boolean) => {\n expandNode(node.id, isExpanded);\n },\n [node, expandNode],\n )}\n inlineActions={inlineActionItems}\n actions={menuActionItems}\n unstable_decorations={decorations}\n error={node.error ? node.error.id : undefined}\n onContextMenu={(e) => {\n if (treeItemProps.onContextMenu) {\n treeItemProps.onContextMenu(e);\n }\n\n if (!contextMenuActions) {\n return;\n }\n\n e.preventDefault();\n const actions = injectActionVariant(contextMenuActions, \"context-menu\");\n if (actions.length === 0) {\n return;\n }\n\n setContextMenuProps({\n position: {\n x: e.clientX,\n y: e.clientY,\n },\n actions,\n });\n }}\n />\n </Popover>\n <DropdownMenu.Provider\n open={contextMenuProps !== undefined}\n setOpen={(open) => {\n if (!open) {\n setContextMenuProps(undefined);\n }\n }}\n key={`${node.id}-${contextMenuProps?.position.x ?? \"\"}-${contextMenuProps?.position.y ?? \"\"}`}\n >\n {contextMenuProps ? (\n <DropdownMenu.Button style={{ position: \"fixed\", top: contextMenuProps.position.y, left: contextMenuProps.position.x }} render={<div />} />\n ) : null}\n {/* `autoFocus` prop is coming from ariakit and is not native HTML `autoFocus` prop. */}\n {/* `focusable` is needed for `autoFocus` to work. StrataKit exposes only `autoFocus` and does not set `focusable` internally. */}\n {/* eslint-disable jsx-a11y/no-autofocus */}\n {/* @ts-expect-error focusable is passed through */}\n <DropdownMenu.Content focusable autoFocus={true}>\n {contextMenuProps?.actions}\n </DropdownMenu.Content>\n </DropdownMenu.Provider>\n </>\n );\n }),\n);\n\nexport const PlaceholderNode: FC<\n PropsWithRef<Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\"> & RefAttributes<HTMLElement>>\n> = memo(\n forwardRef<HTMLElement, Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>(function PlaceholderNode(\n { ...props },\n forwardedRef,\n ) {\n const translate = useTranslation();\n return (\n <Tree.Item {...props} ref={forwardedRef} label={translate(\"loading\")} unstable_decorations={<Spinner size={\"small\"} title={translate(\"loading\")} />} />\n );\n }),\n);\n\nfunction LabelEditor({\n initialLabel,\n labelValidationHint,\n onChange,\n onCancel,\n validate,\n}: {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}) {\n const translate = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [newLabelValue, setNewLabelValue] = useState(initialLabel);\n const [hasError, setHasError] = useState<boolean>(false);\n const handleLabelChange = () => {\n if (validate && !validate(newLabelValue)) {\n setHasError(true);\n return;\n }\n\n if (initialLabel !== newLabelValue) {\n onChange?.(newLabelValue);\n return;\n }\n onCancel?.();\n };\n\n const cancelLabelChange = () => {\n setNewLabelValue(initialLabel);\n onCancel?.();\n };\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;\n const inputId = useId();\n\n return (\n <div key={initialLabel} className=\"phr-node-label-editor\">\n <div className=\"phr-node-label-editor-input-row\">\n <TextBox.Root style={{ width: \"100%\" }} className={hasError ? \"with-error\" : undefined}>\n <TextBox.Input\n id={inputId}\n ref={inputRef}\n aria-label={translate(\"newLabel\")}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyUp={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n </TextBox.Root>\n <IconButton icon={dismissSvg} label={translate(\"cancel\")} onClick={cancelLabelChange} />\n <IconButton icon={checkmarkSvg} label={translate(\"confirm\")} onClick={handleLabelChange} disabled={!canRename} />\n </div>\n {labelValidationHint !== undefined ? (\n <Description id={inputId} tone={hasError ? \"critical\" : \"neutral\"} style={{ display: \"flex\" }}>\n <Text variant=\"caption-lg\">{labelValidationHint}</Text>\n </Description>\n ) : undefined}\n </div>\n );\n}\n\nfunction injectActionVariant(actions: ReactNode[], variant: TreeActionBaseAttributes[\"variant\"]) {\n return actions\n .filter((action) => isValidElement<TreeActionBaseAttributes>(action))\n .map((action) => cloneElement<TreeActionBaseAttributes>(action, { variant }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiEA,MAAa4C,4BAAkGzC,KAC7GF,WAA+C,SAAA6C,cAAAC,OAAAC,cAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAZ;CAAA,IAAAI;CAAA,IAAAS;CAAA,IAAAd;CAAA,IAAAD;CAAA,IAAAD;CAAA,IAAAiB;CAAA,IAAAC;AAAA,KAAAJ,EAAA,OAAAF,OAAA;AAC7C,GAAA,CAAAZ,MAAAO,aAAAL,eAAAD,aAAAE,oBAAAa,YAAAC,eAAAC,iBAAwHN;AAAME,IAAA,KAAAF;AAAAE,IAAA,KAAAX;AAAAW,IAAA,KAAAP;AAAAO,IAAA,KAAAE;AAAAF,IAAA,KAAAZ;AAAAY,IAAA,KAAAb;AAAAa,IAAA,KAAAd;AAAAc,IAAA,KAAAG;AAAAH,IAAA,KAAAI;QAAA;AAAAf,uBAAAW,EAAA;AAAAP,gBAAAO,EAAA;AAAAE,eAAAF,EAAA;AAAAZ,kBAAAY,EAAA;AAAAb,gBAAAa,EAAA;AAAAd,SAAAc,EAAA;AAAAG,eAAAH,EAAA;AAAAI,kBAAAJ,EAAA;;CAC9H,MAAAK,YAAkBnC,gBAAgB;CAClC,MAAAoC,gBAAsBlC,0BAA0B;CAChD,MAAA,CAAAmC,kBAAAC,uBAAgDhD,SAAmFiD,KAAAA,EAAU;CAE7I,MAAAC,QA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AO;aAC1F,oBAAC,MAAD;IAAc,SAAA;cAAc1D;IAC9B,CAAA;GACW,CAAA,GAJZ3B,KAAAA;AAIYT,IAAA,MAAA+E;AAAA/E,IAAA,MAAAuF;AAAAvF,IAAA,MAAAoC;AAAApC,IAAA,MAAAgE;OAAAA,OAAAhE,EAAA;CAAA,IAAAmE;AAAA,KAAAnE,EAAA,QAAAyE,gBAAAzE,EAAA,QAAA+D,OAAA/D,EAAA,QAAAgE,KAAA;AA5BfG,QAAA,qBAAA,OAAA;GAAkC,WAAA;aAAlC,CACEJ,KAuBCC,IAKG;KA7BIS,aA6BJ;AAAAzE,IAAA,MAAAyE;AAAAzE,IAAA,MAAA+D;AAAA/D,IAAA,MAAAgE;AAAAhE,IAAA,MAAAmE;OAAAA,OAAAnE,EAAA;AAAA,QA7BNmE;;AAiCJ,SAAS9C,oBAAoB6B,SAAsB6C,SAA8C;AAC/F,QAAO7C,QACJ8C,QAAQC,WAAWhJ,eAAyCgJ,OAAO,CAAC,CACpEC,KAAKD,WAAWlJ,aAAuCkJ,QAAQ,EAAEF,SAAS,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","names":["cloneElement","forwardRef","isValidElement","memo","useCallback","useEffect","useId","useMemo","useRef","useState","Description","IconButton","Spinner","Text","TextBox","DropdownMenu","unstable_Popover","Popover","Tree","useTranslation","TreeActionBase","useTreeNodeRenameContext","checkmarkSvg","dismissSvg","refreshSvg","ComponentPropsWithoutRef","FC","PropsWithRef","ReactNode","RefAttributes","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeRendererOwnProps","Pick","node","menuActions","inlineActions","contextMenuActions","StrataKitTreeItemProps","Omit","Item","decorations","TreeNodeRendererProps","StrataKitTreeNodeRenderer","HTMLElement","HierarchyNode","props","forwardedRef","$","_c","expandNode","reloadTree","treeItemProps","translate","renameContext","contextMenuProps","setContextMenuProps","undefined","label","t0","bb0","error","type","t1","t2","id","parentNodeId","state","t3","injectActionVariant","inlineActionItems","bb1","menuActionItems","bb2","isNodeExpandable","children","length","isExpanded","expanded","renameParameters","cancelRename","t4","commit","t5","labelValidationHint","t6","validate","t7","labelEditor","t8","nodeId","t9","t10","t11","t12","e","onContextMenu","preventDefault","actions","position","x","clientX","y","clientY","t13","t14","t15","t16","Symbol","for","open","t17","t18","top","left","t19","t20","t21","t22","PlaceholderNode","LabelEditor","initialLabel","onChange","onCancel","inputRef","newLabelValue","setNewLabelValue","hasError","setHasError","handleLabelChange","cancelLabelChange","current","focus","select","canRename","inputId","width","event","target","value","event_0","key","display","variant","filter","action","map"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.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 \"./TreeNodeRenderer.css\";\n\nimport { cloneElement, forwardRef, isValidElement, memo, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Description, IconButton, Spinner, Text, TextBox } from \"@stratakit/bricks\";\nimport { DropdownMenu, unstable_Popover as Popover, Tree } from \"@stratakit/structures\";\nimport { useTranslation } from \"../LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\nimport { useTreeNodeRenameContext } from \"./TreeNodeRenameAction.js\";\n\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\n\nimport type { ComponentPropsWithoutRef, FC, PropsWithRef, ReactNode, RefAttributes } from \"react\";\nimport type { TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @internal */\ninterface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, \"expandNode\" | \"reloadTree\"> {\n /** Node that is rendered. */\n node: TreeNode;\n /**\n * Menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n menuActions?: ReactNode[];\n /**\n * Inline actions for tree item.\n * Must be an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n inlineActions?: ReactNode[];\n /**\n * Context menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n contextMenuActions?: ReactNode[];\n}\n\n/** @alpha */\nexport type StrataKitTreeItemProps = Omit<\n ComponentPropsWithoutRef<typeof Tree.Item>,\n \"actions\" | \"inlineActions\" | \"expanded\" | \"onExpandedChange\" | \"icon\" | \"unstable_decorations\" | \"error\"\n> & {\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n decorations?: ReactNode;\n};\n\n/** @internal */\nexport type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;\n\n/**\n * A component that renders a given `TreeNode` using the `Tree.Item` component from `@stratakit/structures`.\n *\n * @internal\n */\nexport const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>> = memo(\n forwardRef<HTMLElement, TreeNodeRendererProps>(function HierarchyNode(props, forwardedRef) {\n const { node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps } = props;\n const translate = useTranslation();\n const renameContext = useTreeNodeRenameContext();\n const [contextMenuProps, setContextMenuProps] = useState<{ position: { x: number; y: number }; actions: ReactNode[] } | undefined>(undefined);\n\n const label = treeItemProps.label ?? node.label;\n const inlineActionItems = useMemo(() => {\n if (node.error !== undefined && node.error.type === \"ChildrenLoad\") {\n return [\n <TreeActionBase\n key=\"retry\"\n label={translate(\"retry\")}\n onClick={() => reloadTree({ parentNodeId: node.id, state: \"reset\" })}\n visible={true}\n icon={refreshSvg}\n variant=\"inline\"\n />,\n ];\n }\n if (!inlineActions) {\n return undefined;\n }\n return injectActionVariant(inlineActions, \"inline\");\n }, [node, inlineActions, translate, reloadTree]);\n\n const menuActionItems = useMemo(() => {\n if (!menuActions) {\n return undefined;\n }\n return injectActionVariant(menuActions, \"default\");\n }, [menuActions]);\n\n const expanded = useMemo(() => {\n if (node.error && (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable)) {\n return undefined;\n }\n\n // this is a leaf node\n if (node.children !== true && node.children.length === 0) {\n return undefined;\n }\n\n return node.isExpanded;\n }, [node]);\n\n const { renameParameters, cancelRename } = renameContext ?? {};\n const labelEditor = (\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters?.commit}\n onCancel={cancelRename}\n labelValidationHint={renameParameters?.labelValidationHint}\n validate={renameParameters?.validate}\n />\n );\n\n return (\n <>\n <Popover content={labelEditor} placement=\"bottom\" open={renameParameters?.nodeId === node.id} setOpen={cancelRename} unmountOnHide>\n <Tree.Item\n {...treeItemProps}\n ref={forwardedRef}\n label={label}\n expanded={expanded}\n onExpandedChange={useCallback(\n (isExpanded: boolean) => {\n expandNode(node.id, isExpanded);\n },\n [node, expandNode],\n )}\n inlineActions={inlineActionItems}\n actions={menuActionItems}\n unstable_decorations={decorations}\n error={node.error ? node.error.id : undefined}\n onContextMenu={(e) => {\n if (treeItemProps.onContextMenu) {\n treeItemProps.onContextMenu(e);\n }\n\n if (!contextMenuActions) {\n return;\n }\n\n e.preventDefault();\n const actions = injectActionVariant(contextMenuActions, \"context-menu\");\n if (actions.length === 0) {\n return;\n }\n\n setContextMenuProps({\n position: {\n x: e.clientX,\n y: e.clientY,\n },\n actions,\n });\n }}\n />\n </Popover>\n <DropdownMenu.Provider\n open={contextMenuProps !== undefined}\n setOpen={(open) => {\n if (!open) {\n setContextMenuProps(undefined);\n }\n }}\n key={`${node.id}-${contextMenuProps?.position.x ?? \"\"}-${contextMenuProps?.position.y ?? \"\"}`}\n >\n {contextMenuProps ? (\n <DropdownMenu.Button style={{ position: \"fixed\", top: contextMenuProps.position.y, left: contextMenuProps.position.x }} render={<div />} />\n ) : null}\n {/* `autoFocus` prop is coming from ariakit and is not native HTML `autoFocus` prop. */}\n {/* `focusable` is needed for `autoFocus` to work. StrataKit exposes only `autoFocus` and does not set `focusable` internally. */}\n {/* eslint-disable jsx-a11y/no-autofocus */}\n {/* @ts-expect-error focusable is passed through */}\n <DropdownMenu.Content focusable autoFocus={true}>\n {contextMenuProps?.actions}\n </DropdownMenu.Content>\n </DropdownMenu.Provider>\n </>\n );\n }),\n);\n\nexport const PlaceholderNode: FC<\n PropsWithRef<Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\"> & RefAttributes<HTMLElement>>\n> = memo(\n forwardRef<HTMLElement, Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>(function PlaceholderNode(\n { ...props },\n forwardedRef,\n ) {\n const translate = useTranslation();\n return (\n <Tree.Item {...props} ref={forwardedRef} label={translate(\"loading\")} unstable_decorations={<Spinner size={\"small\"} title={translate(\"loading\")} />} />\n );\n }),\n);\n\nfunction LabelEditor({\n initialLabel,\n labelValidationHint,\n onChange,\n onCancel,\n validate,\n}: {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}) {\n const translate = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [newLabelValue, setNewLabelValue] = useState(initialLabel);\n const [hasError, setHasError] = useState<boolean>(false);\n const handleLabelChange = () => {\n if (validate && !validate(newLabelValue)) {\n setHasError(true);\n return;\n }\n\n if (initialLabel !== newLabelValue) {\n onChange?.(newLabelValue);\n return;\n }\n onCancel?.();\n };\n\n const cancelLabelChange = () => {\n setNewLabelValue(initialLabel);\n onCancel?.();\n };\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;\n const inputId = useId();\n\n return (\n <div key={initialLabel} className=\"phr-node-label-editor\">\n <div className=\"phr-node-label-editor-input-row\">\n <TextBox.Root style={{ width: \"100%\" }} className={hasError ? \"with-error\" : undefined}>\n <TextBox.Input\n id={inputId}\n ref={inputRef}\n aria-label={translate(\"newLabel\")}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyUp={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n </TextBox.Root>\n <IconButton icon={dismissSvg} label={translate(\"cancel\")} onClick={cancelLabelChange} />\n <IconButton icon={checkmarkSvg} label={translate(\"confirm\")} onClick={handleLabelChange} disabled={!canRename} />\n </div>\n {labelValidationHint !== undefined ? (\n <Description id={inputId} tone={hasError ? \"critical\" : \"neutral\"} style={{ display: \"flex\" }}>\n <Text variant=\"caption-lg\">{labelValidationHint}</Text>\n </Description>\n ) : undefined}\n </div>\n );\n}\n\nfunction injectActionVariant(actions: ReactNode[], variant: TreeActionBaseAttributes[\"variant\"]) {\n return actions\n .filter((action) => isValidElement<TreeActionBaseAttributes>(action))\n .map((action) => cloneElement<TreeActionBaseAttributes>(action, { variant }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiEA,MAAa4C,4BAAkGzC,KAC7GF,WAA+C,SAAA6C,cAAAC,OAAAC,cAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAZ;CAAA,IAAAI;CAAA,IAAAS;CAAA,IAAAd;CAAA,IAAAD;CAAA,IAAAD;CAAA,IAAAiB;CAAA,IAAAC;AAAA,KAAAJ,EAAA,OAAAF,OAAA;AAC7C,GAAA,CAAAZ,MAAAO,aAAAL,eAAAD,aAAAE,oBAAAa,YAAAC,eAAAC,iBAAwHN;AAAME,IAAA,KAAAF;AAAAE,IAAA,KAAAX;AAAAW,IAAA,KAAAP;AAAAO,IAAA,KAAAE;AAAAF,IAAA,KAAAZ;AAAAY,IAAA,KAAAb;AAAAa,IAAA,KAAAd;AAAAc,IAAA,KAAAG;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IACAG;IACI;;AAAA3D,IAAA,MAAA6C;AAAA7C,IAAA,MAAAwD;AAAAxD,IAAA,MAAA2D;AAAA3D,IAAA,MAAA+D;OAAAA,OAAA/D,EAAA;CAAA,IAAAgE;AAAA,KAAAhE,EAAA,QAAA+E,YAAA/E,EAAA,QAAAuF,WAAAvF,EAAA,QAAAoC,qBAAA;AACL4B,QAAA5B,wBAAwB3B,KAAAA,IACvB,oBAAC,aAAD;GAAiB8E,IAAAA;GAAe,MAAAR,WAAA,aAAA;GAA0C,OAAA,EAAAe,SAAW,QAAO;aAC1F,oBAAC,MAAD;IAAc,SAAA;cAAc1D;IAC9B,CAAA;GACW,CAAA,GAJZ3B,KAAAA;AAIYT,IAAA,MAAA+E;AAAA/E,IAAA,MAAAuF;AAAAvF,IAAA,MAAAoC;AAAApC,IAAA,MAAAgE;OAAAA,OAAAhE,EAAA;CAAA,IAAAmE;AAAA,KAAAnE,EAAA,QAAAyE,gBAAAzE,EAAA,QAAA+D,OAAA/D,EAAA,QAAAgE,KAAA;AA5BfG,QAAA,qBAAA,OAAA;GAAkC,WAAA;aAAlC,CACEJ,KAuBCC,IAKG;KA7BIS,aA6BJ;AAAAzE,IAAA,MAAAyE;AAAAzE,IAAA,MAAA+D;AAAA/D,IAAA,MAAAgE;AAAAhE,IAAA,MAAAmE;OAAAA,OAAAnE,EAAA;AAAA,QA7BNmE;;AAiCJ,SAAS9C,oBAAoB6B,SAAsB6C,SAA8C;AAC/F,QAAO7C,QACJ8C,QAAQC,WAAWhJ,eAAyCgJ,OAAO,CAAC,CACpEC,KAAKD,WAAWlJ,aAAuCkJ,QAAQ,EAAEF,SAAS,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEvent, useMergedRefs } from "../Utils.js";
|
|
2
|
+
import { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from "../FlatTreeNode.js";
|
|
2
3
|
import { TreeNodeRenameContextProvider, useTreeNodeRenameContextValue } from "./TreeNodeRenameAction.js";
|
|
3
4
|
import { useSelectionHandler } from "../UseSelectionHandler.js";
|
|
4
|
-
import { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from "./FlatTreeNode.js";
|
|
5
5
|
import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
|
|
6
6
|
import { PlaceholderNode, StrataKitTreeNodeRenderer } from "./TreeNodeRenderer.js";
|
|
7
7
|
import { c } from "react-compiler-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","names":["forwardRef","memo","useCallback","useEffect","useImperativeHandle","useMemo","useRef","Tree","useVirtualizer","useSelectionHandler","useEvent","useMergedRefs","isPlaceholderItem","useErrorNodes","useFlatTreeItems","TreeErrorRenderer","TreeNodeRenameContextProvider","useTreeNodeRenameContextValue","PlaceholderNode","StrataKitTreeNodeRenderer","ComponentProps","CSSProperties","FC","PropsWithoutRef","ReactElement","ReactNode","RefAttributes","TreeRendererProps","TreeNode","SelectionMode","FlatTreeItem","FlatTreeNodeItem","TreeErrorRendererProps","TreeNodeEditingProps","StrataKitTreeItemProps","TreeNodeRendererProps","TreeRendererOwnProps","id","treeLabel","selectionMode","errorRenderer","props","getEditingProps","node","treeRootProps","Partial","Omit","Root","getTreeItemProps","getMenuActions","targetNode","selectedNodes","getInlineActions","getContextMenuActions","StrataKitTreeRendererAttributes","renameNode","nodePredicate","StrataKitTreeRendererProps","Pick","StrataKitTreeRenderer","forwardedRef","rootNodes","selectNodes","expandNode","getHierarchyLevelDetails","filterHierarchyLevel","reloadTree","isNodeSelected","handleNodeSelect","flatItems","errorNodes","parentRef","HTMLDivElement","virtualizer","count","length","getScrollElement","current","getItemKey","index","estimateSize","overscan","items","getVirtualItems","expandAndScrollToNode","useExpandAndScrollToNode","renameContext","onComplete","requestAnimationFrame","startRename","cancelRename","isScrolling","errorRendererProps","scrollToNode","n","parentNodeId","state","getSelectedNodes","calculatedSelectedNodes","undefined","filter","item","map","height","width","overflowY","getTotalSize","minHeight","position","overflow","virtualizedItem","selected","measureElement","key","start","t0","$","_c","t1","pathToNode","findPathToNode","pop","collapsedNodes","_temp","forEach","didExpand","expandToNode","t2","t3","targetNodeId","findIndex","flatItem","scrollToIndex","align","onScrollComplete","t4","t5","nodePredicate_0","expandResult","targetNode_0","index_0","flatItem_0","pathNode","isExpanded","parent","children","childPath","VirtualTreeItemProps","HierarchyNodeItemProps","VirtualTreeItem","HTMLElement","top","left","transform","willChange","style","level","ReturnType","HierarchyNodeItem","rest","nodeRef","treeItemProps","isDisabled","menuActions","inlineActions","contextMenuActions","nodeActions","t6","e","onClick","detail","nodeId","isSelected","shiftDown","shiftKey","ctrlDown","ctrlKey","t7","e_0","onMouseDown","preventDefault","ref","t8","levelSize","posInLevel"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeRenderer.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 { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from \"react\";\nimport { Tree } from \"@stratakit/structures\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useEvent, useMergedRefs } from \"../Utils.js\";\nimport { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from \"./FlatTreeNode.js\";\nimport { TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\nimport { TreeNodeRenameContextProvider, useTreeNodeRenameContextValue } from \"./TreeNodeRenameAction.js\";\nimport { PlaceholderNode, StrataKitTreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\nimport type { ComponentProps, CSSProperties, FC, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from \"react\";\nimport type { TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { SelectionMode } from \"../UseSelectionHandler.js\";\nimport type { FlatTreeItem, FlatTreeNodeItem } from \"./FlatTreeNode.js\";\nimport type { TreeErrorRendererProps } from \"./TreeErrorRenderer.js\";\nimport type { TreeNodeEditingProps } from \"./TreeNodeRenameAction.js\";\nimport type { StrataKitTreeItemProps, TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\n\n/** @alpha */\ninterface TreeRendererOwnProps {\n id?: string;\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for accessibility purposes.\n */\n treeLabel: string;\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n /** A render function for errors' display component. Defaults to `<TreeErrorRenderer />`. */\n errorRenderer?: (props: TreeErrorRendererProps) => ReactElement;\n /** Props that defines if current node supports editing. */\n getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;\n\n /** Custom props for the root Tree component. */\n treeRootProps?: Partial<Omit<ComponentProps<typeof Tree.Root>, \"style\">>;\n\n /** A callback that returns tree item props for specific node. */\n getTreeItemProps?: (node: TreeNode) => Partial<Omit<StrataKitTreeItemProps, \"selected\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>;\n\n /**\n * Callback that returns menu actions for tree item.\n * Must return an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n getMenuActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n /**\n * Callback that returns inline actions for tree item.\n * Must return an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n getInlineActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n /**\n * Callback that returns actions for tree item context menu.\n * Must return an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n getContextMenuActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n}\n\n/** @alpha */\nexport interface StrataKitTreeRendererAttributes {\n /**\n * Opens rename mode for the first node that matches the given predicate. Node must be already loaded in the tree.\n * If the node is not visible (because its parent is collapsed), all parents will be expanded to make it visible and node will be scrolled into view.\n *\n * Returns \"node-not-found\" if no node matches the predicate, \"success\" if rename was initiated.\n */\n renameNode: (nodePredicate: (node: TreeNode) => boolean) => \"node-not-found\" | \"success\";\n}\n\n/** @alpha */\ntype StrataKitTreeRendererProps = TreeRendererProps & Pick<TreeErrorRendererProps, \"filterHierarchyLevel\"> & TreeRendererOwnProps;\n\n/**\n * A component that renders a tree using the `Tree` component from `@stratakit/structures`.\n *\n * @alpha\n */\nexport const StrataKitTreeRenderer: FC<PropsWithoutRef<StrataKitTreeRendererProps> & RefAttributes<StrataKitTreeRendererAttributes>> = forwardRef<\n StrataKitTreeRendererAttributes,\n StrataKitTreeRendererProps\n>(function StrataKitTreeRenderer(props, forwardedRef) {\n const {\n id,\n rootNodes,\n selectNodes,\n selectionMode,\n expandNode,\n treeLabel,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n isNodeSelected,\n errorRenderer,\n treeRootProps,\n getContextMenuActions,\n getEditingProps,\n getInlineActions,\n getMenuActions,\n getTreeItemProps,\n } = props;\n const { handleNodeSelect } = useSelectionHandler({\n rootNodes,\n selectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const flatItems = useFlatTreeItems(rootNodes);\n const errorNodes = useErrorNodes(rootNodes);\n\n const parentRef = useRef<HTMLDivElement>(null);\n\n // eslint-disable-next-line react-hooks/incompatible-library\n const virtualizer = useVirtualizer({\n count: flatItems.length,\n getScrollElement: () => parentRef.current,\n getItemKey: useCallback((index: number) => flatItems[index].id, [flatItems]),\n estimateSize: () => 28,\n overscan: 10,\n });\n const items = virtualizer.getVirtualItems();\n const expandAndScrollToNode = useExpandAndScrollToNode({ rootNodes, flatItems, expandNode, virtualizer });\n\n const renameContext = useTreeNodeRenameContextValue({\n getEditingProps,\n });\n useImperativeHandle(forwardedRef, () => ({\n renameNode: (nodePredicate) =>\n expandAndScrollToNode({\n nodePredicate,\n onComplete: (targetNode) => {\n // give time to scroll node into view before starting rename\n requestAnimationFrame(() => renameContext.startRename(targetNode));\n },\n }),\n }));\n\n const cancelRename = renameContext.cancelRename;\n const isScrolling = virtualizer.isScrolling;\n useEffect(() => {\n if (isScrolling) {\n // cancel rename when scroll is initiated\n cancelRename();\n }\n }, [isScrolling, cancelRename]);\n\n const errorRendererProps: TreeErrorRendererProps = {\n treeLabel,\n errorNodes,\n scrollToNode: (node) => expandAndScrollToNode({ nodePredicate: (n) => n.id === node.id }),\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree: useCallback<TreeErrorRendererProps[\"reloadTree\"]>(({ parentNodeId }) => reloadTree({ parentNodeId, state: \"reset\" }), [reloadTree]),\n };\n\n const getSelectedNodes = useMemo(() => {\n let calculatedSelectedNodes: TreeNode[] | undefined;\n return () => {\n if (calculatedSelectedNodes === undefined) {\n calculatedSelectedNodes = flatItems\n .filter((item): item is FlatTreeNodeItem => !isPlaceholderItem(item) && isNodeSelected(item.id))\n .map((item) => item.node);\n }\n return calculatedSelectedNodes;\n };\n }, [flatItems, isNodeSelected]);\n\n return (\n <>\n {errorRenderer ? errorRenderer(errorRendererProps) : <TreeErrorRenderer {...errorRendererProps} />}\n <div id={id} style={{ height: \"100%\", width: \"100%\", overflowY: \"auto\" }} ref={parentRef}>\n <Tree.Root\n {...treeRootProps}\n style={{ height: virtualizer.getTotalSize(), minHeight: \"100%\", width: \"100%\", position: \"relative\", overflow: \"hidden\" }}\n >\n <TreeNodeRenameContextProvider value={renameContext}>\n {items.map((virtualizedItem) => {\n const item = flatItems[virtualizedItem.index];\n const selected = isNodeSelected(item.id);\n return (\n <VirtualTreeItem\n ref={virtualizer.measureElement}\n key={virtualizedItem.key}\n data-index={virtualizedItem.index}\n start={virtualizedItem.start}\n item={item}\n selected={selected}\n expandNode={expandNode}\n reloadTree={reloadTree}\n handleNodeSelect={handleNodeSelect}\n getSelectedNodes={getSelectedNodes}\n getContextMenuActions={getContextMenuActions}\n getInlineActions={getInlineActions}\n getMenuActions={getMenuActions}\n getTreeItemProps={getTreeItemProps}\n />\n );\n })}\n </TreeNodeRenameContextProvider>\n </Tree.Root>\n </div>\n </>\n );\n});\n\nfunction useExpandAndScrollToNode({\n rootNodes,\n flatItems,\n expandNode,\n virtualizer,\n}: Pick<StrataKitTreeRendererProps, \"rootNodes\" | \"expandNode\"> & {\n flatItems: ReturnType<typeof useFlatTreeItems>;\n virtualizer: Pick<ReturnType<typeof useVirtualizer>, \"scrollToIndex\">;\n}) {\n const expandToNode = (nodePredicate: (node: TreeNode) => boolean) => {\n const pathToNode = findPathToNode(rootNodes, nodePredicate);\n if (!pathToNode) {\n return undefined;\n }\n const targetNode = pathToNode.pop()!;\n const collapsedNodes = pathToNode.filter((pathNode) => !pathNode.isExpanded);\n collapsedNodes.forEach((node) => expandNode(node.id, true));\n return { targetNode, didExpand: collapsedNodes.length > 0 };\n };\n\n const scrollToNode = useRef<{ id: string; onScrollComplete?: () => void } | undefined>(undefined);\n useEffect(() => {\n if (scrollToNode.current === undefined) {\n return;\n }\n const targetNodeId = scrollToNode.current.id;\n const index = flatItems.findIndex((flatItem) => flatItem.id === targetNodeId);\n if (index === -1) {\n return;\n }\n virtualizer.scrollToIndex(index, { align: \"auto\" });\n scrollToNode.current.onScrollComplete?.();\n scrollToNode.current = undefined;\n }, [flatItems, virtualizer]);\n\n return ({ nodePredicate, onComplete }: { nodePredicate: (node: TreeNode) => boolean; onComplete?: (targetNode: TreeNode) => void }) => {\n const expandResult = expandToNode(nodePredicate);\n if (!expandResult) {\n return \"node-not-found\";\n }\n\n const { targetNode, didExpand } = expandResult;\n if (didExpand) {\n scrollToNode.current = {\n id: targetNode.id,\n onScrollComplete: onComplete ? () => onComplete(targetNode) : undefined,\n };\n } else {\n const index = flatItems.findIndex((flatItem) => flatItem.id === targetNode.id);\n virtualizer.scrollToIndex(index, { align: \"auto\" });\n onComplete?.(targetNode);\n }\n return \"success\";\n };\n}\n\nfunction findPathToNode(rootNodes: TreeNode[], nodePredicate: (node: TreeNode) => boolean): TreeNode[] | undefined {\n for (const parent of rootNodes) {\n if (nodePredicate(parent)) {\n return [parent];\n }\n if (parent.children !== true) {\n const childPath = findPathToNode(parent.children, nodePredicate);\n if (childPath) {\n return [parent, ...childPath];\n }\n }\n }\n return undefined;\n}\n\ntype VirtualTreeItemProps = Omit<HierarchyNodeItemProps, \"item\"> & {\n start: number;\n \"data-index\": number;\n item: FlatTreeItem;\n};\n\nconst VirtualTreeItem = memo(\n forwardRef<HTMLElement, VirtualTreeItemProps>(function VirtualTreeItem({ start, item, ...props }, forwardedRef) {\n const style: CSSProperties = useMemo(\n () => ({\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n transform: `translateY(${start}px)`,\n willChange: \"transform\",\n }),\n [start],\n );\n\n if (isPlaceholderItem(item)) {\n return <PlaceholderNode ref={forwardedRef} data-index={props[\"data-index\"]} style={style} aria-level={item.level} aria-posinset={1} aria-setsize={1} />;\n }\n\n return <HierarchyNodeItem {...props} ref={forwardedRef} style={style} item={item} />;\n }),\n);\n\ntype HierarchyNodeItemProps = {\n item: FlatTreeNodeItem;\n style?: CSSProperties;\n getSelectedNodes: () => TreeNode[];\n} & Pick<TreeNodeRendererProps, \"expandNode\" | \"reloadTree\" | \"selected\"> &\n Pick<TreeRendererOwnProps, \"getContextMenuActions\" | \"getInlineActions\" | \"getMenuActions\" | \"getTreeItemProps\"> &\n Pick<ReturnType<typeof useSelectionHandler>, \"handleNodeSelect\">;\n\nconst HierarchyNodeItem = memo(\n forwardRef<HTMLElement, HierarchyNodeItemProps>(function HierarchyNodeItem(\n { item, selected, getTreeItemProps, handleNodeSelect, getSelectedNodes, getMenuActions, getInlineActions, getContextMenuActions, ...rest },\n forwardedRef,\n ) {\n const nodeRef = useRef<HTMLElement>(null);\n const node = item.node;\n const treeItemProps = getTreeItemProps?.(node);\n\n const isDisabled = treeItemProps?.[\"aria-disabled\"] === true;\n const nodeActions = useMemo(\n () => ({\n menuActions: getMenuActions ? getMenuActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n inlineActions: getInlineActions ? getInlineActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n contextMenuActions: getContextMenuActions ? getContextMenuActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n }),\n [node, getMenuActions, getInlineActions, getContextMenuActions, getSelectedNodes],\n );\n\n const onClick = useEvent<Required<TreeNodeRendererProps>[\"onClick\"]>((e) => {\n if (treeItemProps?.onClick) {\n treeItemProps.onClick(e);\n }\n // ignore if this is double click\n if (isDisabled || e.detail > 1) {\n return;\n }\n handleNodeSelect({ nodeId: node.id, isSelected: selected ?? false, shiftDown: e.shiftKey, ctrlDown: e.ctrlKey });\n });\n\n const onMouseDown = useEvent<Required<TreeNodeRendererProps>[\"onMouseDown\"]>((e) => {\n if (treeItemProps?.onMouseDown) {\n treeItemProps.onMouseDown(e);\n }\n // prevent text selection on shift+click\n if (e.shiftKey) {\n e.preventDefault();\n }\n });\n\n const ref = useMergedRefs(forwardedRef, nodeRef);\n return (\n <StrataKitTreeNodeRenderer\n {...treeItemProps}\n {...rest}\n {...nodeActions}\n ref={ref}\n aria-level={item.level}\n aria-posinset={item.posInLevel}\n aria-setsize={item.levelSize}\n node={item.node}\n selected={selected}\n onClick={onClick}\n onMouseDown={onMouseDown}\n />\n );\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,MAAa2D,wBAA0H3D,WAGrI,SAAS2D,sBAAsBlB,OAAOmB,cAAc;CACpD,MAAM,EACJvB,IACAwB,WACAC,aACAvB,eACAwB,YACAzB,WACA0B,0BACAC,sBACAC,YACAC,gBACA3B,eACAI,eACAS,uBACAX,iBACAU,kBACAH,gBACAD,qBACEP;CACJ,MAAM,EAAE2B,qBAAqB3D,oBAAoB;EAC/CoD;EACAC;EACAvB,eAAeA,iBAAiB;EACjC,CAAC;CACF,MAAM8B,YAAYvD,iBAAiB+C,UAAU;CAC7C,MAAMS,aAAazD,cAAcgD,UAAU;CAE3C,MAAMU,YAAYjE,OAAuB,KAAK;CAG9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er.js","names":["forwardRef","memo","useCallback","useEffect","useImperativeHandle","useMemo","useRef","Tree","useVirtualizer","isPlaceholderItem","useErrorNodes","useFlatTreeItems","useSelectionHandler","useEvent","useMergedRefs","TreeErrorRenderer","TreeNodeRenameContextProvider","useTreeNodeRenameContextValue","PlaceholderNode","StrataKitTreeNodeRenderer","ComponentProps","CSSProperties","FC","PropsWithoutRef","ReactElement","ReactNode","RefAttributes","FlatTreeItem","FlatTreeNodeItem","TreeRendererProps","TreeNode","SelectionMode","TreeErrorRendererProps","TreeNodeEditingProps","StrataKitTreeItemProps","TreeNodeRendererProps","TreeRendererOwnProps","id","treeLabel","selectionMode","errorRenderer","props","getEditingProps","node","treeRootProps","Partial","Omit","Root","getTreeItemProps","getMenuActions","targetNode","selectedNodes","getInlineActions","getContextMenuActions","StrataKitTreeRendererAttributes","renameNode","nodePredicate","StrataKitTreeRendererProps","Pick","StrataKitTreeRenderer","forwardedRef","rootNodes","selectNodes","expandNode","getHierarchyLevelDetails","filterHierarchyLevel","reloadTree","isNodeSelected","handleNodeSelect","flatItems","errorNodes","parentRef","HTMLDivElement","virtualizer","count","length","getScrollElement","current","getItemKey","index","estimateSize","overscan","items","getVirtualItems","expandAndScrollToNode","useExpandAndScrollToNode","renameContext","onComplete","requestAnimationFrame","startRename","cancelRename","isScrolling","errorRendererProps","scrollToNode","n","parentNodeId","state","getSelectedNodes","calculatedSelectedNodes","undefined","filter","item","map","height","width","overflowY","getTotalSize","minHeight","position","overflow","virtualizedItem","selected","measureElement","key","start","t0","$","_c","t1","pathToNode","findPathToNode","pop","collapsedNodes","_temp","forEach","didExpand","expandToNode","t2","t3","targetNodeId","findIndex","flatItem","scrollToIndex","align","onScrollComplete","t4","t5","nodePredicate_0","expandResult","targetNode_0","index_0","flatItem_0","pathNode","isExpanded","parent","children","childPath","VirtualTreeItemProps","HierarchyNodeItemProps","VirtualTreeItem","HTMLElement","top","left","transform","willChange","style","level","ReturnType","HierarchyNodeItem","rest","nodeRef","treeItemProps","isDisabled","menuActions","inlineActions","contextMenuActions","nodeActions","t6","e","onClick","detail","nodeId","isSelected","shiftDown","shiftKey","ctrlDown","ctrlKey","t7","e_0","onMouseDown","preventDefault","ref","t8","levelSize","posInLevel"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeRenderer.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 { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from \"react\";\nimport { Tree } from \"@stratakit/structures\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { isPlaceholderItem, useErrorNodes, useFlatTreeItems } from \"../FlatTreeNode.js\";\nimport { useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useEvent, useMergedRefs } from \"../Utils.js\";\nimport { TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\nimport { TreeNodeRenameContextProvider, useTreeNodeRenameContextValue } from \"./TreeNodeRenameAction.js\";\nimport { PlaceholderNode, StrataKitTreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\nimport type { ComponentProps, CSSProperties, FC, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from \"react\";\nimport type { FlatTreeItem, FlatTreeNodeItem } from \"../FlatTreeNode.js\";\nimport type { TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { SelectionMode } from \"../UseSelectionHandler.js\";\nimport type { TreeErrorRendererProps } from \"./TreeErrorRenderer.js\";\nimport type { TreeNodeEditingProps } from \"./TreeNodeRenameAction.js\";\nimport type { StrataKitTreeItemProps, TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\n\n/** @alpha */\ninterface TreeRendererOwnProps {\n id?: string;\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for accessibility purposes.\n */\n treeLabel: string;\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n /** A render function for errors' display component. Defaults to `<TreeErrorRenderer />`. */\n errorRenderer?: (props: TreeErrorRendererProps) => ReactElement;\n /** Props that defines if current node supports editing. */\n getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;\n\n /** Custom props for the root Tree component. */\n treeRootProps?: Partial<Omit<ComponentProps<typeof Tree.Root>, \"style\">>;\n\n /** A callback that returns tree item props for specific node. */\n getTreeItemProps?: (node: TreeNode) => Partial<Omit<StrataKitTreeItemProps, \"selected\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>;\n\n /**\n * Callback that returns menu actions for tree item.\n * Must return an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n getMenuActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n /**\n * Callback that returns inline actions for tree item.\n * Must return an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n getInlineActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n /**\n * Callback that returns actions for tree item context menu.\n * Must return an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n getContextMenuActions?: (props: { targetNode: TreeNode; selectedNodes: TreeNode[] }) => ReactNode[];\n}\n\n/** @alpha */\nexport interface StrataKitTreeRendererAttributes {\n /**\n * Opens rename mode for the first node that matches the given predicate. Node must be already loaded in the tree.\n * If the node is not visible (because its parent is collapsed), all parents will be expanded to make it visible and node will be scrolled into view.\n *\n * Returns \"node-not-found\" if no node matches the predicate, \"success\" if rename was initiated.\n */\n renameNode: (nodePredicate: (node: TreeNode) => boolean) => \"node-not-found\" | \"success\";\n}\n\n/** @alpha */\ntype StrataKitTreeRendererProps = TreeRendererProps & Pick<TreeErrorRendererProps, \"filterHierarchyLevel\"> & TreeRendererOwnProps;\n\n/**\n * A component that renders a tree using the `Tree` component from `@stratakit/structures`.\n *\n * @alpha\n */\nexport const StrataKitTreeRenderer: FC<PropsWithoutRef<StrataKitTreeRendererProps> & RefAttributes<StrataKitTreeRendererAttributes>> = forwardRef<\n StrataKitTreeRendererAttributes,\n StrataKitTreeRendererProps\n>(function StrataKitTreeRenderer(props, forwardedRef) {\n const {\n id,\n rootNodes,\n selectNodes,\n selectionMode,\n expandNode,\n treeLabel,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n isNodeSelected,\n errorRenderer,\n treeRootProps,\n getContextMenuActions,\n getEditingProps,\n getInlineActions,\n getMenuActions,\n getTreeItemProps,\n } = props;\n const { handleNodeSelect } = useSelectionHandler({\n rootNodes,\n selectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const flatItems = useFlatTreeItems(rootNodes);\n const errorNodes = useErrorNodes(rootNodes);\n\n const parentRef = useRef<HTMLDivElement>(null);\n\n // eslint-disable-next-line react-hooks/incompatible-library\n const virtualizer = useVirtualizer({\n count: flatItems.length,\n getScrollElement: () => parentRef.current,\n getItemKey: useCallback((index: number) => flatItems[index].id, [flatItems]),\n estimateSize: () => 28,\n overscan: 10,\n });\n const items = virtualizer.getVirtualItems();\n const expandAndScrollToNode = useExpandAndScrollToNode({ rootNodes, flatItems, expandNode, virtualizer });\n\n const renameContext = useTreeNodeRenameContextValue({\n getEditingProps,\n });\n useImperativeHandle(forwardedRef, () => ({\n renameNode: (nodePredicate) =>\n expandAndScrollToNode({\n nodePredicate,\n onComplete: (targetNode) => {\n // give time to scroll node into view before starting rename\n requestAnimationFrame(() => renameContext.startRename(targetNode));\n },\n }),\n }));\n\n const cancelRename = renameContext.cancelRename;\n const isScrolling = virtualizer.isScrolling;\n useEffect(() => {\n if (isScrolling) {\n // cancel rename when scroll is initiated\n cancelRename();\n }\n }, [isScrolling, cancelRename]);\n\n const errorRendererProps: TreeErrorRendererProps = {\n treeLabel,\n errorNodes,\n scrollToNode: (node) => expandAndScrollToNode({ nodePredicate: (n) => n.id === node.id }),\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree: useCallback<TreeErrorRendererProps[\"reloadTree\"]>(({ parentNodeId }) => reloadTree({ parentNodeId, state: \"reset\" }), [reloadTree]),\n };\n\n const getSelectedNodes = useMemo(() => {\n let calculatedSelectedNodes: TreeNode[] | undefined;\n return () => {\n if (calculatedSelectedNodes === undefined) {\n calculatedSelectedNodes = flatItems\n .filter((item): item is FlatTreeNodeItem => !isPlaceholderItem(item) && isNodeSelected(item.id))\n .map((item) => item.node);\n }\n return calculatedSelectedNodes;\n };\n }, [flatItems, isNodeSelected]);\n\n return (\n <>\n {errorRenderer ? errorRenderer(errorRendererProps) : <TreeErrorRenderer {...errorRendererProps} />}\n <div id={id} style={{ height: \"100%\", width: \"100%\", overflowY: \"auto\" }} ref={parentRef}>\n <Tree.Root\n {...treeRootProps}\n style={{ height: virtualizer.getTotalSize(), minHeight: \"100%\", width: \"100%\", position: \"relative\", overflow: \"hidden\" }}\n >\n <TreeNodeRenameContextProvider value={renameContext}>\n {items.map((virtualizedItem) => {\n const item = flatItems[virtualizedItem.index];\n const selected = isNodeSelected(item.id);\n return (\n <VirtualTreeItem\n ref={virtualizer.measureElement}\n key={virtualizedItem.key}\n data-index={virtualizedItem.index}\n start={virtualizedItem.start}\n item={item}\n selected={selected}\n expandNode={expandNode}\n reloadTree={reloadTree}\n handleNodeSelect={handleNodeSelect}\n getSelectedNodes={getSelectedNodes}\n getContextMenuActions={getContextMenuActions}\n getInlineActions={getInlineActions}\n getMenuActions={getMenuActions}\n getTreeItemProps={getTreeItemProps}\n />\n );\n })}\n </TreeNodeRenameContextProvider>\n </Tree.Root>\n </div>\n </>\n );\n});\n\nfunction useExpandAndScrollToNode({\n rootNodes,\n flatItems,\n expandNode,\n virtualizer,\n}: Pick<StrataKitTreeRendererProps, \"rootNodes\" | \"expandNode\"> & {\n flatItems: ReturnType<typeof useFlatTreeItems>;\n virtualizer: Pick<ReturnType<typeof useVirtualizer>, \"scrollToIndex\">;\n}) {\n const expandToNode = (nodePredicate: (node: TreeNode) => boolean) => {\n const pathToNode = findPathToNode(rootNodes, nodePredicate);\n if (!pathToNode) {\n return undefined;\n }\n const targetNode = pathToNode.pop()!;\n const collapsedNodes = pathToNode.filter((pathNode) => !pathNode.isExpanded);\n collapsedNodes.forEach((node) => expandNode(node.id, true));\n return { targetNode, didExpand: collapsedNodes.length > 0 };\n };\n\n const scrollToNode = useRef<{ id: string; onScrollComplete?: () => void } | undefined>(undefined);\n useEffect(() => {\n if (scrollToNode.current === undefined) {\n return;\n }\n const targetNodeId = scrollToNode.current.id;\n const index = flatItems.findIndex((flatItem) => flatItem.id === targetNodeId);\n if (index === -1) {\n return;\n }\n virtualizer.scrollToIndex(index, { align: \"auto\" });\n scrollToNode.current.onScrollComplete?.();\n scrollToNode.current = undefined;\n }, [flatItems, virtualizer]);\n\n return ({ nodePredicate, onComplete }: { nodePredicate: (node: TreeNode) => boolean; onComplete?: (targetNode: TreeNode) => void }) => {\n const expandResult = expandToNode(nodePredicate);\n if (!expandResult) {\n return \"node-not-found\";\n }\n\n const { targetNode, didExpand } = expandResult;\n if (didExpand) {\n scrollToNode.current = {\n id: targetNode.id,\n onScrollComplete: onComplete ? () => onComplete(targetNode) : undefined,\n };\n } else {\n const index = flatItems.findIndex((flatItem) => flatItem.id === targetNode.id);\n virtualizer.scrollToIndex(index, { align: \"auto\" });\n onComplete?.(targetNode);\n }\n return \"success\";\n };\n}\n\nfunction findPathToNode(rootNodes: TreeNode[], nodePredicate: (node: TreeNode) => boolean): TreeNode[] | undefined {\n for (const parent of rootNodes) {\n if (nodePredicate(parent)) {\n return [parent];\n }\n if (parent.children !== true) {\n const childPath = findPathToNode(parent.children, nodePredicate);\n if (childPath) {\n return [parent, ...childPath];\n }\n }\n }\n return undefined;\n}\n\ntype VirtualTreeItemProps = Omit<HierarchyNodeItemProps, \"item\"> & {\n start: number;\n \"data-index\": number;\n item: FlatTreeItem;\n};\n\nconst VirtualTreeItem = memo(\n forwardRef<HTMLElement, VirtualTreeItemProps>(function VirtualTreeItem({ start, item, ...props }, forwardedRef) {\n const style: CSSProperties = useMemo(\n () => ({\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n transform: `translateY(${start}px)`,\n willChange: \"transform\",\n }),\n [start],\n );\n\n if (isPlaceholderItem(item)) {\n return <PlaceholderNode ref={forwardedRef} data-index={props[\"data-index\"]} style={style} aria-level={item.level} aria-posinset={1} aria-setsize={1} />;\n }\n\n return <HierarchyNodeItem {...props} ref={forwardedRef} style={style} item={item} />;\n }),\n);\n\ntype HierarchyNodeItemProps = {\n item: FlatTreeNodeItem;\n style?: CSSProperties;\n getSelectedNodes: () => TreeNode[];\n} & Pick<TreeNodeRendererProps, \"expandNode\" | \"reloadTree\" | \"selected\"> &\n Pick<TreeRendererOwnProps, \"getContextMenuActions\" | \"getInlineActions\" | \"getMenuActions\" | \"getTreeItemProps\"> &\n Pick<ReturnType<typeof useSelectionHandler>, \"handleNodeSelect\">;\n\nconst HierarchyNodeItem = memo(\n forwardRef<HTMLElement, HierarchyNodeItemProps>(function HierarchyNodeItem(\n { item, selected, getTreeItemProps, handleNodeSelect, getSelectedNodes, getMenuActions, getInlineActions, getContextMenuActions, ...rest },\n forwardedRef,\n ) {\n const nodeRef = useRef<HTMLElement>(null);\n const node = item.node;\n const treeItemProps = getTreeItemProps?.(node);\n\n const isDisabled = treeItemProps?.[\"aria-disabled\"] === true;\n const nodeActions = useMemo(\n () => ({\n menuActions: getMenuActions ? getMenuActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n inlineActions: getInlineActions ? getInlineActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n contextMenuActions: getContextMenuActions ? getContextMenuActions({ targetNode: node, selectedNodes: getSelectedNodes() }) : undefined,\n }),\n [node, getMenuActions, getInlineActions, getContextMenuActions, getSelectedNodes],\n );\n\n const onClick = useEvent<Required<TreeNodeRendererProps>[\"onClick\"]>((e) => {\n if (treeItemProps?.onClick) {\n treeItemProps.onClick(e);\n }\n // ignore if this is double click\n if (isDisabled || e.detail > 1) {\n return;\n }\n handleNodeSelect({ nodeId: node.id, isSelected: selected ?? false, shiftDown: e.shiftKey, ctrlDown: e.ctrlKey });\n });\n\n const onMouseDown = useEvent<Required<TreeNodeRendererProps>[\"onMouseDown\"]>((e) => {\n if (treeItemProps?.onMouseDown) {\n treeItemProps.onMouseDown(e);\n }\n // prevent text selection on shift+click\n if (e.shiftKey) {\n e.preventDefault();\n }\n });\n\n const ref = useMergedRefs(forwardedRef, nodeRef);\n return (\n <StrataKitTreeNodeRenderer\n {...treeItemProps}\n {...rest}\n {...nodeActions}\n ref={ref}\n aria-level={item.level}\n aria-posinset={item.posInLevel}\n aria-setsize={item.levelSize}\n node={item.node}\n selected={selected}\n onClick={onClick}\n onMouseDown={onMouseDown}\n />\n );\n }),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,MAAa2D,wBAA0H3D,WAGrI,SAAS2D,sBAAsBlB,OAAOmB,cAAc;CACpD,MAAM,EACJvB,IACAwB,WACAC,aACAvB,eACAwB,YACAzB,WACA0B,0BACAC,sBACAC,YACAC,gBACA3B,eACAI,eACAS,uBACAX,iBACAU,kBACAH,gBACAD,qBACEP;CACJ,MAAM,EAAE2B,qBAAqBxD,oBAAoB;EAC/CiD;EACAC;EACAvB,eAAeA,iBAAiB;EACjC,CAAC;CACF,MAAM8B,YAAY1D,iBAAiBkD,UAAU;CAC7C,MAAMS,aAAa5D,cAAcmD,UAAU;CAE3C,MAAMU,YAAYjE,OAAuB,KAAK;CAG9C,MAAMmE,cAAcjE,eAAe;EACjCkE,OAAOL,UAAUM;EACjBC,wBAAwBL,UAAUM;EAClCC,YAAY5E,aAAa6E,UAAkBV,UAAUU,OAAO1C,IAAI,CAACgC,UAAU,CAAC;EAC5EW,oBAAoB;EACpBC,UAAU;EACX,CAAC;CACF,MAAMC,QAAQT,YAAYU,iBAAiB;CAC3C,MAAMC,wBAAwBC,yBAAyB;EAAExB;EAAWQ;EAAWN;EAAYU;EAAa,CAAC;CAEzG,MAAMa,gBAA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EF,MAAAI,MAAYvK,cAAc8C,cAAcoG,QAAQ;CAAC,IAAAsB;AAAA,KAAAlE,EAAA,QAAAf,KAAAuD,SAAAxC,EAAA,QAAAf,KAAAkF,aAAAnE,EAAA,QAAAf,KAAA1D,QAAAyE,EAAA,QAAAf,KAAAmF,cAAApE,EAAA,QAAAkD,eAAAlD,EAAA,QAAAqD,WAAArD,EAAA,QAAA+D,eAAA/D,EAAA,QAAAiE,OAAAjE,EAAA,QAAA2C,QAAA3C,EAAA,QAAAL,YAAAK,EAAA,QAAA6C,eAAA;AAE/CqB,OAAA,oBAAC,2BAAD;GAA0B,GACpBrB;GAAa,GACbF;GAAI,GACJO;GACCe;GACO,cAAAhF,KAAIuD;GACD,iBAAAvD,KAAImF;GACL,gBAAAnF,KAAIkF;GACZ,MAAAlF,KAAI1D;GACAoE;GACD0D;GACIU;GACb,CAAA;AAAA/D,IAAA,MAAAf,KAAAuD;AAAAxC,IAAA,MAAAf,KAAAkF;AAAAnE,IAAA,MAAAf,KAAA1D;AAAAyE,IAAA,MAAAf,KAAAmF;AAAApE,IAAA,MAAAkD;AAAAlD,IAAA,MAAAqD;AAAArD,IAAA,MAAA+D;AAAA/D,IAAA,MAAAiE;AAAAjE,IAAA,MAAA2C;AAAA3C,IAAA,MAAAL;AAAAK,IAAA,MAAA6C;AAAA7C,IAAA,MAAAkE;OAAAA,MAAAlE,EAAA;AAAA,QAZFkE;EAeN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ErrorInfo, GenericErrorInfo, ResultSetTooLargeErrorInfo, TreeNode } from "./presentation-hierarchies-react/TreeNode.js";
|
|
2
|
+
import { HierarchyLevelDetails, TreeRendererProps } from "./presentation-hierarchies-react/Renderers.js";
|
|
3
|
+
import { useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
|
|
4
|
+
import { useNodeHighlighting } from "./presentation-hierarchies-react/UseNodeHighlighting.js";
|
|
5
|
+
import { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
|
|
6
|
+
import { LOCALIZATION_NAMESPACES } from "./presentation-hierarchies-react/internal/LocalizedStrings.js";
|
|
7
|
+
import { FlatTreeItem, useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/FlatTreeNode.js";
|
|
8
|
+
import { LocalizationContextProvider } from "./presentation-hierarchies-react/LocalizationContext.js";
|
|
9
|
+
import { GenericInstanceFilter, HierarchyNode, HierarchyProvider, SelectionStorage, getLogger, setLogger } from "./presentation-hierarchies-react.js";
|
|
10
|
+
import { TreeActionBase, TreeActionBaseAttributes } from "./presentation-hierarchies-react/stratakit/TreeAction.js";
|
|
11
|
+
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
12
|
+
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
13
|
+
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
14
|
+
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
15
|
+
import { StrataKitTreeRenderer, StrataKitTreeRendererAttributes } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
16
|
+
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
17
|
+
export { ErrorInfo, ErrorItemRenderer, FlatTreeItem, GenericErrorInfo, GenericInstanceFilter, HierarchyLevelDetails, HierarchyNode, HierarchyProvider, LOCALIZATION_NAMESPACES, LocalizationContextProvider, ResultSetTooLargeErrorInfo, SelectionStorage, StrataKitRootErrorRenderer, StrataKitTreeRenderer, StrataKitTreeRendererAttributes, TreeActionBase, TreeActionBaseAttributes, TreeErrorRenderer, TreeNode, TreeNodeFilterAction, TreeNodeRenameAction, TreeRendererProps, getLogger, setLogger, useErrorNodes, useFlatTreeItems, useIModelTree, useIModelUnifiedSelectionTree, useNodeHighlighting, useTree, useUnifiedSelectionTree };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
|
|
2
|
+
import { useNodeHighlighting } from "./presentation-hierarchies-react/UseNodeHighlighting.js";
|
|
3
|
+
import { LOCALIZATION_NAMESPACES } from "./presentation-hierarchies-react/internal/LocalizedStrings.js";
|
|
4
|
+
import { LocalizationContextProvider } from "./presentation-hierarchies-react/LocalizationContext.js";
|
|
5
|
+
import { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
|
|
6
|
+
import { useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/FlatTreeNode.js";
|
|
7
|
+
import { GenericInstanceFilter, HierarchyNode, getLogger, setLogger } from "./presentation-hierarchies-react.js";
|
|
8
|
+
import { TreeActionBase } from "./presentation-hierarchies-react/stratakit/TreeAction.js";
|
|
9
|
+
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
10
|
+
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
11
|
+
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
12
|
+
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
13
|
+
import { StrataKitTreeRenderer } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
14
|
+
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
15
|
+
import "./presentation-hierarchies-react-stratakit.js";
|
|
16
|
+
export { ErrorItemRenderer, GenericInstanceFilter, HierarchyNode, LOCALIZATION_NAMESPACES, LocalizationContextProvider, StrataKitRootErrorRenderer, StrataKitTreeRenderer, TreeActionBase, TreeErrorRenderer, TreeNodeFilterAction, TreeNodeRenameAction, getLogger, setLogger, useErrorNodes, useFlatTreeItems, useIModelTree, useIModelUnifiedSelectionTree, useNodeHighlighting, useTree, useUnifiedSelectionTree };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeActionBase, TreeActionBaseAttributes } from "./presentation-hierarchies-react/stratakit/TreeAction.js";
|
|
2
|
+
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
3
|
+
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
4
|
+
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
5
|
+
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
6
|
+
import { StrataKitTreeRenderer, StrataKitTreeRendererAttributes } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
7
|
+
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
8
|
+
export { ErrorItemRenderer, StrataKitRootErrorRenderer, StrataKitTreeRenderer, type StrataKitTreeRendererAttributes, TreeActionBase, type TreeActionBaseAttributes, TreeErrorRenderer, TreeNodeFilterAction, TreeNodeRenameAction };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeActionBase } from "./presentation-hierarchies-react/stratakit/TreeAction.js";
|
|
2
|
+
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
3
|
+
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
4
|
+
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
5
|
+
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
6
|
+
import { StrataKitTreeRenderer } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
7
|
+
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
8
|
+
export { ErrorItemRenderer, StrataKitRootErrorRenderer, StrataKitTreeRenderer, TreeActionBase, TreeErrorRenderer, TreeNodeFilterAction, TreeNodeRenameAction };
|
|
@@ -3,16 +3,9 @@ import { HierarchyLevelDetails, TreeRendererProps } from "./presentation-hierarc
|
|
|
3
3
|
import { useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
|
|
4
4
|
import { useNodeHighlighting } from "./presentation-hierarchies-react/UseNodeHighlighting.js";
|
|
5
5
|
import { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
|
|
6
|
-
import { TreeActionBase, TreeActionBaseAttributes } from "./presentation-hierarchies-react/stratakit/TreeAction.js";
|
|
7
|
-
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
8
|
-
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
9
|
-
import { FlatTreeItem, useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/stratakit/FlatTreeNode.js";
|
|
10
|
-
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
11
|
-
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
12
|
-
import { StrataKitTreeRenderer, StrataKitTreeRendererAttributes } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
13
|
-
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
14
6
|
import { LOCALIZATION_NAMESPACES } from "./presentation-hierarchies-react/internal/LocalizedStrings.js";
|
|
15
|
-
import {
|
|
7
|
+
import { FlatTreeItem, useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/FlatTreeNode.js";
|
|
8
|
+
import { LocalizationContextProvider } from "./presentation-hierarchies-react/LocalizationContext.js";
|
|
16
9
|
import { GenericInstanceFilter, HierarchyNode, HierarchyProvider, getLogger, setLogger } from "@itwin/presentation-hierarchies";
|
|
17
10
|
import { SelectionStorage } from "@itwin/unified-selection";
|
|
18
|
-
export { type ErrorInfo,
|
|
11
|
+
export { type ErrorInfo, type FlatTreeItem, type GenericErrorInfo, GenericInstanceFilter, type HierarchyLevelDetails, HierarchyNode, type HierarchyProvider, LOCALIZATION_NAMESPACES, LocalizationContextProvider, type ResultSetTooLargeErrorInfo, type SelectionStorage, type TreeNode, type TreeRendererProps, getLogger, setLogger, useErrorNodes, useFlatTreeItems, useIModelTree, useIModelUnifiedSelectionTree, useNodeHighlighting, useTree, useUnifiedSelectionTree };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree.js";
|
|
2
2
|
import { useNodeHighlighting } from "./presentation-hierarchies-react/UseNodeHighlighting.js";
|
|
3
3
|
import { LOCALIZATION_NAMESPACES } from "./presentation-hierarchies-react/internal/LocalizedStrings.js";
|
|
4
|
-
import { LocalizationContextProvider } from "./presentation-hierarchies-react/
|
|
4
|
+
import { LocalizationContextProvider } from "./presentation-hierarchies-react/LocalizationContext.js";
|
|
5
5
|
import { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree.js";
|
|
6
|
-
import {
|
|
7
|
-
import { TreeNodeFilterAction } from "./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js";
|
|
8
|
-
import { TreeNodeRenameAction } from "./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js";
|
|
9
|
-
import { useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/stratakit/FlatTreeNode.js";
|
|
10
|
-
import { ErrorItemRenderer } from "./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js";
|
|
11
|
-
import { TreeErrorRenderer } from "./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js";
|
|
12
|
-
import { StrataKitTreeRenderer } from "./presentation-hierarchies-react/stratakit/TreeRenderer.js";
|
|
13
|
-
import { StrataKitRootErrorRenderer } from "./presentation-hierarchies-react/stratakit/RootErrorRenderer.js";
|
|
6
|
+
import { useErrorNodes, useFlatTreeItems } from "./presentation-hierarchies-react/FlatTreeNode.js";
|
|
14
7
|
import { GenericInstanceFilter, HierarchyNode, getLogger, setLogger } from "@itwin/presentation-hierarchies";
|
|
15
|
-
export {
|
|
8
|
+
export { GenericInstanceFilter, HierarchyNode, LOCALIZATION_NAMESPACES, LocalizationContextProvider, getLogger, setLogger, useErrorNodes, useFlatTreeItems, useIModelTree, useIModelUnifiedSelectionTree, useNodeHighlighting, useTree, useUnifiedSelectionTree };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-hierarchies-react",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.59",
|
|
4
4
|
"description": "React components based on `@itwin/presentation-hierarchies`",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,8 +31,13 @@
|
|
|
31
31
|
"types": "lib/presentation-hierarchies-react.d.ts",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
+
"types": "./lib/presentation-hierarchies-react.d.ts",
|
|
34
35
|
"import": "./lib/presentation-hierarchies-react.js"
|
|
35
36
|
},
|
|
37
|
+
"./stratakit": {
|
|
38
|
+
"types": "./lib/presentation-hierarchies-react-stratakit.d.ts",
|
|
39
|
+
"import": "./lib/presentation-hierarchies-react-stratakit.js"
|
|
40
|
+
},
|
|
36
41
|
"./package.json": "./package.json"
|
|
37
42
|
},
|
|
38
43
|
"dependencies": {
|
|
@@ -43,9 +48,9 @@
|
|
|
43
48
|
"react-compiler-runtime": "^1.0.0",
|
|
44
49
|
"react-error-boundary": "^4.1.2",
|
|
45
50
|
"rxjs": "^7.8.2",
|
|
46
|
-
"@itwin/presentation-hierarchies": "
|
|
47
|
-
"@itwin/presentation-shared": "
|
|
48
|
-
"@itwin/unified-selection": "^1.6.
|
|
51
|
+
"@itwin/presentation-hierarchies": "2.0.0-alpha.14",
|
|
52
|
+
"@itwin/presentation-shared": "2.0.0-alpha.9",
|
|
53
|
+
"@itwin/unified-selection": "^1.6.8"
|
|
49
54
|
},
|
|
50
55
|
"peerDependencies": {
|
|
51
56
|
"@stratakit/bricks": "^0.5.4",
|
|
@@ -111,7 +116,7 @@
|
|
|
111
116
|
"tsdown": "^0.21.4",
|
|
112
117
|
"typescript": "~5.7.3",
|
|
113
118
|
"vite": "^8.0.0",
|
|
114
|
-
"presentation-test-utilities": "
|
|
119
|
+
"presentation-test-utilities": "0.0.1"
|
|
115
120
|
},
|
|
116
121
|
"scripts": {
|
|
117
122
|
"build": "tsdown && npm run -s build:locale && npm run -s copy && npm run -s build:test",
|
|
@@ -125,8 +130,8 @@
|
|
|
125
130
|
"lint": "eslint \"./src/**/*.{ts,tsx}\"",
|
|
126
131
|
"test:dev": "node --experimental-test-module-mocks --enable-source-maps --import presentation-test-utilities/node-hooks/ignore-styles ./node_modules/mocha/bin/mocha.js --config ./.mocharc.json",
|
|
127
132
|
"test": "npm run test:dev -- --parallel --jobs=4",
|
|
128
|
-
"extract-api": "betools extract-api --entry=lib/presentation-hierarchies-react --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
129
|
-
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-hierarchies-react.api.md",
|
|
133
|
+
"extract-api": "betools extract-api --entry=lib/presentation-hierarchies-react-extract --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
134
|
+
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-hierarchies-react-extract.api.md",
|
|
130
135
|
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md",
|
|
131
136
|
"check-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md --check",
|
|
132
137
|
"validate-markdowns": "node ../../scripts/validateMarkdowns.js README.md"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlatTreeNode.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"mappings":";;;;;AAO+C;;;UAOrC,mBAAA;EACR,EAAA;EACA,KAAA;EACA,WAAA;AAAA;;AAQF;;;;UAAiB,gBAAA;EACf,EAAA;EACA,KAAA;EACA,SAAA;EACA,UAAA;EACA,IAAA,EAAM,QAAA;AAAA;;AASR;;;;;KAAY,YAAA,GAAe,gBAAA,GAAmB,mBAAA;;;;;;;AA8C9C;iBAhCgB,gBAAA,CAAiB,SAAA,EAAW,QAAA,KAAU,YAAA;;;;;;iBAgCtC,aAAA,CAAc,SAAA,EAAW,QAAA,KAAa,KAAA,CAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,QAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlatTreeNode.js","names":["useMemo","TreeNode","FlatPlaceholderItem","id","level","placeholder","FlatTreeNodeItem","levelSize","posInLevel","node","FlatTreeItem","isPlaceholderItem","item","useFlatTreeItems","rootNodes","$","_c","t0","getFlatItems","nodes","flatItems","forEach","index","push","length","isExpanded","error","type","isNodeExpandable","children","childNodes","useErrorNodes","flatMap","_temp","rootNode","errors","isErrorNode","getErrorNodes","parent","errorList","ReturnType","childErrorList","Pick","Required","undefined"],"sources":["../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.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 { useMemo } from \"react\";\n\nimport type { TreeNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded) {\n return;\n }\n\n if (node.error && (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable)) {\n return;\n }\n\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n const errors = isErrorNode(rootNode) ? [rootNode] : [];\n if (rootNode.children === true) {\n return errors;\n }\n\n if (errors.length === 1 && (rootNode.error?.type !== \"Unknown\" || !rootNode.error.isNodeExpandable)) {\n return errors;\n }\n errors.push(...getErrorNodes(rootNode));\n return errors;\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n if (node.error.type !== \"Unknown\" || !node.error.isNodeExpandable) {\n return;\n }\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"],"mappings":";;;AA0CA,SAAgBW,kBAAkBC,MAAiD;AACjF,QAAO,iBAAiBA;;;;;;;;;AAU1B,SAAOC,iBAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AACgBG,OAAAC,aAAaJ,WAAW,EAAE;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAA1BE;;AAGvB,SAASC,aAAaC,OAAmBf,OAAe;CACtD,MAAMgB,YAA4B,EAAE;AACpCD,OAAME,SAASZ,MAAMa,UAAU;AAC7BF,YAAUG,KAAK;GAAEd;GAAMN,IAAIM,KAAKN;GAAIC;GAAOG,WAAWY,MAAMK;GAAQhB,YAAYc,QAAQ;GAAG,CAAC;AAC5F,MAAI,CAACb,KAAKgB,WACR;AAGF,MAAIhB,KAAKiB,UAAUjB,KAAKiB,MAAMC,SAAS,aAAa,CAAClB,KAAKiB,MAAME,kBAC9D;AAGF,MAAInB,KAAKoB,aAAa,MAAM;GAC1B,MAAMC,aAAaZ,aAAaT,KAAKoB,UAAUzB,QAAQ,EAAE;AACzDgB,aAAUG,KAAK,GAAGO,WAAW;AAC7B;;AAGFV,YAAUG,KAAK;GAAEpB,IAAI,GAAGM,KAAKN,GAAE;GAAyBC,OAAOA,QAAQ;GAAGC,aAAa;GAAM,CAA+B;GAC5H;AACF,QAAOe;;;;;;;AAQT,SAAOW,cAAAjB,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AAGDG,OAAAH,UAASkB,QAASC,MAWhB;AAAAlB,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAXFE;;AAHC,SAAAgB,MAAAC,UAAA;CAIC,MAAAC,SAAeC,YAAYF,SAA2B,GAAvC,CAAyBA,SAAc,GAAvC,EAAuC;AACtD,KAAIA,SAAQL,aAAc,KAAI,QACrBM;AAGT,KAAIA,OAAMX,WAAY,MAAMU,SAAQR,OAAYC,SAAK,aAAzB,CAAuCO,SAAQR,MAAME,kBAAkB,QAC1FO;AAETA,QAAMZ,KAAK,GAAIc,cAAcH,SAAS,CAAC;AAAA,QAChCC;;AAMf,SAASE,cAAcC,QAAkB;CACvC,MAAMC,YAA8C,EAAE;AAEtD,KAAID,OAAOT,aAAa,KACtB,QAAO,EAAE;AAGXS,QAAOT,SAASR,SAASZ,SAAS;AAChC,MAAI2B,YAAY3B,KAAK,EAAE;AACrB8B,aAAUhB,KAAKd,KAAK;AACpB,OAAIA,KAAKiB,MAAMC,SAAS,aAAa,CAAClB,KAAKiB,MAAME,iBAC/C;;AAIJ,MAAInB,KAAKoB,aAAa,MAAM;GAC1B,MAAMY,iBAAiBJ,cAAc5B,KAAK;AAC1C8B,aAAUhB,KAAK,GAAGkB,eAAe;AACjC;;GAEF;AACF,QAAOF;;AAGT,SAASH,YAAY3B,MAAsE;AACzF,QAAOA,KAAKiB,UAAUkB,KAAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationContext.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"mappings":";;;AAW0C;;;;AAAA,UAQhC,gCAAA;EAGN;EADF,YAAA;IACE,kBAAA,GAAqB,GAAA;EAAA;AAAA;;;;;iBAQT,2BAAA,CAAA;EAA8B,YAAA;EAAc;AAAA,GAAY,iBAAA,CAAkB,gCAAA,IAAoC,GAAA,CAAI,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationContext.js","names":["createContext","useContext","useMemo","LOCALIZATION_NAMESPACE","JSX","PropsWithChildren","LocalizationKey","TranslateFunc","key","localizationContext","LocalizationContextProviderProps","localization","getLocalizedString","LocalizationContextProvider","t0","$","_c","children","t1","translate","t2","useTranslation"],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.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 { createContext, useContext, useMemo } from \"react\";\nimport { LOCALIZATION_NAMESPACE } from \"../internal/LocalizedStrings.js\";\n\nimport type { JSX, PropsWithChildren } from \"react\";\nimport type { LocalizationKey } from \"../internal/LocalizedStrings.js\";\n\ntype TranslateFunc = (key: LocalizationKey) => string;\n\nconst localizationContext = createContext<TranslateFunc>((key) => key);\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localization object compatible with `@itwin/core-common` */\n localization: {\n getLocalizedString: (key: string) => string;\n };\n}\n\n/**\n * Context provider for localizing components.\n * @public\n */\nexport function LocalizationContextProvider({ localization, children }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element {\n const translate = useMemo<TranslateFunc>(() => {\n return (key: LocalizationKey) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);\n }, [localization]);\n return <localizationContext.Provider value={translate}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useTranslation() {\n return useContext(localizationContext);\n}\n"],"mappings":";;;;;AAaA,MAAMS,sBAAsBT,eAA8BQ,QAAQA,IAAI;;;;;AAiBtE,SAAOK,4BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqC,MAAA,EAAAL,cAAAM,aAAAH;CAA+E,IAAAI;AAAA,KAAAH,EAAA,OAAAJ,cAAA;AAEhHO,QAAAV,QAA0BG,aAAYC,mBAAoB,GAAGT,uBAAsB,GAAIK,MAAM;AAAAO,IAAA,KAAAJ;AAAAI,IAAA,KAAAG;OAAAA,MAAAH,EAAA;CADtG,MAAAI,YACED;CACiB,IAAAE;AAAA,KAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,WAAA;AACZC,OAAA,oBAAA,oBAAA,UAAA;GAAqCD,OAAAA;GAAYF;GAAwC,CAAA;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;AAAA,QAAzFK;;;AAIT,SAAOC,iBAAA;AAAA,QACEpB,WAAWQ,oBAAoB"}
|