@itwin/presentation-hierarchies-react 2.0.0-alpha.47 → 2.0.0-alpha.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +2 -40
  3. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +4 -1
  4. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +1 -1
  5. package/lib/esm/presentation-hierarchies-react/Utils.js +16 -0
  6. package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -1
  7. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +2 -0
  8. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
  9. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +15 -0
  10. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
  11. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +10 -0
  12. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
  13. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +2 -0
  14. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
  15. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
  16. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +6 -1
  17. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
  18. package/lib/esm/presentation-hierarchies-react/stratakit/{FilterAction.d.ts → TreeNodeFilterAction.d.ts} +8 -7
  19. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
  20. package/lib/esm/presentation-hierarchies-react/stratakit/{FilterAction.js → TreeNodeFilterAction.js} +8 -2
  21. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
  22. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +57 -0
  23. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
  24. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +71 -0
  25. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
  26. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
  27. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +24 -34
  28. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  29. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +69 -87
  30. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  31. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +21 -16
  32. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  33. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +91 -32
  34. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react.d.ts +3 -4
  36. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react.js +2 -3
  38. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  39. package/package.json +9 -9
  40. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +0 -1
  41. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +0 -1
  42. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts +0 -21
  43. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts.map +0 -1
  44. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js +0 -36
  45. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # @itwin/presentation-hierarchies-react
2
2
 
3
+ ## 2.0.0-alpha.49
4
+
5
+ ### Major Changes
6
+
7
+ - [#1166](https://github.com/iTwin/presentation/pull/1166): Added ability to enter node rename mode programmatically through `StrataKitTreeRenderer` ref. The `renameNode` method accepts a predicate function to identify the target node. If the node is not visible (because its parent is collapsed), all parents will be expanded automatically to make it visible and the node will be scrolled into view.
8
+
9
+ Example:
10
+
11
+ ```tsx
12
+ import { StrataKitTreeRenderer, StrataKitTreeRendererAttributes } from "@itwin/presentation-hierarchies-react";
13
+
14
+ function MyTree() {
15
+ const treeRef = useRef<StrataKitTreeRendererAttributes>(null);
16
+
17
+ return (
18
+ <>
19
+ <div className="tree-header">
20
+ <button
21
+ onClick={() => {
22
+ treeRef.current?.renameNode((node) => node.label === "Node to rename");
23
+ }}
24
+ >
25
+ Rename node
26
+ </button>
27
+ </div>
28
+ <StrataKitTreeRenderer ref={treeRef} />
29
+ </>
30
+ );
31
+ }
32
+ ```
33
+
34
+ **Breaking changes**
35
+ - `StrataKitTreeNodeRenderer` is no longer exported.
36
+ - `RenameContextProvider` is no longer exported. It is not necessary when using `StrataKitTreeRenderer`.
37
+ - `RenameAction` now requires a `node` prop.
38
+
39
+ - [#1179](https://github.com/iTwin/presentation/pull/1179): **Breaking change:** Rename tree node action components for clarity.
40
+ - `FilterAction` -> `TreeNodeFilterAction`
41
+ - `RenameAction` -> `TreeNodeRenameAction`
42
+
43
+ - [#1178](https://github.com/iTwin/presentation/pull/1178): Updated tree node rename UI to show input in popover instead of inline. Additionally added ability to show hint for supported characters and validate new label.
44
+
45
+ Example:
46
+
47
+ ```tsx
48
+ type TreeRendererProps = ComponentProps<typeof StrataKitTreeRenderer>;
49
+
50
+ const getEditingProps = useCallback<Required<TreeRendererProps>["getEditingProps"]>((node) => {
51
+ return {
52
+ onLabelChanged: (newLabel: string) => {
53
+ // Handle label change
54
+ },
55
+ labelValidationHint: `Allowed are A to Z, 0 to 9, "-" and "_"`,
56
+ validate: (newLabel: string) => /^[A-Za-z0-9\- ]+$/.test(newLabel),
57
+ };
58
+ }, []);
59
+
60
+ return <StrataKitTreeRenderer {...treeProps} getEditingProps={getEditingProps} />;
61
+ ```
62
+
63
+ **Breaking changes**
64
+ - `getEditingProps` callback was changed to require `onLabelChanged`. If node does not support renaming `getEditingProps` should return `undefined`.
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies:
69
+ - @itwin/presentation-hierarchies@2.0.0-alpha.10
70
+ - @itwin/presentation-shared@2.0.0-alpha.6
71
+ - @itwin/unified-selection@1.6.6-alpha.0
72
+
73
+ ## 2.0.0-alpha.48
74
+
75
+ ### Minor Changes
76
+
77
+ - [#1159](https://github.com/iTwin/presentation/pull/1159): Introduced `getTreeItemProps` and `treeRootProps` to `StrataKitTreeRenderer`. This allows passing props to underlying `Tree.Item` and `Tree.Root` components.
78
+
79
+ **Breaking changes**
80
+
81
+ `StrataKitTreeNodeRenderer` props changes:
82
+ - `getMenuActions` callback changed to `menuActions` prop (type: `ReactNode[]`)
83
+ - `getInlineActions` callback changed to `inlineActions` prop (type: `ReactNode[]`)
84
+ - `getContextMenuActions` callback changed to `contextMenuActions` prop (type: `ReactNode[]`)
85
+ - `getLabel` callback removed - use `label` prop instead
86
+ - `getSublabel` callback removed - use `description` prop instead
87
+ - `getDecorations` callback removed - use `decorations` prop instead
88
+ - `getClassName` callback removed - use `className` prop instead
89
+ - `onNodeClick` and `onNodeKeyDown` callbacks removed - use `onClick` and `onKeyDown` props instead
90
+
91
+ `StrataKitTreeRenderer` props changes:
92
+ - Props previously passed to `StrataKitTreeNodeRenderer` are no longer accepted
93
+ - Use `getTreeItemProps` callback to provide props to specific `Tree.Item` components
94
+ - Use `getMenuActions`, `getInlineActions`, and `getContextMenuActions` on `StrataKitTreeRenderer` to provide actions for nodes
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies:
99
+ - @itwin/presentation-hierarchies@2.0.0-alpha.9
100
+
3
101
  ## 2.0.0-alpha.47
4
102
 
5
103
  ### Patch Changes
@@ -626,6 +724,34 @@
626
724
 
627
725
  - [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
628
726
 
727
+ ## 1.9.10
728
+
729
+ ### Patch Changes
730
+
731
+ - [#1168](https://github.com/iTwin/presentation/pull/1168): Bump dependencies.
732
+ - [#1167](https://github.com/iTwin/presentation/pull/1167): Fix a greedy regular expression in `TreeNodeRenderer` that renders a "result set too large" error node.
733
+ - [#1161](https://github.com/iTwin/presentation/pull/1161): Bump iTwin.js dependencies to `^5.5.0`.
734
+ - Updated dependencies:
735
+ - @itwin/presentation-hierarchies@1.7.8
736
+ - @itwin/presentation-shared@1.2.7
737
+ - @itwin/unified-selection@1.6.5
738
+
739
+ ## 1.9.9
740
+
741
+ ### Patch Changes
742
+
743
+ - [#1160](https://github.com/iTwin/presentation/pull/1160): Fixed tree placeholder node spinner size to match tree node icons.
744
+
745
+ ## 1.9.8
746
+
747
+ ### Patch Changes
748
+
749
+ - [#1152](https://github.com/iTwin/presentation/pull/1152): Bump dependencies.
750
+ - Updated dependencies:
751
+ - @itwin/presentation-hierarchies@1.7.7
752
+ - @itwin/presentation-shared@1.2.6
753
+ - @itwin/unified-selection@1.6.4
754
+
629
755
  ## 1.9.7
630
756
 
631
757
  ### Patch Changes
package/README.md CHANGED
@@ -59,31 +59,12 @@ The hook takes 2 required properties:
59
59
 
60
60
  ```tsx
61
61
  import { IModelConnection } from "@itwin/core-frontend";
62
- import { SchemaContext } from "@itwin/ecschema-metadata";
63
- import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
64
62
  import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
65
63
  import { createECSchemaProvider, createECSqlQueryExecutor, createIModelKey } from "@itwin/presentation-core-interop";
66
64
  import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, HierarchyDefinition } from "@itwin/presentation-hierarchies";
67
65
 
68
- // Not really part of the package, but we need SchemaContext to create the tree state. It's
69
- // recommended to cache the schema context and reuse it across different application's components to
70
- // avoid loading and storing same schemas multiple times.
71
- const imodelSchemaContextsCache = new Map<string, SchemaContext>();
72
-
73
- function getIModelSchemaContext(imodel: IModelConnection) {
74
- const imodelKey = createIModelKey(imodel);
75
- let context = imodelSchemaContextsCache.get(imodelKey);
76
- if (!context) {
77
- context = new SchemaContext();
78
- context.addLocater(new ECSchemaRpcLocater(imodel.getRpcProps()));
79
- imodelSchemaContextsCache.set(imodelKey, context);
80
- imodel.onClose.addListener(() => imodelSchemaContextsCache.delete(imodelKey));
81
- }
82
- return context;
83
- }
84
-
85
66
  function createIModelAccess(imodel: IModelConnection) {
86
- const schemaProvider = createECSchemaProvider(getIModelSchemaContext(imodel));
67
+ const schemaProvider = createECSchemaProvider(imodel.schemaContext);
87
68
  return {
88
69
  imodelKey: createIModelKey(imodel),
89
70
  ...schemaProvider,
@@ -143,8 +124,6 @@ The component is based on `Tree.Item` component from StrataKit library and suppo
143
124
 
144
125
  ```tsx
145
126
  import { IModelConnection } from "@itwin/core-frontend";
146
- import { SchemaContext } from "@itwin/ecschema-metadata";
147
- import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
148
127
  import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
149
128
  import { createECSchemaProvider, createECSqlQueryExecutor, createIModelKey } from "@itwin/presentation-core-interop";
150
129
  import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, HierarchyDefinition } from "@itwin/presentation-hierarchies";
@@ -155,25 +134,8 @@ import { TreeRenderer, useIModelUnifiedSelectionTree } from "@itwin/presentation
155
134
  import { createStorage, SelectionStorage } from "@itwin/unified-selection";
156
135
  import { useEffect, useState } from "react";
157
136
 
158
- // Not really part of the package, but we need SchemaContext to create the tree state. It's
159
- // recommended to cache the schema context and reuse it across different application's components to
160
- // avoid loading and storing same schemas multiple times.
161
- const imodelSchemaContextsCache = new Map<string, SchemaContext>();
162
-
163
- function getIModelSchemaContext(imodel: IModelConnection) {
164
- const imodelKey = createIModelKey(imodel);
165
- let context = imodelSchemaContextsCache.get(imodelKey);
166
- if (!context) {
167
- context = new SchemaContext();
168
- context.addLocater(new ECSchemaRpcLocater(imodel.getRpcProps()));
169
- imodelSchemaContextsCache.set(imodelKey, context);
170
- imodel.onClose.addListener(() => imodelSchemaContextsCache.delete(imodelKey));
171
- }
172
- return context;
173
- }
174
-
175
137
  function createIModelAccess(imodel: IModelConnection) {
176
- const schemaProvider = createECSchemaProvider(getIModelSchemaContext(imodel));
138
+ const schemaProvider = createECSchemaProvider(imodel.schemaContext);
177
139
  return {
178
140
  imodelKey: createIModelKey(imodel),
179
141
  ...schemaProvider,
@@ -1,5 +1,8 @@
1
+ import { LegacyRef, MutableRefObject, Ref } from "react";
1
2
  /** @internal */
2
- export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
3
+ export declare function useLatest<T>(value: T): MutableRefObject<T>;
3
4
  /** @internal */
4
5
  export declare function useEvent<TCallback extends (...args: any[]) => void>(callback: TCallback): (...args: Parameters<TCallback>) => void;
6
+ /** @internal */
7
+ export declare function useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>): (instance: T | null) => void;
5
8
  //# sourceMappingURL=Utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Utils.ts"],"names":[],"mappings":"AAOA,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,uCAQpC;AAGD,gBAAgB;AAChB,wBAAgB,QAAQ,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ,EAAE,SAAS,aAI1E,UAAU,CAAC,SAAS,CAAC,UAKlC"}
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,EAA2C,MAAM,OAAO,CAAC;AAElG,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,uBAQpC;AAGD,gBAAgB;AAChB,wBAAgB,QAAQ,CAAC,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ,EAAE,SAAS,aAI1E,UAAU,CAAC,SAAS,CAAC,UAKlC;AAID,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,cAElF,CAAC,GAAG,IAAI,UAWtB"}
@@ -20,4 +20,20 @@ export function useEvent(callback) {
20
20
  }, [latestCallback]);
21
21
  }
22
22
  /* c8 ignore end */
23
+ /* c8 ignore start */
24
+ /** @internal */
25
+ export function useMergedRefs(...refs) {
26
+ return useCallback((instance) => {
27
+ refs.forEach((ref) => {
28
+ if (typeof ref === "function") {
29
+ ref(instance);
30
+ }
31
+ else if (ref) {
32
+ ref.current = instance;
33
+ }
34
+ });
35
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ [...refs]);
37
+ }
38
+ /* c8 ignore end */
23
39
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEhE,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,kBAAkB,CAAC,GAAG,EAAE;QACtB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qBAAqB;AACrB,gBAAgB;AAChB,MAAM,UAAU,QAAQ,CAA6C,QAAmB;IACtF,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,WAAW,CAChB,CAAC,GAAG,IAA2B,EAAE,EAAE;QACjC,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;AACJ,CAAC;AACD,mBAAmB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useInsertionEffect, useRef } from \"react\";\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n\n useInsertionEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\n/* c8 ignore start */\n/** @internal */\nexport function useEvent<TCallback extends (...args: any[]) => void>(callback: TCallback) {\n const latestCallback = useLatest(callback);\n\n return useCallback(\n (...args: Parameters<TCallback>) => {\n latestCallback.current(...args);\n },\n [latestCallback],\n );\n}\n/* c8 ignore end */\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAoC,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAElG,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,kBAAkB,CAAC,GAAG,EAAE;QACtB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qBAAqB;AACrB,gBAAgB;AAChB,MAAM,UAAU,QAAQ,CAA6C,QAAmB;IACtF,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE3C,OAAO,WAAW,CAChB,CAAC,GAAG,IAA2B,EAAE,EAAE;QACjC,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;AACJ,CAAC;AACD,mBAAmB;AAEnB,qBAAqB;AACrB,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAI,GAAG,IAA6D;IAC/F,OAAO,WAAW,CAChB,CAAC,QAAkB,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACd,GAAkC,CAAC,OAAO,GAAG,QAAQ,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,uDAAuD;IAC1D,CAAC,GAAG,IAAI,CAAC,CACV,CAAC;AACJ,CAAC;AACD,mBAAmB","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 { LegacyRef, MutableRefObject, Ref, useCallback, useInsertionEffect, useRef } from \"react\";\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n\n useInsertionEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref;\n}\n\n/* c8 ignore start */\n/** @internal */\nexport function useEvent<TCallback extends (...args: any[]) => void>(callback: TCallback) {\n const latestCallback = useLatest(callback);\n\n return useCallback(\n (...args: Parameters<TCallback>) => {\n latestCallback.current(...args);\n },\n [latestCallback],\n );\n}\n/* c8 ignore end */\n\n/* c8 ignore start */\n/** @internal */\nexport function useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n/* c8 ignore end */\n"]}
@@ -54,5 +54,7 @@ export declare function useFlatTreeItems(rootNodes: PresentationHierarchyNode[])
54
54
  * @alpha
55
55
  */
56
56
  export declare function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[];
57
+ /** @internal */
58
+ export declare function findPathToNode(rootNodes: PresentationHierarchyNode[], predicate: (node: PresentationHierarchyNode) => boolean): PresentationHierarchyNode[] | undefined;
57
59
  export {};
58
60
  //# sourceMappingURL=FlatTreeNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;KAIK;AACL,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED;;;;;KAKK;AACL,MAAM,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KAAK,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,mBAAmB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,yBAAyB,EAAE,kBAEtE;AAoBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,yBAAyB,EAAE,GAAG,SAAS,EAAE,CAchF;AAED,gBAAgB;AAChB,wBAAgB,cAAc,CAC5B,SAAS,EAAE,yBAAyB,EAAE,EACtC,SAAS,EAAE,CAAC,IAAI,EAAE,yBAAyB,KAAK,OAAO,GACtD,yBAAyB,EAAE,GAAG,SAAS,CAazC"}
@@ -49,6 +49,21 @@ export function useErrorList(rootNodes) {
49
49
  return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);
50
50
  }), [rootNodes]);
51
51
  }
52
+ /** @internal */
53
+ export function findPathToNode(rootNodes, predicate) {
54
+ for (const parent of rootNodes) {
55
+ if (predicate(parent)) {
56
+ return [parent];
57
+ }
58
+ if (parent.children && parent.children !== true) {
59
+ const childPath = findPathToNode(parent.children, predicate);
60
+ if (childPath) {
61
+ return [parent, ...childPath];
62
+ }
63
+ }
64
+ }
65
+ return undefined;
66
+ }
52
67
  function getErrorItems(parent, path) {
53
68
  const errorList = [];
54
69
  if (parent.children === true) {
@@ -1 +1 @@
1
- {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA8ChC,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,IAAkB;IAClD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAA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AW,CAAC,CAAC;YACxD,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,UAAoC,EAAE,IAAc;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { PresentationHierarchyNode } 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 `PresentationHierarchyNode` 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: PresentationHierarchyNode;\n}\n\n/**\n * An item used to build an error message.\n * Returned by `useErrorList`.\n *\n * @alpha\n * */\nexport interface ErrorItem {\n errorNode: PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\">;\n expandTo: (expandNode: (nodeId: string) => void) => void;\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 `PresentationHierarchyNode` 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: PresentationHierarchyNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: PresentationHierarchyNode[], 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 || node.error) {\n return;\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 items containing errors in a given hierarchy in the form of `ErrorItem[]`.\n *\n * @alpha\n */\nexport function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[] {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorItems(parent: PresentationHierarchyNode, path: string[]) {\n const errorList: ErrorItem[] = [];\n\n if (parent.children === true) {\n return [];\n }\n\n const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorItems(node, pathToChild);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction expandTo(expandNode: (nodeId: string) => void, path: string[]) {\n path.forEach((nodeId) => expandNode(nodeId));\n}\n\nfunction isErrorNode(node: PresentationHierarchyNode): node is PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
1
+ {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA8ChC,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,IAAkB;IAClD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAsC;IACrE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,KAAkC,EAAE,KAAa;IACrE,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC1D,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,S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AAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { PresentationHierarchyNode } 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 `PresentationHierarchyNode` 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: PresentationHierarchyNode;\n}\n\n/**\n * An item used to build an error message.\n * Returned by `useErrorList`.\n *\n * @alpha\n * */\nexport interface ErrorItem {\n errorNode: PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\">;\n expandTo: (expandNode: (nodeId: string) => void) => void;\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 `PresentationHierarchyNode` 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: PresentationHierarchyNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: PresentationHierarchyNode[], 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 || node.error) {\n return;\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 items containing errors in a given hierarchy in the form of `ErrorItem[]`.\n *\n * @alpha\n */\nexport function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[] {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);\n }),\n [rootNodes],\n );\n}\n\n/** @internal */\nexport function findPathToNode(\n rootNodes: PresentationHierarchyNode[],\n predicate: (node: PresentationHierarchyNode) => boolean,\n): PresentationHierarchyNode[] | undefined {\n for (const parent of rootNodes) {\n if (predicate(parent)) {\n return [parent];\n }\n if (parent.children && parent.children !== true) {\n const childPath = findPathToNode(parent.children, predicate);\n if (childPath) {\n return [parent, ...childPath];\n }\n }\n }\n return undefined;\n}\n\nfunction getErrorItems(parent: PresentationHierarchyNode, path: string[]) {\n const errorList: ErrorItem[] = [];\n\n if (parent.children === true) {\n return [];\n }\n\n const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorItems(node, pathToChild);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction expandTo(expandNode: (nodeId: string) => void, path: string[]) {\n path.forEach((nodeId) => expandNode(nodeId));\n}\n\nfunction isErrorNode(node: PresentationHierarchyNode): node is PresentationHierarchyNode & Pick<Required<PresentationHierarchyNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
@@ -99,6 +99,16 @@ export interface LocalizedStrings {
99
99
  * Default value: `More`.
100
100
  */
101
101
  more: string;
102
+ /**
103
+ * Label for confirm button.
104
+ * Default value: `Confirm`.
105
+ */
106
+ confirm: string;
107
+ /**
108
+ * Label for cancel button.
109
+ * Default value: `Cancel`.
110
+ */
111
+ cancel: string;
102
112
  }
103
113
  /** @internal */
104
114
  export interface LocalizationContext {
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA0BD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
1
+ {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA4BD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
@@ -24,6 +24,8 @@ const defaultLocalizedStrings = {
24
24
  retry: "Retry",
25
25
  rename: "Rename",
26
26
  more: "More",
27
+ confirm: "Confirm",
28
+ cancel: "Cancel",
27
29
  };
28
30
  const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
29
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA6G1F,MAAM,uBAAuB,GAAqB;IAChD,O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["/*---------------------------------------------------------------------------------------------\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, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
1
+ {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuH1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAqC,EAAE,mBAAmB;IAC1D,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,6CAA6C;IACjE,8BAA8B,EAAE,eAAe;IAC/C,uBAAuB,EAAE,0CAA0C;IACnE,2BAA2B,EAAE,sBAAsB;IACnD,mBAAmB,EAAE,gGAAgG;IACrH,uBAAuB,EAAE,8EAA8E;IACvG,aAAa,EAAE,4BAA4B;IAC3C,WAAW,EAAE,sCAAsC;IACnD,aAAa,EAAE,kBAAkB;IACjC,sBAAsB,EAAE,6BAA6B;IACrD,iCAAiC,EAAE,cAAc;IACjD,mCAAmC,EAAE,YAAY;IACjD,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,iGAAiG;IACjG,UAAU,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACpF,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvE,4FAA4F;IAC5F,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CACjD;AACD;;;;GAIG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,uIAAuI;IACvI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,YAAY,CAAC;CAC/D;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAE1I;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,WAAW,GACZ,EAAE,sBAAsB,2CA4BxB"}
1
+ {"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,iGAAiG;IACjG,UAAU,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACpF,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvE,4FAA4F;IAC5F,eAAe,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;CACjD;AACD;;;;GAIG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,uIAAuI;IACvI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,YAAY,CAAC;CAC/D;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAE1I;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,WAAW,GACZ,EAAE,sBAAsB,2CA4BxB"}
@@ -1,4 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ import { cloneElement } from "react";
2
7
  import { unstable_ErrorRegion as ErrorRegion } from "@stratakit/structures";
3
8
  import { ErrorItemRenderer } from "./ErrorItemRenderer.js";
4
9
  import { useLocalizationContext } from "./LocalizationContext.js";
@@ -19,7 +24,7 @@ export function TreeErrorRenderer({ treeLabel, errorList, reloadTree, scrollToEl
19
24
  onFilterClick,
20
25
  };
21
26
  if (renderError) {
22
- return renderError(errorRendererProps);
27
+ return cloneElement(renderError(errorRendererProps), { key: errorItem.errorNode.id });
23
28
  }
24
29
  return _jsx(ErrorItemRenderer, { ...errorRendererProps }, errorItem.errorNode.id);
25
30
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAmClE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,WAAW,GACY;IACvB,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,MAAM,kBAAkB,GAA2B;YACjD,SAAS;YACT,eAAe,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC;YACjD,UAAU;YACV,wBAAwB;YACxB,aAAa;SACd,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,KAAC,iBAAiB,OAAkC,kBAAkB,IAA9C,SAAS,CAAC,SAAS,CAAC,EAAE,CAA4B,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,gBACZ,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC/E,KAAK,EACH,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAErJ,KAAK,EAAE,UAAU,GACjB,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ReactElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { ErrorItemRenderer, ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport { ErrorItem } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/**\n * Interface containing error item related actions.\n *\n * @alpha\n */\ninterface TreeErrorItemProps {\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Action to perform when an error occurs and node label is clicked in the error message */\n scrollToElement: (errorNode: ErrorItem) => void;\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 errors to be displayed */\n errorList: ErrorItem[];\n /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({\n treeLabel,\n errorList,\n reloadTree,\n scrollToElement,\n getHierarchyLevelDetails,\n onFilterClick,\n renderError,\n}: TreeErrorRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorList.map((errorItem) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorItem,\n scrollToElement: () => scrollToElement(errorItem),\n reloadTree,\n getHierarchyLevelDetails,\n onFilterClick,\n };\n\n if (renderError) {\n return renderError(errorRendererProps);\n }\n\n return <ErrorItemRenderer key={errorItem.errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={localizedStrings.issuesForTree.replace(\"{{tree_label}}\", treeLabel)}\n label={\n errorList.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace(\"{{number_of_issues}}\", errorList.length.toString())\n }\n items={errorItems}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,YAAY,EAAgB,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAmClE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,EACV,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,WAAW,GACY;IACvB,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,MAAM,kBAAkB,GAA2B;YACjD,SAAS;YACT,eAAe,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC;YACjD,UAAU;YACV,wBAAwB;YACxB,aAAa;SACd,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACxF,CAAC;QAED,OAAO,KAAC,iBAAiB,OAAkC,kBAAkB,IAA9C,SAAS,CAAC,SAAS,CAAC,EAAE,CAA4B,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,gBACZ,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC/E,KAAK,EACH,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAErJ,KAAK,EAAE,UAAU,GACjB,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { cloneElement, ReactElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { ErrorItemRenderer, ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport { ErrorItem } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/**\n * Interface containing error item related actions.\n *\n * @alpha\n */\ninterface TreeErrorItemProps {\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Action to perform when an error occurs and node label is clicked in the error message */\n scrollToElement: (errorNode: ErrorItem) => void;\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 errors to be displayed */\n errorList: ErrorItem[];\n /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({\n treeLabel,\n errorList,\n reloadTree,\n scrollToElement,\n getHierarchyLevelDetails,\n onFilterClick,\n renderError,\n}: TreeErrorRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorList.map((errorItem) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorItem,\n scrollToElement: () => scrollToElement(errorItem),\n reloadTree,\n getHierarchyLevelDetails,\n onFilterClick,\n };\n\n if (renderError) {\n return cloneElement(renderError(errorRendererProps), { key: errorItem.errorNode.id });\n }\n\n return <ErrorItemRenderer key={errorItem.errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={localizedStrings.issuesForTree.replace(\"{{tree_label}}\", treeLabel)}\n label={\n errorList.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace(\"{{number_of_issues}}\", errorList.length.toString())\n }\n items={errorItems}\n />\n );\n}\n"]}
@@ -1,19 +1,20 @@
1
1
  import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
2
2
  import { PresentationHierarchyNode } from "../TreeNode.js";
3
3
  import { TreeActionBaseAttributes } from "./TreeAction.js";
4
- /** @alpha */
5
- export type FilterActionProps = {
6
- /** Action to perform when the filter button is clicked for this node. */
7
- onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
8
- } & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails">;
9
4
  /**
10
5
  * React component that renders a filter action for a tree item.
6
+ *
7
+ * The action calls the `onFilter` callback prop when clicked.
8
+ *
9
+ * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
10
+ * to tree items.
11
+ *
11
12
  * @alpha
12
13
  */
13
- export declare const FilterAction: import("react").NamedExoticComponent<{
14
+ export declare const TreeNodeFilterAction: import("react").NamedExoticComponent<{
14
15
  /** Action to perform when the filter button is clicked for this node. */
15
16
  onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
16
17
  } & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails"> & {
17
18
  node: PresentationHierarchyNode;
18
19
  }>;
19
- //# sourceMappingURL=FilterAction.d.ts.map
20
+ //# sourceMappingURL=TreeNodeFilterAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeNodeFilterAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;IAf/B,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;;UAmB5B,yBAAyB;EAoB9D,CAAC"}
@@ -9,9 +9,15 @@ import { useLocalizationContext } from "./LocalizationContext.js";
9
9
  import { TreeActionBase } from "./TreeAction.js";
10
10
  /**
11
11
  * React component that renders a filter action for a tree item.
12
+ *
13
+ * The action calls the `onFilter` callback prop when clicked.
14
+ *
15
+ * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
16
+ * to tree items.
17
+ *
12
18
  * @alpha
13
19
  */
14
- export const FilterAction = memo(function FilterAction({ node, onFilter, getHierarchyLevelDetails, ...actionAttributes }) {
20
+ export const TreeNodeFilterAction = memo(function TreeNodeFilterAction({ node, onFilter, getHierarchyLevelDetails, ...actionAttributes }) {
15
21
  const { localizedStrings } = useLocalizationContext();
16
22
  const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
17
23
  const handleClick = useCallback(() => {
@@ -20,4 +26,4 @@ export const FilterAction = memo(function FilterAction({ node, onFilter, getHier
20
26
  }, [node, getHierarchyLevelDetails, onFilter]);
21
27
  return (_jsx(TreeActionBase, { ...actionAttributes, label: filterHierarchyLevel, onClick: handleClick, icon: filterSvg, visible: node.isFiltered ? true : undefined, dot: node.isFiltered ? filterHierarchyLevelActiveDescription : undefined, hide: !onFilter || !node.isFilterable }));
22
28
  });
23
- //# sourceMappingURL=FilterAction.js.map
29
+ //# sourceMappingURL=TreeNodeFilterAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeNodeFilterAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,oBAAoB,CAAC,EACrE,IAAI,EACJ,QAAQ,EACR,wBAAwB,EACxB,GAAG,gBAAgB,EAC6C;IAChE,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,GAAG,gBAAgB,CAAC;IAEzF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE/C,OAAO,CACL,KAAC,cAAc,OACT,gBAAgB,EACpB,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC3C,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS,EACxE,IAAI,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,GACrC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\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 = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: PresentationHierarchyNode }) {\n const { localizedStrings } = useLocalizationContext();\n const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;\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"]}
@@ -0,0 +1,57 @@
1
+ import { PropsWithChildren } from "react";
2
+ import { PresentationHierarchyNode } from "../TreeNode.js";
3
+ import { TreeActionBaseAttributes } from "./TreeAction.js";
4
+ /**
5
+ * React component that renders a rename action for a tree item.
6
+ *
7
+ * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When
8
+ * rename is completed, the `onLabelChanged` function is called to make the actual data update.
9
+ *
10
+ * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
11
+ * to tree items.
12
+ *
13
+ * @alpha
14
+ */
15
+ export declare const TreeNodeRenameAction: import("react").NamedExoticComponent<TreeActionBaseAttributes & {
16
+ node: PresentationHierarchyNode;
17
+ }>;
18
+ /** @alpha */
19
+ export interface TreeNodeEditingProps {
20
+ /**
21
+ * A callback that is invoked when node label is changed. Should be used together
22
+ * with `<TreeNodeRenameAction />` to enter label editing mode.
23
+ */
24
+ onLabelChanged: (newLabel: string) => void;
25
+ labelValidationHint?: string;
26
+ validate?: (newLabel: string) => boolean;
27
+ }
28
+ /** @internal */
29
+ export interface RenameParameters {
30
+ nodeId: string;
31
+ commit: (newLabel: string) => void;
32
+ labelValidationHint?: string;
33
+ validate?: (newLabel: string) => boolean;
34
+ }
35
+ interface TreeNodeRenameContext {
36
+ renameParameters?: RenameParameters;
37
+ startRename: (node: PresentationHierarchyNode) => void;
38
+ canRename: (node: PresentationHierarchyNode) => boolean;
39
+ cancelRename: () => void;
40
+ }
41
+ /** @internal */
42
+ export declare const useTreeNodeRenameContext: () => TreeNodeRenameContext | undefined;
43
+ /** @internal */
44
+ export declare function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{
45
+ value: TreeNodeRenameContext;
46
+ }>): import("react/jsx-runtime").JSX.Element;
47
+ /** @internal */
48
+ export declare function useTreeNodeRenameContextValue({ getEditingProps, }: {
49
+ getEditingProps?: (node: PresentationHierarchyNode) => TreeNodeEditingProps | undefined;
50
+ }): {
51
+ renameParameters: RenameParameters | undefined;
52
+ cancelRename: () => void;
53
+ startRename: (node: PresentationHierarchyNode) => void;
54
+ canRename: (node: PresentationHierarchyNode) => boolean;
55
+ };
56
+ export {};
57
+ //# sourceMappingURL=TreeNodeRenameAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeNodeRenameAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAuB,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAE3G,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB;UAGK,yBAAyB;EAY7D,CAAC;AAEH,aAAa;AACb,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C;AAED,UAAU,qBAAqB;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,WAAW,EAAE,CAAC,IAAI,EAAE,yBA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