@itwin/presentation-hierarchies-react 2.0.0-alpha.53 → 2.0.0-alpha.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +23 -61
  3. package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
  4. package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
  5. package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +33 -29
  6. package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
  7. package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -17
  8. package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
  9. package/lib/presentation-hierarchies-react/UseIModelTree.js +184 -0
  10. package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
  11. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
  12. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
  13. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +58 -0
  14. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
  15. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +25 -0
  16. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
  17. package/lib/presentation-hierarchies-react/UseSelectionHandler.js +125 -0
  18. package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
  19. package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
  20. package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
  21. package/lib/presentation-hierarchies-react/UseTree.js +294 -0
  22. package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
  23. package/lib/presentation-hierarchies-react/Utils.js +56 -0
  24. package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
  25. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
  26. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
  27. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
  28. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
  29. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
  30. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
  31. package/lib/presentation-hierarchies-react/internal/TreeActions.js +295 -0
  32. package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
  33. package/lib/presentation-hierarchies-react/internal/TreeLoader.js +99 -0
  34. package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
  35. package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -0
  36. package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
  37. package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
  38. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +37 -0
  39. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
  40. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +142 -0
  41. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
  42. package/lib/presentation-hierarchies-react/internal/Utils.js +43 -0
  43. package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
  44. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
  45. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
  46. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +381 -0
  47. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
  48. package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +16 -15
  49. package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
  50. package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +91 -0
  51. package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
  52. package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +24 -0
  53. package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
  54. package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +41 -0
  55. package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
  56. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
  57. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
  58. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +186 -0
  59. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
  60. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
  61. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
  62. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +89 -0
  63. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
  64. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
  65. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
  66. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +64 -0
  67. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
  68. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
  69. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
  70. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +92 -0
  71. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
  72. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +33 -0
  73. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
  74. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +156 -0
  75. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
  76. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +18 -0
  77. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
  78. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +535 -0
  79. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
  80. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
  81. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
  82. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +418 -0
  83. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
  84. package/lib/presentation-hierarchies-react.d.ts +18 -0
  85. package/lib/presentation-hierarchies-react.js +16 -0
  86. package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
  87. package/package.json +27 -21
  88. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +0 -85
  89. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
  91. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
  92. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
  93. package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
  94. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
  95. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
  96. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
  97. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
  98. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +0 -24
  99. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
  100. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +0 -53
  101. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
  102. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -48
  103. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
  104. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -83
  105. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
  106. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -94
  107. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
  108. package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -241
  109. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
  110. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
  111. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
  112. package/lib/esm/presentation-hierarchies-react/Utils.js +0 -39
  113. package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
  114. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
  115. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  116. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
  117. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
  118. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  119. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  120. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -322
  121. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
  122. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
  123. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  124. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -90
  125. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
  126. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -47
  127. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  128. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -157
  129. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
  130. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -42
  131. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
  132. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -115
  133. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
  134. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  135. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  136. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
  137. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
  138. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +0 -27
  139. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
  140. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +0 -74
  141. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +0 -1
  142. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
  143. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +0 -73
  144. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
  145. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +0 -138
  146. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
  147. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +0 -47
  148. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
  149. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +0 -16
  150. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
  151. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +0 -42
  152. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
  153. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +0 -45
  154. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
  155. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +0 -36
  156. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
  157. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +0 -30
  158. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
  159. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +0 -30
  160. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
  161. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -20
  162. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
  163. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +0 -29
  164. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
  165. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -57
  166. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
  167. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +0 -71
  168. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
  169. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -46
  170. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
  171. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +0 -133
  172. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
  173. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -75
  174. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
  175. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +0 -193
  176. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
  177. package/lib/esm/presentation-hierarchies-react.d.ts +0 -17
  178. package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
  179. package/lib/esm/presentation-hierarchies-react.js +0 -18
  180. package/lib/esm/presentation-hierarchies-react.js.map +0 -1
  181. /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
@@ -0,0 +1,535 @@
1
+ import { useTranslation } from "./LocalizationContext.js";
2
+ import { TreeActionBase } from "./TreeAction.js";
3
+ import { useTreeNodeRenameContext } from "./TreeNodeRenameAction.js";
4
+ import { c } from "react-compiler-runtime";
5
+ import { cloneElement, forwardRef, isValidElement, memo, useEffect, useId, useRef, useState } from "react";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { DropdownMenu, Tree, unstable_Popover } from "@stratakit/structures";
8
+ import { Description, IconButton, Spinner, Text, TextBox } from "@stratakit/bricks";
9
+ import "./TreeNodeRenderer.css";
10
+ import checkmarkSvg from "@stratakit/icons/checkmark.svg";
11
+ import dismissSvg from "@stratakit/icons/dismiss.svg";
12
+ import refreshSvg from "@stratakit/icons/refresh.svg";
13
+
14
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx
15
+ /**
16
+ * A component that renders a given `TreeNode` using the `Tree.Item` component from `@stratakit/structures`.
17
+ *
18
+ * @internal
19
+ */
20
+ const StrataKitTreeNodeRenderer = memo(forwardRef(function HierarchyNode(props, forwardedRef) {
21
+ const $ = c(64);
22
+ let contextMenuActions;
23
+ let decorations;
24
+ let expandNode;
25
+ let inlineActions;
26
+ let menuActions;
27
+ let node;
28
+ let reloadTree;
29
+ let treeItemProps;
30
+ if ($[0] !== props) {
31
+ ({node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps} = props);
32
+ $[0] = props;
33
+ $[1] = contextMenuActions;
34
+ $[2] = decorations;
35
+ $[3] = expandNode;
36
+ $[4] = inlineActions;
37
+ $[5] = menuActions;
38
+ $[6] = node;
39
+ $[7] = reloadTree;
40
+ $[8] = treeItemProps;
41
+ } else {
42
+ contextMenuActions = $[1];
43
+ decorations = $[2];
44
+ expandNode = $[3];
45
+ inlineActions = $[4];
46
+ menuActions = $[5];
47
+ node = $[6];
48
+ reloadTree = $[7];
49
+ treeItemProps = $[8];
50
+ }
51
+ const translate = useTranslation();
52
+ const renameContext = useTreeNodeRenameContext();
53
+ const [contextMenuProps, setContextMenuProps] = useState(void 0);
54
+ const label = treeItemProps.label ?? node.label;
55
+ let t0;
56
+ bb0: {
57
+ if (node.error !== void 0 && node.error.type === "ChildrenLoad") {
58
+ let t1;
59
+ if ($[9] !== translate) {
60
+ t1 = translate("retry");
61
+ $[9] = translate;
62
+ $[10] = t1;
63
+ } else t1 = $[10];
64
+ let t2;
65
+ if ($[11] !== node.id || $[12] !== reloadTree) {
66
+ t2 = () => reloadTree({
67
+ parentNodeId: node.id,
68
+ state: "reset"
69
+ });
70
+ $[11] = node.id;
71
+ $[12] = reloadTree;
72
+ $[13] = t2;
73
+ } else t2 = $[13];
74
+ let t3;
75
+ if ($[14] !== t1 || $[15] !== t2) {
76
+ t3 = [/* @__PURE__ */ jsx(TreeActionBase, {
77
+ label: t1,
78
+ onClick: t2,
79
+ visible: true,
80
+ icon: refreshSvg,
81
+ variant: "inline"
82
+ }, "retry")];
83
+ $[14] = t1;
84
+ $[15] = t2;
85
+ $[16] = t3;
86
+ } else t3 = $[16];
87
+ t0 = t3;
88
+ break bb0;
89
+ }
90
+ if (!inlineActions) {
91
+ t0 = void 0;
92
+ break bb0;
93
+ }
94
+ let t1;
95
+ if ($[17] !== inlineActions) {
96
+ t1 = injectActionVariant(inlineActions, "inline");
97
+ $[17] = inlineActions;
98
+ $[18] = t1;
99
+ } else t1 = $[18];
100
+ t0 = t1;
101
+ }
102
+ const inlineActionItems = t0;
103
+ let t1;
104
+ bb1: {
105
+ if (!menuActions) {
106
+ t1 = void 0;
107
+ break bb1;
108
+ }
109
+ let t2;
110
+ if ($[19] !== menuActions) {
111
+ t2 = injectActionVariant(menuActions, "default");
112
+ $[19] = menuActions;
113
+ $[20] = t2;
114
+ } else t2 = $[20];
115
+ t1 = t2;
116
+ }
117
+ const menuActionItems = t1;
118
+ let t2;
119
+ bb2: {
120
+ if (node.error) {
121
+ t2 = void 0;
122
+ break bb2;
123
+ }
124
+ if (node.children !== true && node.children.length === 0) {
125
+ t2 = void 0;
126
+ break bb2;
127
+ }
128
+ t2 = node.isExpanded;
129
+ }
130
+ const expanded = t2;
131
+ let t3;
132
+ if ($[21] !== renameContext) {
133
+ t3 = renameContext ?? {};
134
+ $[21] = renameContext;
135
+ $[22] = t3;
136
+ } else t3 = $[22];
137
+ const { renameParameters, cancelRename } = t3;
138
+ const t4 = renameParameters?.commit;
139
+ const t5 = renameParameters?.labelValidationHint;
140
+ const t6 = renameParameters?.validate;
141
+ let t7;
142
+ if ($[23] !== cancelRename || $[24] !== node.label || $[25] !== t4 || $[26] !== t5 || $[27] !== t6) {
143
+ t7 = /* @__PURE__ */ jsx(LabelEditor, {
144
+ initialLabel: node.label,
145
+ onChange: t4,
146
+ onCancel: cancelRename,
147
+ labelValidationHint: t5,
148
+ validate: t6
149
+ });
150
+ $[23] = cancelRename;
151
+ $[24] = node.label;
152
+ $[25] = t4;
153
+ $[26] = t5;
154
+ $[27] = t6;
155
+ $[28] = t7;
156
+ } else t7 = $[28];
157
+ const labelEditor = t7;
158
+ const t8 = renameParameters?.nodeId === node.id;
159
+ let t9;
160
+ if ($[29] !== expandNode || $[30] !== node.id) {
161
+ t9 = (isExpanded) => {
162
+ expandNode(node.id, isExpanded);
163
+ };
164
+ $[29] = expandNode;
165
+ $[30] = node.id;
166
+ $[31] = t9;
167
+ } else t9 = $[31];
168
+ const t10 = t9;
169
+ const t11 = node.error ? node.error.id : void 0;
170
+ let t12;
171
+ if ($[32] !== contextMenuActions || $[33] !== treeItemProps) {
172
+ t12 = (e) => {
173
+ if (treeItemProps.onContextMenu) treeItemProps.onContextMenu(e);
174
+ if (!contextMenuActions) return;
175
+ e.preventDefault();
176
+ const actions = injectActionVariant(contextMenuActions, "context-menu");
177
+ if (actions.length === 0) return;
178
+ setContextMenuProps({
179
+ position: {
180
+ x: e.clientX,
181
+ y: e.clientY
182
+ },
183
+ actions
184
+ });
185
+ };
186
+ $[32] = contextMenuActions;
187
+ $[33] = treeItemProps;
188
+ $[34] = t12;
189
+ } else t12 = $[34];
190
+ let t13;
191
+ if ($[35] !== decorations || $[36] !== expanded || $[37] !== forwardedRef || $[38] !== inlineActionItems || $[39] !== label || $[40] !== menuActionItems || $[41] !== t10 || $[42] !== t11 || $[43] !== t12 || $[44] !== treeItemProps) {
192
+ t13 = /* @__PURE__ */ jsx(Tree.Item, {
193
+ ...treeItemProps,
194
+ ref: forwardedRef,
195
+ label,
196
+ expanded,
197
+ onExpandedChange: t10,
198
+ inlineActions: inlineActionItems,
199
+ actions: menuActionItems,
200
+ unstable_decorations: decorations,
201
+ error: t11,
202
+ onContextMenu: t12
203
+ });
204
+ $[35] = decorations;
205
+ $[36] = expanded;
206
+ $[37] = forwardedRef;
207
+ $[38] = inlineActionItems;
208
+ $[39] = label;
209
+ $[40] = menuActionItems;
210
+ $[41] = t10;
211
+ $[42] = t11;
212
+ $[43] = t12;
213
+ $[44] = treeItemProps;
214
+ $[45] = t13;
215
+ } else t13 = $[45];
216
+ let t14;
217
+ if ($[46] !== cancelRename || $[47] !== labelEditor || $[48] !== t13 || $[49] !== t8) {
218
+ t14 = /* @__PURE__ */ jsx(unstable_Popover, {
219
+ content: labelEditor,
220
+ placement: "bottom",
221
+ open: t8,
222
+ setOpen: cancelRename,
223
+ unmountOnHide: true,
224
+ children: t13
225
+ });
226
+ $[46] = cancelRename;
227
+ $[47] = labelEditor;
228
+ $[48] = t13;
229
+ $[49] = t8;
230
+ $[50] = t14;
231
+ } else t14 = $[50];
232
+ const t15 = contextMenuProps !== void 0;
233
+ let t16;
234
+ if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
235
+ t16 = (open) => {
236
+ if (!open) setContextMenuProps(void 0);
237
+ };
238
+ $[51] = t16;
239
+ } else t16 = $[51];
240
+ const t17 = `${node.id}-${contextMenuProps?.position.x ?? ""}-${contextMenuProps?.position.y ?? ""}`;
241
+ let t18;
242
+ if ($[52] !== contextMenuProps) {
243
+ t18 = contextMenuProps ? /* @__PURE__ */ jsx(DropdownMenu.Button, {
244
+ style: {
245
+ position: "fixed",
246
+ top: contextMenuProps.position.y,
247
+ left: contextMenuProps.position.x
248
+ },
249
+ render: /* @__PURE__ */ jsx("div", {})
250
+ }) : null;
251
+ $[52] = contextMenuProps;
252
+ $[53] = t18;
253
+ } else t18 = $[53];
254
+ const t19 = contextMenuProps?.actions;
255
+ let t20;
256
+ if ($[54] !== t19) {
257
+ t20 = /* @__PURE__ */ jsx(DropdownMenu.Content, {
258
+ focusable: true,
259
+ autoFocus: true,
260
+ children: t19
261
+ });
262
+ $[54] = t19;
263
+ $[55] = t20;
264
+ } else t20 = $[55];
265
+ let t21;
266
+ if ($[56] !== t15 || $[57] !== t17 || $[58] !== t18 || $[59] !== t20) {
267
+ t21 = /* @__PURE__ */ jsxs(DropdownMenu.Provider, {
268
+ open: t15,
269
+ setOpen: t16,
270
+ children: [t18, t20]
271
+ }, t17);
272
+ $[56] = t15;
273
+ $[57] = t17;
274
+ $[58] = t18;
275
+ $[59] = t20;
276
+ $[60] = t21;
277
+ } else t21 = $[60];
278
+ let t22;
279
+ if ($[61] !== t14 || $[62] !== t21) {
280
+ t22 = /* @__PURE__ */ jsxs(Fragment, { children: [t14, t21] });
281
+ $[61] = t14;
282
+ $[62] = t21;
283
+ $[63] = t22;
284
+ } else t22 = $[63];
285
+ return t22;
286
+ }));
287
+ const PlaceholderNode = memo(forwardRef(function PlaceholderNode(t0, forwardedRef) {
288
+ const $ = c(13);
289
+ let props;
290
+ if ($[0] !== t0) {
291
+ ({...props} = t0);
292
+ $[0] = t0;
293
+ $[1] = props;
294
+ } else props = $[1];
295
+ const translate = useTranslation();
296
+ let t1;
297
+ if ($[2] !== translate) {
298
+ t1 = translate("loading");
299
+ $[2] = translate;
300
+ $[3] = t1;
301
+ } else t1 = $[3];
302
+ let t2;
303
+ if ($[4] !== translate) {
304
+ t2 = translate("loading");
305
+ $[4] = translate;
306
+ $[5] = t2;
307
+ } else t2 = $[5];
308
+ let t3;
309
+ if ($[6] !== t2) {
310
+ t3 = /* @__PURE__ */ jsx(Spinner, {
311
+ size: "small",
312
+ title: t2
313
+ });
314
+ $[6] = t2;
315
+ $[7] = t3;
316
+ } else t3 = $[7];
317
+ let t4;
318
+ if ($[8] !== forwardedRef || $[9] !== props || $[10] !== t1 || $[11] !== t3) {
319
+ t4 = /* @__PURE__ */ jsx(Tree.Item, {
320
+ ...props,
321
+ ref: forwardedRef,
322
+ label: t1,
323
+ unstable_decorations: t3
324
+ });
325
+ $[8] = forwardedRef;
326
+ $[9] = props;
327
+ $[10] = t1;
328
+ $[11] = t3;
329
+ $[12] = t4;
330
+ } else t4 = $[12];
331
+ return t4;
332
+ }));
333
+ function LabelEditor(t0) {
334
+ const $ = c(49);
335
+ const { initialLabel, labelValidationHint, onChange, onCancel, validate } = t0;
336
+ const translate = useTranslation();
337
+ const inputRef = useRef(null);
338
+ const [newLabelValue, setNewLabelValue] = useState(initialLabel);
339
+ const [hasError, setHasError] = useState(false);
340
+ let t1;
341
+ if ($[0] !== initialLabel || $[1] !== newLabelValue || $[2] !== onCancel || $[3] !== onChange || $[4] !== validate) {
342
+ t1 = () => {
343
+ if (validate && !validate(newLabelValue)) {
344
+ setHasError(true);
345
+ return;
346
+ }
347
+ if (initialLabel !== newLabelValue) {
348
+ onChange?.(newLabelValue);
349
+ return;
350
+ }
351
+ onCancel?.();
352
+ };
353
+ $[0] = initialLabel;
354
+ $[1] = newLabelValue;
355
+ $[2] = onCancel;
356
+ $[3] = onChange;
357
+ $[4] = validate;
358
+ $[5] = t1;
359
+ } else t1 = $[5];
360
+ const handleLabelChange = t1;
361
+ let t2;
362
+ if ($[6] !== initialLabel || $[7] !== onCancel) {
363
+ t2 = () => {
364
+ setNewLabelValue(initialLabel);
365
+ onCancel?.();
366
+ };
367
+ $[6] = initialLabel;
368
+ $[7] = onCancel;
369
+ $[8] = t2;
370
+ } else t2 = $[8];
371
+ const cancelLabelChange = t2;
372
+ let t3;
373
+ let t4;
374
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
375
+ t3 = () => {
376
+ if (inputRef.current) {
377
+ inputRef.current.focus();
378
+ inputRef.current.select();
379
+ }
380
+ };
381
+ t4 = [];
382
+ $[9] = t3;
383
+ $[10] = t4;
384
+ } else {
385
+ t3 = $[9];
386
+ t4 = $[10];
387
+ }
388
+ useEffect(t3, t4);
389
+ const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
390
+ const inputId = useId();
391
+ let t5;
392
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
393
+ t5 = { width: "100%" };
394
+ $[11] = t5;
395
+ } else t5 = $[11];
396
+ const t6 = hasError ? "with-error" : void 0;
397
+ let t7;
398
+ if ($[12] !== translate) {
399
+ t7 = translate("newLabel");
400
+ $[12] = translate;
401
+ $[13] = t7;
402
+ } else t7 = $[13];
403
+ let t8;
404
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
405
+ t8 = (event) => {
406
+ setNewLabelValue(event.target.value);
407
+ setHasError(false);
408
+ };
409
+ $[14] = t8;
410
+ } else t8 = $[14];
411
+ let t9;
412
+ if ($[15] !== cancelLabelChange || $[16] !== handleLabelChange) {
413
+ t9 = (event_0) => {
414
+ if (event_0.key === "Enter") handleLabelChange();
415
+ else if (event_0.key === "Escape") cancelLabelChange();
416
+ };
417
+ $[15] = cancelLabelChange;
418
+ $[16] = handleLabelChange;
419
+ $[17] = t9;
420
+ } else t9 = $[17];
421
+ let t10;
422
+ if ($[18] !== inputId || $[19] !== newLabelValue || $[20] !== t7 || $[21] !== t9) {
423
+ t10 = /* @__PURE__ */ jsx(TextBox.Input, {
424
+ id: inputId,
425
+ ref: inputRef,
426
+ "aria-label": t7,
427
+ value: newLabelValue,
428
+ onChange: t8,
429
+ onKeyUp: t9
430
+ });
431
+ $[18] = inputId;
432
+ $[19] = newLabelValue;
433
+ $[20] = t7;
434
+ $[21] = t9;
435
+ $[22] = t10;
436
+ } else t10 = $[22];
437
+ let t11;
438
+ if ($[23] !== t10 || $[24] !== t6) {
439
+ t11 = /* @__PURE__ */ jsx(TextBox.Root, {
440
+ style: t5,
441
+ className: t6,
442
+ children: t10
443
+ });
444
+ $[23] = t10;
445
+ $[24] = t6;
446
+ $[25] = t11;
447
+ } else t11 = $[25];
448
+ let t12;
449
+ if ($[26] !== translate) {
450
+ t12 = translate("cancel");
451
+ $[26] = translate;
452
+ $[27] = t12;
453
+ } else t12 = $[27];
454
+ let t13;
455
+ if ($[28] !== cancelLabelChange || $[29] !== t12) {
456
+ t13 = /* @__PURE__ */ jsx(IconButton, {
457
+ icon: dismissSvg,
458
+ label: t12,
459
+ onClick: cancelLabelChange
460
+ });
461
+ $[28] = cancelLabelChange;
462
+ $[29] = t12;
463
+ $[30] = t13;
464
+ } else t13 = $[30];
465
+ let t14;
466
+ if ($[31] !== translate) {
467
+ t14 = translate("confirm");
468
+ $[31] = translate;
469
+ $[32] = t14;
470
+ } else t14 = $[32];
471
+ const t15 = !canRename;
472
+ let t16;
473
+ if ($[33] !== handleLabelChange || $[34] !== t14 || $[35] !== t15) {
474
+ t16 = /* @__PURE__ */ jsx(IconButton, {
475
+ icon: checkmarkSvg,
476
+ label: t14,
477
+ onClick: handleLabelChange,
478
+ disabled: t15
479
+ });
480
+ $[33] = handleLabelChange;
481
+ $[34] = t14;
482
+ $[35] = t15;
483
+ $[36] = t16;
484
+ } else t16 = $[36];
485
+ let t17;
486
+ if ($[37] !== t11 || $[38] !== t13 || $[39] !== t16) {
487
+ t17 = /* @__PURE__ */ jsxs("div", {
488
+ className: "phr-node-label-editor-input-row",
489
+ children: [
490
+ t11,
491
+ t13,
492
+ t16
493
+ ]
494
+ });
495
+ $[37] = t11;
496
+ $[38] = t13;
497
+ $[39] = t16;
498
+ $[40] = t17;
499
+ } else t17 = $[40];
500
+ let t18;
501
+ if ($[41] !== hasError || $[42] !== inputId || $[43] !== labelValidationHint) {
502
+ t18 = labelValidationHint !== void 0 ? /* @__PURE__ */ jsx(Description, {
503
+ id: inputId,
504
+ tone: hasError ? "critical" : "neutral",
505
+ style: { display: "flex" },
506
+ children: /* @__PURE__ */ jsx(Text, {
507
+ variant: "caption-lg",
508
+ children: labelValidationHint
509
+ })
510
+ }) : void 0;
511
+ $[41] = hasError;
512
+ $[42] = inputId;
513
+ $[43] = labelValidationHint;
514
+ $[44] = t18;
515
+ } else t18 = $[44];
516
+ let t19;
517
+ if ($[45] !== initialLabel || $[46] !== t17 || $[47] !== t18) {
518
+ t19 = /* @__PURE__ */ jsxs("div", {
519
+ className: "phr-node-label-editor",
520
+ children: [t17, t18]
521
+ }, initialLabel);
522
+ $[45] = initialLabel;
523
+ $[46] = t17;
524
+ $[47] = t18;
525
+ $[48] = t19;
526
+ } else t19 = $[48];
527
+ return t19;
528
+ }
529
+ function injectActionVariant(actions, variant) {
530
+ return actions.filter((action) => isValidElement(action)).map((action) => cloneElement(action, { variant }));
531
+ }
532
+
533
+ //#endregion
534
+ export { PlaceholderNode, StrataKitTreeNodeRenderer };
535
+ //# sourceMappingURL=TreeNodeRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeNodeRenderer.js","names":["cloneElement","forwardRef","isValidElement","memo","useCallback","useEffect","useId","useMemo","useRef","useState","Description","IconButton","Spinner","Text","TextBox","checkmarkSvg","dismissSvg","refreshSvg","DropdownMenu","unstable_Popover","Popover","Tree","useTranslation","TreeActionBase","useTreeNodeRenameContext","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","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 checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\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 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) {\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) =>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{ TreeNode } from "../TreeNode.js";
2
+ import { TreeRendererProps } from "../Renderers.js";
3
+ import { SelectionMode } from "../UseSelectionHandler.js";
4
+ import { TreeNodeEditingProps } from "./TreeNodeRenameAction.js";
5
+ import { TreeErrorRendererProps } from "./TreeErrorRenderer.js";
6
+ import { StrataKitTreeItemProps } from "./TreeNodeRenderer.js";
7
+ import { ComponentProps, FC, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from "react";
8
+ import { Tree } from "@stratakit/structures";
9
+
10
+ //#region src/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts
11
+ /** @alpha */
12
+ interface TreeRendererOwnProps {
13
+ id?: string;
14
+ /**
15
+ * A user friendly display label of the tree. Should be unique within the consuming application,
16
+ * as it's used for accessibility purposes.
17
+ */
18
+ treeLabel: string;
19
+ /** Active selection mode used by the tree. Defaults to `"single"`. */
20
+ selectionMode?: SelectionMode;
21
+ /** A render function for errors' display component. Defaults to `<TreeErrorRenderer />`. */
22
+ errorRenderer?: (props: TreeErrorRendererProps) => ReactElement;
23
+ /** Props that defines if current node supports editing. */
24
+ getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined;
25
+ /** Custom props for the root Tree component. */
26
+ treeRootProps?: Partial<Omit<ComponentProps<typeof Tree.Root>, "style">>;
27
+ /** A callback that returns tree item props for specific node. */
28
+ getTreeItemProps?: (node: TreeNode) => Partial<Omit<StrataKitTreeItemProps, "selected" | "aria-level" | "aria-posinset" | "aria-setsize">>;
29
+ /**
30
+ * Callback that returns menu actions for tree item.
31
+ * Must return an array of `<TreeActionBase />` or `<Divider />` elements.
32
+ */
33
+ getMenuActions?: (props: {
34
+ targetNode: TreeNode;
35
+ selectedNodes: TreeNode[];
36
+ }) => ReactNode[];
37
+ /**
38
+ * Callback that returns inline actions for tree item.
39
+ * Must return an array of `<TreeActionBase />` elements.
40
+ * Max 2 items.
41
+ */
42
+ getInlineActions?: (props: {
43
+ targetNode: TreeNode;
44
+ selectedNodes: TreeNode[];
45
+ }) => ReactNode[];
46
+ /**
47
+ * Callback that returns actions for tree item context menu.
48
+ * Must return an array of `<TreeActionBase />` or `<Divider />` elements.
49
+ */
50
+ getContextMenuActions?: (props: {
51
+ targetNode: TreeNode;
52
+ selectedNodes: TreeNode[];
53
+ }) => ReactNode[];
54
+ }
55
+ /** @alpha */
56
+ interface StrataKitTreeRendererAttributes {
57
+ /**
58
+ * Opens rename mode for the first node that matches the given predicate. Node must be already loaded in the tree.
59
+ * 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.
60
+ *
61
+ * Returns "node-not-found" if no node matches the predicate, "success" if rename was initiated.
62
+ */
63
+ renameNode: (nodePredicate: (node: TreeNode) => boolean) => "node-not-found" | "success";
64
+ }
65
+ /** @alpha */
66
+ type StrataKitTreeRendererProps = TreeRendererProps & Pick<TreeErrorRendererProps, "filterHierarchyLevel"> & TreeRendererOwnProps;
67
+ /**
68
+ * A component that renders a tree using the `Tree` component from `@stratakit/structures`.
69
+ *
70
+ * @alpha
71
+ */
72
+ declare const StrataKitTreeRenderer: FC<PropsWithoutRef<StrataKitTreeRendererProps> & RefAttributes<StrataKitTreeRendererAttributes>>;
73
+ //#endregion
74
+ export { StrataKitTreeRenderer, StrataKitTreeRendererAttributes };
75
+ //# sourceMappingURL=TreeRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeRenderer.tsx"],"mappings":";;;;;;;;;;;UAyBU,oBAAA;EACR,EAAA;EAD4B;;;;EAM5B,SAAA;EAMyB;EAJzB,aAAA,GAAgB,aAAA;EAOmC;EALnD,aAAA,IAAiB,KAAA,EAAO,sBAAA,KAA2B,YAAA;EAK3B;EAHxB,eAAA,IAAmB,IAAA,EAAM,QAAA,KAAa,oBAAA;EAMZ;EAH1B,aAAA,GAAgB,OAAA,CAAQ,IAAA,CAAK,cAAA,QAAsB,IAAA,CAAK,IAAA;EAGT;EAA/C,gBAAA,IAAoB,IAAA,EAAM,QAAA,KAAa,OAAA,CAAQ,IAAA,CAAK,sBAAA;EAMb;;;;EAAvC,cAAA,IAAkB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;EAWO;;;;;EALxF,gBAAA,IAAoB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;EApBlE;;;;EAyBjB,qBAAA,IAAyB,KAAA;IAAS,UAAA,EAAY,QAAA;IAAU,aAAA,EAAe,QAAA;EAAA,MAAiB,SAAA;AAAA;;UAIzE,+BAAA;EAxByC;;;;;;EA+BxD,UAAA,GAAa,aAAA,GAAgB,IAAA,EAAM,QAAA;AAAA;;KAIhC,0BAAA,GAA6B,iBAAA,GAAoB,IAAA,CAAK,sBAAA,4BAAkD,oBAAA;;;;;;cAOhG,qBAAA,EAAuB,EAAA,CAAG,eAAA,CAAgB,0BAAA,IAA8B,aAAA,CAAc,+BAAA"}