@flipdish/ui-library 0.48.2 → 0.48.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.
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.cjs +2 -23
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.js +3 -24
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.cjs +48 -0
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.cjs.map +1 -0
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.d.ts +47 -0
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.d.ts.map +1 -0
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.js +44 -0
- package/dist/components/organisms/HeaderNavigation/headerNavigation.utils.js.map +1 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.cjs +35 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.cjs.map +1 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.d.ts +10 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.d.ts.map +1 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.js +33 -0
- package/dist/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.js.map +1 -0
- package/dist/components/organisms/HeaderNavigation/index.cjs +7 -15
- package/dist/components/organisms/HeaderNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.js +8 -16
- package/dist/components/organisms/HeaderNavigation/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,37 +8,16 @@ var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
|
8
8
|
var useBreakpoints = require('@flipdish/ui-library/hooks/useBreakpoints');
|
|
9
9
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
10
10
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
11
|
-
var focus = require('@react-aria/focus');
|
|
12
11
|
var React = require('react');
|
|
13
12
|
var reactAriaComponents = require('react-aria-components');
|
|
14
13
|
var useHotkeyHint = require('../../../../hooks/__internal__/useHotkeyHint/useHotkeyHint.cjs');
|
|
15
14
|
var log_utils = require('../../../../utilities/__internal__/logUtils/log.utils.cjs');
|
|
15
|
+
var useAccountMenuArrowKeys = require('../hooks/useAccountMenuArrowKeys.cjs');
|
|
16
16
|
|
|
17
17
|
const NavAccountMenu = ({ className, selectedAccountId, accounts = [], menuItems = [], bottomMenuItems = [], testIdPrefix, ...dialogProps }) => {
|
|
18
18
|
const menuItemTestId = (item) => item['data-testid'] ?? (testIdPrefix ? testIdUtils.joinTestId(testIdPrefix, `menu-item-${item.id ?? testIdUtils.slugifyTestId(item.label)}`) : undefined);
|
|
19
|
-
const focusManager = focus.useFocusManager();
|
|
20
19
|
const dialogRef = React.useRef(null);
|
|
21
|
-
|
|
22
|
-
switch (e.key) {
|
|
23
|
-
case 'ArrowDown':
|
|
24
|
-
focusManager?.focusNext({ tabbable: true, wrap: true });
|
|
25
|
-
break;
|
|
26
|
-
case 'ArrowUp':
|
|
27
|
-
focusManager?.focusPrevious({ tabbable: true, wrap: true });
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}, [focusManager]);
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
const element = dialogRef.current;
|
|
33
|
-
if (element) {
|
|
34
|
-
element.addEventListener('keydown', onKeyDown);
|
|
35
|
-
}
|
|
36
|
-
return () => {
|
|
37
|
-
if (element) {
|
|
38
|
-
element.removeEventListener('keydown', onKeyDown);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}, [onKeyDown]);
|
|
20
|
+
useAccountMenuArrowKeys.useAccountMenuArrowKeys(dialogRef);
|
|
42
21
|
return (jsxRuntime.jsxs(reactAriaComponents.Dialog, { ...dialogProps, ref: dialogRef, className: cx.cx('w-66 rounded-xl bg-secondary_alt shadow-lg ring ring-secondary_alt outline-hidden', className), children: [jsxRuntime.jsxs("div", { className: "rounded-xl bg-primary ring-1 ring-secondary", children: [menuItems.length > 0 && (jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5 py-1.5", children: menuItems.map((item) => (jsxRuntime.jsx(NavAccountCardMenuItem, { label: item.label, icon: item.icon, shortcut: item.shortcut, onClick: item.onClick, "data-testid": menuItemTestId(item) }, item.label))) })), jsxRuntime.jsxs("div", { className: cx.cx('flex flex-col gap-0.5 py-1.5', menuItems.length > 0 && 'border-t border-secondary'), children: [jsxRuntime.jsx("div", { className: "px-3 pt-1.5 pb-1 text-xs font-semibold text-tertiary", children: "Switch account" }), jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5 px-1.5", children: accounts.map((account) => (
|
|
43
22
|
// biome-ignore lint/a11y/useButtonType: using a button element for the account switch
|
|
44
23
|
jsxRuntime.jsxs("button", { className: cx.cx('relative w-full cursor-pointer rounded-md px-2 py-1.5 text-left outline-focus-ring transition duration-100 ease-linear hover:bg-primary_hover focus:z-10 focus-visible:outline-2 focus-visible:outline-offset-2', account.id === selectedAccountId && 'bg-primary_hover'), children: [jsxRuntime.jsx(Avatar.AvatarLabelGroup, { status: account.status, size: "md", src: account.avatar, title: account.name, subtitle: account.email }), jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: account.id === selectedAccountId, className: "absolute top-2 right-2" })] }, account.id))) })] }), jsxRuntime.jsx("div", { className: "flex flex-col gap-2 px-2 pt-0.5 pb-2", children: jsxRuntime.jsx(Button.Button, { iconLeading: uiIcons.Plus, color: "secondary", size: "sm", children: "Add account" }) })] }), bottomMenuItems.length > 0 && (jsxRuntime.jsx("div", { className: "pt-1 pb-1.5", children: bottomMenuItems.map((item) => (jsxRuntime.jsx(NavAccountCardMenuItem, { label: item.label, icon: item.icon, shortcut: item.shortcut, onClick: item.onClick, "data-testid": menuItemTestId(item) }, item.label))) }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavAccountCard.cjs","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"sourcesContent":[null],"names":["joinTestId","slugifyTestId","
|
|
1
|
+
{"version":3,"file":"NavAccountCard.cjs","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"sourcesContent":[null],"names":["joinTestId","slugifyTestId","useRef","useAccountMenuArrowKeys","_jsxs","AriaDialog","cx","_jsx","AvatarLabelGroup","RadioButtonBase","Button","Plus","useHotkeyHint","useBreakpoints","useResolvedTestId","warnOnce","AriaDialogTrigger","AriaButton","ChevronSelectorVertical","AriaPopover"],"mappings":";;;;;;;;;;;;;;;;AA6CO,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,iBAAiB,EACjB,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,EACd,eAAe,GAAG,EAAE,EACpB,YAAY,EACZ,GAAG,WAAW,EAYf,KAAI;AACH,IAAA,MAAM,cAAc,GAAG,CAAC,IAA4B,KAClD,IAAI,CAAC,aAAa,CAAC,KAAK,YAAY,GAAGA,sBAAU,CAAC,YAAY,EAAE,aAAa,IAAI,CAAC,EAAE,IAAIC,yBAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;AAEnI,IAAA,MAAM,SAAS,GAAGC,YAAM,CAAiB,IAAI,CAAC;IAC9CC,+CAAuB,CAAC,SAAS,CAAC;IAElC,QACEC,eAAA,CAACC,0BAAU,EAAA,EAAA,GACL,WAAW,EACf,GAAG,EAAE,SAAS,EACd,SAAS,EAAEC,KAAE,CAAC,mFAAmF,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA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EAC/B,MAAM,EAAE,eAAe,CAAC,MAAM,EAC9B,OAAO,EAAE,aAAa,EAAA,CACtB,EAEFJ,eAAA,CAACY,iCAAiB,EAAA,EAAA,QAAA,EAAA,CAChBT,cAAA,CAACU,0BAAU,EAAA,EAAA,aAAA,EACI,aAAa,EAAA,YAAA,EACf,mBAAmB,EAC9B,SAAS,EAAC,0UAA0U,EAAA,QAAA,EAEpVV,cAAA,CAACW,+BAAuB,IAAC,SAAS,EAAC,iCAAiC,EAAA,CAAG,EAAA,CAC5D,EACbX,eAACY,2BAAW,EAAA,EACV,SAAS,EAAE,gBAAgB,KAAK,SAAS,GAAG,cAAc,GAAG,WAAW,CAAC,EACzE,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,SAAS,EAAsB,KACvDb,KAAE,CACA,uDAAuD,EACvD,UAAU;AACR,4BAAA,+JAA+J,EACjK,SAAS;AACP,4BAAA,6JAA6J,CAChK,EAAA,QAAA,EAGHC,cAAA,CAAC,cAAc,EAAA,EACb,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,KAAK,EACf,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,aAAa,EAAA,CAC3B,EAAA,CACU,CAAA,EAAA,CACI,CAAA,EAAA,CAChB;AAEV;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavAccountCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavAccountCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAAkB,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,SAAS,EAAsB,MAAM,u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EAAE,cAAc,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACrC,iDAAiD;IACjD,eAAe,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC3C,mGAAmG;IACnG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,uCAwDA,CAAC"}
|
|
@@ -6,37 +6,16 @@ import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButt
|
|
|
6
6
|
import { useBreakpoints } from '@flipdish/ui-library/hooks/useBreakpoints';
|
|
7
7
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
8
8
|
import { useResolvedTestId, joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
9
|
-
import {
|
|
10
|
-
import { useRef, useCallback, useEffect } from 'react';
|
|
9
|
+
import { useRef } from 'react';
|
|
11
10
|
import { DialogTrigger, Button, Popover, Dialog } from 'react-aria-components';
|
|
12
11
|
import { useHotkeyHint } from '../../../../hooks/__internal__/useHotkeyHint/useHotkeyHint.js';
|
|
13
12
|
import { warnOnce } from '../../../../utilities/__internal__/logUtils/log.utils.js';
|
|
13
|
+
import { useAccountMenuArrowKeys } from '../hooks/useAccountMenuArrowKeys.js';
|
|
14
14
|
|
|
15
15
|
const NavAccountMenu = ({ className, selectedAccountId, accounts = [], menuItems = [], bottomMenuItems = [], testIdPrefix, ...dialogProps }) => {
|
|
16
16
|
const menuItemTestId = (item) => item['data-testid'] ?? (testIdPrefix ? joinTestId(testIdPrefix, `menu-item-${item.id ?? slugifyTestId(item.label)}`) : undefined);
|
|
17
|
-
const focusManager = useFocusManager();
|
|
18
17
|
const dialogRef = useRef(null);
|
|
19
|
-
|
|
20
|
-
switch (e.key) {
|
|
21
|
-
case 'ArrowDown':
|
|
22
|
-
focusManager?.focusNext({ tabbable: true, wrap: true });
|
|
23
|
-
break;
|
|
24
|
-
case 'ArrowUp':
|
|
25
|
-
focusManager?.focusPrevious({ tabbable: true, wrap: true });
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
}, [focusManager]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const element = dialogRef.current;
|
|
31
|
-
if (element) {
|
|
32
|
-
element.addEventListener('keydown', onKeyDown);
|
|
33
|
-
}
|
|
34
|
-
return () => {
|
|
35
|
-
if (element) {
|
|
36
|
-
element.removeEventListener('keydown', onKeyDown);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}, [onKeyDown]);
|
|
18
|
+
useAccountMenuArrowKeys(dialogRef);
|
|
40
19
|
return (jsxs(Dialog, { ...dialogProps, ref: dialogRef, className: cx('w-66 rounded-xl bg-secondary_alt shadow-lg ring ring-secondary_alt outline-hidden', className), children: [jsxs("div", { className: "rounded-xl bg-primary ring-1 ring-secondary", children: [menuItems.length > 0 && (jsx("div", { className: "flex flex-col gap-0.5 py-1.5", children: menuItems.map((item) => (jsx(NavAccountCardMenuItem, { label: item.label, icon: item.icon, shortcut: item.shortcut, onClick: item.onClick, "data-testid": menuItemTestId(item) }, item.label))) })), jsxs("div", { className: cx('flex flex-col gap-0.5 py-1.5', menuItems.length > 0 && 'border-t border-secondary'), children: [jsx("div", { className: "px-3 pt-1.5 pb-1 text-xs font-semibold text-tertiary", children: "Switch account" }), jsx("div", { className: "flex flex-col gap-0.5 px-1.5", children: accounts.map((account) => (
|
|
41
20
|
// biome-ignore lint/a11y/useButtonType: using a button element for the account switch
|
|
42
21
|
jsxs("button", { className: cx('relative w-full cursor-pointer rounded-md px-2 py-1.5 text-left outline-focus-ring transition duration-100 ease-linear hover:bg-primary_hover focus:z-10 focus-visible:outline-2 focus-visible:outline-offset-2', account.id === selectedAccountId && 'bg-primary_hover'), children: [jsx(AvatarLabelGroup, { status: account.status, size: "md", src: account.avatar, title: account.name, subtitle: account.email }), jsx(RadioButtonBase, { isSelected: account.id === selectedAccountId, className: "absolute top-2 right-2" })] }, account.id))) })] }), jsx("div", { className: "flex flex-col gap-2 px-2 pt-0.5 pb-2", children: jsx(Button$1, { iconLeading: Plus, color: "secondary", size: "sm", children: "Add account" }) })] }), bottomMenuItems.length > 0 && (jsx("div", { className: "pt-1 pb-1.5", children: bottomMenuItems.map((item) => (jsx(NavAccountCardMenuItem, { label: item.label, icon: item.icon, shortcut: item.shortcut, onClick: item.onClick, "data-testid": menuItemTestId(item) }, item.label))) }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavAccountCard.js","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaDialog","_jsx","Button","AriaDialogTrigger","AriaButton","AriaPopover"],"mappings":";;;;;;;;;;;;;;AA6CO,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,iBAAiB,EACjB,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,EACd,eAAe,GAAG,EAAE,EACpB,YAAY,EACZ,GAAG,WAAW,EAYf,KAAI;AACH,IAAA,MAAM,cAAc,GAAG,CAAC,IAA4B,KAClD,IAAI,CAAC,aAAa,CAAC,KAAK,YAAY,GAAG,UAAU,CAAC,YAAY,EAAE,aAAa,IAAI,CAAC,EAAE,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;AAEnI,IAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"NavAccountCard.js","sources":["../../../../../src/components/organisms/HeaderNavigation/components/NavAccountCard.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaDialog","_jsx","Button","AriaDialogTrigger","AriaButton","AriaPopover"],"mappings":";;;;;;;;;;;;;;AA6CO,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,iBAAiB,EACjB,QAAQ,GAAG,EAAE,EACb,SAAS,GAAG,EAAE,EACd,eAAe,GAAG,EAAE,EACpB,YAAY,EACZ,GAAG,WAAW,EAYf,KAAI;AACH,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,CAAA,EAAA,CACI,CAAA,EAAA,CAChB;AAEV;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
4
|
+
var nav_utils = require('../../__internal__/navigation/nav.utils.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether a desktop header link is the current page. A set `current` flag wins, including `false`.
|
|
8
|
+
*
|
|
9
|
+
* @param link The link, including an optional forced active flag.
|
|
10
|
+
* @param activeUrl The page URL the header was given. Omitted means nothing matches by URL.
|
|
11
|
+
* @returns The forced flag when it is set, otherwise whether `href` matches `activeUrl`.
|
|
12
|
+
*/
|
|
13
|
+
const isHeaderLinkActive = (link, activeUrl) => link.current ?? nav_utils.isHrefActive(link.href, activeUrl);
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the secondary row. An explicit `subItems` list, even an empty one, replaces the active parent's children.
|
|
16
|
+
* A parent counts as active when it is the current page, or when one of its children matches `activeUrl` by href;
|
|
17
|
+
* a child's `current` flag does not select the parent.
|
|
18
|
+
*
|
|
19
|
+
* @param items Top-level links, in display order.
|
|
20
|
+
* @param subItems The explicit secondary list, or `undefined` to use the active parent's children.
|
|
21
|
+
* @param activeUrl The page URL used to mark links current.
|
|
22
|
+
* @returns The links to render, the same links as underline tabs, and the selected tab's label.
|
|
23
|
+
*/
|
|
24
|
+
const resolveSecondaryNav = (items, subItems, activeUrl) => {
|
|
25
|
+
const activeParent = items.find((item) => isHeaderLinkActive(item, activeUrl) || item.items?.some((sub) => nav_utils.isHrefActive(sub.href, activeUrl)));
|
|
26
|
+
const links = subItems || activeParent?.items;
|
|
27
|
+
if (!links || links.length === 0)
|
|
28
|
+
return { links: [], tabs: [], activeTabKey: undefined };
|
|
29
|
+
return {
|
|
30
|
+
links,
|
|
31
|
+
tabs: links.map((item) => ({ id: item.label, children: item.label })),
|
|
32
|
+
activeTabKey: links.find((item) => isHeaderLinkActive(item, activeUrl))?.label,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Derived testid for a desktop header link. An explicit `data-testid` is returned unchanged.
|
|
37
|
+
*
|
|
38
|
+
* @param item The link the id is derived from.
|
|
39
|
+
* @param base The resolved root or drawer id the segment is appended to.
|
|
40
|
+
* @param segment `nav-item` for a primary link, `sub-nav` for a secondary one.
|
|
41
|
+
* @returns The override, or `<base>--<segment>-<id or slug of label>`.
|
|
42
|
+
*/
|
|
43
|
+
const headerLinkTestId = (item, base, segment) => item['data-testid'] ?? testIdUtils.joinTestId(base, `${segment}-${item.id ?? testIdUtils.slugifyTestId(item.label)}`);
|
|
44
|
+
|
|
45
|
+
exports.headerLinkTestId = headerLinkTestId;
|
|
46
|
+
exports.isHeaderLinkActive = isHeaderLinkActive;
|
|
47
|
+
exports.resolveSecondaryNav = resolveSecondaryNav;
|
|
48
|
+
//# sourceMappingURL=headerNavigation.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerNavigation.utils.cjs","sources":["../../../../src/components/organisms/HeaderNavigation/headerNavigation.utils.ts"],"sourcesContent":[null],"names":["isHrefActive","joinTestId","slugifyTestId"],"mappings":";;;;;AAoBA;;;;;;AAMG;MACU,kBAAkB,GAAG,CAAC,IAA6C,EAAE,SAA6B,KAC7G,IAAI,CAAC,OAAO,IAAIA,sBAAY,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS;AAEnD;;;;;;;;;AASG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAA+B,EAC/B,QAA8C,EAC9C,SAA6B,KACb;AAChB,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,KAAKA,sBAAY,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9I,IAAA,MAAM,KAAK,GAAG,QAAQ,IAAI,YAAY,EAAE,KAAK;AAE7C,IAAA,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE;IAEzF,OAAO;QACL,KAAK;QACL,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AACrE,QAAA,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,KAAK;KAC/E;AACH;AAEA;;;;;;;AAOG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAyD,EAAE,IAAY,EAAE,OAA+B,KACvI,IAAI,CAAC,aAAa,CAAC,IAAIC,sBAAU,CAAC,IAAI,EAAE,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,IAAIC,yBAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA,CAAE;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** A desktop header link. `current` forces the active state; children open the secondary row. */
|
|
2
|
+
export interface HeaderNavLink {
|
|
3
|
+
label: string;
|
|
4
|
+
href: string;
|
|
5
|
+
current?: boolean;
|
|
6
|
+
id?: string;
|
|
7
|
+
'data-testid'?: string;
|
|
8
|
+
items?: readonly HeaderNavLink[];
|
|
9
|
+
}
|
|
10
|
+
/** The secondary row under the desktop header. An empty `links` list means the row stays hidden. */
|
|
11
|
+
export interface SecondaryNav {
|
|
12
|
+
links: readonly HeaderNavLink[];
|
|
13
|
+
tabs: {
|
|
14
|
+
id: string;
|
|
15
|
+
children: string;
|
|
16
|
+
}[];
|
|
17
|
+
activeTabKey: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a desktop header link is the current page. A set `current` flag wins, including `false`.
|
|
21
|
+
*
|
|
22
|
+
* @param link The link, including an optional forced active flag.
|
|
23
|
+
* @param activeUrl The page URL the header was given. Omitted means nothing matches by URL.
|
|
24
|
+
* @returns The forced flag when it is set, otherwise whether `href` matches `activeUrl`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const isHeaderLinkActive: (link: Pick<HeaderNavLink, "href" | "current">, activeUrl: string | undefined) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the secondary row. An explicit `subItems` list, even an empty one, replaces the active parent's children.
|
|
29
|
+
* A parent counts as active when it is the current page, or when one of its children matches `activeUrl` by href;
|
|
30
|
+
* a child's `current` flag does not select the parent.
|
|
31
|
+
*
|
|
32
|
+
* @param items Top-level links, in display order.
|
|
33
|
+
* @param subItems The explicit secondary list, or `undefined` to use the active parent's children.
|
|
34
|
+
* @param activeUrl The page URL used to mark links current.
|
|
35
|
+
* @returns The links to render, the same links as underline tabs, and the selected tab's label.
|
|
36
|
+
*/
|
|
37
|
+
export declare const resolveSecondaryNav: (items: readonly HeaderNavLink[], subItems: readonly HeaderNavLink[] | undefined, activeUrl: string | undefined) => SecondaryNav;
|
|
38
|
+
/**
|
|
39
|
+
* Derived testid for a desktop header link. An explicit `data-testid` is returned unchanged.
|
|
40
|
+
*
|
|
41
|
+
* @param item The link the id is derived from.
|
|
42
|
+
* @param base The resolved root or drawer id the segment is appended to.
|
|
43
|
+
* @param segment `nav-item` for a primary link, `sub-nav` for a secondary one.
|
|
44
|
+
* @returns The override, or `<base>--<segment>-<id or slug of label>`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const headerLinkTestId: (item: Pick<HeaderNavLink, "label" | "id" | "data-testid">, base: string, segment: "nav-item" | "sub-nav") => string;
|
|
47
|
+
//# sourceMappingURL=headerNavigation.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerNavigation.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/HeaderNavigation/headerNavigation.utils.ts"],"names":[],"mappings":"AAGA,iGAAiG;AACjG,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAClC;AAED,oGAAoG;AACpG,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,WAAW,MAAM,GAAG,SAAS,KAAG,OAC9D,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,SAAS,aAAa,EAAE,EAC/B,UAAU,SAAS,aAAa,EAAE,GAAG,SAAS,EAC9C,WAAW,MAAM,GAAG,SAAS,KAC5B,YAWF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,aAAa,CAAC,EAAE,MAAM,MAAM,EAAE,SAAS,UAAU,GAAG,SAAS,KAAG,MAC7C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
2
|
+
import { isHrefActive } from '../../__internal__/navigation/nav.utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether a desktop header link is the current page. A set `current` flag wins, including `false`.
|
|
6
|
+
*
|
|
7
|
+
* @param link The link, including an optional forced active flag.
|
|
8
|
+
* @param activeUrl The page URL the header was given. Omitted means nothing matches by URL.
|
|
9
|
+
* @returns The forced flag when it is set, otherwise whether `href` matches `activeUrl`.
|
|
10
|
+
*/
|
|
11
|
+
const isHeaderLinkActive = (link, activeUrl) => link.current ?? isHrefActive(link.href, activeUrl);
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the secondary row. An explicit `subItems` list, even an empty one, replaces the active parent's children.
|
|
14
|
+
* A parent counts as active when it is the current page, or when one of its children matches `activeUrl` by href;
|
|
15
|
+
* a child's `current` flag does not select the parent.
|
|
16
|
+
*
|
|
17
|
+
* @param items Top-level links, in display order.
|
|
18
|
+
* @param subItems The explicit secondary list, or `undefined` to use the active parent's children.
|
|
19
|
+
* @param activeUrl The page URL used to mark links current.
|
|
20
|
+
* @returns The links to render, the same links as underline tabs, and the selected tab's label.
|
|
21
|
+
*/
|
|
22
|
+
const resolveSecondaryNav = (items, subItems, activeUrl) => {
|
|
23
|
+
const activeParent = items.find((item) => isHeaderLinkActive(item, activeUrl) || item.items?.some((sub) => isHrefActive(sub.href, activeUrl)));
|
|
24
|
+
const links = subItems || activeParent?.items;
|
|
25
|
+
if (!links || links.length === 0)
|
|
26
|
+
return { links: [], tabs: [], activeTabKey: undefined };
|
|
27
|
+
return {
|
|
28
|
+
links,
|
|
29
|
+
tabs: links.map((item) => ({ id: item.label, children: item.label })),
|
|
30
|
+
activeTabKey: links.find((item) => isHeaderLinkActive(item, activeUrl))?.label,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Derived testid for a desktop header link. An explicit `data-testid` is returned unchanged.
|
|
35
|
+
*
|
|
36
|
+
* @param item The link the id is derived from.
|
|
37
|
+
* @param base The resolved root or drawer id the segment is appended to.
|
|
38
|
+
* @param segment `nav-item` for a primary link, `sub-nav` for a secondary one.
|
|
39
|
+
* @returns The override, or `<base>--<segment>-<id or slug of label>`.
|
|
40
|
+
*/
|
|
41
|
+
const headerLinkTestId = (item, base, segment) => item['data-testid'] ?? joinTestId(base, `${segment}-${item.id ?? slugifyTestId(item.label)}`);
|
|
42
|
+
|
|
43
|
+
export { headerLinkTestId, isHeaderLinkActive, resolveSecondaryNav };
|
|
44
|
+
//# sourceMappingURL=headerNavigation.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerNavigation.utils.js","sources":["../../../../src/components/organisms/HeaderNavigation/headerNavigation.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAoBA;;;;;;AAMG;MACU,kBAAkB,GAAG,CAAC,IAA6C,EAAE,SAA6B,KAC7G,IAAI,CAAC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS;AAEnD;;;;;;;;;AASG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAA+B,EAC/B,QAA8C,EAC9C,SAA6B,KACb;AAChB,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC9I,IAAA,MAAM,KAAK,GAAG,QAAQ,IAAI,YAAY,EAAE,KAAK;AAE7C,IAAA,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE;IAEzF,OAAO;QACL,KAAK;QACL,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AACrE,QAAA,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,KAAK;KAC/E;AACH;AAEA;;;;;;;AAOG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAyD,EAAE,IAAY,EAAE,OAA+B,KACvI,IAAI,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA,CAAE;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var focus = require('@react-aria/focus');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Moves focus between the tabbable controls inside an account menu with ArrowUp and ArrowDown,
|
|
8
|
+
* wrapping at either end. Other keys are left to the control that has focus.
|
|
9
|
+
*
|
|
10
|
+
* @param menuRef The menu element the listener is attached to. Nothing is listened to while its current value is null.
|
|
11
|
+
* @returns Nothing. The listener stays while the element from this render is mounted.
|
|
12
|
+
*/
|
|
13
|
+
const useAccountMenuArrowKeys = (menuRef) => {
|
|
14
|
+
const focusManager = focus.useFocusManager();
|
|
15
|
+
const onKeyDown = React.useCallback((event) => {
|
|
16
|
+
switch (event.key) {
|
|
17
|
+
case 'ArrowDown':
|
|
18
|
+
focusManager?.focusNext({ tabbable: true, wrap: true });
|
|
19
|
+
break;
|
|
20
|
+
case 'ArrowUp':
|
|
21
|
+
focusManager?.focusPrevious({ tabbable: true, wrap: true });
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}, [focusManager]);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
const element = menuRef.current;
|
|
27
|
+
if (!element)
|
|
28
|
+
return;
|
|
29
|
+
element.addEventListener('keydown', onKeyDown);
|
|
30
|
+
return () => element.removeEventListener('keydown', onKeyDown);
|
|
31
|
+
}, [menuRef, onKeyDown]);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useAccountMenuArrowKeys = useAccountMenuArrowKeys;
|
|
35
|
+
//# sourceMappingURL=useAccountMenuArrowKeys.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountMenuArrowKeys.cjs","sources":["../../../../../src/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.ts"],"sourcesContent":[null],"names":["useFocusManager","useCallback","useEffect"],"mappings":";;;;;AAKA;;;;;;AAMG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAsC,KAAI;AAChF,IAAA,MAAM,YAAY,GAAGA,qBAAe,EAAE;AAEtC,IAAA,MAAM,SAAS,GAAGC,iBAAW,CAC3B,CAAC,KAAoB,KAAI;AACvB,QAAA,QAAQ,KAAK,CAAC,GAAG;AACf,YAAA,KAAK,WAAW;AACd,gBAAA,YAAY,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACvD;AACF,YAAA,KAAK,SAAS;AACZ,gBAAA,YAAY,EAAE,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC3D;;AAEN,IAAA,CAAC,EACD,CAAC,YAAY,CAAC,CACf;IAEDC,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO;AAC/B,QAAA,IAAI,CAAC,OAAO;YAAE;AAEd,QAAA,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;QAC9C,OAAO,MAAM,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;AAChE,IAAA,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC1B;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Moves focus between the tabbable controls inside an account menu with ArrowUp and ArrowDown,
|
|
4
|
+
* wrapping at either end. Other keys are left to the control that has focus.
|
|
5
|
+
*
|
|
6
|
+
* @param menuRef The menu element the listener is attached to. Nothing is listened to while its current value is null.
|
|
7
|
+
* @returns Nothing. The listener stays while the element from this render is mounted.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useAccountMenuArrowKeys: (menuRef: RefObject<HTMLElement | null>) => void;
|
|
10
|
+
//# sourceMappingURL=useAccountMenuArrowKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountMenuArrowKeys.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAA0B,MAAM,OAAO,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,SAwB7E,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useFocusManager } from '@react-aria/focus';
|
|
2
|
+
import { useCallback, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Moves focus between the tabbable controls inside an account menu with ArrowUp and ArrowDown,
|
|
6
|
+
* wrapping at either end. Other keys are left to the control that has focus.
|
|
7
|
+
*
|
|
8
|
+
* @param menuRef The menu element the listener is attached to. Nothing is listened to while its current value is null.
|
|
9
|
+
* @returns Nothing. The listener stays while the element from this render is mounted.
|
|
10
|
+
*/
|
|
11
|
+
const useAccountMenuArrowKeys = (menuRef) => {
|
|
12
|
+
const focusManager = useFocusManager();
|
|
13
|
+
const onKeyDown = useCallback((event) => {
|
|
14
|
+
switch (event.key) {
|
|
15
|
+
case 'ArrowDown':
|
|
16
|
+
focusManager?.focusNext({ tabbable: true, wrap: true });
|
|
17
|
+
break;
|
|
18
|
+
case 'ArrowUp':
|
|
19
|
+
focusManager?.focusPrevious({ tabbable: true, wrap: true });
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}, [focusManager]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const element = menuRef.current;
|
|
25
|
+
if (!element)
|
|
26
|
+
return;
|
|
27
|
+
element.addEventListener('keydown', onKeyDown);
|
|
28
|
+
return () => element.removeEventListener('keydown', onKeyDown);
|
|
29
|
+
}, [menuRef, onKeyDown]);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useAccountMenuArrowKeys };
|
|
33
|
+
//# sourceMappingURL=useAccountMenuArrowKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountMenuArrowKeys.js","sources":["../../../../../src/components/organisms/HeaderNavigation/hooks/useAccountMenuArrowKeys.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKA;;;;;;AAMG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAsC,KAAI;AAChF,IAAA,MAAM,YAAY,GAAG,eAAe,EAAE;AAEtC,IAAA,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,KAAoB,KAAI;AACvB,QAAA,QAAQ,KAAK,CAAC,GAAG;AACf,YAAA,KAAK,WAAW;AACd,gBAAA,YAAY,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBACvD;AACF,YAAA,KAAK,SAAS;AACZ,gBAAA,YAAY,EAAE,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC3D;;AAEN,IAAA,CAAC,EACD,CAAC,YAAY,CAAC,CACf;IAED,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO;AAC/B,QAAA,IAAI,CAAC,OAAO;YAAE;AAEd,QAAA,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;QAC9C,OAAO,MAAM,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;AAChE,IAAA,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC1B;;"}
|
|
@@ -6,12 +6,12 @@ var SearchInput = require('@flipdish/ui-library/components/atoms/SearchInput');
|
|
|
6
6
|
var Tabs = require('@flipdish/ui-library/components/molecules/Tabs');
|
|
7
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
8
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
9
|
-
var nav_utils = require('../../__internal__/navigation/nav.utils.cjs');
|
|
10
9
|
var MobileHeader = require('./components/MobileHeader.cjs');
|
|
11
10
|
var NavAccountCard = require('./components/NavAccountCard.cjs');
|
|
12
11
|
var NavButton = require('./components/NavButton.cjs');
|
|
13
12
|
var NavItem = require('./components/NavItem.cjs');
|
|
14
13
|
var NavList = require('./components/NavList.cjs');
|
|
14
|
+
var headerNavigation_utils = require('./headerNavigation.utils.cjs');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Full-width top navigation bar with the logo, primary links, an optional secondary row and a
|
|
@@ -21,24 +21,16 @@ var NavList = require('./components/NavList.cjs');
|
|
|
21
21
|
* @summary top navigation bar that collapses to a drawer on mobile
|
|
22
22
|
*/
|
|
23
23
|
const HeaderNavigationBase = ({ activeUrl, items, subItems, hideBorder = false, actions, centered = false, secondaryType = 'buttons', footerItems = [], account, 'data-testid': dataTestId, }) => {
|
|
24
|
-
const isActive = (item) =>
|
|
24
|
+
const isActive = (item) => headerNavigation_utils.isHeaderLinkActive(item, activeUrl);
|
|
25
25
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'header-navigation', rootName: 'header-navigation' });
|
|
26
26
|
// The mobile drawer and the desktop header both render the same nav items; re-root the
|
|
27
27
|
// drawer subtree under `drawer` so their derived testids don't collide in the DOM.
|
|
28
28
|
const drawerTestId = testIdUtils.joinTestId(rootTestId, 'drawer');
|
|
29
|
-
const navItemTestId = (item, base = rootTestId) => item
|
|
30
|
-
const subNavItemTestId = (item) => item
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const tabItems = showSecondaryNav
|
|
35
|
-
? activeSubNavItems.map((item) => ({
|
|
36
|
-
id: item.label,
|
|
37
|
-
children: item.label,
|
|
38
|
-
}))
|
|
39
|
-
: [];
|
|
40
|
-
const activeTabKey = activeSubNavItems?.find((item) => isActive(item))?.label;
|
|
41
|
-
return (jsxRuntime.jsxs(testIdUtils.TestIdProvider, { value: rootTestId, children: [jsxRuntime.jsx(MobileHeader.MobileNavigationHeader, { testIdPrefix: rootTestId, children: jsxRuntime.jsxs("aside", { className: "flex h-full max-w-full flex-col overflow-auto bg-primary pt-4", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-5 px-4", children: [jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm" }), jsxRuntime.jsx(SearchInput.SearchInput, { size: "md", "aria-label": "Search", placeholder: "Search", "data-testid": testIdUtils.joinTestId(drawerTestId, 'input') })] }), jsxRuntime.jsx(NavList.NavList, { items: items, activeUrl: activeUrl, className: "flex-1", testIdPrefix: drawerTestId }), (footerItems.length > 0 || account) && (jsxRuntime.jsxs("div", { className: "mt-auto flex flex-col gap-3 p-4", children: [footerItems.length > 0 && (jsxRuntime.jsx("div", { className: "flex flex-col", children: footerItems.map((item) => (jsxRuntime.jsx(NavItem.NavItemBase, { type: "link", href: item.href, icon: item.icon, badge: item.badge, current: isActive(item), "data-testid": navItemTestId(item, drawerTestId), children: item.label }, item.label))) })), account && (jsxRuntime.jsx(NavAccountCard.NavAccountCard, { items: account.accounts, selectedAccountId: account.selectedAccountId, menuItems: account.menuItems, bottomMenuItems: account.bottomMenuItems }))] }))] }) }), jsxRuntime.jsxs("header", { className: "max-lg:hidden", children: [jsxRuntime.jsx("section", { className: cx.cx('flex h-16 w-full items-center justify-center bg-primary', (!hideBorder || showSecondaryNav) && 'border-b border-secondary'), children: jsxRuntime.jsxs("div", { className: cx.cx('flex w-full max-w-container items-center pr-3 pl-4 md:px-8', centered && 'gap-8'), children: [jsxRuntime.jsx("div", { className: cx.cx('flex items-center', centered ? 'flex-1' : 'mr-4'), children: jsxRuntime.jsx("a", { "aria-label": "Go to homepage", href: "/", className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm" }) }) }), jsxRuntime.jsx("nav", { "aria-label": "Main", children: jsxRuntime.jsx("ul", { className: "flex items-center gap-0.5", children: items.map((item) => (jsxRuntime.jsx("li", { children: jsxRuntime.jsx(NavButton.NavButton, { current: isActive(item), href: item.href, "data-testid": navItemTestId(item), children: item.label }) }, item.label))) }) }), (actions || centered) && jsxRuntime.jsx("div", { className: cx.cx('flex items-center gap-3', centered ? 'flex-1 justify-end' : 'ml-auto'), children: actions })] }) }), showSecondaryNav && (jsxRuntime.jsx("section", { className: cx.cx('flex w-full items-center justify-center bg-primary', !hideBorder && 'border-b border-secondary'), children: secondaryType === 'tabs' ? (jsxRuntime.jsx("div", { className: "w-full max-w-container px-8 pt-3", children: jsxRuntime.jsx(Tabs.Tabs, { selectedKey: activeTabKey, children: jsxRuntime.jsx(Tabs.TabList, { size: "sm", type: "underline", items: tabItems, className: "-mb-px before:hidden" }) }) })) : (jsxRuntime.jsxs("div", { className: cx.cx('flex h-16 w-full max-w-container items-center gap-8 px-8', centered ? 'justify-center' : 'justify-between'), children: [jsxRuntime.jsx("nav", { "aria-label": "Secondary", children: jsxRuntime.jsx("ul", { className: cx.cx('flex items-center gap-0.5', centered && 'justify-center'), children: activeSubNavItems.map((item) => (jsxRuntime.jsx("li", { children: jsxRuntime.jsx(NavButton.NavButton, { href: item.href, current: isActive(item), "data-testid": subNavItemTestId(item), children: item.label }) }, item.label))) }) }), !centered && (jsxRuntime.jsx(SearchInput.SearchInput, { shortcut: true, "aria-label": "Search", placeholder: "Search", size: "sm", className: "max-w-70", "data-testid": testIdUtils.joinTestId(rootTestId, 'input') }))] })) }))] })] }));
|
|
29
|
+
const navItemTestId = (item, base = rootTestId) => headerNavigation_utils.headerLinkTestId(item, base, 'nav-item');
|
|
30
|
+
const subNavItemTestId = (item) => headerNavigation_utils.headerLinkTestId(item, rootTestId, 'sub-nav');
|
|
31
|
+
const secondary = headerNavigation_utils.resolveSecondaryNav(items, subItems, activeUrl);
|
|
32
|
+
const showSecondaryNav = secondary.links.length > 0;
|
|
33
|
+
return (jsxRuntime.jsxs(testIdUtils.TestIdProvider, { value: rootTestId, children: [jsxRuntime.jsx(MobileHeader.MobileNavigationHeader, { testIdPrefix: rootTestId, children: jsxRuntime.jsxs("aside", { className: "flex h-full max-w-full flex-col overflow-auto bg-primary pt-4", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-5 px-4", children: [jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm" }), jsxRuntime.jsx(SearchInput.SearchInput, { size: "md", "aria-label": "Search", placeholder: "Search", "data-testid": testIdUtils.joinTestId(drawerTestId, 'input') })] }), jsxRuntime.jsx(NavList.NavList, { items: items, activeUrl: activeUrl, className: "flex-1", testIdPrefix: drawerTestId }), (footerItems.length > 0 || account) && (jsxRuntime.jsxs("div", { className: "mt-auto flex flex-col gap-3 p-4", children: [footerItems.length > 0 && (jsxRuntime.jsx("div", { className: "flex flex-col", children: footerItems.map((item) => (jsxRuntime.jsx(NavItem.NavItemBase, { type: "link", href: item.href, icon: item.icon, badge: item.badge, current: isActive(item), "data-testid": navItemTestId(item, drawerTestId), children: item.label }, item.label))) })), account && (jsxRuntime.jsx(NavAccountCard.NavAccountCard, { items: account.accounts, selectedAccountId: account.selectedAccountId, menuItems: account.menuItems, bottomMenuItems: account.bottomMenuItems }))] }))] }) }), jsxRuntime.jsxs("header", { className: "max-lg:hidden", children: [jsxRuntime.jsx("section", { className: cx.cx('flex h-16 w-full items-center justify-center bg-primary', (!hideBorder || showSecondaryNav) && 'border-b border-secondary'), children: jsxRuntime.jsxs("div", { className: cx.cx('flex w-full max-w-container items-center pr-3 pl-4 md:px-8', centered && 'gap-8'), children: [jsxRuntime.jsx("div", { className: cx.cx('flex items-center', centered ? 'flex-1' : 'mr-4'), children: jsxRuntime.jsx("a", { "aria-label": "Go to homepage", href: "/", className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsxRuntime.jsx(FlipdishLogo.FlipdishLogo, { size: "sm" }) }) }), jsxRuntime.jsx("nav", { "aria-label": "Main", children: jsxRuntime.jsx("ul", { className: "flex items-center gap-0.5", children: items.map((item) => (jsxRuntime.jsx("li", { children: jsxRuntime.jsx(NavButton.NavButton, { current: isActive(item), href: item.href, "data-testid": navItemTestId(item), children: item.label }) }, item.label))) }) }), (actions || centered) && jsxRuntime.jsx("div", { className: cx.cx('flex items-center gap-3', centered ? 'flex-1 justify-end' : 'ml-auto'), children: actions })] }) }), showSecondaryNav && (jsxRuntime.jsx("section", { className: cx.cx('flex w-full items-center justify-center bg-primary', !hideBorder && 'border-b border-secondary'), children: secondaryType === 'tabs' ? (jsxRuntime.jsx("div", { className: "w-full max-w-container px-8 pt-3", children: jsxRuntime.jsx(Tabs.Tabs, { selectedKey: secondary.activeTabKey, children: jsxRuntime.jsx(Tabs.TabList, { size: "sm", type: "underline", items: secondary.tabs, className: "-mb-px before:hidden" }) }) })) : (jsxRuntime.jsxs("div", { className: cx.cx('flex h-16 w-full max-w-container items-center gap-8 px-8', centered ? 'justify-center' : 'justify-between'), children: [jsxRuntime.jsx("nav", { "aria-label": "Secondary", children: jsxRuntime.jsx("ul", { className: cx.cx('flex items-center gap-0.5', centered && 'justify-center'), children: secondary.links.map((item) => (jsxRuntime.jsx("li", { children: jsxRuntime.jsx(NavButton.NavButton, { href: item.href, current: isActive(item), "data-testid": subNavItemTestId(item), children: item.label }) }, item.label))) }) }), !centered && (jsxRuntime.jsx(SearchInput.SearchInput, { shortcut: true, "aria-label": "Search", placeholder: "Search", size: "sm", className: "max-w-70", "data-testid": testIdUtils.joinTestId(rootTestId, 'input') }))] })) }))] })] }));
|
|
42
34
|
};
|
|
43
35
|
|
|
44
36
|
exports.NavAccountCard = NavAccountCard.NavAccountCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/HeaderNavigation/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/HeaderNavigation/index.tsx"],"sourcesContent":[null],"names":["isHeaderLinkActive","useResolvedTestId","joinTestId","headerLinkTestId","resolveSecondaryNav","_jsxs","TestIdProvider","_jsx","MobileNavigationHeader","FlipdishLogo","SearchInput","NavList","NavItemBase","NavAccountCard","cx","NavButton","Tabs","TabList"],"mappings":";;;;;;;;;;;;;;;AA4FA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,EACnC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,aAAa,GAAG,SAAS,EACzB,WAAW,GAAG,EAAE,EAChB,OAAO,EACP,aAAa,EAAE,UAAU,GACC,KAAI;AAC9B,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAuC,KAAKA,yCAAkB,CAAC,IAAI,EAAE,SAAS,CAAC;AAEjG,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;;;IAGzH,MAAM,YAAY,GAAGC,sBAAU,CAAC,UAAU,EAAE,QAAQ,CAAC;AACrD,IAAA,MAAM,aAAa,GAAG,CAA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,EAAC,WAAW,EAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,EAAC,sBAAsB,EAAA,CAAG,EAAA,CACzF,EAAA,CACH,KAENZ,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAES,KAAE,CAAC,0DAA0D,EAAE,QAAQ,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,EAAA,QAAA,EAAA,CAC7HP,cAAA,CAAA,KAAA,EAAA,EAAA,YAAA,EAAgB,WAAW,EAAA,QAAA,EACzBA,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAEO,KAAE,CAAC,2BAA2B,EAAE,QAAQ,IAAI,gBAAgB,CAAC,YACzE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MACxBP,cAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EACEA,cAAA,CAACQ,mBAAS,EAAA,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAA,aAAA,EAAe,gBAAgB,CAAC,IAAI,CAAC,YACrF,IAAI,CAAC,KAAK,EAAA,CACD,EAAA,EAHL,IAAI,CAAC,KAAK,CAId,CACN,CAAC,EAAA,CACC,EAAA,CACD,EAEL,CAAC,QAAQ,KACRR,cAAA,CAACG,uBAAW,EAAA,EACV,QAAQ,EAAA,IAAA,EAAA,YAAA,EACG,QAAQ,EACnB,WAAW,EAAC,QAAQ,EACpB,IAAI,EAAC,IAAI,EACT,SAAS,EAAC,UAAU,EAAA,aAAA,EACPR,sBAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAAA,CAC5C,CACH,CAAA,EAAA,CACG,CACP,EAAA,CACO,CACX,CAAA,EAAA,CACM,CAAA,EAAA,CACM;AAErB;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/HeaderNavigation/index.tsx"],"names":[],"mappings":"AAOA,OA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AAW,yBAAyB;IACxC,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,sEAAsE;IACtE,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAEnC,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IAExB,4HAA4H;IAC5H,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,gIAWlC,yBAAyB,gCAgI3B,CAAC"}
|
|
@@ -3,14 +3,14 @@ import { FlipdishLogo } from '@flipdish/ui-library/components/atoms/FlipdishLogo
|
|
|
3
3
|
import { SearchInput } from '@flipdish/ui-library/components/atoms/SearchInput';
|
|
4
4
|
import { Tabs, TabList } from '@flipdish/ui-library/components/molecules/Tabs';
|
|
5
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
|
-
import { useResolvedTestId, joinTestId, TestIdProvider
|
|
7
|
-
import { isHrefActive } from '../../__internal__/navigation/nav.utils.js';
|
|
6
|
+
import { useResolvedTestId, joinTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
8
7
|
import { MobileNavigationHeader } from './components/MobileHeader.js';
|
|
9
8
|
import { NavAccountCard } from './components/NavAccountCard.js';
|
|
10
9
|
export { NavAccountMenu } from './components/NavAccountCard.js';
|
|
11
10
|
import { NavButton } from './components/NavButton.js';
|
|
12
11
|
import { NavItemBase } from './components/NavItem.js';
|
|
13
12
|
import { NavList } from './components/NavList.js';
|
|
13
|
+
import { resolveSecondaryNav, headerLinkTestId, isHeaderLinkActive } from './headerNavigation.utils.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Full-width top navigation bar with the logo, primary links, an optional secondary row and a
|
|
@@ -20,24 +20,16 @@ import { NavList } from './components/NavList.js';
|
|
|
20
20
|
* @summary top navigation bar that collapses to a drawer on mobile
|
|
21
21
|
*/
|
|
22
22
|
const HeaderNavigationBase = ({ activeUrl, items, subItems, hideBorder = false, actions, centered = false, secondaryType = 'buttons', footerItems = [], account, 'data-testid': dataTestId, }) => {
|
|
23
|
-
const isActive = (item) =>
|
|
23
|
+
const isActive = (item) => isHeaderLinkActive(item, activeUrl);
|
|
24
24
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'header-navigation', rootName: 'header-navigation' });
|
|
25
25
|
// The mobile drawer and the desktop header both render the same nav items; re-root the
|
|
26
26
|
// drawer subtree under `drawer` so their derived testids don't collide in the DOM.
|
|
27
27
|
const drawerTestId = joinTestId(rootTestId, 'drawer');
|
|
28
|
-
const navItemTestId = (item, base = rootTestId) => item
|
|
29
|
-
const subNavItemTestId = (item) => item
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const tabItems = showSecondaryNav
|
|
34
|
-
? activeSubNavItems.map((item) => ({
|
|
35
|
-
id: item.label,
|
|
36
|
-
children: item.label,
|
|
37
|
-
}))
|
|
38
|
-
: [];
|
|
39
|
-
const activeTabKey = activeSubNavItems?.find((item) => isActive(item))?.label;
|
|
40
|
-
return (jsxs(TestIdProvider, { value: rootTestId, children: [jsx(MobileNavigationHeader, { testIdPrefix: rootTestId, children: jsxs("aside", { className: "flex h-full max-w-full flex-col overflow-auto bg-primary pt-4", children: [jsxs("div", { className: "flex flex-col gap-5 px-4", children: [jsx(FlipdishLogo, { size: "sm" }), jsx(SearchInput, { size: "md", "aria-label": "Search", placeholder: "Search", "data-testid": joinTestId(drawerTestId, 'input') })] }), jsx(NavList, { items: items, activeUrl: activeUrl, className: "flex-1", testIdPrefix: drawerTestId }), (footerItems.length > 0 || account) && (jsxs("div", { className: "mt-auto flex flex-col gap-3 p-4", children: [footerItems.length > 0 && (jsx("div", { className: "flex flex-col", children: footerItems.map((item) => (jsx(NavItemBase, { type: "link", href: item.href, icon: item.icon, badge: item.badge, current: isActive(item), "data-testid": navItemTestId(item, drawerTestId), children: item.label }, item.label))) })), account && (jsx(NavAccountCard, { items: account.accounts, selectedAccountId: account.selectedAccountId, menuItems: account.menuItems, bottomMenuItems: account.bottomMenuItems }))] }))] }) }), jsxs("header", { className: "max-lg:hidden", children: [jsx("section", { className: cx('flex h-16 w-full items-center justify-center bg-primary', (!hideBorder || showSecondaryNav) && 'border-b border-secondary'), children: jsxs("div", { className: cx('flex w-full max-w-container items-center pr-3 pl-4 md:px-8', centered && 'gap-8'), children: [jsx("div", { className: cx('flex items-center', centered ? 'flex-1' : 'mr-4'), children: jsx("a", { "aria-label": "Go to homepage", href: "/", className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsx(FlipdishLogo, { size: "sm" }) }) }), jsx("nav", { "aria-label": "Main", children: jsx("ul", { className: "flex items-center gap-0.5", children: items.map((item) => (jsx("li", { children: jsx(NavButton, { current: isActive(item), href: item.href, "data-testid": navItemTestId(item), children: item.label }) }, item.label))) }) }), (actions || centered) && jsx("div", { className: cx('flex items-center gap-3', centered ? 'flex-1 justify-end' : 'ml-auto'), children: actions })] }) }), showSecondaryNav && (jsx("section", { className: cx('flex w-full items-center justify-center bg-primary', !hideBorder && 'border-b border-secondary'), children: secondaryType === 'tabs' ? (jsx("div", { className: "w-full max-w-container px-8 pt-3", children: jsx(Tabs, { selectedKey: activeTabKey, children: jsx(TabList, { size: "sm", type: "underline", items: tabItems, className: "-mb-px before:hidden" }) }) })) : (jsxs("div", { className: cx('flex h-16 w-full max-w-container items-center gap-8 px-8', centered ? 'justify-center' : 'justify-between'), children: [jsx("nav", { "aria-label": "Secondary", children: jsx("ul", { className: cx('flex items-center gap-0.5', centered && 'justify-center'), children: activeSubNavItems.map((item) => (jsx("li", { children: jsx(NavButton, { href: item.href, current: isActive(item), "data-testid": subNavItemTestId(item), children: item.label }) }, item.label))) }) }), !centered && (jsx(SearchInput, { shortcut: true, "aria-label": "Search", placeholder: "Search", size: "sm", className: "max-w-70", "data-testid": joinTestId(rootTestId, 'input') }))] })) }))] })] }));
|
|
28
|
+
const navItemTestId = (item, base = rootTestId) => headerLinkTestId(item, base, 'nav-item');
|
|
29
|
+
const subNavItemTestId = (item) => headerLinkTestId(item, rootTestId, 'sub-nav');
|
|
30
|
+
const secondary = resolveSecondaryNav(items, subItems, activeUrl);
|
|
31
|
+
const showSecondaryNav = secondary.links.length > 0;
|
|
32
|
+
return (jsxs(TestIdProvider, { value: rootTestId, children: [jsx(MobileNavigationHeader, { testIdPrefix: rootTestId, children: jsxs("aside", { className: "flex h-full max-w-full flex-col overflow-auto bg-primary pt-4", children: [jsxs("div", { className: "flex flex-col gap-5 px-4", children: [jsx(FlipdishLogo, { size: "sm" }), jsx(SearchInput, { size: "md", "aria-label": "Search", placeholder: "Search", "data-testid": joinTestId(drawerTestId, 'input') })] }), jsx(NavList, { items: items, activeUrl: activeUrl, className: "flex-1", testIdPrefix: drawerTestId }), (footerItems.length > 0 || account) && (jsxs("div", { className: "mt-auto flex flex-col gap-3 p-4", children: [footerItems.length > 0 && (jsx("div", { className: "flex flex-col", children: footerItems.map((item) => (jsx(NavItemBase, { type: "link", href: item.href, icon: item.icon, badge: item.badge, current: isActive(item), "data-testid": navItemTestId(item, drawerTestId), children: item.label }, item.label))) })), account && (jsx(NavAccountCard, { items: account.accounts, selectedAccountId: account.selectedAccountId, menuItems: account.menuItems, bottomMenuItems: account.bottomMenuItems }))] }))] }) }), jsxs("header", { className: "max-lg:hidden", children: [jsx("section", { className: cx('flex h-16 w-full items-center justify-center bg-primary', (!hideBorder || showSecondaryNav) && 'border-b border-secondary'), children: jsxs("div", { className: cx('flex w-full max-w-container items-center pr-3 pl-4 md:px-8', centered && 'gap-8'), children: [jsx("div", { className: cx('flex items-center', centered ? 'flex-1' : 'mr-4'), children: jsx("a", { "aria-label": "Go to homepage", href: "/", className: "rounded-xs outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", children: jsx(FlipdishLogo, { size: "sm" }) }) }), jsx("nav", { "aria-label": "Main", children: jsx("ul", { className: "flex items-center gap-0.5", children: items.map((item) => (jsx("li", { children: jsx(NavButton, { current: isActive(item), href: item.href, "data-testid": navItemTestId(item), children: item.label }) }, item.label))) }) }), (actions || centered) && jsx("div", { className: cx('flex items-center gap-3', centered ? 'flex-1 justify-end' : 'ml-auto'), children: actions })] }) }), showSecondaryNav && (jsx("section", { className: cx('flex w-full items-center justify-center bg-primary', !hideBorder && 'border-b border-secondary'), children: secondaryType === 'tabs' ? (jsx("div", { className: "w-full max-w-container px-8 pt-3", children: jsx(Tabs, { selectedKey: secondary.activeTabKey, children: jsx(TabList, { size: "sm", type: "underline", items: secondary.tabs, className: "-mb-px before:hidden" }) }) })) : (jsxs("div", { className: cx('flex h-16 w-full max-w-container items-center gap-8 px-8', centered ? 'justify-center' : 'justify-between'), children: [jsx("nav", { "aria-label": "Secondary", children: jsx("ul", { className: cx('flex items-center gap-0.5', centered && 'justify-center'), children: secondary.links.map((item) => (jsx("li", { children: jsx(NavButton, { href: item.href, current: isActive(item), "data-testid": subNavItemTestId(item), children: item.label }) }, item.label))) }) }), !centered && (jsx(SearchInput, { shortcut: true, "aria-label": "Search", placeholder: "Search", size: "sm", className: "max-w-70", "data-testid": joinTestId(rootTestId, 'input') }))] })) }))] })] }));
|
|
41
33
|
};
|
|
42
34
|
|
|
43
35
|
export { HeaderNavigationBase, NavAccountCard, NavItemBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/HeaderNavigation/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AA4FA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,EACnC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,aAAa,GAAG,SAAS,EACzB,WAAW,GAAG,EAAE,EAChB,OAAO,EACP,aAAa,EAAE,UAAU,GACC,KAAI;AAC9B,IAAA,MAAM,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/HeaderNavigation/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AA4FA;;;;;;AAMG;AACI,MAAM,oBAAoB,GAAG,CAAC,EACnC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,aAAa,GAAG,SAAS,EACzB,WAAW,GAAG,EAAE,EAChB,OAAO,EACP,aAAa,EAAE,UAAU,GACC,KAAI;AAC9B,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAuC,KAAK,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC;AAEjG,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;;;IAGzH,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC;AACrD,IAAA,MAAM,aAAa,GAAG,CAAC,IAAmD,EAAE,IAAA,GAAe,UAAU,KAAK,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC;AAClJ,IAAA,MAAM,gBAAgB,GAAG,CAAC,IAAmD,KAAK,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;IAE/H,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,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