@itwin/presentation-hierarchies-react 2.0.0-alpha.52 → 2.0.0-alpha.54

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 (98) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +62 -55
  3. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
  4. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +33 -29
  5. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  6. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +27 -16
  7. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  8. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +181 -54
  9. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  10. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +12 -6
  11. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
  12. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +54 -49
  13. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
  14. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -30
  15. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  16. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +116 -74
  17. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  18. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +67 -54
  19. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  20. package/lib/esm/presentation-hierarchies-react/UseTree.js +283 -226
  21. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  22. package/lib/esm/presentation-hierarchies-react/Utils.js +44 -27
  23. package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -1
  24. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +6 -7
  25. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
  26. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +271 -298
  27. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  28. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +91 -82
  29. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  30. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -47
  31. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +114 -151
  32. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  33. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +32 -37
  34. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +128 -101
  36. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +29 -44
  38. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +24 -13
  40. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +344 -67
  42. package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +16 -15
  44. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +78 -60
  46. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +122 -117
  48. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
  49. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +59 -38
  50. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
  51. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -5
  52. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
  53. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +161 -35
  54. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
  55. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +21 -17
  56. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
  57. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +84 -31
  58. package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
  59. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +22 -14
  60. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
  61. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +61 -26
  62. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
  63. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +15 -6
  64. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
  65. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +75 -25
  66. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
  67. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +16 -40
  68. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
  69. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +140 -61
  70. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
  71. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -42
  72. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  73. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +489 -121
  74. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  75. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +58 -55
  76. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  77. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +412 -181
  78. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  79. package/lib/esm/presentation-hierarchies-react.d.ts +17 -17
  80. package/lib/esm/presentation-hierarchies-react.js +15 -18
  81. package/package.json +17 -14
  82. package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
  83. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
  84. package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
  85. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
  86. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
  87. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
  88. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
  89. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  91. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  92. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
  93. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  94. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  95. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  96. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  97. package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
  98. package/lib/esm/presentation-hierarchies-react.js.map +0 -1
@@ -1,132 +1,500 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 "./TreeNodeRenderer.css";
7
- import { cloneElement, forwardRef, isValidElement, memo, useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
1
+ import { TreeActionBase } from "./TreeAction.js";
2
+ import { useLocalizationContext } from "./LocalizationContext.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
8
  import { Description, IconButton, Spinner, Text, TextBox } from "@stratakit/bricks";
9
+ import "./TreeNodeRenderer.css";
9
10
  import checkmarkSvg from "@stratakit/icons/checkmark.svg";
10
11
  import dismissSvg from "@stratakit/icons/dismiss.svg";
11
12
  import refreshSvg from "@stratakit/icons/refresh.svg";
12
- import { DropdownMenu, unstable_Popover as Popover, Tree } from "@stratakit/structures";
13
- import { useLocalizationContext } from "./LocalizationContext.js";
14
- import { TreeActionBase } from "./TreeAction.js";
15
- import { useTreeNodeRenameContext } from "./TreeNodeRenameAction.js";
13
+
14
+ //#region src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx
16
15
  /**
17
- * A component that renders given `FlatTreeNode` using the `Tree.Item` component from `@itwin/itwinui-react`. The
18
- * `FlatTreeNode` objects for this renderer are generally created using the `useFlatTreeNodeList` hook.
19
- *
20
- * @internal
21
- */
22
- export const StrataKitTreeNodeRenderer = memo(forwardRef(function HierarchyNode(props, forwardedRef) {
23
- const { node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps } = props;
24
- const { localizedStrings } = useLocalizationContext();
25
- const renameContext = useTreeNodeRenameContext();
26
- const [contextMenuProps, setContextMenuProps] = useState(undefined);
27
- const label = treeItemProps.label ?? node.label;
28
- const inlineActionItems = useMemo(() => {
29
- if (node.error !== undefined && node.error.type === "ChildrenLoad") {
30
- return [
31
- _jsx(TreeActionBase, { label: localizedStrings.retry, onClick: () => reloadTree({ parentNodeId: node.id, state: "reset" }), visible: true, icon: refreshSvg, variant: "inline" }, "retry"),
32
- ];
33
- }
34
- if (!inlineActions) {
35
- return undefined;
36
- }
37
- return injectActionVariant(inlineActions, "inline");
38
- }, [node, inlineActions, localizedStrings.retry, reloadTree]);
39
- const menuActionItems = useMemo(() => {
40
- if (!menuActions) {
41
- return undefined;
42
- }
43
- return injectActionVariant(menuActions, "default");
44
- }, [menuActions]);
45
- const expanded = useMemo(() => {
46
- if (node.error) {
47
- return undefined;
48
- }
49
- if (node.isExpanded || node.children === true || node.children.length > 0) {
50
- return node.isExpanded;
51
- }
52
- return undefined;
53
- }, [node.children, node.error, node.isExpanded]);
54
- const { renameParameters, cancelRename } = renameContext ?? {};
55
- const labelEditor = (_jsx(LabelEditor, { initialLabel: node.label, onChange: renameParameters?.commit, onCancel: cancelRename, labelValidationHint: renameParameters?.labelValidationHint, validate: renameParameters?.validate }));
56
- return (_jsxs(_Fragment, { children: [_jsx(Popover, { content: labelEditor, placement: "bottom", open: renameParameters?.nodeId === node.id, setOpen: cancelRename, unmountOnHide: true, children: _jsx(Tree.Item, { ...treeItemProps, ref: forwardedRef, label: label, expanded: expanded, onExpandedChange: useCallback((isExpanded) => {
57
- expandNode(node.id, isExpanded);
58
- }, [node, expandNode]), inlineActions: inlineActionItems, actions: menuActionItems, unstable_decorations: decorations, error: node.error ? node.error.id : undefined, onContextMenu: (e) => {
59
- if (treeItemProps.onContextMenu) {
60
- treeItemProps.onContextMenu(e);
61
- }
62
- if (!contextMenuActions) {
63
- return;
64
- }
65
- e.preventDefault();
66
- const actions = injectActionVariant(contextMenuActions, "context-menu");
67
- if (actions.length === 0) {
68
- return;
69
- }
70
- setContextMenuProps({
71
- position: {
72
- x: e.clientX,
73
- y: e.clientY,
74
- },
75
- actions,
76
- });
77
- } }) }), _jsxs(DropdownMenu.Provider, { open: contextMenuProps !== undefined, setOpen: (open) => {
78
- if (!open) {
79
- setContextMenuProps(undefined);
80
- }
81
- }, children: [contextMenuProps ? (_jsx(DropdownMenu.Button, { style: { position: "fixed", top: contextMenuProps.position.y, left: contextMenuProps.position.x }, render: _jsx("div", {}) })) : null, _jsx(DropdownMenu.Content, { focusable: true, autoFocus: true, children: contextMenuProps?.actions })] }, `${node.id}-${contextMenuProps?.position.x ?? ""}-${contextMenuProps?.position.y ?? ""}`)] }));
16
+ * A component that renders given `FlatTreeNode` using the `Tree.Item` component from `@itwin/itwinui-react`. The
17
+ * `FlatTreeNode` objects for this renderer are generally created using the `useFlatTreeNodeList` hook.
18
+ *
19
+ * @internal
20
+ */
21
+ const StrataKitTreeNodeRenderer = memo(forwardRef(function HierarchyNode(props, forwardedRef) {
22
+ const $ = c(62);
23
+ let contextMenuActions;
24
+ let decorations;
25
+ let expandNode;
26
+ let inlineActions;
27
+ let menuActions;
28
+ let node;
29
+ let reloadTree;
30
+ let treeItemProps;
31
+ if ($[0] !== props) {
32
+ ({node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps} = props);
33
+ $[0] = props;
34
+ $[1] = contextMenuActions;
35
+ $[2] = decorations;
36
+ $[3] = expandNode;
37
+ $[4] = inlineActions;
38
+ $[5] = menuActions;
39
+ $[6] = node;
40
+ $[7] = reloadTree;
41
+ $[8] = treeItemProps;
42
+ } else {
43
+ contextMenuActions = $[1];
44
+ decorations = $[2];
45
+ expandNode = $[3];
46
+ inlineActions = $[4];
47
+ menuActions = $[5];
48
+ node = $[6];
49
+ reloadTree = $[7];
50
+ treeItemProps = $[8];
51
+ }
52
+ const { localizedStrings } = useLocalizationContext();
53
+ const renameContext = useTreeNodeRenameContext();
54
+ const [contextMenuProps, setContextMenuProps] = useState(void 0);
55
+ const label = treeItemProps.label ?? node.label;
56
+ let t0;
57
+ bb0: {
58
+ if (node.error !== void 0 && node.error.type === "ChildrenLoad") {
59
+ let t1;
60
+ if ($[9] !== node.id || $[10] !== reloadTree) {
61
+ t1 = () => reloadTree({
62
+ parentNodeId: node.id,
63
+ state: "reset"
64
+ });
65
+ $[9] = node.id;
66
+ $[10] = reloadTree;
67
+ $[11] = t1;
68
+ } else t1 = $[11];
69
+ let t2;
70
+ if ($[12] !== localizedStrings.retry || $[13] !== t1) {
71
+ t2 = [/* @__PURE__ */ jsx(TreeActionBase, {
72
+ label: localizedStrings.retry,
73
+ onClick: t1,
74
+ visible: true,
75
+ icon: refreshSvg,
76
+ variant: "inline"
77
+ }, "retry")];
78
+ $[12] = localizedStrings.retry;
79
+ $[13] = t1;
80
+ $[14] = t2;
81
+ } else t2 = $[14];
82
+ t0 = t2;
83
+ break bb0;
84
+ }
85
+ if (!inlineActions) {
86
+ t0 = void 0;
87
+ break bb0;
88
+ }
89
+ let t1;
90
+ if ($[15] !== inlineActions) {
91
+ t1 = injectActionVariant(inlineActions, "inline");
92
+ $[15] = inlineActions;
93
+ $[16] = t1;
94
+ } else t1 = $[16];
95
+ t0 = t1;
96
+ }
97
+ const inlineActionItems = t0;
98
+ let t1;
99
+ bb1: {
100
+ if (!menuActions) {
101
+ t1 = void 0;
102
+ break bb1;
103
+ }
104
+ let t2;
105
+ if ($[17] !== menuActions) {
106
+ t2 = injectActionVariant(menuActions, "default");
107
+ $[17] = menuActions;
108
+ $[18] = t2;
109
+ } else t2 = $[18];
110
+ t1 = t2;
111
+ }
112
+ const menuActionItems = t1;
113
+ let t2;
114
+ bb2: {
115
+ if (node.error) {
116
+ t2 = void 0;
117
+ break bb2;
118
+ }
119
+ if (node.children !== true && node.children.length === 0) {
120
+ t2 = void 0;
121
+ break bb2;
122
+ }
123
+ t2 = node.isExpanded;
124
+ }
125
+ const expanded = t2;
126
+ let t3;
127
+ if ($[19] !== renameContext) {
128
+ t3 = renameContext ?? {};
129
+ $[19] = renameContext;
130
+ $[20] = t3;
131
+ } else t3 = $[20];
132
+ const { renameParameters, cancelRename } = t3;
133
+ const t4 = renameParameters?.commit;
134
+ const t5 = renameParameters?.labelValidationHint;
135
+ const t6 = renameParameters?.validate;
136
+ let t7;
137
+ if ($[21] !== cancelRename || $[22] !== node.label || $[23] !== t4 || $[24] !== t5 || $[25] !== t6) {
138
+ t7 = /* @__PURE__ */ jsx(LabelEditor, {
139
+ initialLabel: node.label,
140
+ onChange: t4,
141
+ onCancel: cancelRename,
142
+ labelValidationHint: t5,
143
+ validate: t6
144
+ });
145
+ $[21] = cancelRename;
146
+ $[22] = node.label;
147
+ $[23] = t4;
148
+ $[24] = t5;
149
+ $[25] = t6;
150
+ $[26] = t7;
151
+ } else t7 = $[26];
152
+ const labelEditor = t7;
153
+ const t8 = renameParameters?.nodeId === node.id;
154
+ let t9;
155
+ if ($[27] !== expandNode || $[28] !== node.id) {
156
+ t9 = (isExpanded) => {
157
+ expandNode(node.id, isExpanded);
158
+ };
159
+ $[27] = expandNode;
160
+ $[28] = node.id;
161
+ $[29] = t9;
162
+ } else t9 = $[29];
163
+ const t10 = t9;
164
+ const t11 = node.error ? node.error.id : void 0;
165
+ let t12;
166
+ if ($[30] !== contextMenuActions || $[31] !== treeItemProps) {
167
+ t12 = (e) => {
168
+ if (treeItemProps.onContextMenu) treeItemProps.onContextMenu(e);
169
+ if (!contextMenuActions) return;
170
+ e.preventDefault();
171
+ const actions = injectActionVariant(contextMenuActions, "context-menu");
172
+ if (actions.length === 0) return;
173
+ setContextMenuProps({
174
+ position: {
175
+ x: e.clientX,
176
+ y: e.clientY
177
+ },
178
+ actions
179
+ });
180
+ };
181
+ $[30] = contextMenuActions;
182
+ $[31] = treeItemProps;
183
+ $[32] = t12;
184
+ } else t12 = $[32];
185
+ let t13;
186
+ if ($[33] !== decorations || $[34] !== expanded || $[35] !== forwardedRef || $[36] !== inlineActionItems || $[37] !== label || $[38] !== menuActionItems || $[39] !== t10 || $[40] !== t11 || $[41] !== t12 || $[42] !== treeItemProps) {
187
+ t13 = /* @__PURE__ */ jsx(Tree.Item, {
188
+ ...treeItemProps,
189
+ ref: forwardedRef,
190
+ label,
191
+ expanded,
192
+ onExpandedChange: t10,
193
+ inlineActions: inlineActionItems,
194
+ actions: menuActionItems,
195
+ unstable_decorations: decorations,
196
+ error: t11,
197
+ onContextMenu: t12
198
+ });
199
+ $[33] = decorations;
200
+ $[34] = expanded;
201
+ $[35] = forwardedRef;
202
+ $[36] = inlineActionItems;
203
+ $[37] = label;
204
+ $[38] = menuActionItems;
205
+ $[39] = t10;
206
+ $[40] = t11;
207
+ $[41] = t12;
208
+ $[42] = treeItemProps;
209
+ $[43] = t13;
210
+ } else t13 = $[43];
211
+ let t14;
212
+ if ($[44] !== cancelRename || $[45] !== labelEditor || $[46] !== t13 || $[47] !== t8) {
213
+ t14 = /* @__PURE__ */ jsx(unstable_Popover, {
214
+ content: labelEditor,
215
+ placement: "bottom",
216
+ open: t8,
217
+ setOpen: cancelRename,
218
+ unmountOnHide: true,
219
+ children: t13
220
+ });
221
+ $[44] = cancelRename;
222
+ $[45] = labelEditor;
223
+ $[46] = t13;
224
+ $[47] = t8;
225
+ $[48] = t14;
226
+ } else t14 = $[48];
227
+ const t15 = contextMenuProps !== void 0;
228
+ let t16;
229
+ if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
230
+ t16 = (open) => {
231
+ if (!open) setContextMenuProps(void 0);
232
+ };
233
+ $[49] = t16;
234
+ } else t16 = $[49];
235
+ const t17 = `${node.id}-${contextMenuProps?.position.x ?? ""}-${contextMenuProps?.position.y ?? ""}`;
236
+ let t18;
237
+ if ($[50] !== contextMenuProps) {
238
+ t18 = contextMenuProps ? /* @__PURE__ */ jsx(DropdownMenu.Button, {
239
+ style: {
240
+ position: "fixed",
241
+ top: contextMenuProps.position.y,
242
+ left: contextMenuProps.position.x
243
+ },
244
+ render: /* @__PURE__ */ jsx("div", {})
245
+ }) : null;
246
+ $[50] = contextMenuProps;
247
+ $[51] = t18;
248
+ } else t18 = $[51];
249
+ const t19 = contextMenuProps?.actions;
250
+ let t20;
251
+ if ($[52] !== t19) {
252
+ t20 = /* @__PURE__ */ jsx(DropdownMenu.Content, {
253
+ focusable: true,
254
+ autoFocus: true,
255
+ children: t19
256
+ });
257
+ $[52] = t19;
258
+ $[53] = t20;
259
+ } else t20 = $[53];
260
+ let t21;
261
+ if ($[54] !== t15 || $[55] !== t17 || $[56] !== t18 || $[57] !== t20) {
262
+ t21 = /* @__PURE__ */ jsxs(DropdownMenu.Provider, {
263
+ open: t15,
264
+ setOpen: t16,
265
+ children: [t18, t20]
266
+ }, t17);
267
+ $[54] = t15;
268
+ $[55] = t17;
269
+ $[56] = t18;
270
+ $[57] = t20;
271
+ $[58] = t21;
272
+ } else t21 = $[58];
273
+ let t22;
274
+ if ($[59] !== t14 || $[60] !== t21) {
275
+ t22 = /* @__PURE__ */ jsxs(Fragment, { children: [t14, t21] });
276
+ $[59] = t14;
277
+ $[60] = t21;
278
+ $[61] = t22;
279
+ } else t22 = $[61];
280
+ return t22;
82
281
  }));
83
- export const PlaceholderNode = memo(forwardRef(function PlaceholderNode({ ...props }, forwardedRef) {
84
- const { localizedStrings } = useLocalizationContext();
85
- return (_jsx(Tree.Item, { ...props, ref: forwardedRef, label: localizedStrings.loading, unstable_decorations: _jsx(Spinner, { size: "small", title: localizedStrings.loading }) }));
282
+ const PlaceholderNode = memo(forwardRef(function PlaceholderNode(t0, forwardedRef) {
283
+ const $ = c(9);
284
+ let props;
285
+ if ($[0] !== t0) {
286
+ ({...props} = t0);
287
+ $[0] = t0;
288
+ $[1] = props;
289
+ } else props = $[1];
290
+ const { localizedStrings } = useLocalizationContext();
291
+ let t1;
292
+ if ($[2] !== localizedStrings.loading) {
293
+ t1 = /* @__PURE__ */ jsx(Spinner, {
294
+ size: "small",
295
+ title: localizedStrings.loading
296
+ });
297
+ $[2] = localizedStrings.loading;
298
+ $[3] = t1;
299
+ } else t1 = $[3];
300
+ let t2;
301
+ if ($[4] !== forwardedRef || $[5] !== localizedStrings.loading || $[6] !== props || $[7] !== t1) {
302
+ t2 = /* @__PURE__ */ jsx(Tree.Item, {
303
+ ...props,
304
+ ref: forwardedRef,
305
+ label: localizedStrings.loading,
306
+ unstable_decorations: t1
307
+ });
308
+ $[4] = forwardedRef;
309
+ $[5] = localizedStrings.loading;
310
+ $[6] = props;
311
+ $[7] = t1;
312
+ $[8] = t2;
313
+ } else t2 = $[8];
314
+ return t2;
86
315
  }));
87
- function LabelEditor({ initialLabel, labelValidationHint, onChange, onCancel, validate, }) {
88
- const { localizedStrings } = useLocalizationContext();
89
- const inputRef = useRef(null);
90
- const [newLabelValue, setNewLabelValue] = useState(initialLabel);
91
- const [hasError, setHasError] = useState(false);
92
- const handleLabelChange = () => {
93
- if (validate && !validate(newLabelValue)) {
94
- setHasError(true);
95
- return;
96
- }
97
- if (initialLabel !== newLabelValue) {
98
- onChange?.(newLabelValue);
99
- return;
100
- }
101
- onCancel?.();
102
- };
103
- const cancelLabelChange = () => {
104
- setNewLabelValue(initialLabel);
105
- onCancel?.();
106
- };
107
- useEffect(() => {
108
- if (inputRef.current) {
109
- inputRef.current.focus();
110
- inputRef.current.select();
111
- }
112
- }, []);
113
- const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
114
- const inputId = useId();
115
- return (_jsxs("div", { className: "phr-node-label-editor", children: [_jsxs("div", { className: "phr-node-label-editor-input-row", children: [_jsx(TextBox.Root, { style: { width: "100%" }, className: hasError ? "with-error" : undefined, children: _jsx(TextBox.Input, { id: inputId, ref: inputRef, value: newLabelValue, onChange: (event) => {
116
- setNewLabelValue(event.target.value);
117
- setHasError(false);
118
- }, onKeyUp: (event) => {
119
- if (event.key === "Enter") {
120
- handleLabelChange();
121
- }
122
- else if (event.key === "Escape") {
123
- cancelLabelChange();
124
- }
125
- } }) }), _jsx(IconButton, { icon: dismissSvg, label: localizedStrings.cancel, onClick: cancelLabelChange }), _jsx(IconButton, { icon: checkmarkSvg, label: localizedStrings.confirm, onClick: handleLabelChange, disabled: !canRename })] }), labelValidationHint !== undefined ? (_jsx(Description, { id: inputId, tone: hasError ? "critical" : "neutral", style: { display: "flex" }, children: _jsx(Text, { variant: "caption-lg", children: labelValidationHint }) })) : undefined] }, initialLabel));
316
+ function LabelEditor(t0) {
317
+ const $ = c(43);
318
+ const { initialLabel, labelValidationHint, onChange, onCancel, validate } = t0;
319
+ const { localizedStrings } = useLocalizationContext();
320
+ const inputRef = useRef(null);
321
+ const [newLabelValue, setNewLabelValue] = useState(initialLabel);
322
+ const [hasError, setHasError] = useState(false);
323
+ let t1;
324
+ if ($[0] !== initialLabel || $[1] !== newLabelValue || $[2] !== onCancel || $[3] !== onChange || $[4] !== validate) {
325
+ t1 = () => {
326
+ if (validate && !validate(newLabelValue)) {
327
+ setHasError(true);
328
+ return;
329
+ }
330
+ if (initialLabel !== newLabelValue) {
331
+ onChange?.(newLabelValue);
332
+ return;
333
+ }
334
+ onCancel?.();
335
+ };
336
+ $[0] = initialLabel;
337
+ $[1] = newLabelValue;
338
+ $[2] = onCancel;
339
+ $[3] = onChange;
340
+ $[4] = validate;
341
+ $[5] = t1;
342
+ } else t1 = $[5];
343
+ const handleLabelChange = t1;
344
+ let t2;
345
+ if ($[6] !== initialLabel || $[7] !== onCancel) {
346
+ t2 = () => {
347
+ setNewLabelValue(initialLabel);
348
+ onCancel?.();
349
+ };
350
+ $[6] = initialLabel;
351
+ $[7] = onCancel;
352
+ $[8] = t2;
353
+ } else t2 = $[8];
354
+ const cancelLabelChange = t2;
355
+ let t3;
356
+ let t4;
357
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
358
+ t3 = () => {
359
+ if (inputRef.current) {
360
+ inputRef.current.focus();
361
+ inputRef.current.select();
362
+ }
363
+ };
364
+ t4 = [];
365
+ $[9] = t3;
366
+ $[10] = t4;
367
+ } else {
368
+ t3 = $[9];
369
+ t4 = $[10];
370
+ }
371
+ useEffect(t3, t4);
372
+ const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
373
+ const inputId = useId();
374
+ let t5;
375
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
376
+ t5 = { width: "100%" };
377
+ $[11] = t5;
378
+ } else t5 = $[11];
379
+ const t6 = hasError ? "with-error" : void 0;
380
+ let t7;
381
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
382
+ t7 = (event) => {
383
+ setNewLabelValue(event.target.value);
384
+ setHasError(false);
385
+ };
386
+ $[12] = t7;
387
+ } else t7 = $[12];
388
+ let t8;
389
+ if ($[13] !== cancelLabelChange || $[14] !== handleLabelChange) {
390
+ t8 = (event_0) => {
391
+ if (event_0.key === "Enter") handleLabelChange();
392
+ else if (event_0.key === "Escape") cancelLabelChange();
393
+ };
394
+ $[13] = cancelLabelChange;
395
+ $[14] = handleLabelChange;
396
+ $[15] = t8;
397
+ } else t8 = $[15];
398
+ let t9;
399
+ if ($[16] !== inputId || $[17] !== localizedStrings.newLabel || $[18] !== newLabelValue || $[19] !== t8) {
400
+ t9 = /* @__PURE__ */ jsx(TextBox.Input, {
401
+ id: inputId,
402
+ ref: inputRef,
403
+ "aria-label": localizedStrings.newLabel,
404
+ value: newLabelValue,
405
+ onChange: t7,
406
+ onKeyUp: t8
407
+ });
408
+ $[16] = inputId;
409
+ $[17] = localizedStrings.newLabel;
410
+ $[18] = newLabelValue;
411
+ $[19] = t8;
412
+ $[20] = t9;
413
+ } else t9 = $[20];
414
+ let t10;
415
+ if ($[21] !== t6 || $[22] !== t9) {
416
+ t10 = /* @__PURE__ */ jsx(TextBox.Root, {
417
+ style: t5,
418
+ className: t6,
419
+ children: t9
420
+ });
421
+ $[21] = t6;
422
+ $[22] = t9;
423
+ $[23] = t10;
424
+ } else t10 = $[23];
425
+ let t11;
426
+ if ($[24] !== cancelLabelChange || $[25] !== localizedStrings.cancel) {
427
+ t11 = /* @__PURE__ */ jsx(IconButton, {
428
+ icon: dismissSvg,
429
+ label: localizedStrings.cancel,
430
+ onClick: cancelLabelChange
431
+ });
432
+ $[24] = cancelLabelChange;
433
+ $[25] = localizedStrings.cancel;
434
+ $[26] = t11;
435
+ } else t11 = $[26];
436
+ const t12 = !canRename;
437
+ let t13;
438
+ if ($[27] !== handleLabelChange || $[28] !== localizedStrings.confirm || $[29] !== t12) {
439
+ t13 = /* @__PURE__ */ jsx(IconButton, {
440
+ icon: checkmarkSvg,
441
+ label: localizedStrings.confirm,
442
+ onClick: handleLabelChange,
443
+ disabled: t12
444
+ });
445
+ $[27] = handleLabelChange;
446
+ $[28] = localizedStrings.confirm;
447
+ $[29] = t12;
448
+ $[30] = t13;
449
+ } else t13 = $[30];
450
+ let t14;
451
+ if ($[31] !== t10 || $[32] !== t11 || $[33] !== t13) {
452
+ t14 = /* @__PURE__ */ jsxs("div", {
453
+ className: "phr-node-label-editor-input-row",
454
+ children: [
455
+ t10,
456
+ t11,
457
+ t13
458
+ ]
459
+ });
460
+ $[31] = t10;
461
+ $[32] = t11;
462
+ $[33] = t13;
463
+ $[34] = t14;
464
+ } else t14 = $[34];
465
+ let t15;
466
+ if ($[35] !== hasError || $[36] !== inputId || $[37] !== labelValidationHint) {
467
+ t15 = labelValidationHint !== void 0 ? /* @__PURE__ */ jsx(Description, {
468
+ id: inputId,
469
+ tone: hasError ? "critical" : "neutral",
470
+ style: { display: "flex" },
471
+ children: /* @__PURE__ */ jsx(Text, {
472
+ variant: "caption-lg",
473
+ children: labelValidationHint
474
+ })
475
+ }) : void 0;
476
+ $[35] = hasError;
477
+ $[36] = inputId;
478
+ $[37] = labelValidationHint;
479
+ $[38] = t15;
480
+ } else t15 = $[38];
481
+ let t16;
482
+ if ($[39] !== initialLabel || $[40] !== t14 || $[41] !== t15) {
483
+ t16 = /* @__PURE__ */ jsxs("div", {
484
+ className: "phr-node-label-editor",
485
+ children: [t14, t15]
486
+ }, initialLabel);
487
+ $[39] = initialLabel;
488
+ $[40] = t14;
489
+ $[41] = t15;
490
+ $[42] = t16;
491
+ } else t16 = $[42];
492
+ return t16;
126
493
  }
127
494
  function injectActionVariant(actions, variant) {
128
- return actions
129
- .filter((action) => isValidElement(action))
130
- .map((action) => cloneElement(action, { variant }));
495
+ return actions.filter((action) => isValidElement(action)).map((action) => cloneElement(action, { variant }));
131
496
  }
497
+
498
+ //#endregion
499
+ export { PlaceholderNode, StrataKitTreeNodeRenderer };
132
500
  //# sourceMappingURL=TreeNodeRenderer.js.map