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

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 (55) hide show
  1. package/CapNavigationSPA/CapNavigationSPASidebar/index.d.ts +10 -0
  2. package/CapNavigationSPA/CapNavigationSPASidebar/index.d.ts.map +1 -0
  3. package/CapNavigationSPA/CapNavigationSPASidebar/index.js +373 -0
  4. package/CapNavigationSPA/CapNavigationSPASidebar/styles.css +318 -0
  5. package/CapNavigationSPA/CapNavigationSPASidebar/styles.module.scss.js +56 -0
  6. package/CapNavigationSPA/CapNavigationSPASidebar/styles.scss +385 -0
  7. package/CapNavigationSPA/CapNavigationSPASidebar/types.d.ts +31 -0
  8. package/CapNavigationSPA/CapNavigationSPASidebar/types.d.ts.map +1 -0
  9. package/CapNavigationSPA/CapNavigationSPASidebar/types.js +1 -0
  10. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts +10 -0
  11. package/CapNavigationSPA/CapNavigationSPATopBar/index.d.ts.map +1 -0
  12. package/CapNavigationSPA/CapNavigationSPATopBar/index.js +119 -0
  13. package/CapNavigationSPA/CapNavigationSPATopBar/styles.css +141 -0
  14. package/CapNavigationSPA/CapNavigationSPATopBar/styles.module.scss.js +19 -0
  15. package/CapNavigationSPA/CapNavigationSPATopBar/styles.scss +163 -0
  16. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts +28 -0
  17. package/CapNavigationSPA/CapNavigationSPATopBar/types.d.ts.map +1 -0
  18. package/CapNavigationSPA/CapNavigationSPATopBar/types.js +1 -0
  19. package/CapNavigationSPA/constants.d.ts +2 -0
  20. package/CapNavigationSPA/constants.d.ts.map +1 -0
  21. package/CapNavigationSPA/constants.js +4 -0
  22. package/CapNavigationSPA/index.d.ts +10 -0
  23. package/CapNavigationSPA/index.d.ts.map +1 -0
  24. package/CapNavigationSPA/index.js +436 -0
  25. package/CapNavigationSPA/messages.d.ts +13 -0
  26. package/CapNavigationSPA/messages.d.ts.map +1 -0
  27. package/CapNavigationSPA/messages.js +16 -0
  28. package/CapNavigationSPA/mockdata.d.ts +6 -0
  29. package/CapNavigationSPA/mockdata.d.ts.map +1 -0
  30. package/CapNavigationSPA/mockdata.js +4 -0
  31. package/CapNavigationSPA/styles.css +59 -0
  32. package/CapNavigationSPA/styles.module.scss.js +10 -0
  33. package/CapNavigationSPA/styles.scss +60 -0
  34. package/CapNavigationSPA/tests/CapNavigationSPA.mockData.d.ts +31 -0
  35. package/CapNavigationSPA/tests/CapNavigationSPA.mockData.d.ts.map +1 -0
  36. package/CapNavigationSPA/types.d.ts +39 -0
  37. package/CapNavigationSPA/types.d.ts.map +1 -0
  38. package/CapNavigationSPA/types.js +1 -0
  39. package/assets/svgIcons/Icons/AiraNav.js +23 -0
  40. package/assets/svgIcons/Icons/CreativesNav.js +22 -0
  41. package/assets/svgIcons/Icons/DataManagement.js +22 -0
  42. package/assets/svgIcons/Icons/EngageNav.js +23 -0
  43. package/assets/svgIcons/Icons/InsightsNav.js +22 -0
  44. package/assets/svgIcons/Icons/LoyaltyTag.js +22 -0
  45. package/assets/svgIcons/Icons/Members.js +22 -0
  46. package/assets/svgIcons/Icons/RewardsOutline.js +4 -6
  47. package/assets/svgIcons/Icons/SidebarCollapse.js +17 -0
  48. package/assets/svgIcons/Icons/SidebarExpand.js +22 -0
  49. package/assets/svgIcons/Icons/ThreeStars.js +36 -18
  50. package/assets/svgIcons/component.js +27 -0
  51. package/assets/svgIcons/index.js +612 -594
  52. package/index.d.ts +2 -0
  53. package/index.d.ts.map +1 -1
  54. package/index.js +195 -193
  55. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CapNavigationSPASidebar – Left sidebar matching New navigation Figma design.
3
+ * 240px width, Capillary logo at top, nav items (icon + label), L2 flyout for items with children, divider, Settings at bottom.
4
+ */
5
+ import React from 'react';
6
+ import type { CapNavigationSPASidebarProps } from './types';
7
+ declare const CapNavigationSPASidebar: React.FC<CapNavigationSPASidebarProps>;
8
+ export default CapNavigationSPASidebar;
9
+ export type { CapNavigationSPASidebarProps, CapNavigationSPASidebarItem } from './types';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/CapNavigationSPA/CapNavigationSPASidebar/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAwC,MAAM,OAAO,CAAC;AAK7D,OAAO,KAAK,EAA+B,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAoBzF,QAAA,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAgZnE,CAAC;AAEF,eAAe,uBAAuB,CAAC;AACvC,YAAY,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,373 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ import { useRef, useState, useCallback } from "react";
4
+ import CapIcon from "../../CapIcon/index.js";
5
+ import styles from "./styles.module.scss.js";
6
+ const SIDEBAR_DIVIDER_BEFORE_KEY = "data-management";
7
+ const DEFAULT_ICON_MAP = {
8
+ loyalty: "loyalty-tag",
9
+ // Figma 583:6938 – heart inside tag
10
+ engage: "engage-nav",
11
+ // Figma 646-59790 – megaphone with settings
12
+ rewards: "rewards-outline",
13
+ insights: "insights-nav",
14
+ // Figma 646-59984 – bar chart in frame
15
+ aira: "aira-nav",
16
+ // Figma 646-59790 – three sparkles, stroke icon
17
+ members: "members",
18
+ audiences: "groups",
19
+ creatives: "creatives-nav",
20
+ // Figma 646-59984 – document with pen
21
+ "data-management": "data-management",
22
+ extensions: "code",
23
+ settings: "settings"
24
+ };
25
+ const CapNavigationSPASidebar = ({
26
+ items,
27
+ selectedKey = "",
28
+ onItemClick,
29
+ settingsLabel = "Settings",
30
+ logo,
31
+ className,
32
+ collapsed = false,
33
+ onCollapseExpand,
34
+ navigateToLink = true
35
+ }) => {
36
+ const wrapperRef = useRef(null);
37
+ const [hoverExpandedKey, setHoverExpandedKey] = useState(null);
38
+ const [clickExpandedKey, setClickExpandedKey] = useState(null);
39
+ const [hoverL1TooltipKey, setHoverL1TooltipKey] = useState(null);
40
+ const expandedParentKey = clickExpandedKey ?? hoverExpandedKey;
41
+ const closeFlyout = useCallback(() => {
42
+ setHoverExpandedKey(null);
43
+ setClickExpandedKey(null);
44
+ setHoverL1TooltipKey(null);
45
+ }, []);
46
+ const handleClick = useCallback(
47
+ (item) => {
48
+ if (navigateToLink && item.link && item.link !== window.location.pathname) {
49
+ window.location.pathname = item.link;
50
+ }
51
+ onItemClick == null ? void 0 : onItemClick(item);
52
+ },
53
+ [navigateToLink, onItemClick]
54
+ );
55
+ const toggleParentExpanded = useCallback(
56
+ (parentKey) => {
57
+ if (expandedParentKey === parentKey) {
58
+ closeFlyout();
59
+ } else {
60
+ setHoverExpandedKey(null);
61
+ setClickExpandedKey(parentKey);
62
+ }
63
+ },
64
+ [expandedParentKey, closeFlyout]
65
+ );
66
+ const handleItemClick = useCallback(
67
+ (item) => {
68
+ var _a, _b;
69
+ if (collapsed) {
70
+ if (onCollapseExpand) {
71
+ onCollapseExpand();
72
+ }
73
+ if ((_a = item.children) == null ? void 0 : _a.length) {
74
+ setHoverExpandedKey(null);
75
+ setClickExpandedKey(item.key);
76
+ } else {
77
+ closeFlyout();
78
+ handleClick(item);
79
+ }
80
+ return;
81
+ }
82
+ if ((_b = item.children) == null ? void 0 : _b.length) {
83
+ toggleParentExpanded(item.key);
84
+ } else {
85
+ closeFlyout();
86
+ handleClick(item);
87
+ }
88
+ },
89
+ [collapsed, onCollapseExpand, toggleParentExpanded, closeFlyout, handleClick]
90
+ );
91
+ const getIconType = (item) => item.iconType ?? DEFAULT_ICON_MAP[item.key] ?? void 0;
92
+ const handleWrapperMouseLeave = useCallback(() => {
93
+ setHoverExpandedKey(null);
94
+ setHoverL1TooltipKey(null);
95
+ }, []);
96
+ return /* @__PURE__ */ jsx(
97
+ "div",
98
+ {
99
+ ref: wrapperRef,
100
+ className: styles["cap-navigation-spa-sidebar__wrapper"],
101
+ 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);
149
+ }
150
+ setHoverL1TooltipKey(null);
151
+ } else if (collapsed) {
152
+ setHoverL1TooltipKey(item.key);
153
+ }
154
+ },
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,
162
+ {
163
+ type: expandedParentKey === item.key ? "chevron-down" : "chevron-right",
164
+ size: "s",
165
+ className: styles["cap-navigation-spa-sidebar__item-chevron"]
166
+ }
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(
188
+ "button",
189
+ {
190
+ type: "button",
191
+ 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"]
203
+ ),
204
+ onClick: () => {
205
+ handleClick(child);
206
+ },
207
+ "data-testid": `cap-navigation-spa-sidebar-l2-item-${child.key}`,
208
+ children: child.title
209
+ },
210
+ child.key
211
+ ))
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: [
228
+ /* @__PURE__ */ jsx(
229
+ "div",
230
+ {
231
+ className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
232
+ "aria-hidden": true
233
+ }
234
+ ),
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: [
272
+ /* @__PURE__ */ jsx(
273
+ "div",
274
+ {
275
+ className: styles["cap-navigation-spa-sidebar__l2-flyout-arrow"],
276
+ "aria-hidden": true
277
+ }
278
+ ),
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
305
+ },
306
+ `divider-${item.key}`
307
+ ),
308
+ renderedButton,
309
+ ...l2Inline ? [l2Inline] : []
310
+ ];
311
+ }
312
+ if (item.key === "settings") {
313
+ return [
314
+ /* @__PURE__ */ jsx(
315
+ "div",
316
+ {
317
+ className: styles["cap-navigation-spa-sidebar__divider"],
318
+ "aria-hidden": true
319
+ },
320
+ "divider-settings"
321
+ ),
322
+ renderedButton,
323
+ ...l2Inline ? [l2Inline] : []
324
+ ];
325
+ }
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
+ )
368
+ }
369
+ );
370
+ };
371
+ export {
372
+ CapNavigationSPASidebar as default
373
+ };