@capillarytech/blaze-ui 6.1.5 → 6.1.6-beta.3

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 (102) hide show
  1. package/CapEmojiPicker/Picker/index.d.ts +6 -0
  2. package/CapEmojiPicker/Picker/index.d.ts.map +1 -0
  3. package/CapEmojiPicker/Picker/index.js +114 -0
  4. package/CapEmojiPicker/Picker/messages.d.ts +21 -0
  5. package/CapEmojiPicker/Picker/messages.d.ts.map +1 -0
  6. package/CapEmojiPicker/Picker/messages.js +24 -0
  7. package/CapEmojiPicker/TriggerButton/_triggerButton.scss +45 -0
  8. package/CapEmojiPicker/TriggerButton/index.d.ts +9 -0
  9. package/CapEmojiPicker/TriggerButton/index.d.ts.map +1 -0
  10. package/CapEmojiPicker/TriggerButton/index.js +35 -0
  11. package/CapEmojiPicker/Wrapper/index.d.ts +4 -0
  12. package/CapEmojiPicker/Wrapper/index.d.ts.map +1 -0
  13. package/CapEmojiPicker/Wrapper/index.js +166 -0
  14. package/CapEmojiPicker/Wrapper/messages.d.ts +13 -0
  15. package/CapEmojiPicker/Wrapper/messages.d.ts.map +1 -0
  16. package/CapEmojiPicker/Wrapper/messages.js +16 -0
  17. package/CapEmojiPicker/Wrapper/useEmojiTriggerPosition.d.ts +18 -0
  18. package/CapEmojiPicker/Wrapper/useEmojiTriggerPosition.d.ts.map +1 -0
  19. package/CapEmojiPicker/Wrapper/useEmojiTriggerPosition.js +108 -0
  20. package/CapEmojiPicker/_capEmojiPicker.css +231 -0
  21. package/CapEmojiPicker/_capEmojiPicker.scss +281 -0
  22. package/CapEmojiPicker/_config.scss +7 -0
  23. package/CapEmojiPicker/assets/sentiment-satsified.svg +3 -0
  24. package/CapEmojiPicker/assets/sentiment-satsified.svg.js +4 -0
  25. package/CapEmojiPicker/constants.d.ts +34 -0
  26. package/CapEmojiPicker/constants.d.ts.map +1 -0
  27. package/CapEmojiPicker/constants.js +18 -0
  28. package/CapEmojiPicker/index.d.ts +4 -0
  29. package/CapEmojiPicker/index.d.ts.map +1 -0
  30. package/CapEmojiPicker/index.js +11 -0
  31. package/CapEmojiPicker/utils.d.ts +20 -0
  32. package/CapEmojiPicker/utils.d.ts.map +1 -0
  33. package/CapEmojiPicker/utils.js +24 -0
  34. package/CapNavigationSPA/CapNavigationSPASidebar/index.d.ts +10 -0
  35. package/CapNavigationSPA/CapNavigationSPASidebar/index.d.ts.map +1 -0
  36. package/CapNavigationSPA/CapNavigationSPASidebar/index.js +603 -0
  37. package/CapNavigationSPA/CapNavigationSPASidebar/styles.css +350 -0
  38. package/CapNavigationSPA/CapNavigationSPASidebar/styles.module.scss.js +59 -0
  39. package/CapNavigationSPA/CapNavigationSPASidebar/styles.scss +422 -0
  40. package/CapNavigationSPA/CapNavigationSPASidebar/types.d.ts +31 -0
  41. package/CapNavigationSPA/CapNavigationSPASidebar/types.d.ts.map +1 -0
  42. package/CapNavigationSPA/CapNavigationSPASidebar/types.js +1 -0
  43. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts +11 -0
  44. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts.map +1 -0
  45. package/CapNavigationSPA/CapNavigationSPATopBar/index.js +95 -0
  46. package/CapNavigationSPA/CapNavigationSPATopBar/styles.css +147 -0
  47. package/CapNavigationSPA/CapNavigationSPATopBar/styles.module.scss.js +18 -0
  48. package/CapNavigationSPA/CapNavigationSPATopBar/styles.scss +173 -0
  49. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts +24 -0
  50. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts.map +1 -0
  51. package/CapNavigationSPA/CapNavigationSPATopBar/types.js +1 -0
  52. package/CapNavigationSPA/constants.d.ts +2 -0
  53. package/CapNavigationSPA/constants.d.ts.map +1 -0
  54. package/CapNavigationSPA/constants.js +4 -0
  55. package/CapNavigationSPA/index.d.ts +10 -0
  56. package/CapNavigationSPA/index.d.ts.map +1 -0
  57. package/CapNavigationSPA/index.js +436 -0
  58. package/CapNavigationSPA/messages.d.ts +13 -0
  59. package/CapNavigationSPA/messages.d.ts.map +1 -0
  60. package/CapNavigationSPA/messages.js +16 -0
  61. package/CapNavigationSPA/mockdata.d.ts +6 -0
  62. package/CapNavigationSPA/mockdata.d.ts.map +1 -0
  63. package/CapNavigationSPA/mockdata.js +4 -0
  64. package/CapNavigationSPA/styles.css +48 -0
  65. package/CapNavigationSPA/styles.module.scss.js +9 -0
  66. package/CapNavigationSPA/styles.scss +49 -0
  67. package/CapNavigationSPA/tests/CapNavigationSPA.mockData.d.ts +31 -0
  68. package/CapNavigationSPA/tests/CapNavigationSPA.mockData.d.ts.map +1 -0
  69. package/CapNavigationSPA/types.d.ts +39 -0
  70. package/CapNavigationSPA/types.d.ts.map +1 -0
  71. package/CapNavigationSPA/types.js +1 -0
  72. package/assets/icons/blocks.svg +9 -0
  73. package/assets/icons/closed-lock.svg +1 -0
  74. package/assets/icons/csv.svg +21 -0
  75. package/assets/icons/databricks.svg +7 -0
  76. package/assets/icons/four-join.svg +19 -0
  77. package/assets/icons/http.svg +18 -0
  78. package/assets/icons/kafka.svg +9 -0
  79. package/assets/icons/open-lock.svg +1 -0
  80. package/assets/icons/s3.svg +3 -0
  81. package/assets/icons/sftp.svg +32 -0
  82. package/assets/icons/split-json.svg +9 -0
  83. package/assets/icons/three-join.svg +17 -0
  84. package/assets/icons/two-join.svg +15 -0
  85. package/assets/icons/xml.svg +12 -0
  86. package/assets/svgIcons/Icons/AiraNav.js +23 -0
  87. package/assets/svgIcons/Icons/CreativesNav.js +22 -0
  88. package/assets/svgIcons/Icons/DataManagement.js +22 -0
  89. package/assets/svgIcons/Icons/EngageNav.js +23 -0
  90. package/assets/svgIcons/Icons/InsightsNav.js +22 -0
  91. package/assets/svgIcons/Icons/LoyaltyTag.js +22 -0
  92. package/assets/svgIcons/Icons/Members.js +22 -0
  93. package/assets/svgIcons/Icons/RewardsOutline.js +4 -6
  94. package/assets/svgIcons/Icons/SidebarCollapse.js +17 -0
  95. package/assets/svgIcons/Icons/SidebarExpand.js +22 -0
  96. package/assets/svgIcons/Icons/ThreeStars.js +36 -18
  97. package/assets/svgIcons/component.js +27 -0
  98. package/assets/svgIcons/index.js +612 -594
  99. package/index.d.ts +2 -0
  100. package/index.d.ts.map +1 -1
  101. package/index.js +195 -193
  102. package/package.json +2 -1
@@ -0,0 +1,603 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ import { useRef, useState, useCallback, useEffect, useLayoutEffect } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import CapIcon from "../../CapIcon/index.js";
6
+ import styles from "./styles.module.scss.js";
7
+ const SIDEBAR_DIVIDER_BEFORE_KEY = "data-management";
8
+ const DEFAULT_ICON_MAP = {
9
+ loyalty: "loyalty-tag",
10
+ // Figma 583:6938 – heart inside tag
11
+ engage: "engage-nav",
12
+ // Figma 646-59790 – megaphone with settings
13
+ rewards: "rewards-outline",
14
+ insights: "insights-nav",
15
+ // Figma 646-59984 – bar chart in frame
16
+ aira: "aira-nav",
17
+ // Figma 646-59790 – three sparkles, stroke icon
18
+ members: "members",
19
+ audiences: "groups",
20
+ creatives: "creatives-nav",
21
+ // Figma 646-59984 – document with pen
22
+ "data-management": "data-management",
23
+ extensions: "code",
24
+ settings: "settings"
25
+ };
26
+ const CapNavigationSPASidebar = ({
27
+ items,
28
+ selectedKey = "",
29
+ onItemClick,
30
+ settingsLabel = "Settings",
31
+ logo,
32
+ className,
33
+ collapsed = false,
34
+ onCollapseExpand,
35
+ navigateToLink = true
36
+ }) => {
37
+ const wrapperRef = useRef(null);
38
+ const flyoutAnchorRef = useRef(null);
39
+ const closeFlyoutTimeoutRef = useRef(null);
40
+ const [hoverExpandedKey, setHoverExpandedKey] = useState(null);
41
+ const [flyoutAnchorRect, setFlyoutAnchorRect] = useState(null);
42
+ const [clickExpandedKey, setClickExpandedKey] = useState(null);
43
+ const [hoverL1TooltipKey, setHoverL1TooltipKey] = useState(null);
44
+ const [showExpandTooltip, setShowExpandTooltip] = useState(false);
45
+ const expandBtnRef = useRef(null);
46
+ const transitioningRef = useRef(false);
47
+ const pendingExpandKeyRef = useRef(null);
48
+ const expandedParentKey = clickExpandedKey ?? hoverExpandedKey;
49
+ const closeFlyout = useCallback(() => {
50
+ if (closeFlyoutTimeoutRef.current) {
51
+ clearTimeout(closeFlyoutTimeoutRef.current);
52
+ closeFlyoutTimeoutRef.current = null;
53
+ }
54
+ setHoverExpandedKey(null);
55
+ setClickExpandedKey(null);
56
+ setHoverL1TooltipKey(null);
57
+ }, []);
58
+ const scheduleCloseFlyout = useCallback(() => {
59
+ if (closeFlyoutTimeoutRef.current) clearTimeout(closeFlyoutTimeoutRef.current);
60
+ closeFlyoutTimeoutRef.current = setTimeout(() => {
61
+ closeFlyoutTimeoutRef.current = null;
62
+ setHoverExpandedKey(null);
63
+ setHoverL1TooltipKey(null);
64
+ }, 150);
65
+ }, []);
66
+ const cancelCloseFlyout = useCallback(() => {
67
+ if (closeFlyoutTimeoutRef.current) {
68
+ clearTimeout(closeFlyoutTimeoutRef.current);
69
+ closeFlyoutTimeoutRef.current = null;
70
+ }
71
+ }, []);
72
+ useEffect(() => {
73
+ if (closeFlyoutTimeoutRef.current) {
74
+ clearTimeout(closeFlyoutTimeoutRef.current);
75
+ closeFlyoutTimeoutRef.current = null;
76
+ }
77
+ setHoverExpandedKey(null);
78
+ setHoverL1TooltipKey(null);
79
+ setFlyoutAnchorRect(null);
80
+ setShowExpandTooltip(false);
81
+ const pendingKey = pendingExpandKeyRef.current;
82
+ pendingExpandKeyRef.current = null;
83
+ if (!collapsed && pendingKey) {
84
+ setClickExpandedKey(pendingKey);
85
+ } else {
86
+ setClickExpandedKey(null);
87
+ }
88
+ transitioningRef.current = true;
89
+ const tid = setTimeout(() => {
90
+ transitioningRef.current = false;
91
+ }, 250);
92
+ return () => clearTimeout(tid);
93
+ }, [collapsed]);
94
+ useLayoutEffect(() => {
95
+ if (!hoverExpandedKey && !hoverL1TooltipKey) {
96
+ setFlyoutAnchorRect(null);
97
+ return;
98
+ }
99
+ const el = flyoutAnchorRef.current;
100
+ if (!el) return;
101
+ setFlyoutAnchorRect(el.getBoundingClientRect());
102
+ }, [hoverExpandedKey, hoverL1TooltipKey, collapsed]);
103
+ const getExpandTooltipPos = useCallback(() => {
104
+ const btnEl = expandBtnRef.current;
105
+ const sidebarEl = wrapperRef.current;
106
+ if (!btnEl || !sidebarEl) return null;
107
+ const btnRect = btnEl.getBoundingClientRect();
108
+ const sidebarRect = sidebarEl.getBoundingClientRect();
109
+ return {
110
+ top: btnRect.top,
111
+ height: btnRect.height,
112
+ right: sidebarRect.right
113
+ };
114
+ }, []);
115
+ const handleClick = useCallback(
116
+ (item) => {
117
+ if (navigateToLink && item.link && item.link !== window.location.pathname) {
118
+ window.location.pathname = item.link;
119
+ }
120
+ onItemClick == null ? void 0 : onItemClick(item);
121
+ },
122
+ [navigateToLink, onItemClick]
123
+ );
124
+ const toggleParentExpanded = useCallback(
125
+ (parentKey) => {
126
+ if (expandedParentKey === parentKey) {
127
+ closeFlyout();
128
+ } else {
129
+ setHoverExpandedKey(null);
130
+ setClickExpandedKey(parentKey);
131
+ }
132
+ },
133
+ [expandedParentKey, closeFlyout]
134
+ );
135
+ const handleItemClick = useCallback(
136
+ (item) => {
137
+ var _a, _b;
138
+ if (collapsed) {
139
+ if ((_a = item.children) == null ? void 0 : _a.length) {
140
+ pendingExpandKeyRef.current = item.key;
141
+ if (onCollapseExpand) onCollapseExpand();
142
+ setHoverExpandedKey(null);
143
+ } else {
144
+ closeFlyout();
145
+ handleClick(item);
146
+ }
147
+ return;
148
+ }
149
+ if ((_b = item.children) == null ? void 0 : _b.length) {
150
+ toggleParentExpanded(item.key);
151
+ } else {
152
+ closeFlyout();
153
+ handleClick(item);
154
+ onCollapseExpand == null ? void 0 : onCollapseExpand();
155
+ }
156
+ },
157
+ [collapsed, onCollapseExpand, toggleParentExpanded, closeFlyout, handleClick]
158
+ );
159
+ const getIconType = (item) => item.iconType ?? DEFAULT_ICON_MAP[item.key] ?? void 0;
160
+ const handleWrapperMouseLeave = useCallback(() => {
161
+ scheduleCloseFlyout();
162
+ }, [scheduleCloseFlyout]);
163
+ return /* @__PURE__ */ jsxs(
164
+ "div",
165
+ {
166
+ ref: wrapperRef,
167
+ className: styles["cap-navigation-spa-sidebar__wrapper"],
168
+ onMouseLeave: handleWrapperMouseLeave,
169
+ children: [
170
+ /* @__PURE__ */ jsxs(
171
+ "aside",
172
+ {
173
+ className: classNames(
174
+ styles["cap-navigation-spa-sidebar"],
175
+ collapsed && styles["cap-navigation-spa-sidebar--collapsed"],
176
+ className
177
+ ),
178
+ "data-testid": "cap-navigation-spa-sidebar",
179
+ children: [
180
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__logo"], children: logo !== void 0 ? logo : /* @__PURE__ */ jsxs(Fragment, { children: [
181
+ /* @__PURE__ */ jsx(
182
+ CapIcon,
183
+ {
184
+ type: "capillary",
185
+ size: "s",
186
+ className: styles["cap-navigation-spa-sidebar__logo-icon"]
187
+ }
188
+ ),
189
+ !collapsed && /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__logo-text"], children: "capillary" })
190
+ ] }) }),
191
+ /* @__PURE__ */ jsx("nav", { className: styles["cap-navigation-spa-sidebar__nav"], children: items.flatMap((item) => {
192
+ var _a, _b, _c, _d, _e;
193
+ const isExpandedWithChildren = !collapsed && ((_a = item.children) == null ? void 0 : _a.length) && expandedParentKey === item.key;
194
+ const parentButton = /* @__PURE__ */ jsxs(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ className: classNames(
199
+ styles["cap-navigation-spa-sidebar__item"],
200
+ expandedParentKey === item.key && styles["cap-navigation-spa-sidebar__item--expanded"],
201
+ expandedParentKey === item.key && item.key === "loyalty" && styles["cap-navigation-spa-sidebar__item--expanded-loyalty"],
202
+ expandedParentKey === item.key && item.key === "engage" && styles["cap-navigation-spa-sidebar__item--expanded-engage"],
203
+ expandedParentKey === item.key && item.key === "insights" && styles["cap-navigation-spa-sidebar__item--expanded-insights"],
204
+ expandedParentKey === item.key && item.key === "members" && styles["cap-navigation-spa-sidebar__item--expanded-members"],
205
+ expandedParentKey === item.key && item.key === "rewards" && styles["cap-navigation-spa-sidebar__item--expanded-rewards"],
206
+ expandedParentKey === item.key && item.key === "audiences" && styles["cap-navigation-spa-sidebar__item--expanded-audiences"],
207
+ expandedParentKey === item.key && item.key === "data-management" && styles["cap-navigation-spa-sidebar__item--expanded-data-management"],
208
+ expandedParentKey === item.key && item.key === "extensions" && styles["cap-navigation-spa-sidebar__item--expanded-extensions"],
209
+ expandedParentKey === item.key && item.key === "settings" && styles["cap-navigation-spa-sidebar__item--expanded-settings"]
210
+ ),
211
+ onClick: () => handleItemClick(item),
212
+ onMouseEnter: () => {
213
+ var _a2;
214
+ if (transitioningRef.current) return;
215
+ cancelCloseFlyout();
216
+ if ((_a2 = item.children) == null ? void 0 : _a2.length) {
217
+ if (collapsed) {
218
+ setHoverExpandedKey(item.key);
219
+ }
220
+ setHoverL1TooltipKey(null);
221
+ } else if (collapsed) {
222
+ setHoverExpandedKey(null);
223
+ setHoverL1TooltipKey(item.key);
224
+ }
225
+ },
226
+ "data-testid": `cap-navigation-spa-sidebar-item-${item.key}`,
227
+ children: [
228
+ /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-icon"], children: getIconType(item) ? /* @__PURE__ */ jsx(CapIcon, { type: getIconType(item), size: "s" }) : /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-dot"] }) }),
229
+ !collapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
230
+ /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-label"], children: item.title }),
231
+ ((_b = item.children) == null ? void 0 : _b.length) ? /* @__PURE__ */ jsx(
232
+ CapIcon,
233
+ {
234
+ type: expandedParentKey === item.key ? "chevron-down" : "chevron-right",
235
+ size: "s",
236
+ className: styles["cap-navigation-spa-sidebar__item-chevron"]
237
+ }
238
+ ) : null
239
+ ] })
240
+ ]
241
+ },
242
+ item.key
243
+ );
244
+ const showCollapsedFlyout = collapsed && ((_c = item.children) == null ? void 0 : _c.length) && expandedParentKey === item.key;
245
+ const showL1TooltipFlyout = collapsed && !((_d = item.children) == null ? void 0 : _d.length) && hoverL1TooltipKey === item.key;
246
+ const l2Inline = isExpandedWithChildren ? /* @__PURE__ */ jsxs(
247
+ "div",
248
+ {
249
+ className: styles["cap-navigation-spa-sidebar__l2-wrapper"],
250
+ children: [
251
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-divider"], "aria-hidden": true }),
252
+ /* @__PURE__ */ jsx(
253
+ "div",
254
+ {
255
+ className: styles["cap-navigation-spa-sidebar__l2-inline"],
256
+ onMouseEnter: () => setHoverExpandedKey(item.key),
257
+ "data-testid": `cap-navigation-spa-sidebar-l2-${item.key}`,
258
+ children: item.children.map((child) => /* @__PURE__ */ jsx(
259
+ "button",
260
+ {
261
+ type: "button",
262
+ className: classNames(
263
+ styles["cap-navigation-spa-sidebar__l2-inline-item"],
264
+ selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected"],
265
+ item.key === "loyalty" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-loyalty"],
266
+ item.key === "engage" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-engage"],
267
+ item.key === "insights" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-insights"],
268
+ item.key === "members" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-members"],
269
+ item.key === "rewards" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-rewards"],
270
+ item.key === "audiences" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-audiences"],
271
+ item.key === "data-management" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-data-management"],
272
+ item.key === "extensions" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-extensions"],
273
+ item.key === "settings" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-settings"]
274
+ ),
275
+ onClick: () => {
276
+ closeFlyout();
277
+ handleClick(child);
278
+ onCollapseExpand == null ? void 0 : onCollapseExpand();
279
+ },
280
+ "data-testid": `cap-navigation-spa-sidebar-l2-item-${child.key}`,
281
+ children: child.title
282
+ },
283
+ child.key
284
+ ))
285
+ },
286
+ `${item.key}-l2`
287
+ )
288
+ ]
289
+ },
290
+ `${item.key}-l2-wrapper`
291
+ ) : null;
292
+ const collapsedFlyout = showCollapsedFlyout ? /* @__PURE__ */ jsxs(
293
+ "div",
294
+ {
295
+ className: styles["cap-navigation-spa-sidebar__l2-flyout"],
296
+ onMouseEnter: () => {
297
+ cancelCloseFlyout();
298
+ setHoverExpandedKey(item.key);
299
+ },
300
+ onMouseLeave: scheduleCloseFlyout,
301
+ "data-testid": `cap-navigation-spa-sidebar-l2-flyout-${item.key}`,
302
+ role: "menu",
303
+ "aria-label": item.title,
304
+ children: [
305
+ /* @__PURE__ */ jsx(
306
+ "div",
307
+ {
308
+ className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
309
+ "aria-hidden": true
310
+ }
311
+ ),
312
+ /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-card"], children: [
313
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-parent"], children: item.title }),
314
+ item.children.map((child) => /* @__PURE__ */ jsx(
315
+ "button",
316
+ {
317
+ type: "button",
318
+ className: classNames(
319
+ styles["cap-navigation-spa-sidebar__l2-flyout-item"],
320
+ selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-flyout-item--selected"]
321
+ ),
322
+ onClick: () => {
323
+ setClickExpandedKey(item.key);
324
+ if (collapsed && onCollapseExpand) {
325
+ onCollapseExpand();
326
+ }
327
+ handleClick(child);
328
+ },
329
+ "data-testid": `cap-navigation-spa-sidebar-l2-flyout-item-${child.key}`,
330
+ role: "menuitem",
331
+ children: child.title
332
+ },
333
+ child.key
334
+ ))
335
+ ] })
336
+ ]
337
+ },
338
+ `${item.key}-l2-flyout`
339
+ ) : null;
340
+ const l1TooltipFlyout = showL1TooltipFlyout ? /* @__PURE__ */ jsxs(
341
+ "div",
342
+ {
343
+ className: styles["cap-navigation-spa-sidebar__l1-tooltip-flyout"],
344
+ onMouseEnter: () => {
345
+ cancelCloseFlyout();
346
+ setHoverL1TooltipKey(item.key);
347
+ },
348
+ onMouseLeave: scheduleCloseFlyout,
349
+ "data-testid": `cap-navigation-spa-sidebar-l1-tooltip-${item.key}`,
350
+ role: "tooltip",
351
+ "aria-label": item.title,
352
+ children: [
353
+ /* @__PURE__ */ jsx(
354
+ "div",
355
+ {
356
+ className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
357
+ "aria-hidden": true
358
+ }
359
+ ),
360
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-card"], children: /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-label"], children: item.title }) })
361
+ ]
362
+ },
363
+ `${item.key}-l1-tooltip`
364
+ ) : null;
365
+ const isActiveFlyoutAnchor = collapsed && (expandedParentKey === item.key && !!((_e = item.children) == null ? void 0 : _e.length) || hoverL1TooltipKey === item.key);
366
+ const wrapForCollapsedFlyout = collapsed;
367
+ const renderedButton = wrapForCollapsedFlyout ? /* @__PURE__ */ jsxs(
368
+ "div",
369
+ {
370
+ ref: isActiveFlyoutAnchor ? flyoutAnchorRef : void 0,
371
+ className: styles["cap-navigation-spa-sidebar__item-flyout-wrap"],
372
+ onMouseLeave: scheduleCloseFlyout,
373
+ children: [
374
+ parentButton,
375
+ !collapsed && collapsedFlyout,
376
+ !collapsed && l1TooltipFlyout
377
+ ]
378
+ },
379
+ `${item.key}-flyout-wrap`
380
+ ) : parentButton;
381
+ if (item.key === SIDEBAR_DIVIDER_BEFORE_KEY) {
382
+ return [
383
+ /* @__PURE__ */ jsx(
384
+ "div",
385
+ {
386
+ className: styles["cap-navigation-spa-sidebar__divider"],
387
+ "aria-hidden": true
388
+ },
389
+ `divider-${item.key}`
390
+ ),
391
+ renderedButton,
392
+ ...l2Inline ? [l2Inline] : []
393
+ ];
394
+ }
395
+ if (item.key === "settings") {
396
+ return [
397
+ /* @__PURE__ */ jsx(
398
+ "div",
399
+ {
400
+ className: styles["cap-navigation-spa-sidebar__divider"],
401
+ "aria-hidden": true
402
+ },
403
+ "divider-settings"
404
+ ),
405
+ renderedButton,
406
+ ...l2Inline ? [l2Inline] : []
407
+ ];
408
+ }
409
+ return [renderedButton, ...l2Inline ? [l2Inline] : []];
410
+ }) }),
411
+ /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__footer"], children: [
412
+ !items.some((i) => i.key === "settings") && /* @__PURE__ */ jsxs(
413
+ "button",
414
+ {
415
+ type: "button",
416
+ className: styles["cap-navigation-spa-sidebar__item"],
417
+ onClick: () => {
418
+ closeFlyout();
419
+ const settingsItem = { key: "settings", title: settingsLabel, link: "/settings" };
420
+ handleClick(settingsItem);
421
+ if (!collapsed) onCollapseExpand == null ? void 0 : onCollapseExpand();
422
+ },
423
+ "data-testid": "cap-navigation-spa-sidebar-settings",
424
+ children: [
425
+ /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-icon"], children: /* @__PURE__ */ jsx(CapIcon, { type: "settings", size: "s" }) }),
426
+ !collapsed && /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-label"], children: settingsLabel })
427
+ ]
428
+ }
429
+ ),
430
+ onCollapseExpand && (collapsed ? /* @__PURE__ */ jsx(
431
+ "div",
432
+ {
433
+ className: styles["cap-navigation-spa-sidebar__collapse-wrap"],
434
+ onMouseEnter: () => {
435
+ if (!transitioningRef.current) setShowExpandTooltip(true);
436
+ },
437
+ onMouseLeave: () => setShowExpandTooltip(false),
438
+ children: /* @__PURE__ */ jsx(
439
+ "button",
440
+ {
441
+ ref: expandBtnRef,
442
+ type: "button",
443
+ className: styles["cap-navigation-spa-sidebar__collapse-btn"],
444
+ onClick: onCollapseExpand,
445
+ "aria-label": "Expand sidebar",
446
+ "data-testid": "cap-navigation-spa-sidebar-collapse-toggle",
447
+ children: /* @__PURE__ */ jsx(
448
+ CapIcon,
449
+ {
450
+ type: "sidebar-expand",
451
+ size: "s",
452
+ className: styles["cap-navigation-spa-sidebar__collapse-btn-icon"]
453
+ }
454
+ )
455
+ }
456
+ )
457
+ }
458
+ ) : /* @__PURE__ */ jsx(
459
+ "div",
460
+ {
461
+ className: styles["cap-navigation-spa-sidebar__collapse-row"],
462
+ "data-testid": "cap-navigation-spa-sidebar-collapse-row",
463
+ children: /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__collapse-panel-group"], children: [
464
+ /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__collapse-panel-label"], children: "Collapse panel" }),
465
+ /* @__PURE__ */ jsx(
466
+ "button",
467
+ {
468
+ type: "button",
469
+ className: styles["cap-navigation-spa-sidebar__collapse-btn"],
470
+ onClick: onCollapseExpand,
471
+ "aria-label": "Collapse sidebar",
472
+ "data-testid": "cap-navigation-spa-sidebar-collapse-toggle",
473
+ children: /* @__PURE__ */ jsx(
474
+ CapIcon,
475
+ {
476
+ type: "sidebar-collapse",
477
+ size: "s",
478
+ className: styles["cap-navigation-spa-sidebar__collapse-btn-icon"]
479
+ }
480
+ )
481
+ }
482
+ )
483
+ ] })
484
+ }
485
+ ))
486
+ ] })
487
+ ]
488
+ }
489
+ ),
490
+ collapsed && flyoutAnchorRect && (() => {
491
+ var _a;
492
+ const activeItem = items.find(
493
+ (i) => {
494
+ var _a2;
495
+ return ((_a2 = i.children) == null ? void 0 : _a2.length) && expandedParentKey === i.key || hoverL1TooltipKey === i.key;
496
+ }
497
+ );
498
+ if (!activeItem) return null;
499
+ const isL2 = !!((_a = activeItem.children) == null ? void 0 : _a.length) && expandedParentKey === activeItem.key;
500
+ const portalStyle = {
501
+ position: "fixed",
502
+ left: flyoutAnchorRect.right + 4,
503
+ top: flyoutAnchorRect.top + flyoutAnchorRect.height / 2,
504
+ transform: "translateY(-50%)",
505
+ zIndex: 10,
506
+ display: "flex",
507
+ alignItems: "center"
508
+ };
509
+ const portalContent = isL2 ? /* @__PURE__ */ jsxs(
510
+ "div",
511
+ {
512
+ className: styles["cap-navigation-spa-sidebar__l2-flyout"],
513
+ style: portalStyle,
514
+ onMouseEnter: () => {
515
+ cancelCloseFlyout();
516
+ setHoverExpandedKey(activeItem.key);
517
+ },
518
+ onMouseLeave: scheduleCloseFlyout,
519
+ "data-testid": `cap-navigation-spa-sidebar-l2-flyout-${activeItem.key}`,
520
+ role: "menu",
521
+ "aria-label": activeItem.title,
522
+ children: [
523
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"], "aria-hidden": true }),
524
+ /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-card"], children: [
525
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-parent"], children: activeItem.title }),
526
+ activeItem.children.map((child) => /* @__PURE__ */ jsx(
527
+ "button",
528
+ {
529
+ type: "button",
530
+ className: classNames(
531
+ styles["cap-navigation-spa-sidebar__l2-flyout-item"],
532
+ selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-flyout-item--selected"]
533
+ ),
534
+ onClick: () => {
535
+ handleClick(child);
536
+ },
537
+ "data-testid": `cap-navigation-spa-sidebar-l2-flyout-item-${child.key}`,
538
+ role: "menuitem",
539
+ children: child.title
540
+ },
541
+ child.key
542
+ ))
543
+ ] })
544
+ ]
545
+ }
546
+ ) : /* @__PURE__ */ jsxs(
547
+ "div",
548
+ {
549
+ className: styles["cap-navigation-spa-sidebar__l1-tooltip-flyout"],
550
+ style: portalStyle,
551
+ onMouseEnter: () => {
552
+ cancelCloseFlyout();
553
+ setHoverL1TooltipKey(activeItem.key);
554
+ },
555
+ onMouseLeave: scheduleCloseFlyout,
556
+ "data-testid": `cap-navigation-spa-sidebar-l1-tooltip-${activeItem.key}`,
557
+ role: "tooltip",
558
+ "aria-label": activeItem.title,
559
+ children: [
560
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"], "aria-hidden": true }),
561
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-card"], children: /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-label"], children: activeItem.title }) })
562
+ ]
563
+ }
564
+ );
565
+ return createPortal(portalContent, document.body);
566
+ })(),
567
+ collapsed && showExpandTooltip && (() => {
568
+ const pos = getExpandTooltipPos();
569
+ if (!pos) return null;
570
+ return createPortal(
571
+ /* @__PURE__ */ jsxs(
572
+ "div",
573
+ {
574
+ className: styles["cap-navigation-spa-sidebar__l1-tooltip-flyout"],
575
+ style: {
576
+ position: "fixed",
577
+ left: pos.right + 4,
578
+ top: pos.top + pos.height / 2,
579
+ transform: "translateY(-50%)",
580
+ zIndex: 10,
581
+ display: "flex",
582
+ alignItems: "center"
583
+ },
584
+ onMouseEnter: () => setShowExpandTooltip(true),
585
+ onMouseLeave: () => setShowExpandTooltip(false),
586
+ role: "tooltip",
587
+ "aria-label": "Expand panel",
588
+ children: [
589
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"], "aria-hidden": true }),
590
+ /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-card"], children: /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l1-tooltip-label"], children: "Expand panel" }) })
591
+ ]
592
+ }
593
+ ),
594
+ document.body
595
+ );
596
+ })()
597
+ ]
598
+ }
599
+ );
600
+ };
601
+ export {
602
+ CapNavigationSPASidebar as default
603
+ };