@capillarytech/blaze-ui 6.1.6-beta.1 → 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 (66) 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.map +1 -1
  35. package/CapNavigationSPA/CapNavigationSPASidebar/index.js +476 -246
  36. package/CapNavigationSPA/CapNavigationSPASidebar/styles.css +34 -2
  37. package/CapNavigationSPA/CapNavigationSPASidebar/styles.module.scss.js +3 -0
  38. package/CapNavigationSPA/CapNavigationSPASidebar/styles.scss +43 -6
  39. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts +3 -2
  40. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts.map +1 -1
  41. package/CapNavigationSPA/CapNavigationSPATopBar/index.js +72 -96
  42. package/CapNavigationSPA/CapNavigationSPATopBar/styles.css +75 -69
  43. package/CapNavigationSPA/CapNavigationSPATopBar/styles.module.scss.js +6 -7
  44. package/CapNavigationSPA/CapNavigationSPATopBar/styles.scss +102 -92
  45. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts +6 -10
  46. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts.map +1 -1
  47. package/CapNavigationSPA/index.d.ts.map +1 -1
  48. package/CapNavigationSPA/index.js +5 -5
  49. package/CapNavigationSPA/styles.css +5 -16
  50. package/CapNavigationSPA/styles.module.scss.js +1 -2
  51. package/CapNavigationSPA/styles.scss +8 -19
  52. package/assets/icons/blocks.svg +9 -0
  53. package/assets/icons/closed-lock.svg +1 -0
  54. package/assets/icons/csv.svg +21 -0
  55. package/assets/icons/databricks.svg +7 -0
  56. package/assets/icons/four-join.svg +19 -0
  57. package/assets/icons/http.svg +18 -0
  58. package/assets/icons/kafka.svg +9 -0
  59. package/assets/icons/open-lock.svg +1 -0
  60. package/assets/icons/s3.svg +3 -0
  61. package/assets/icons/sftp.svg +32 -0
  62. package/assets/icons/split-json.svg +9 -0
  63. package/assets/icons/three-join.svg +17 -0
  64. package/assets/icons/two-join.svg +15 -0
  65. package/assets/icons/xml.svg +12 -0
  66. package/package.json +2 -1
@@ -1,6 +1,7 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import classNames from "classnames";
3
- import { useRef, useState, useCallback } from "react";
3
+ import { useRef, useState, useCallback, useEffect, useLayoutEffect } from "react";
4
+ import { createPortal } from "react-dom";
4
5
  import CapIcon from "../../CapIcon/index.js";
5
6
  import styles from "./styles.module.scss.js";
6
7
  const SIDEBAR_DIVIDER_BEFORE_KEY = "data-management";
@@ -34,15 +35,83 @@ const CapNavigationSPASidebar = ({
34
35
  navigateToLink = true
35
36
  }) => {
36
37
  const wrapperRef = useRef(null);
38
+ const flyoutAnchorRef = useRef(null);
39
+ const closeFlyoutTimeoutRef = useRef(null);
37
40
  const [hoverExpandedKey, setHoverExpandedKey] = useState(null);
41
+ const [flyoutAnchorRect, setFlyoutAnchorRect] = useState(null);
38
42
  const [clickExpandedKey, setClickExpandedKey] = useState(null);
39
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);
40
48
  const expandedParentKey = clickExpandedKey ?? hoverExpandedKey;
41
49
  const closeFlyout = useCallback(() => {
50
+ if (closeFlyoutTimeoutRef.current) {
51
+ clearTimeout(closeFlyoutTimeoutRef.current);
52
+ closeFlyoutTimeoutRef.current = null;
53
+ }
42
54
  setHoverExpandedKey(null);
43
55
  setClickExpandedKey(null);
44
56
  setHoverL1TooltipKey(null);
45
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
+ }, []);
46
115
  const handleClick = useCallback(
47
116
  (item) => {
48
117
  if (navigateToLink && item.link && item.link !== window.location.pathname) {
@@ -67,12 +136,10 @@ const CapNavigationSPASidebar = ({
67
136
  (item) => {
68
137
  var _a, _b;
69
138
  if (collapsed) {
70
- if (onCollapseExpand) {
71
- onCollapseExpand();
72
- }
73
139
  if ((_a = item.children) == null ? void 0 : _a.length) {
140
+ pendingExpandKeyRef.current = item.key;
141
+ if (onCollapseExpand) onCollapseExpand();
74
142
  setHoverExpandedKey(null);
75
- setClickExpandedKey(item.key);
76
143
  } else {
77
144
  closeFlyout();
78
145
  handleClick(item);
@@ -84,287 +151,450 @@ const CapNavigationSPASidebar = ({
84
151
  } else {
85
152
  closeFlyout();
86
153
  handleClick(item);
154
+ onCollapseExpand == null ? void 0 : onCollapseExpand();
87
155
  }
88
156
  },
89
157
  [collapsed, onCollapseExpand, toggleParentExpanded, closeFlyout, handleClick]
90
158
  );
91
159
  const getIconType = (item) => item.iconType ?? DEFAULT_ICON_MAP[item.key] ?? void 0;
92
160
  const handleWrapperMouseLeave = useCallback(() => {
93
- setHoverExpandedKey(null);
94
- setHoverL1TooltipKey(null);
95
- }, []);
96
- return /* @__PURE__ */ jsx(
161
+ scheduleCloseFlyout();
162
+ }, [scheduleCloseFlyout]);
163
+ return /* @__PURE__ */ jsxs(
97
164
  "div",
98
165
  {
99
166
  ref: wrapperRef,
100
167
  className: styles["cap-navigation-spa-sidebar__wrapper"],
101
168
  onMouseLeave: handleWrapperMouseLeave,
102
- children: /* @__PURE__ */ jsxs(
103
- "aside",
104
- {
105
- className: classNames(
106
- styles["cap-navigation-spa-sidebar"],
107
- collapsed && styles["cap-navigation-spa-sidebar--collapsed"],
108
- className
109
- ),
110
- "data-testid": "cap-navigation-spa-sidebar",
111
- children: [
112
- /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__logo"], children: logo !== void 0 ? logo : /* @__PURE__ */ jsxs(Fragment, { children: [
113
- /* @__PURE__ */ jsx(
114
- CapIcon,
115
- {
116
- type: "capillary",
117
- size: "s",
118
- className: styles["cap-navigation-spa-sidebar__logo-icon"]
119
- }
120
- ),
121
- !collapsed && /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__logo-text"], children: "capillary" })
122
- ] }) }),
123
- /* @__PURE__ */ jsx("nav", { className: styles["cap-navigation-spa-sidebar__nav"], children: items.flatMap((item) => {
124
- var _a, _b, _c, _d;
125
- const isExpandedWithChildren = !collapsed && ((_a = item.children) == null ? void 0 : _a.length) && expandedParentKey === item.key;
126
- const parentButton = /* @__PURE__ */ jsxs(
127
- "button",
128
- {
129
- type: "button",
130
- className: classNames(
131
- styles["cap-navigation-spa-sidebar__item"],
132
- expandedParentKey === item.key && styles["cap-navigation-spa-sidebar__item--expanded"],
133
- expandedParentKey === item.key && item.key === "loyalty" && styles["cap-navigation-spa-sidebar__item--expanded-loyalty"],
134
- expandedParentKey === item.key && item.key === "engage" && styles["cap-navigation-spa-sidebar__item--expanded-engage"],
135
- expandedParentKey === item.key && item.key === "insights" && styles["cap-navigation-spa-sidebar__item--expanded-insights"],
136
- expandedParentKey === item.key && item.key === "members" && styles["cap-navigation-spa-sidebar__item--expanded-members"],
137
- expandedParentKey === item.key && item.key === "rewards" && styles["cap-navigation-spa-sidebar__item--expanded-rewards"],
138
- expandedParentKey === item.key && item.key === "audiences" && styles["cap-navigation-spa-sidebar__item--expanded-audiences"],
139
- expandedParentKey === item.key && item.key === "data-management" && styles["cap-navigation-spa-sidebar__item--expanded-data-management"],
140
- expandedParentKey === item.key && item.key === "extensions" && styles["cap-navigation-spa-sidebar__item--expanded-extensions"],
141
- expandedParentKey === item.key && item.key === "settings" && styles["cap-navigation-spa-sidebar__item--expanded-settings"]
142
- ),
143
- onClick: () => handleItemClick(item),
144
- onMouseEnter: () => {
145
- var _a2;
146
- if ((_a2 = item.children) == null ? void 0 : _a2.length) {
147
- if (collapsed) {
148
- setHoverExpandedKey(item.key);
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);
149
224
  }
150
- setHoverL1TooltipKey(null);
151
- } else if (collapsed) {
152
- setHoverL1TooltipKey(item.key);
153
- }
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
+ ]
154
289
  },
155
- "data-testid": `cap-navigation-spa-sidebar-item-${item.key}`,
156
- children: [
157
- /* @__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"] }) }),
158
- !collapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
159
- /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-label"], children: item.title }),
160
- ((_b = item.children) == null ? void 0 : _b.length) ? /* @__PURE__ */ jsx(
161
- CapIcon,
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",
162
307
  {
163
- type: expandedParentKey === item.key ? "chevron-down" : "chevron-right",
164
- size: "s",
165
- className: styles["cap-navigation-spa-sidebar__item-chevron"]
308
+ className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
309
+ "aria-hidden": true
166
310
  }
167
- ) : null
168
- ] })
169
- ]
170
- },
171
- item.key
172
- );
173
- const showCollapsedFlyout = collapsed && ((_c = item.children) == null ? void 0 : _c.length) && expandedParentKey === item.key;
174
- const showL1TooltipFlyout = collapsed && !((_d = item.children) == null ? void 0 : _d.length) && hoverL1TooltipKey === item.key;
175
- const l2Inline = isExpandedWithChildren ? /* @__PURE__ */ jsxs(
176
- "div",
177
- {
178
- className: styles["cap-navigation-spa-sidebar__l2-wrapper"],
179
- children: [
180
- /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-divider"], "aria-hidden": true }),
181
- /* @__PURE__ */ jsx(
182
- "div",
183
- {
184
- className: styles["cap-navigation-spa-sidebar__l2-inline"],
185
- onMouseEnter: () => setHoverExpandedKey(item.key),
186
- "data-testid": `cap-navigation-spa-sidebar-l2-${item.key}`,
187
- children: item.children.map((child) => /* @__PURE__ */ jsx(
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(
188
315
  "button",
189
316
  {
190
317
  type: "button",
191
318
  className: classNames(
192
- styles["cap-navigation-spa-sidebar__l2-inline-item"],
193
- selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected"],
194
- item.key === "loyalty" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-loyalty"],
195
- item.key === "engage" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-engage"],
196
- item.key === "insights" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-insights"],
197
- item.key === "members" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-members"],
198
- item.key === "rewards" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-rewards"],
199
- item.key === "audiences" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-audiences"],
200
- item.key === "data-management" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-data-management"],
201
- item.key === "extensions" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-extensions"],
202
- item.key === "settings" && selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-inline-item--selected-settings"]
319
+ styles["cap-navigation-spa-sidebar__l2-flyout-item"],
320
+ selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-flyout-item--selected"]
203
321
  ),
204
322
  onClick: () => {
323
+ setClickExpandedKey(item.key);
324
+ if (collapsed && onCollapseExpand) {
325
+ onCollapseExpand();
326
+ }
205
327
  handleClick(child);
206
328
  },
207
- "data-testid": `cap-navigation-spa-sidebar-l2-item-${child.key}`,
329
+ "data-testid": `cap-navigation-spa-sidebar-l2-flyout-item-${child.key}`,
330
+ role: "menuitem",
208
331
  children: child.title
209
332
  },
210
333
  child.key
211
334
  ))
212
- },
213
- `${item.key}-l2`
214
- )
215
- ]
216
- },
217
- `${item.key}-l2-wrapper`
218
- ) : null;
219
- const collapsedFlyout = showCollapsedFlyout ? /* @__PURE__ */ jsxs(
220
- "div",
221
- {
222
- className: styles["cap-navigation-spa-sidebar__l2-flyout"],
223
- onMouseEnter: () => setHoverExpandedKey(item.key),
224
- "data-testid": `cap-navigation-spa-sidebar-l2-flyout-${item.key}`,
225
- role: "menu",
226
- "aria-label": item.title,
227
- children: [
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 [
228
383
  /* @__PURE__ */ jsx(
229
384
  "div",
230
385
  {
231
- className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
386
+ className: styles["cap-navigation-spa-sidebar__divider"],
232
387
  "aria-hidden": true
233
- }
388
+ },
389
+ `divider-${item.key}`
234
390
  ),
235
- /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-card"], children: [
236
- /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__l2-flyout-parent"], children: item.title }),
237
- item.children.map((child) => /* @__PURE__ */ jsx(
238
- "button",
239
- {
240
- type: "button",
241
- className: classNames(
242
- styles["cap-navigation-spa-sidebar__l2-flyout-item"],
243
- selectedKey === child.key && styles["cap-navigation-spa-sidebar__l2-flyout-item--selected"]
244
- ),
245
- onClick: () => {
246
- setClickExpandedKey(item.key);
247
- if (collapsed && onCollapseExpand) {
248
- onCollapseExpand();
249
- }
250
- handleClick(child);
251
- },
252
- "data-testid": `cap-navigation-spa-sidebar-l2-flyout-item-${child.key}`,
253
- role: "menuitem",
254
- children: child.title
255
- },
256
- child.key
257
- ))
258
- ] })
259
- ]
260
- },
261
- `${item.key}-l2-flyout`
262
- ) : null;
263
- const l1TooltipFlyout = showL1TooltipFlyout ? /* @__PURE__ */ jsxs(
264
- "div",
265
- {
266
- className: styles["cap-navigation-spa-sidebar__l1-tooltip-flyout"],
267
- onMouseEnter: () => setHoverL1TooltipKey(item.key),
268
- "data-testid": `cap-navigation-spa-sidebar-l1-tooltip-${item.key}`,
269
- role: "tooltip",
270
- "aria-label": item.title,
271
- children: [
391
+ renderedButton,
392
+ ...l2Inline ? [l2Inline] : []
393
+ ];
394
+ }
395
+ if (item.key === "settings") {
396
+ return [
272
397
  /* @__PURE__ */ jsx(
273
398
  "div",
274
399
  {
275
- className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
400
+ className: styles["cap-navigation-spa-sidebar__divider"],
276
401
  "aria-hidden": true
277
- }
402
+ },
403
+ "divider-settings"
278
404
  ),
279
- /* @__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 }) })
280
- ]
281
- },
282
- `${item.key}-l1-tooltip`
283
- ) : null;
284
- const wrapForCollapsedFlyout = collapsed;
285
- const renderedButton = wrapForCollapsedFlyout ? /* @__PURE__ */ jsxs(
286
- "div",
287
- {
288
- className: styles["cap-navigation-spa-sidebar__item-flyout-wrap"],
289
- onMouseLeave: closeFlyout,
290
- children: [
291
- parentButton,
292
- collapsedFlyout,
293
- l1TooltipFlyout
294
- ]
295
- },
296
- `${item.key}-flyout-wrap`
297
- ) : parentButton;
298
- if (item.key === SIDEBAR_DIVIDER_BEFORE_KEY) {
299
- return [
300
- /* @__PURE__ */ jsx(
301
- "div",
302
- {
303
- className: styles["cap-navigation-spa-sidebar__divider"],
304
- "aria-hidden": true
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();
305
422
  },
306
- `divider-${item.key}`
307
- ),
308
- renderedButton,
309
- ...l2Inline ? [l2Inline] : []
310
- ];
311
- }
312
- if (item.key === "settings") {
313
- return [
314
- /* @__PURE__ */ jsx(
315
- "div",
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",
316
528
  {
317
- className: styles["cap-navigation-spa-sidebar__divider"],
318
- "aria-hidden": true
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
319
540
  },
320
- "divider-settings"
321
- ),
322
- renderedButton,
323
- ...l2Inline ? [l2Inline] : []
324
- ];
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
+ ]
325
592
  }
326
- return [renderedButton, ...l2Inline ? [l2Inline] : []];
327
- }) }),
328
- /* @__PURE__ */ jsxs("div", { className: styles["cap-navigation-spa-sidebar__footer"], children: [
329
- !items.some((i) => i.key === "settings") && /* @__PURE__ */ jsxs(
330
- "button",
331
- {
332
- type: "button",
333
- className: styles["cap-navigation-spa-sidebar__item"],
334
- onClick: () => {
335
- closeFlyout();
336
- const settingsItem = { key: "settings", title: settingsLabel, link: "/settings" };
337
- handleClick(settingsItem);
338
- },
339
- "data-testid": "cap-navigation-spa-sidebar-settings",
340
- children: [
341
- /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-icon"], children: /* @__PURE__ */ jsx(CapIcon, { type: "settings", size: "s" }) }),
342
- !collapsed && /* @__PURE__ */ jsx("span", { className: styles["cap-navigation-spa-sidebar__item-label"], children: settingsLabel })
343
- ]
344
- }
345
- ),
346
- onCollapseExpand && /* @__PURE__ */ jsx("div", { className: styles["cap-navigation-spa-sidebar__collapse-wrap"], children: /* @__PURE__ */ jsx(
347
- "button",
348
- {
349
- type: "button",
350
- className: styles["cap-navigation-spa-sidebar__collapse-btn"],
351
- onClick: onCollapseExpand,
352
- "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
353
- "data-testid": "cap-navigation-spa-sidebar-collapse-toggle",
354
- children: /* @__PURE__ */ jsx(
355
- CapIcon,
356
- {
357
- type: collapsed ? "sidebar-expand" : "sidebar-collapse",
358
- size: "s",
359
- className: styles["cap-navigation-spa-sidebar__collapse-btn-icon"]
360
- }
361
- )
362
- }
363
- ) })
364
- ] })
365
- ]
366
- }
367
- )
593
+ ),
594
+ document.body
595
+ );
596
+ })()
597
+ ]
368
598
  }
369
599
  );
370
600
  };