@hitachivantara/uikit-react-lab 6.1.9 → 6.1.10

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 (68) hide show
  1. package/dist/Blade/Blade.js +134 -173
  2. package/dist/Blade/Blade.styles.js +54 -69
  3. package/dist/Blades/Blades.js +70 -101
  4. package/dist/Blades/Blades.styles.js +7 -10
  5. package/dist/Dashboard/Dashboard.js +57 -60
  6. package/dist/Dashboard/Dashboard.styles.js +6 -10
  7. package/dist/Flow/Background/Background.js +10 -16
  8. package/dist/Flow/Controls/Controls.js +77 -91
  9. package/dist/Flow/DroppableFlow.js +135 -200
  10. package/dist/Flow/Empty/Empty.js +12 -9
  11. package/dist/Flow/Empty/Empty.styles.js +12 -15
  12. package/dist/Flow/Flow.js +28 -30
  13. package/dist/Flow/Flow.styles.js +12 -18
  14. package/dist/Flow/FlowContext/FlowContext.js +22 -23
  15. package/dist/Flow/FlowContext/NodeMetaContext.js +36 -39
  16. package/dist/Flow/Minimap/Minimap.js +15 -28
  17. package/dist/Flow/Minimap/Minimap.styles.js +4 -9
  18. package/dist/Flow/Node/BaseNode.js +144 -190
  19. package/dist/Flow/Node/BaseNode.styles.js +122 -133
  20. package/dist/Flow/Node/Node.js +90 -108
  21. package/dist/Flow/Node/Node.styles.js +30 -40
  22. package/dist/Flow/Node/Parameters/ParamRenderer.js +17 -14
  23. package/dist/Flow/Node/Parameters/Select.js +33 -38
  24. package/dist/Flow/Node/Parameters/Slider.js +27 -29
  25. package/dist/Flow/Node/Parameters/Text.js +17 -17
  26. package/dist/Flow/Node/utils.js +44 -49
  27. package/dist/Flow/Sidebar/Sidebar.js +115 -137
  28. package/dist/Flow/Sidebar/Sidebar.styles.js +21 -22
  29. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.js +57 -60
  30. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroup.styles.js +27 -33
  31. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/DraggableSidebarGroupItem.js +27 -47
  32. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.js +14 -32
  33. package/dist/Flow/Sidebar/SidebarGroup/SidebarGroupItem/SidebarGroupItem.styles.js +17 -23
  34. package/dist/Flow/base.js +5 -5
  35. package/dist/Flow/hooks/useFlowContext.js +5 -5
  36. package/dist/Flow/hooks/useFlowInstance.js +5 -4
  37. package/dist/Flow/hooks/useFlowNode.js +92 -113
  38. package/dist/Flow/hooks/useFlowNodeMeta.js +7 -7
  39. package/dist/Flow/hooks/useNode.js +136 -154
  40. package/dist/Flow/hooks/useNodeId.js +8 -7
  41. package/dist/Flow/nodes/DashboardNode.js +64 -86
  42. package/dist/Flow/nodes/DashboardNode.styles.js +8 -14
  43. package/dist/Flow/nodes/StickyNode.js +370 -435
  44. package/dist/StepNavigation/DefaultNavigation/DefaultNavigation.js +36 -52
  45. package/dist/StepNavigation/DefaultNavigation/Step/Step.js +40 -51
  46. package/dist/StepNavigation/DefaultNavigation/Step/Step.styles.js +22 -33
  47. package/dist/StepNavigation/DefaultNavigation/utils.js +38 -30
  48. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.js +24 -41
  49. package/dist/StepNavigation/SimpleNavigation/Dot/Dot.styles.js +13 -16
  50. package/dist/StepNavigation/SimpleNavigation/SimpleNavigation.js +35 -47
  51. package/dist/StepNavigation/SimpleNavigation/utils.js +10 -11
  52. package/dist/StepNavigation/StepNavigation.js +136 -179
  53. package/dist/StepNavigation/StepNavigation.styles.js +29 -32
  54. package/dist/Wizard/Wizard.js +81 -104
  55. package/dist/Wizard/Wizard.styles.js +4 -7
  56. package/dist/Wizard/WizardActions/WizardActions.js +111 -131
  57. package/dist/Wizard/WizardActions/WizardActions.styles.js +19 -20
  58. package/dist/Wizard/WizardContainer/WizardContainer.js +19 -28
  59. package/dist/Wizard/WizardContainer/WizardContainer.styles.js +8 -14
  60. package/dist/Wizard/WizardContent/WizardContent.js +103 -120
  61. package/dist/Wizard/WizardContent/WizardContent.styles.js +33 -36
  62. package/dist/Wizard/WizardContext/WizardContext.js +10 -13
  63. package/dist/Wizard/WizardTitle/WizardTitle.js +74 -79
  64. package/dist/Wizard/WizardTitle/WizardTitle.styles.js +12 -15
  65. package/dist/index.d.ts +1 -1
  66. package/dist/index.js +30 -81
  67. package/package.json +6 -6
  68. package/dist/StepNavigation/utils.js +0 -8
@@ -1,439 +1,374 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { useMemo, useState, useRef, useCallback } from "react";
3
- import { cx, css } from "@emotion/css";
1
+ import { useCallback, useMemo, useRef, useState } from "react";
2
+ import { HvButton, HvCheckBox, HvColorPicker, HvDialogContent, HvDialogTitle, HvIconButton, HvListItem, HvMultiButton, HvSelectionList, theme } from "@hitachivantara/uikit-react-core";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { NodeResizer, NodeToolbar, Position, useReactFlow } from "reactflow";
5
+ import { ActualSize, Bold, Delete, FontSize, Fullscreen, Italic, Palette } from "@hitachivantara/uikit-react-icons";
6
+ import { css, cx } from "@emotion/css";
4
7
  import Popover from "@mui/material/Popover";
5
- import { useReactFlow, NodeResizer, NodeToolbar, Position } from "reactflow";
6
- import { theme, HvDialogTitle, HvDialogContent, HvColorPicker, HvCheckBox, HvButton, HvSelectionList, HvListItem, HvMultiButton, HvIconButton } from "@hitachivantara/uikit-react-core";
7
- import { FontSize, Bold, Italic, Palette, Delete, ActualSize, Fullscreen } from "@hitachivantara/uikit-react-icons";
8
- const defaultData = {
9
- title: "Sticky Note",
10
- backgroundColor: theme.colors.warningSubtle,
11
- borderColor: theme.colors.warningSubtle,
12
- textColor: theme.colors.text,
13
- hasShadow: true,
14
- bold: false,
15
- italic: false,
16
- fontSize: 14,
17
- expanded: true,
18
- visible: true
8
+ //#region src/Flow/nodes/StickyNode.tsx
9
+ var defaultData = {
10
+ title: "Sticky Note",
11
+ backgroundColor: theme.colors.warningSubtle,
12
+ borderColor: theme.colors.warningSubtle,
13
+ textColor: theme.colors.text,
14
+ hasShadow: true,
15
+ bold: false,
16
+ italic: false,
17
+ fontSize: 14,
18
+ expanded: true,
19
+ visible: true
19
20
  };
20
- const classes = {
21
- root: css({
22
- width: "100%",
23
- height: "100%",
24
- position: "relative",
25
- display: "flex",
26
- outline: "none"
27
- }),
28
- nodeToolbar: css({
29
- backgroundColor: "transparent",
30
- borderRadius: theme.radii.full,
31
- top: 10
32
- }),
33
- buttonsContainer: css({
34
- padding: theme.space.xs
35
- }),
36
- textAreaRoot: css({
37
- flex: 1,
38
- width: "100%",
39
- border: "none",
40
- background: "transparent",
41
- outline: "none"
42
- }),
43
- textAreaInput: css({
44
- resize: "none",
45
- height: "100%",
46
- width: "100%",
47
- padding: theme.space.xs,
48
- "&:focus-visible": {
49
- outline: "none"
50
- },
51
- paddingRight: 32
52
- }),
53
- textAreaInputFolded: css({
54
- resize: "none",
55
- width: "100%",
56
- padding: 0,
57
- border: "none",
58
- overflow: "hidden",
59
- minHeight: "1.5rem",
60
- height: "auto"
61
- }),
62
- colorConfig: css({
63
- display: "flex",
64
- flexDirection: "column",
65
- gap: theme.space.sm
66
- }),
67
- folded: css({
68
- width: 34,
69
- height: 34
70
- }),
71
- expandButton: css({
72
- position: "absolute",
73
- top: theme.space.xxs,
74
- right: theme.space.xxs
75
- }),
76
- fontSizes: css({
77
- maxHeight: 160,
78
- overflowY: "auto",
79
- padding: theme.space.xs
80
- })
21
+ var classes = {
22
+ root: css({
23
+ width: "100%",
24
+ height: "100%",
25
+ position: "relative",
26
+ display: "flex",
27
+ outline: "none"
28
+ }),
29
+ nodeToolbar: css({
30
+ backgroundColor: "transparent",
31
+ borderRadius: theme.radii.full,
32
+ top: 10
33
+ }),
34
+ buttonsContainer: css({ padding: theme.space.xs }),
35
+ textAreaRoot: css({
36
+ flex: 1,
37
+ width: "100%",
38
+ border: "none",
39
+ background: "transparent",
40
+ outline: "none"
41
+ }),
42
+ textAreaInput: css({
43
+ resize: "none",
44
+ height: "100%",
45
+ width: "100%",
46
+ padding: theme.space.xs,
47
+ "&:focus-visible": { outline: "none" },
48
+ paddingRight: 32
49
+ }),
50
+ textAreaInputFolded: css({
51
+ resize: "none",
52
+ width: "100%",
53
+ padding: 0,
54
+ border: "none",
55
+ overflow: "hidden",
56
+ minHeight: "1.5rem",
57
+ height: "auto"
58
+ }),
59
+ colorConfig: css({
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ gap: theme.space.sm
63
+ }),
64
+ folded: css({
65
+ width: 34,
66
+ height: 34
67
+ }),
68
+ expandButton: css({
69
+ position: "absolute",
70
+ top: theme.space.xxs,
71
+ right: theme.space.xxs
72
+ }),
73
+ fontSizes: css({
74
+ maxHeight: 160,
75
+ overflowY: "auto",
76
+ padding: theme.space.xs
77
+ })
81
78
  };
82
- const colorsToConfig = ["textColor", "backgroundColor", "borderColor"];
83
- const fontSizes = [10, 11, 12, 14, 16, 20, 24, 32, 36, 40, 48, 64, 96, 128];
84
- const StickyNode = ({
85
- id,
86
- selected,
87
- data = {}
88
- }) => {
89
- const mergedData = useMemo(() => ({ ...defaultData, ...data }), [data]);
90
- const [text, setText] = useState("");
91
- const { setNodes } = useReactFlow();
92
- const [editing, setEditing] = useState(false);
93
- const [toolbarVisible, setToolbarVisible] = useState(false);
94
- const [colorsConfigOpen, setColorsConfigOpen] = useState(false);
95
- const [fontSizeConfigOpen, setFontSizeConfigOpen] = useState(false);
96
- const [fontSize, setFontSize] = useState(mergedData.fontSize ?? 14);
97
- const colorConfigBtnRef = useRef(null);
98
- const fontSizeConfigBtnRef = useRef(null);
99
- const handleToggleBold = useCallback(() => {
100
- setNodes(
101
- (nds) => nds.map((node) => {
102
- if (node.id === id) {
103
- node.data = {
104
- ...node.data,
105
- bold: !node.data?.bold
106
- };
107
- }
108
- return node;
109
- })
110
- );
111
- }, [setNodes, id]);
112
- const handleToggleItalic = useCallback(() => {
113
- setNodes(
114
- (nds) => nds.map((node) => {
115
- if (node.id === id) {
116
- node.data = {
117
- ...node.data,
118
- italic: !node.data?.italic
119
- };
120
- }
121
- return node;
122
- })
123
- );
124
- }, [setNodes, id]);
125
- const handleChangeFontSize = useCallback(
126
- (size) => {
127
- setFontSize(size);
128
- setNodes(
129
- (nds) => nds.map((node) => {
130
- if (node.id === id) {
131
- node.data = {
132
- ...node.data,
133
- fontSize: size
134
- };
135
- }
136
- return node;
137
- })
138
- );
139
- setFontSizeConfigOpen(false);
140
- },
141
- [setNodes, id]
142
- );
143
- const handleToggleExpand = useCallback(() => {
144
- setNodes(
145
- (nds) => nds.map((node) => {
146
- if (node.id === id) {
147
- node.data = {
148
- ...node.data,
149
- expanded: !node.data?.expanded
150
- };
151
- }
152
- return node;
153
- })
154
- );
155
- }, [setNodes, id]);
156
- const handleResetColors = useCallback(() => {
157
- setNodes(
158
- (nds) => nds.map((node) => {
159
- if (node.id === id) {
160
- node.data = {
161
- ...node.data,
162
- backgroundColor: defaultData.backgroundColor,
163
- borderColor: defaultData.borderColor,
164
- textColor: defaultData.textColor,
165
- hasShadow: defaultData.hasShadow
166
- };
167
- }
168
- return node;
169
- })
170
- );
171
- }, [setNodes, id]);
172
- const handleDeleteSticky = useCallback(() => {
173
- setNodes((nds) => nds.filter((node) => node.id !== id));
174
- mergedData.onDelete?.();
175
- }, [mergedData, setNodes, id]);
176
- if (!mergedData.visible) return null;
177
- return /* @__PURE__ */ jsxs(Fragment, { children: [
178
- /* @__PURE__ */ jsxs(
179
- Popover,
180
- {
181
- open: colorsConfigOpen,
182
- anchorEl: colorConfigBtnRef.current,
183
- onClose: () => {
184
- setColorsConfigOpen(false);
185
- setEditing(false);
186
- },
187
- anchorOrigin: {
188
- vertical: "bottom",
189
- horizontal: "left"
190
- },
191
- transformOrigin: {
192
- vertical: "top",
193
- horizontal: "left"
194
- },
195
- children: [
196
- /* @__PURE__ */ jsx(HvDialogTitle, { children: "Customize Colors" }),
197
- /* @__PURE__ */ jsx(HvDialogContent, { children: /* @__PURE__ */ jsxs("div", { className: classes.colorConfig, children: [
198
- colorsToConfig.map((c) => /* @__PURE__ */ jsx(
199
- HvColorPicker,
200
- {
201
- label: `${c.charAt(0).toUpperCase() + c.slice(1).replace("Color", " Color")}`,
202
- value: mergedData[c] ?? "",
203
- onChange: (color) => {
204
- setNodes(
205
- (nds) => nds.map((node) => {
206
- if (node.id === id) {
207
- node.data = {
208
- ...node.data,
209
- [c]: color
210
- };
211
- }
212
- return node;
213
- })
214
- );
215
- }
216
- },
217
- c
218
- )),
219
- /* @__PURE__ */ jsx(
220
- HvCheckBox,
221
- {
222
- label: "Drop Shadow",
223
- defaultChecked: mergedData.hasShadow,
224
- onChange: (_, checked) => {
225
- setNodes(
226
- (nds) => nds.map((node) => {
227
- if (node.id === id) {
228
- node.data = {
229
- ...node.data,
230
- hasShadow: checked
231
- };
232
- }
233
- return node;
234
- })
235
- );
236
- }
237
- }
238
- ),
239
- /* @__PURE__ */ jsx(HvButton, { variant: "secondarySubtle", onClick: handleResetColors, children: "Reset to defaults" })
240
- ] }) })
241
- ]
242
- }
243
- ),
244
- /* @__PURE__ */ jsx(
245
- Popover,
246
- {
247
- open: fontSizeConfigOpen,
248
- anchorEl: fontSizeConfigBtnRef.current,
249
- onClose: () => {
250
- setFontSizeConfigOpen(false);
251
- setEditing(false);
252
- },
253
- anchorOrigin: {
254
- vertical: "bottom",
255
- horizontal: "right"
256
- },
257
- transformOrigin: {
258
- vertical: "top",
259
- horizontal: "right"
260
- },
261
- children: /* @__PURE__ */ jsx(
262
- HvSelectionList,
263
- {
264
- className: classes.fontSizes,
265
- value: fontSize,
266
- onChange: (evt, newValue) => {
267
- handleChangeFontSize(newValue);
268
- },
269
- children: fontSizes.map((size) => /* @__PURE__ */ jsx(HvListItem, { value: size, children: size }, size))
270
- }
271
- )
272
- }
273
- ),
274
- /* @__PURE__ */ jsxs(
275
- "div",
276
- {
277
- className: cx(
278
- classes.root,
279
- "nowheel",
280
- !mergedData.expanded && classes.folded
281
- ),
282
- style: {
283
- backgroundColor: mergedData.backgroundColor ?? theme.colors.bgContainer,
284
- boxShadow: mergedData.hasShadow ? "0 8px 12px rgba(65,65,65,0.25)" : "none",
285
- border: mergedData.borderColor ? `1px solid ${mergedData.borderColor}` : "none",
286
- fontSize: `${mergedData.fontSize ?? 14}px`,
287
- lineHeight: `${mergedData.fontSize ?? 14}px`
288
- },
289
- children: [
290
- mergedData.expanded && /* @__PURE__ */ jsxs(Fragment, { children: [
291
- /* @__PURE__ */ jsx(
292
- NodeResizer,
293
- {
294
- isVisible: selected,
295
- minWidth: 100,
296
- minHeight: 75,
297
- lineStyle: {
298
- color: theme.colors.primary,
299
- borderStyle: "solid"
300
- },
301
- handleStyle: {
302
- width: 6,
303
- height: 6,
304
- border: `1px solid ${theme.colors.primary}`,
305
- backgroundColor: mergedData.backgroundColor ?? "transparent",
306
- borderRadius: theme.radii.full
307
- }
308
- }
309
- ),
310
- /* @__PURE__ */ jsx(
311
- NodeToolbar,
312
- {
313
- isVisible: editing || toolbarVisible || selected,
314
- position: Position.Top,
315
- className: classes.nodeToolbar,
316
- onMouseEnter: () => setToolbarVisible(true),
317
- onMouseLeave: () => setToolbarVisible(false),
318
- children: /* @__PURE__ */ jsx("div", { className: classes.buttonsContainer, children: /* @__PURE__ */ jsxs(HvMultiButton, { children: [
319
- /* @__PURE__ */ jsx(
320
- HvIconButton,
321
- {
322
- "aria-label": "Font Size",
323
- title: "Font Size",
324
- ref: fontSizeConfigBtnRef,
325
- onClick: () => {
326
- setEditing(true);
327
- setFontSizeConfigOpen(true);
328
- },
329
- children: /* @__PURE__ */ jsx(FontSize, {})
330
- }
331
- ),
332
- /* @__PURE__ */ jsx(
333
- HvIconButton,
334
- {
335
- "aria-label": "Bold",
336
- title: "Bold",
337
- selected: mergedData.bold,
338
- onClick: handleToggleBold,
339
- children: /* @__PURE__ */ jsx(Bold, {})
340
- }
341
- ),
342
- /* @__PURE__ */ jsx(
343
- HvIconButton,
344
- {
345
- "aria-label": "Italic",
346
- title: "Italic",
347
- selected: mergedData.italic,
348
- onClick: handleToggleItalic,
349
- children: /* @__PURE__ */ jsx(Italic, {})
350
- }
351
- ),
352
- /* @__PURE__ */ jsx(
353
- HvIconButton,
354
- {
355
- "aria-label": "Customize Colors",
356
- title: "Customize Colors",
357
- ref: colorConfigBtnRef,
358
- onClick: () => {
359
- setEditing(true);
360
- setColorsConfigOpen(true);
361
- },
362
- children: /* @__PURE__ */ jsx(Palette, {})
363
- }
364
- ),
365
- /* @__PURE__ */ jsx(
366
- HvIconButton,
367
- {
368
- "aria-label": "Delete",
369
- title: "Delete",
370
- onClick: handleDeleteSticky,
371
- children: /* @__PURE__ */ jsx(Delete, {})
372
- }
373
- )
374
- ] }) })
375
- }
376
- ),
377
- /* @__PURE__ */ jsxs(
378
- "div",
379
- {
380
- onMouseEnter: () => setToolbarVisible(true),
381
- onMouseLeave: () => setToolbarVisible(false),
382
- className: classes.textAreaRoot,
383
- children: [
384
- /* @__PURE__ */ jsx(
385
- HvIconButton,
386
- {
387
- className: classes.expandButton,
388
- title: "Fold",
389
- onClick: handleToggleExpand,
390
- children: /* @__PURE__ */ jsx(ActualSize, {})
391
- }
392
- ),
393
- /* @__PURE__ */ jsx(
394
- "textarea",
395
- {
396
- id: `sticky-textarea-${id}`,
397
- value: text || "",
398
- onChange: (e) => setText(e.target.value),
399
- className: classes.textAreaInput,
400
- placeholder: "Type here...",
401
- style: {
402
- color: mergedData.textColor ?? theme.colors.text,
403
- fontWeight: mergedData.bold ? "bold" : "normal",
404
- fontStyle: mergedData.italic ? "italic" : "normal",
405
- fontSize: mergedData.fontSize ?? "14px"
406
- },
407
- onFocus: () => setEditing(true),
408
- onBlur: () => {
409
- setEditing(false);
410
- setColorsConfigOpen(false);
411
- }
412
- }
413
- )
414
- ]
415
- }
416
- )
417
- ] }),
418
- !mergedData.expanded && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
419
- HvIconButton,
420
- {
421
- title: /* @__PURE__ */ jsx(
422
- "span",
423
- {
424
- style: { whiteSpace: "pre-wrap", wordBreak: "break-word" },
425
- children: text
426
- }
427
- ),
428
- onClick: handleToggleExpand,
429
- children: /* @__PURE__ */ jsx(Fullscreen, {})
430
- }
431
- ) })
432
- ]
433
- }
434
- )
435
- ] });
436
- };
437
- export {
438
- StickyNode
79
+ var colorsToConfig = [
80
+ "textColor",
81
+ "backgroundColor",
82
+ "borderColor"
83
+ ];
84
+ var fontSizes = [
85
+ 10,
86
+ 11,
87
+ 12,
88
+ 14,
89
+ 16,
90
+ 20,
91
+ 24,
92
+ 32,
93
+ 36,
94
+ 40,
95
+ 48,
96
+ 64,
97
+ 96,
98
+ 128
99
+ ];
100
+ var StickyNode = ({ id, selected, data = {} }) => {
101
+ const mergedData = useMemo(() => ({
102
+ ...defaultData,
103
+ ...data
104
+ }), [data]);
105
+ const [text, setText] = useState("");
106
+ const { setNodes } = useReactFlow();
107
+ const [editing, setEditing] = useState(false);
108
+ const [toolbarVisible, setToolbarVisible] = useState(false);
109
+ const [colorsConfigOpen, setColorsConfigOpen] = useState(false);
110
+ const [fontSizeConfigOpen, setFontSizeConfigOpen] = useState(false);
111
+ const [fontSize, setFontSize] = useState(mergedData.fontSize ?? 14);
112
+ const colorConfigBtnRef = useRef(null);
113
+ const fontSizeConfigBtnRef = useRef(null);
114
+ const handleToggleBold = useCallback(() => {
115
+ setNodes((nds) => nds.map((node) => {
116
+ if (node.id === id) node.data = {
117
+ ...node.data,
118
+ bold: !node.data?.bold
119
+ };
120
+ return node;
121
+ }));
122
+ }, [setNodes, id]);
123
+ const handleToggleItalic = useCallback(() => {
124
+ setNodes((nds) => nds.map((node) => {
125
+ if (node.id === id) node.data = {
126
+ ...node.data,
127
+ italic: !node.data?.italic
128
+ };
129
+ return node;
130
+ }));
131
+ }, [setNodes, id]);
132
+ const handleChangeFontSize = useCallback((size) => {
133
+ setFontSize(size);
134
+ setNodes((nds) => nds.map((node) => {
135
+ if (node.id === id) node.data = {
136
+ ...node.data,
137
+ fontSize: size
138
+ };
139
+ return node;
140
+ }));
141
+ setFontSizeConfigOpen(false);
142
+ }, [setNodes, id]);
143
+ const handleToggleExpand = useCallback(() => {
144
+ setNodes((nds) => nds.map((node) => {
145
+ if (node.id === id) node.data = {
146
+ ...node.data,
147
+ expanded: !node.data?.expanded
148
+ };
149
+ return node;
150
+ }));
151
+ }, [setNodes, id]);
152
+ const handleResetColors = useCallback(() => {
153
+ setNodes((nds) => nds.map((node) => {
154
+ if (node.id === id) node.data = {
155
+ ...node.data,
156
+ backgroundColor: defaultData.backgroundColor,
157
+ borderColor: defaultData.borderColor,
158
+ textColor: defaultData.textColor,
159
+ hasShadow: defaultData.hasShadow
160
+ };
161
+ return node;
162
+ }));
163
+ }, [setNodes, id]);
164
+ const handleDeleteSticky = useCallback(() => {
165
+ setNodes((nds) => nds.filter((node) => node.id !== id));
166
+ mergedData.onDelete?.();
167
+ }, [
168
+ mergedData,
169
+ setNodes,
170
+ id
171
+ ]);
172
+ if (!mergedData.visible) return null;
173
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
174
+ /* @__PURE__ */ jsxs(Popover, {
175
+ open: colorsConfigOpen,
176
+ anchorEl: colorConfigBtnRef.current,
177
+ onClose: () => {
178
+ setColorsConfigOpen(false);
179
+ setEditing(false);
180
+ },
181
+ anchorOrigin: {
182
+ vertical: "bottom",
183
+ horizontal: "left"
184
+ },
185
+ transformOrigin: {
186
+ vertical: "top",
187
+ horizontal: "left"
188
+ },
189
+ children: [/* @__PURE__ */ jsx(HvDialogTitle, { children: "Customize Colors" }), /* @__PURE__ */ jsx(HvDialogContent, { children: /* @__PURE__ */ jsxs("div", {
190
+ className: classes.colorConfig,
191
+ children: [
192
+ colorsToConfig.map((c) => /* @__PURE__ */ jsx(HvColorPicker, {
193
+ label: `${c.charAt(0).toUpperCase() + c.slice(1).replace("Color", " Color")}`,
194
+ value: mergedData[c] ?? "",
195
+ onChange: (color) => {
196
+ setNodes((nds) => nds.map((node) => {
197
+ if (node.id === id) node.data = {
198
+ ...node.data,
199
+ [c]: color
200
+ };
201
+ return node;
202
+ }));
203
+ }
204
+ }, c)),
205
+ /* @__PURE__ */ jsx(HvCheckBox, {
206
+ label: "Drop Shadow",
207
+ defaultChecked: mergedData.hasShadow,
208
+ onChange: (_, checked) => {
209
+ setNodes((nds) => nds.map((node) => {
210
+ if (node.id === id) node.data = {
211
+ ...node.data,
212
+ hasShadow: checked
213
+ };
214
+ return node;
215
+ }));
216
+ }
217
+ }),
218
+ /* @__PURE__ */ jsx(HvButton, {
219
+ variant: "secondarySubtle",
220
+ onClick: handleResetColors,
221
+ children: "Reset to defaults"
222
+ })
223
+ ]
224
+ }) })]
225
+ }),
226
+ /* @__PURE__ */ jsx(Popover, {
227
+ open: fontSizeConfigOpen,
228
+ anchorEl: fontSizeConfigBtnRef.current,
229
+ onClose: () => {
230
+ setFontSizeConfigOpen(false);
231
+ setEditing(false);
232
+ },
233
+ anchorOrigin: {
234
+ vertical: "bottom",
235
+ horizontal: "right"
236
+ },
237
+ transformOrigin: {
238
+ vertical: "top",
239
+ horizontal: "right"
240
+ },
241
+ children: /* @__PURE__ */ jsx(HvSelectionList, {
242
+ className: classes.fontSizes,
243
+ value: fontSize,
244
+ onChange: (evt, newValue) => {
245
+ handleChangeFontSize(newValue);
246
+ },
247
+ children: fontSizes.map((size) => /* @__PURE__ */ jsx(HvListItem, {
248
+ value: size,
249
+ children: size
250
+ }, size))
251
+ })
252
+ }),
253
+ /* @__PURE__ */ jsxs("div", {
254
+ className: cx(classes.root, "nowheel", !mergedData.expanded && classes.folded),
255
+ style: {
256
+ backgroundColor: mergedData.backgroundColor ?? theme.colors.bgContainer,
257
+ boxShadow: mergedData.hasShadow ? "0 8px 12px rgba(65,65,65,0.25)" : "none",
258
+ border: mergedData.borderColor ? `1px solid ${mergedData.borderColor}` : "none",
259
+ fontSize: `${mergedData.fontSize ?? 14}px`,
260
+ lineHeight: `${mergedData.fontSize ?? 14}px`
261
+ },
262
+ children: [mergedData.expanded && /* @__PURE__ */ jsxs(Fragment, { children: [
263
+ /* @__PURE__ */ jsx(NodeResizer, {
264
+ isVisible: selected,
265
+ minWidth: 100,
266
+ minHeight: 75,
267
+ lineStyle: {
268
+ color: theme.colors.primary,
269
+ borderStyle: "solid"
270
+ },
271
+ handleStyle: {
272
+ width: 6,
273
+ height: 6,
274
+ border: `1px solid ${theme.colors.primary}`,
275
+ backgroundColor: mergedData.backgroundColor ?? "transparent",
276
+ borderRadius: theme.radii.full
277
+ }
278
+ }),
279
+ /* @__PURE__ */ jsx(NodeToolbar, {
280
+ isVisible: editing || toolbarVisible || selected,
281
+ position: Position.Top,
282
+ className: classes.nodeToolbar,
283
+ onMouseEnter: () => setToolbarVisible(true),
284
+ onMouseLeave: () => setToolbarVisible(false),
285
+ children: /* @__PURE__ */ jsx("div", {
286
+ className: classes.buttonsContainer,
287
+ children: /* @__PURE__ */ jsxs(HvMultiButton, { children: [
288
+ /* @__PURE__ */ jsx(HvIconButton, {
289
+ "aria-label": "Font Size",
290
+ title: "Font Size",
291
+ ref: fontSizeConfigBtnRef,
292
+ onClick: () => {
293
+ setEditing(true);
294
+ setFontSizeConfigOpen(true);
295
+ },
296
+ children: /* @__PURE__ */ jsx(FontSize, {})
297
+ }),
298
+ /* @__PURE__ */ jsx(HvIconButton, {
299
+ "aria-label": "Bold",
300
+ title: "Bold",
301
+ selected: mergedData.bold,
302
+ onClick: handleToggleBold,
303
+ children: /* @__PURE__ */ jsx(Bold, {})
304
+ }),
305
+ /* @__PURE__ */ jsx(HvIconButton, {
306
+ "aria-label": "Italic",
307
+ title: "Italic",
308
+ selected: mergedData.italic,
309
+ onClick: handleToggleItalic,
310
+ children: /* @__PURE__ */ jsx(Italic, {})
311
+ }),
312
+ /* @__PURE__ */ jsx(HvIconButton, {
313
+ "aria-label": "Customize Colors",
314
+ title: "Customize Colors",
315
+ ref: colorConfigBtnRef,
316
+ onClick: () => {
317
+ setEditing(true);
318
+ setColorsConfigOpen(true);
319
+ },
320
+ children: /* @__PURE__ */ jsx(Palette, {})
321
+ }),
322
+ /* @__PURE__ */ jsx(HvIconButton, {
323
+ "aria-label": "Delete",
324
+ title: "Delete",
325
+ onClick: handleDeleteSticky,
326
+ children: /* @__PURE__ */ jsx(Delete, {})
327
+ })
328
+ ] })
329
+ })
330
+ }),
331
+ /* @__PURE__ */ jsxs("div", {
332
+ onMouseEnter: () => setToolbarVisible(true),
333
+ onMouseLeave: () => setToolbarVisible(false),
334
+ className: classes.textAreaRoot,
335
+ children: [/* @__PURE__ */ jsx(HvIconButton, {
336
+ className: classes.expandButton,
337
+ title: "Fold",
338
+ onClick: handleToggleExpand,
339
+ children: /* @__PURE__ */ jsx(ActualSize, {})
340
+ }), /* @__PURE__ */ jsx("textarea", {
341
+ id: `sticky-textarea-${id}`,
342
+ value: text || "",
343
+ onChange: (e) => setText(e.target.value),
344
+ className: classes.textAreaInput,
345
+ placeholder: "Type here...",
346
+ style: {
347
+ color: mergedData.textColor ?? theme.colors.text,
348
+ fontWeight: mergedData.bold ? "bold" : "normal",
349
+ fontStyle: mergedData.italic ? "italic" : "normal",
350
+ fontSize: mergedData.fontSize ?? "14px"
351
+ },
352
+ onFocus: () => setEditing(true),
353
+ onBlur: () => {
354
+ setEditing(false);
355
+ setColorsConfigOpen(false);
356
+ }
357
+ })]
358
+ })
359
+ ] }), !mergedData.expanded && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(HvIconButton, {
360
+ title: /* @__PURE__ */ jsx("span", {
361
+ style: {
362
+ whiteSpace: "pre-wrap",
363
+ wordBreak: "break-word"
364
+ },
365
+ children: text
366
+ }),
367
+ onClick: handleToggleExpand,
368
+ children: /* @__PURE__ */ jsx(Fullscreen, {})
369
+ }) })]
370
+ })
371
+ ] });
439
372
  };
373
+ //#endregion
374
+ export { StickyNode };