@handijitcom/ui 3.6.0 → 3.7.0
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/README.md +194 -36
- package/build/chat.cjs +3 -3
- package/build/chat.cjs.map +1 -1
- package/build/chat.css +1 -1
- package/build/chat.js +168 -160
- package/build/chat.js.map +1 -1
- package/build/components/Alert/index.cjs +1 -1
- package/build/components/Alert/index.cjs.map +1 -1
- package/build/components/Alert/index.d.cts +7 -0
- package/build/components/Alert/index.d.ts +7 -0
- package/build/components/Alert/index.js +32 -19
- package/build/components/Alert/index.js.map +1 -1
- package/build/components/Alert/style.css +1 -1
- package/build/components/AppShell/style.css +1 -1
- package/build/components/AppliedFilters/style.css +1 -1
- package/build/components/Chip/style.css +1 -1
- package/build/components/CommandPalette/style.css +1 -1
- package/build/components/Directory/style.css +1 -1
- package/build/components/EmptyState/style.css +1 -1
- package/build/components/FacetSection/index.cjs +1 -1
- package/build/components/FacetSection/index.cjs.map +1 -1
- package/build/components/FacetSection/index.js +145 -138
- package/build/components/FacetSection/index.js.map +1 -1
- package/build/components/FacetSection/style.css +1 -1
- package/build/components/FacetSidebar/index.cjs +1 -1
- package/build/components/FacetSidebar/index.cjs.map +1 -1
- package/build/components/FacetSidebar/index.js +22 -29
- package/build/components/FacetSidebar/index.js.map +1 -1
- package/build/components/Heading/index.cjs +2 -0
- package/build/components/Heading/index.cjs.map +1 -0
- package/build/components/Heading/index.d.cts +34 -0
- package/build/components/Heading/index.d.ts +34 -0
- package/build/components/Heading/index.js +44 -0
- package/build/components/Heading/index.js.map +1 -0
- package/build/components/Heading/style.css +1 -0
- package/build/components/MegaMenu/index.cjs +1 -1
- package/build/components/MegaMenu/index.cjs.map +1 -1
- package/build/components/MegaMenu/index.d.cts +5 -1
- package/build/components/MegaMenu/index.d.ts +5 -1
- package/build/components/MegaMenu/index.js +131 -111
- package/build/components/MegaMenu/index.js.map +1 -1
- package/build/components/MegaMenu/style.css +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/NotificationCenter/style.css +1 -1
- package/build/components/PageHeader/style.css +1 -1
- package/build/components/Price/index.cjs +1 -1
- package/build/components/Price/index.cjs.map +1 -1
- package/build/components/Price/index.d.cts +5 -1
- package/build/components/Price/index.d.ts +5 -1
- package/build/components/Price/index.js +31 -32
- package/build/components/Price/index.js.map +1 -1
- package/build/components/Price/style.css +1 -1
- package/build/components/Radio/style.css +1 -1
- package/build/components/SectionHeader/style.css +1 -1
- package/build/components/Stat/index.cjs +1 -1
- package/build/components/Stat/index.cjs.map +1 -1
- package/build/components/Stat/index.d.cts +7 -3
- package/build/components/Stat/index.d.ts +7 -3
- package/build/components/Stat/index.js +61 -66
- package/build/components/Stat/index.js.map +1 -1
- package/build/components/StatCard/StatDelta.cjs +2 -0
- package/build/components/StatCard/StatDelta.cjs.map +1 -0
- package/build/components/StatCard/StatDelta.d.cts +17 -0
- package/build/components/StatCard/StatDelta.d.ts +17 -0
- package/build/components/StatCard/StatDelta.js +45 -0
- package/build/components/StatCard/StatDelta.js.map +1 -0
- package/build/components/StatCard/index.cjs +2 -0
- package/build/components/StatCard/index.cjs.map +1 -0
- package/build/components/StatCard/index.d.cts +36 -0
- package/build/components/StatCard/index.d.ts +36 -0
- package/build/components/StatCard/index.js +60 -0
- package/build/components/StatCard/index.js.map +1 -0
- package/build/components/StatCard/style.css +1 -0
- package/build/components/Table/style.css +1 -1
- package/build/components/Tabs/index.cjs +1 -1
- package/build/components/Tabs/index.cjs.map +1 -1
- package/build/components/Tabs/index.d.cts +26 -1
- package/build/components/Tabs/index.d.ts +26 -1
- package/build/components/Tabs/index.js +140 -112
- package/build/components/Tabs/index.js.map +1 -1
- package/build/components/Tabs/style.css +1 -1
- package/build/components/Text/index.cjs +2 -0
- package/build/components/Text/index.cjs.map +1 -0
- package/build/components/Text/index.d.cts +49 -0
- package/build/components/Text/index.d.ts +49 -0
- package/build/components/Text/index.js +47 -0
- package/build/components/Text/index.js.map +1 -0
- package/build/components/Text/style.css +1 -0
- package/build/design/index.cjs +12 -2
- package/build/design/index.cjs.map +1 -1
- package/build/design/index.d.cts +1 -5
- package/build/design/index.d.mts +1 -5
- package/build/design/index.mjs +12 -2
- package/build/design/index.mjs.map +1 -1
- package/build/design/index.umd.cjs +1 -1
- package/build/design/index.umd.cjs.map +1 -1
- package/build/design/tokens.css +29 -4
- package/build/design/tokens.json +42 -2
- package/build/design/tokens.scss +55 -0
- package/build/helpers/text.helper.cjs +1 -1
- package/build/helpers/text.helper.cjs.map +1 -1
- package/build/helpers/text.helper.d.cts +5 -0
- package/build/helpers/text.helper.d.ts +5 -0
- package/build/helpers/text.helper.js +3 -2
- package/build/helpers/text.helper.js.map +1 -1
- package/build/index.cjs +1 -1
- package/build/index.d.cts +5 -2
- package/build/index.d.ts +5 -2
- package/build/index.js +169 -163
- package/build/index.js.map +1 -1
- package/build/scss/_mixins.scss +101 -13
- package/build/scss/_variables.scss +5 -1
- package/build/styles.css +24 -18
- package/build/types/chat/DescriptionList/index.d.cts +6 -0
- package/build/types/chat/DescriptionList/index.d.ts +6 -0
- package/build/types/stat.type.d.cts +2 -0
- package/build/types/stat.type.d.ts +2 -0
- package/package.json +31 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as m, Fragment as M, jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { memo as B, useId as R, useEffect as T } from "react";
|
|
4
4
|
import { XCircleFill as U } from "react-bootstrap-icons";
|
|
5
5
|
import { ABOVE_TABLET_MEDIA_QUERY as k } from "../../constants/breakpoint.constants.js";
|
|
@@ -16,9 +16,9 @@ const X = ({
|
|
|
16
16
|
children: o,
|
|
17
17
|
title: p,
|
|
18
18
|
activeCount: r = 0,
|
|
19
|
-
onClearAll:
|
|
19
|
+
onClearAll: c,
|
|
20
20
|
isDrawerOpen: s = !1,
|
|
21
|
-
onDrawerClose:
|
|
21
|
+
onDrawerClose: a,
|
|
22
22
|
onApply: A,
|
|
23
23
|
applyLabel: F,
|
|
24
24
|
labels: t,
|
|
@@ -34,46 +34,39 @@ const X = ({
|
|
|
34
34
|
"FacetSidebar.labels.clearAll",
|
|
35
35
|
t == null ? void 0 : t.clearAll,
|
|
36
36
|
(E = e == null ? void 0 : e.facets) == null ? void 0 : E.clearAll
|
|
37
|
-
), S = () =>
|
|
37
|
+
), S = () => a == null ? void 0 : a();
|
|
38
38
|
T(() => {
|
|
39
39
|
if (!s || typeof window.matchMedia != "function") return;
|
|
40
|
-
const n = window.matchMedia(k), b = () => n.matches && (
|
|
40
|
+
const n = window.matchMedia(k), b = () => n.matches && (a == null ? void 0 : a());
|
|
41
41
|
return n.addEventListener("change", b), () => n.removeEventListener("change", b);
|
|
42
|
-
}, [s,
|
|
43
|
-
const x = !!
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
42
|
+
}, [s, a]);
|
|
43
|
+
const x = !!c && r > 0;
|
|
44
|
+
return /* @__PURE__ */ m(M, { children: [
|
|
45
|
+
/* @__PURE__ */ m(
|
|
46
46
|
"aside",
|
|
47
47
|
{
|
|
48
48
|
className: Y(d.sidebar, I),
|
|
49
49
|
"aria-labelledby": _,
|
|
50
50
|
"data-testid": L,
|
|
51
51
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
x && /* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ m("header", { className: d.sidebar__header, children: [
|
|
53
|
+
/* @__PURE__ */ i("h2", { id: _, className: d.sidebar__title, children: u }),
|
|
54
|
+
x && /* @__PURE__ */ i(
|
|
55
55
|
l,
|
|
56
56
|
{
|
|
57
57
|
variant: h.GHOST,
|
|
58
58
|
size: z.XSMALL,
|
|
59
|
-
startIcon: /* @__PURE__ */
|
|
60
|
-
onClick:
|
|
61
|
-
children:
|
|
62
|
-
y,
|
|
63
|
-
/* @__PURE__ */ c("span", { className: d.sidebar__count, children: [
|
|
64
|
-
" (",
|
|
65
|
-
r,
|
|
66
|
-
")"
|
|
67
|
-
] })
|
|
68
|
-
]
|
|
59
|
+
startIcon: /* @__PURE__ */ i(U, { "aria-hidden": !0 }),
|
|
60
|
+
onClick: c,
|
|
61
|
+
children: /* @__PURE__ */ i("span", { className: d.sidebar__count, children: `${y} (${r})` })
|
|
69
62
|
}
|
|
70
63
|
)
|
|
71
64
|
] }),
|
|
72
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ i("div", { className: d.sidebar__body, children: o })
|
|
73
66
|
]
|
|
74
67
|
}
|
|
75
68
|
),
|
|
76
|
-
s && /* @__PURE__ */
|
|
69
|
+
s && /* @__PURE__ */ i(
|
|
77
70
|
V,
|
|
78
71
|
{
|
|
79
72
|
isOpen: !0,
|
|
@@ -81,23 +74,23 @@ const X = ({
|
|
|
81
74
|
title: u,
|
|
82
75
|
side: "start",
|
|
83
76
|
size: "sm",
|
|
84
|
-
footer: /* @__PURE__ */
|
|
85
|
-
|
|
77
|
+
footer: /* @__PURE__ */ m("div", { className: d.footer, children: [
|
|
78
|
+
c && /* @__PURE__ */ i(
|
|
86
79
|
l,
|
|
87
80
|
{
|
|
88
81
|
variant: h.SECONDARY,
|
|
89
82
|
disabled: r === 0,
|
|
90
|
-
onClick:
|
|
83
|
+
onClick: c,
|
|
91
84
|
children: y
|
|
92
85
|
}
|
|
93
86
|
),
|
|
94
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ i(l, { variant: h.PRIMARY, onClick: A ?? S, children: f(
|
|
95
88
|
"FacetSidebar.applyLabel",
|
|
96
89
|
F ?? (t == null ? void 0 : t.apply),
|
|
97
90
|
(N = e == null ? void 0 : e.facets) == null ? void 0 : N.apply
|
|
98
91
|
) })
|
|
99
92
|
] }),
|
|
100
|
-
children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ i("div", { className: d.sidebar__body, children: o })
|
|
101
94
|
}
|
|
102
95
|
)
|
|
103
96
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/FacetSidebar/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useEffect, useId } from 'react';\n\nimport { XCircleFill } from 'react-bootstrap-icons';\n\nimport { ABOVE_TABLET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport Button from '../Button';\nimport Drawer from '../Drawer';\n\nimport styles from './index.module.scss';\n\nexport type FacetSidebarLabels = {\n title: string;\n clearAll: string;\n apply: string;\n};\n\ntype Props = {\n /** `FacetSection`s, in the order of the decision (\"my vehicle\" before brands). */\n children: ReactNode;\n /** The sidebar's heading and the drawer's title; `labels.facets.title` by default. */\n title?: string;\n /** Applied filters: the \"clear all\" button shows while it is above zero. */\n activeCount?: number;\n onClearAll?: () => void;\n /**\n * Narrow screens: the same sections in a `Drawer` from the start edge, with clear and apply\n * buttons at the foot. The sidebar column itself is hidden at tablet width and below.\n */\n isDrawerOpen?: boolean;\n onDrawerClose?: () => void;\n /** The drawer's apply button; closes the drawer when omitted. */\n onApply?: () => void;\n /** The apply button's text with the result count (\"128 ürünü göster\"); `labels.facets.apply` by default. */\n applyLabel?: string;\n labels?: Partial<FacetSidebarLabels>;\n className?: string;\n testId?: string;\n};\n\n/**\n * The catalogue's filter column (3.4): a heading with \"clear all\" over `FacetSection`s, sticky\n * below the header on a wide screen and a drawer with an apply button on a narrow one.\n */\nconst FacetSidebar = ({\n children,\n title,\n activeCount = 0,\n onClearAll,\n isDrawerOpen = false,\n onDrawerClose,\n onApply,\n applyLabel,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const headingId = useId();\n\n const heading = resolveLabel(\n 'FacetSidebar.title',\n title ?? labelProps?.title,\n config?.facets?.title,\n );\n const clearAllText = resolveLabel(\n 'FacetSidebar.labels.clearAll',\n labelProps?.clearAll,\n config?.facets?.clearAll,\n );\n const close = () => onDrawerClose?.();\n\n /* The drawer belongs to a narrow window: widening it past the tablet width shows the column. */\n useEffect(() => {\n if (!isDrawerOpen || typeof window.matchMedia !== 'function') return;\n\n const query = window.matchMedia(ABOVE_TABLET_MEDIA_QUERY);\n const handleChange = () => query.matches && onDrawerClose?.();\n query.addEventListener('change', handleChange);\n\n return () => query.removeEventListener('change', handleChange);\n }, [isDrawerOpen, onDrawerClose]);\n\n const canClear = Boolean(onClearAll) && activeCount > 0;\n\n return (\n <>\n <aside\n className={cx(styles.sidebar, className)}\n aria-labelledby={headingId}\n data-testid={testId}\n >\n <header className={styles.sidebar__header}>\n <h2 id={headingId} className={styles.sidebar__title}>\n {heading}\n </h2>\n {canClear && (\n <Button\n variant={UIVariant.GHOST}\n size={UISize.XSMALL}\n startIcon={<XCircleFill aria-hidden />}\n onClick={onClearAll}\n >\n {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/FacetSidebar/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useEffect, useId } from 'react';\n\nimport { XCircleFill } from 'react-bootstrap-icons';\n\nimport { ABOVE_TABLET_MEDIA_QUERY } from '../../constants/breakpoint.constants';\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport Button from '../Button';\nimport Drawer from '../Drawer';\n\nimport styles from './index.module.scss';\n\nexport type FacetSidebarLabels = {\n title: string;\n clearAll: string;\n apply: string;\n};\n\ntype Props = {\n /** `FacetSection`s, in the order of the decision (\"my vehicle\" before brands). */\n children: ReactNode;\n /** The sidebar's heading and the drawer's title; `labels.facets.title` by default. */\n title?: string;\n /** Applied filters: the \"clear all\" button shows while it is above zero. */\n activeCount?: number;\n onClearAll?: () => void;\n /**\n * Narrow screens: the same sections in a `Drawer` from the start edge, with clear and apply\n * buttons at the foot. The sidebar column itself is hidden at tablet width and below.\n */\n isDrawerOpen?: boolean;\n onDrawerClose?: () => void;\n /** The drawer's apply button; closes the drawer when omitted. */\n onApply?: () => void;\n /** The apply button's text with the result count (\"128 ürünü göster\"); `labels.facets.apply` by default. */\n applyLabel?: string;\n labels?: Partial<FacetSidebarLabels>;\n className?: string;\n testId?: string;\n};\n\n/**\n * The catalogue's filter column (3.4): a heading with \"clear all\" over `FacetSection`s, sticky\n * below the header on a wide screen and a drawer with an apply button on a narrow one.\n */\nconst FacetSidebar = ({\n children,\n title,\n activeCount = 0,\n onClearAll,\n isDrawerOpen = false,\n onDrawerClose,\n onApply,\n applyLabel,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const headingId = useId();\n\n const heading = resolveLabel(\n 'FacetSidebar.title',\n title ?? labelProps?.title,\n config?.facets?.title,\n );\n const clearAllText = resolveLabel(\n 'FacetSidebar.labels.clearAll',\n labelProps?.clearAll,\n config?.facets?.clearAll,\n );\n const close = () => onDrawerClose?.();\n\n /* The drawer belongs to a narrow window: widening it past the tablet width shows the column. */\n useEffect(() => {\n if (!isDrawerOpen || typeof window.matchMedia !== 'function') return;\n\n const query = window.matchMedia(ABOVE_TABLET_MEDIA_QUERY);\n const handleChange = () => query.matches && onDrawerClose?.();\n query.addEventListener('change', handleChange);\n\n return () => query.removeEventListener('change', handleChange);\n }, [isDrawerOpen, onDrawerClose]);\n\n const canClear = Boolean(onClearAll) && activeCount > 0;\n\n return (\n <>\n <aside\n className={cx(styles.sidebar, className)}\n aria-labelledby={headingId}\n data-testid={testId}\n >\n <header className={styles.sidebar__header}>\n <h2 id={headingId} className={styles.sidebar__title}>\n {heading}\n </h2>\n {canClear && (\n <Button\n variant={UIVariant.GHOST}\n size={UISize.XSMALL}\n startIcon={<XCircleFill aria-hidden />}\n onClick={onClearAll}\n >\n {/*\n 3.7: one text node. The leading space of a separate `<span>` was trimmed at the\n start of the button's flex item and the label read \"Tümünü temizle(1)\".\n */}\n <span className={styles.sidebar__count}>{`${clearAllText} (${activeCount})`}</span>\n </Button>\n )}\n </header>\n <div className={styles.sidebar__body}>{children}</div>\n </aside>\n\n {/* Drawn only while open: a closed drawer would keep a second copy of every section. */}\n {isDrawerOpen && (\n <Drawer\n isOpen\n onClose={close}\n title={heading}\n side=\"start\"\n size=\"sm\"\n footer={\n <div className={styles.footer}>\n {onClearAll && (\n <Button\n variant={UIVariant.SECONDARY}\n disabled={activeCount === 0}\n onClick={onClearAll}\n >\n {clearAllText}\n </Button>\n )}\n <Button variant={UIVariant.PRIMARY} onClick={onApply ?? close}>\n {resolveLabel(\n 'FacetSidebar.applyLabel',\n applyLabel ?? labelProps?.apply,\n config?.facets?.apply,\n )}\n </Button>\n </div>\n }\n >\n <div className={styles.sidebar__body}>{children}</div>\n </Drawer>\n )}\n </>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(FacetSidebar, 'FacetSidebar'),\n) as typeof FacetSidebar;\n"],"names":["FacetSidebar","children","title","activeCount","onClearAll","isDrawerOpen","onDrawerClose","onApply","applyLabel","labelProps","className","testId","config","useUi","headingId","useId","heading","resolveLabel","_a","clearAllText","_b","close","useEffect","query","ABOVE_TABLET_MEDIA_QUERY","handleChange","canClear","jsxs","Fragment","cx","styles","jsx","Button","UIVariant","UISize","XCircleFill","Drawer","_c","index","memo","named"],"mappings":";;;;;;;;;;;;;;AAkDA,MAAMA,IAAe,CAAC;AAAA,EACpB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,YAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,eAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAQC;AAAA,EACR,WAAAC;AAAA,EACA,QAAAC;AAC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AAA,gBACpC,SAAS/B;AAAA,gBAMT,UAAA,gBAAA2B,EAAC,UAAK,WAAWD,EAAO,gBAAiB,UAAA,GAAGX,CAAY,KAAKhB,CAAW,IAAA,CAAI;AAAA,cAAA;AAAA,YAAA;AAAA,UAC9E,GAEJ;AAAA,UACA,gBAAA4B,EAAC,OAAA,EAAI,WAAWD,EAAO,eAAgB,UAAA7B,EAAA,CAAS;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAIjDI,KACC,gBAAA0B;AAAA,MAACK;AAAA,MAAA;AAAA,QACC,QAAM;AAAA,QACN,SAASf;AAAA,QACT,OAAOL;AAAA,QACP,MAAK;AAAA,QACL,MAAK;AAAA,QACL,QACE,gBAAAW,EAAC,OAAA,EAAI,WAAWG,EAAO,QACpB,UAAA;AAAA,UAAA1B,KACC,gBAAA2B;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,SAASC,EAAU;AAAA,cACnB,UAAU9B,MAAgB;AAAA,cAC1B,SAASC;AAAA,cAER,UAAAe;AAAA,YAAA;AAAA,UAAA;AAAA,4BAGJa,GAAA,EAAO,SAASC,EAAU,SAAS,SAAS1B,KAAWc,GACrD,UAAAJ;AAAA,YACC;AAAA,YACAT,MAAcC,KAAA,gBAAAA,EAAY;AAAA,aAC1B4B,IAAAzB,KAAA,gBAAAA,EAAQ,WAAR,gBAAAyB,EAAgB;AAAA,UAAA,EAClB,CACF;AAAA,QAAA,GACF;AAAA,QAGF,UAAA,gBAAAN,EAAC,OAAA,EAAI,WAAWD,EAAO,eAAgB,UAAA7B,EAAA,CAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAClD,GAEJ;AAEJ,GAEAqC,IAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAMxC,GAAc,cAAc;AAClD;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),l=require("react"),m=require("../../helpers/class-name.helper.cjs"),g=require("../../helpers/component.helper.cjs"),x=require("../../helpers/text.helper.cjs"),t={default:{"heading":"ui-heading-Jzj8r","heading--xl":"ui-heading--xl-cET5u","heading--lg":"ui-heading--lg-C2PYU","heading--md":"ui-heading--md-SW2DJ","heading--sm":"ui-heading--sm-sYxwY","heading--xs":"ui-heading--xs-wXibD","heading--clamp-1":"ui-heading--clamp-1-9XGfX","heading--clamp-2":"ui-heading--clamp-2-KqnI5","heading--clamp-3":"ui-heading--clamp-3-rdti-"}},_={1:"xl",2:"md",3:"sm",4:"xs",5:"xs",6:"xs"},p=({children:s,level:r=2,size:n,maxLines:e,title:a,id:o,className:d,testId:i})=>{const u=`h${r}`;return c.jsx(u,{id:o,className:m.cx(t.default.heading,t.default[`heading--${n??_[r]}`],e!==void 0&&t.default[`heading--clamp-${e}`],d),title:e===void 0?a:x.clampTitle(s,a),"data-testid":i,children:s})},h=l.memo(g.named(p,"Heading"));exports.default=h;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Heading/index.tsx"],"sourcesContent":["import { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { clampTitle } from '../../helpers/text.helper';\n\nimport styles from './index.module.scss';\n\n/** The semantic level: `<h1>` … `<h6>`. */\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * The visual size, independent of the level: `xl` 32px (the page title), `lg` 28px (a product\n * title), `md` 22px (a section), `sm` 18px (a sub-section), `xs` 15px (a block inside a surface).\n */\nexport type HeadingSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';\n\ntype Props = {\n children: ReactNode;\n /** The element: `1` is `<h1>`. One visible `<h1>` per page. Default `2`. */\n level?: HeadingLevel;\n /** The look; follows the level by default (1 `xl` · 2 `md` · 3 `sm` · 4–6 `xs`). */\n size?: HeadingSize;\n /**\n * Cut after this many lines with an ellipsis; a string title is shown in full in `title`.\n * Titles of cards and rows use `2`.\n */\n maxLines?: 1 | 2 | 3;\n /** The full text for the tooltip when `children` is not a string. */\n title?: string;\n id?: string;\n className?: string;\n testId?: string;\n};\n\nconst SIZE_OF_LEVEL: Record<HeadingLevel, HeadingSize> = {\n 1: 'xl',\n 2: 'md',\n 3: 'sm',\n 4: 'xs',\n 5: 'xs',\n 6: 'xs',\n};\n\n/**\n * Heading (3.7) — a heading whose look is chosen apart from its level: a product title is an\n * `<h1>` drawn at 28px, a card title an `<h3>` at 15px. Archivo 600 at its normal width, from\n * the design's `title-*` roles; a page never writes a raw `<h1>`–`<h6>` with its own size.\n * @example <Heading level={1} size=\"lg\" maxLines={2}>Ön far (sol)</Heading>\n */\nconst Heading: FC<Props> = ({\n children,\n level = 2,\n size,\n maxLines,\n title,\n id,\n className,\n testId,\n}) => {\n const Tag = `h${level}` as const;\n\n return (\n <Tag\n id={id}\n className={cx(\n styles.heading,\n styles[`heading--${size ?? SIZE_OF_LEVEL[level]}`],\n maxLines !== undefined && styles[`heading--clamp-${maxLines}`],\n className,\n )}\n title={maxLines === undefined ? title : clampTitle(children, title)}\n data-testid={testId}\n >\n {children}\n </Tag>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Heading, 'Heading')) as typeof Heading;\n"],"names":["SIZE_OF_LEVEL","Heading","children","level","size","maxLines","title","id","className","testId","Tag","jsx","cx","styles","clampTitle","index","memo","named"],"mappings":"qVAmCMA,EAAmD,CACvD,EAAG,KACH,EAAG,KACH,EAAG,KACH,EAAG,KACH,EAAG,KACH,EAAG,IACL,EAQMC,EAAqB,CAAC,CAC1B,SAAAC,EACA,MAAAC,EAAQ,EACR,KAAAC,EACA,SAAAC,EACA,MAAAC,EACA,GAAAC,EACA,UAAAC,EACA,OAAAC,CACF,IAAM,CACJ,MAAMC,EAAM,IAAIP,CAAK,GAErB,OACEQ,EAAAA,IAACD,EAAA,CACC,GAAAH,EACA,UAAWK,EAAAA,GACTC,EAAAA,QAAO,QACPA,EAAAA,QAAO,YAAYT,GAAQJ,EAAcG,CAAK,CAAC,EAAE,EACjDE,IAAa,QAAaQ,EAAAA,QAAO,kBAAkBR,CAAQ,EAAE,EAC7DG,CAAA,EAEF,MAAOH,IAAa,OAAYC,EAAQQ,EAAAA,WAAWZ,EAAUI,CAAK,EAClE,cAAaG,EAEZ,SAAAP,CAAA,CAAA,CAGP,EAEAa,EAA6BC,OAAmBC,EAAAA,MAAMhB,EAAS,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
/** The semantic level: `<h1>` … `<h6>`. */
|
|
3
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
/**
|
|
5
|
+
* The visual size, independent of the level: `xl` 32px (the page title), `lg` 28px (a product
|
|
6
|
+
* title), `md` 22px (a section), `sm` 18px (a sub-section), `xs` 15px (a block inside a surface).
|
|
7
|
+
*/
|
|
8
|
+
export type HeadingSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
9
|
+
type Props = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** The element: `1` is `<h1>`. One visible `<h1>` per page. Default `2`. */
|
|
12
|
+
level?: HeadingLevel;
|
|
13
|
+
/** The look; follows the level by default (1 `xl` · 2 `md` · 3 `sm` · 4–6 `xs`). */
|
|
14
|
+
size?: HeadingSize;
|
|
15
|
+
/**
|
|
16
|
+
* Cut after this many lines with an ellipsis; a string title is shown in full in `title`.
|
|
17
|
+
* Titles of cards and rows use `2`.
|
|
18
|
+
*/
|
|
19
|
+
maxLines?: 1 | 2 | 3;
|
|
20
|
+
/** The full text for the tooltip when `children` is not a string. */
|
|
21
|
+
title?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
testId?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Heading (3.7) — a heading whose look is chosen apart from its level: a product title is an
|
|
28
|
+
* `<h1>` drawn at 28px, a card title an `<h3>` at 15px. Archivo 600 at its normal width, from
|
|
29
|
+
* the design's `title-*` roles; a page never writes a raw `<h1>`–`<h6>` with its own size.
|
|
30
|
+
* @example <Heading level={1} size="lg" maxLines={2}>Ön far (sol)</Heading>
|
|
31
|
+
*/
|
|
32
|
+
declare const Heading: FC<Props>;
|
|
33
|
+
declare const _default: typeof Heading;
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
/** The semantic level: `<h1>` … `<h6>`. */
|
|
3
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
/**
|
|
5
|
+
* The visual size, independent of the level: `xl` 32px (the page title), `lg` 28px (a product
|
|
6
|
+
* title), `md` 22px (a section), `sm` 18px (a sub-section), `xs` 15px (a block inside a surface).
|
|
7
|
+
*/
|
|
8
|
+
export type HeadingSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
9
|
+
type Props = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/** The element: `1` is `<h1>`. One visible `<h1>` per page. Default `2`. */
|
|
12
|
+
level?: HeadingLevel;
|
|
13
|
+
/** The look; follows the level by default (1 `xl` · 2 `md` · 3 `sm` · 4–6 `xs`). */
|
|
14
|
+
size?: HeadingSize;
|
|
15
|
+
/**
|
|
16
|
+
* Cut after this many lines with an ellipsis; a string title is shown in full in `title`.
|
|
17
|
+
* Titles of cards and rows use `2`.
|
|
18
|
+
*/
|
|
19
|
+
maxLines?: 1 | 2 | 3;
|
|
20
|
+
/** The full text for the tooltip when `children` is not a string. */
|
|
21
|
+
title?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
testId?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Heading (3.7) — a heading whose look is chosen apart from its level: a product title is an
|
|
28
|
+
* `<h1>` drawn at 28px, a card title an `<h3>` at 15px. Archivo 600 at its normal width, from
|
|
29
|
+
* the design's `title-*` roles; a page never writes a raw `<h1>`–`<h6>` with its own size.
|
|
30
|
+
* @example <Heading level={1} size="lg" maxLines={2}>Ön far (sol)</Heading>
|
|
31
|
+
*/
|
|
32
|
+
declare const Heading: FC<Props>;
|
|
33
|
+
declare const _default: typeof Heading;
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { memo as c } from "react";
|
|
3
|
+
import { cx as f } from "../../helpers/class-name.helper.js";
|
|
4
|
+
import { named as g } from "../../helpers/component.helper.js";
|
|
5
|
+
import { clampTitle as x } from "../../helpers/text.helper.js";
|
|
6
|
+
const m = {"heading":"ui-heading-Jzj8r","heading--xl":"ui-heading--xl-cET5u","heading--lg":"ui-heading--lg-C2PYU","heading--md":"ui-heading--md-SW2DJ","heading--sm":"ui-heading--sm-sYxwY","heading--xs":"ui-heading--xs-wXibD","heading--clamp-1":"ui-heading--clamp-1-9XGfX","heading--clamp-2":"ui-heading--clamp-2-KqnI5","heading--clamp-3":"ui-heading--clamp-3-rdti-"};
|
|
7
|
+
const l = {
|
|
8
|
+
1: "xl",
|
|
9
|
+
2: "md",
|
|
10
|
+
3: "sm",
|
|
11
|
+
4: "xs",
|
|
12
|
+
5: "xs",
|
|
13
|
+
6: "xs"
|
|
14
|
+
}, h = ({
|
|
15
|
+
children: t,
|
|
16
|
+
level: r = 2,
|
|
17
|
+
size: i,
|
|
18
|
+
maxLines: o,
|
|
19
|
+
title: a,
|
|
20
|
+
id: s,
|
|
21
|
+
className: d,
|
|
22
|
+
testId: e
|
|
23
|
+
}) => {
|
|
24
|
+
const n = `h${r}`;
|
|
25
|
+
return /* @__PURE__ */ p(
|
|
26
|
+
n,
|
|
27
|
+
{
|
|
28
|
+
id: s,
|
|
29
|
+
className: f(
|
|
30
|
+
m.heading,
|
|
31
|
+
m[`heading--${i ?? l[r]}`],
|
|
32
|
+
o !== void 0 && m[`heading--clamp-${o}`],
|
|
33
|
+
d
|
|
34
|
+
),
|
|
35
|
+
title: o === void 0 ? a : x(t, a),
|
|
36
|
+
"data-testid": e,
|
|
37
|
+
children: t
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}, j = /* @__PURE__ */ c(/* @__PURE__ */ g(h, "Heading"));
|
|
41
|
+
export {
|
|
42
|
+
j as default
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Heading/index.tsx"],"sourcesContent":["import { type FC, memo, type ReactNode } from 'react';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { clampTitle } from '../../helpers/text.helper';\n\nimport styles from './index.module.scss';\n\n/** The semantic level: `<h1>` … `<h6>`. */\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * The visual size, independent of the level: `xl` 32px (the page title), `lg` 28px (a product\n * title), `md` 22px (a section), `sm` 18px (a sub-section), `xs` 15px (a block inside a surface).\n */\nexport type HeadingSize = 'xl' | 'lg' | 'md' | 'sm' | 'xs';\n\ntype Props = {\n children: ReactNode;\n /** The element: `1` is `<h1>`. One visible `<h1>` per page. Default `2`. */\n level?: HeadingLevel;\n /** The look; follows the level by default (1 `xl` · 2 `md` · 3 `sm` · 4–6 `xs`). */\n size?: HeadingSize;\n /**\n * Cut after this many lines with an ellipsis; a string title is shown in full in `title`.\n * Titles of cards and rows use `2`.\n */\n maxLines?: 1 | 2 | 3;\n /** The full text for the tooltip when `children` is not a string. */\n title?: string;\n id?: string;\n className?: string;\n testId?: string;\n};\n\nconst SIZE_OF_LEVEL: Record<HeadingLevel, HeadingSize> = {\n 1: 'xl',\n 2: 'md',\n 3: 'sm',\n 4: 'xs',\n 5: 'xs',\n 6: 'xs',\n};\n\n/**\n * Heading (3.7) — a heading whose look is chosen apart from its level: a product title is an\n * `<h1>` drawn at 28px, a card title an `<h3>` at 15px. Archivo 600 at its normal width, from\n * the design's `title-*` roles; a page never writes a raw `<h1>`–`<h6>` with its own size.\n * @example <Heading level={1} size=\"lg\" maxLines={2}>Ön far (sol)</Heading>\n */\nconst Heading: FC<Props> = ({\n children,\n level = 2,\n size,\n maxLines,\n title,\n id,\n className,\n testId,\n}) => {\n const Tag = `h${level}` as const;\n\n return (\n <Tag\n id={id}\n className={cx(\n styles.heading,\n styles[`heading--${size ?? SIZE_OF_LEVEL[level]}`],\n maxLines !== undefined && styles[`heading--clamp-${maxLines}`],\n className,\n )}\n title={maxLines === undefined ? title : clampTitle(children, title)}\n data-testid={testId}\n >\n {children}\n </Tag>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(Heading, 'Heading')) as typeof Heading;\n"],"names":["SIZE_OF_LEVEL","Heading","children","level","size","maxLines","title","id","className","testId","Tag","jsx","cx","styles","clampTitle","index","memo","named"],"mappings":";;;;;;AAmCA,MAAMA,IAAmD;AAAA,EACvD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL,GAQMC,IAAqB,CAAC;AAAA,EAC1B,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AACF,MAAM;AACJ,QAAMC,IAAM,IAAIP,CAAK;AAErB,SACE,gBAAAQ;AAAA,IAACD;AAAA,IAAA;AAAA,MACC,IAAAH;AAAA,MACA,WAAWK;AAAA,QACTC,EAAO;AAAA,QACPA,EAAO,YAAYT,KAAQJ,EAAcG,CAAK,CAAC,EAAE;AAAA,QACjDE,MAAa,UAAaQ,EAAO,kBAAkBR,CAAQ,EAAE;AAAA,QAC7DG;AAAA,MAAA;AAAA,MAEF,OAAOH,MAAa,SAAYC,IAAQQ,EAAWZ,GAAUI,CAAK;AAAA,MAClE,eAAaG;AAAA,MAEZ,UAAAP;AAAA,IAAA;AAAA,EAAA;AAGP,GAEAa,IAA6B,gBAAAC,EAAmB,gBAAAC,EAAMhB,GAAS,SAAS,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer ui{.ui-heading-Jzj8r{margin:0;min-width:0;color:var(--hd-text);overflow-wrap:break-word;text-wrap:pretty}.ui-heading--xl-cET5u{font-family:var(--hd-font-display);font-size:var(--hd-type-title-1-size);font-weight:var(--hd-type-title-1-weight);font-stretch:var(--hd-type-title-1-stretch);line-height:var(--hd-type-title-1-line-height);letter-spacing:var(--hd-type-title-1-letter-spacing);text-wrap:balance}.ui-heading--lg-C2PYU{font-family:var(--hd-font-display);font-size:var(--hd-type-title-2-size);font-weight:var(--hd-type-title-2-weight);font-stretch:var(--hd-type-title-2-stretch);line-height:var(--hd-type-title-2-line-height);letter-spacing:var(--hd-type-title-2-letter-spacing);text-wrap:balance}.ui-heading--md-SW2DJ{font-family:var(--hd-font-display);font-size:var(--hd-type-title-3-size);font-weight:var(--hd-type-title-3-weight);font-stretch:var(--hd-type-title-3-stretch);line-height:var(--hd-type-title-3-line-height);letter-spacing:var(--hd-type-title-3-letter-spacing)}.ui-heading--sm-sYxwY{font-family:var(--hd-font-display);font-size:var(--hd-type-title-4-size);font-weight:var(--hd-type-title-4-weight);font-stretch:var(--hd-type-title-4-stretch);line-height:var(--hd-type-title-4-line-height);letter-spacing:var(--hd-type-title-4-letter-spacing)}.ui-heading--xs-wXibD{font-family:var(--hd-font-display);font-size:var(--hd-type-title-5-size);font-weight:var(--hd-type-title-5-weight);font-stretch:var(--hd-type-title-5-stretch);line-height:var(--hd-type-title-5-line-height);letter-spacing:var(--hd-type-title-5-letter-spacing)}.ui-heading--clamp-1-9XGfX{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;display:block}.ui-heading--clamp-2-KqnI5{display:-webkit-box;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow-wrap:anywhere}.ui-heading--clamp-3-rdti-{display:-webkit-box;min-width:0;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow-wrap:anywhere}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),d=require("react"),X=require("react-bootstrap-icons"),j=require("../../helpers/class-name.helper.cjs"),G=require("../../helpers/component.helper.cjs"),J=require("../../helpers/focus.helper.cjs"),L=require("../../helpers/label.helper.cjs"),Q=require("../../theme/context.cjs"),V=require("../Disclosure/index.cjs"),Z=require("../Drawer/index.cjs"),_=require("../Link/index.cjs"),a={default:{"menu":"ui-menu-jtqmU","menu__bar":"ui-menu__bar-UfVrS","menu__entry":"ui-menu__entry-HlGup","top":"ui-top-3IV6E","top--active":"ui-top--active-Dyxdn","top--open":"ui-top--open-tZfGv","top__icon":"ui-top__icon-pJ4qx","top__chevron":"ui-top__chevron-Q78lv","panel":"ui-panel-5tVKC","panel__columns":"ui-panel__columns-FIEC2","panel__feature":"ui-panel__feature-UpJps","panel__all":"ui-panel__all-P8gKX","column":"ui-column-XjUAF","column__title":"ui-column__title-vUwA-","column__link":"ui-column__link-hbfhD","column__list":"ui-column__list-2Lfk1","column--split":"ui-column--split-4DxoK","link":"ui-link-rgH63","link__media":"ui-link__media-GGkAB","link__media--image":"ui-link__media--image-IGyD8","link__text":"ui-link__text-DdDSW","link__label":"ui-link__label-477IK","link__count":"ui-link__count-7rNAa","link__description":"ui-link__description--aYQy","drawer":"ui-drawer-OlUga","drawer__section":"ui-drawer__section-mhWRx","drawer__link":"ui-drawer__link--rbtx"}},ee=120,ne=200,M=o=>{var v;return(((v=o.columns)==null?void 0:v.length)??0)>0},D=3,te=8,T=o=>o.length>1?Math.min(o.length,D):Math.min(Math.ceil(o[0].links.length/te),D)||1,ae=({items:o,label:v,isDrawerOpen:I=!1,onDrawerClose:E,labels:c,className:B,testId:F})=>{const{labels:A}=Q.useUi(),i=A==null?void 0:A.megaMenu,g=d.useId(),h=d.useRef(null),x=d.useRef(void 0),[u,f]=d.useState(null),k=L.resolveLabel("MegaMenu.label",v??(c==null?void 0:c.navigation),i==null?void 0:i.navigation),b=e=>L.resolveFormatter("MegaMenu.labels.seeAll",(c==null?void 0:c.seeAll)??(i==null?void 0:i.seeAll),e.label),q=(e,n)=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>f(e),n)};d.useEffect(()=>()=>window.clearTimeout(x.current),[]),d.useEffect(()=>{if(u===null)return;const e=n=>{var r;(r=h.current)!=null&&r.contains(n.target)||f(null)};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[u]);const K=e=>{var n;return(n=h.current)==null?void 0:n.querySelector(`[data-ui-mega-top="${e}"]`)},[U,Y]=d.useState(0);d.useLayoutEffect(()=>{if(u===null)return;const e=document.getElementById(`${g}-${u}`),n=h.current,r=e.previousElementSibling,s=n.getBoundingClientRect(),l=r.getBoundingClientRect(),m=getComputedStyle(n).direction==="rtl"?s.right-l.right:l.left-s.left;Y(Math.max(0,Math.min(m,s.width-e.offsetWidth)))},[u,g]);const z=e=>{var n;window.clearTimeout(x.current),f(null),(n=K(e))==null||n.focus()},S=(e,n)=>{const r=e.target;if(e.key==="Escape"&&u===n.id){e.preventDefault(),z(n.id);return}if(r.dataset.uiMegaTop===void 0)return;if(e.key==="ArrowDown"&&M(n)){e.preventDefault(),f(n.id),window.requestAnimationFrame(()=>{var R,$;return($=(R=document.getElementById(`${g}-${n.id}`))==null?void 0:R.querySelector(J.FOCUSABLE_SELECTOR))==null?void 0:$.focus()});return}const l=[...h.current.querySelectorAll("[data-ui-mega-top]")],p=l.indexOf(r),m=document.dir==="rtl"?"ArrowLeft":"ArrowRight",w=document.dir==="rtl"?"ArrowRight":"ArrowLeft",y=e.key===m?(p+1)%l.length:e.key===w?(p-1+l.length)%l.length:e.key==="Home"?0:e.key==="End"?l.length-1:-1;y!==-1&&(e.preventDefault(),u!==null&&f(null),l[y].focus())},O=(e,n)=>{e.pointerType==="mouse"&&q(M(n)?n.id:null,ee)},H=e=>{e.pointerType==="mouse"&&q(null,ne)},P=e=>{var n;(n=h.current)!=null&&n.contains(e.relatedTarget)||f(null)},W=(e,n)=>t.jsx("li",{children:t.jsxs(_.default,{...e.linkProps,href:e.href,className:a.default.link,onClick:n,children:[(e.image??e.icon)&&t.jsx("span",{"aria-hidden":!0,className:j.cx(a.default.link__media,e.image!==void 0&&a.default["link__media--image"]),children:e.image??e.icon}),t.jsxs("span",{className:a.default.link__text,children:[t.jsx("span",{className:a.default.link__label,children:e.label}),e.description&&t.jsx("span",{className:a.default.link__description,children:e.description})]}),e.count!==void 0&&t.jsx("span",{className:a.default.link__count,children:e.count})]})},e.id),C=(e,n,r)=>{var s;return(s=e.columns)==null?void 0:s.map(l=>{var w;const p=`${g}-${n}-${e.id}-${l.id}`,m=n==="bar"&&((w=e.columns)==null?void 0:w.length)===1&&T([l])>1;return t.jsxs("div",{className:j.cx(a.default.column,m&&a.default["column--split"]),children:[l.title&&t.jsx("p",{id:p,className:a.default.column__title,children:l.href?t.jsx(_.default,{href:l.href,className:a.default.column__link,onClick:r,children:l.title}):l.title}),t.jsx("ul",{className:a.default.column__list,"aria-labelledby":l.title?p:void 0,children:l.links.map(y=>W(y,r))})]},l.id)})},N=()=>E==null?void 0:E();return t.jsxs(t.Fragment,{children:[t.jsx("nav",{ref:h,"aria-label":k,className:j.cx(a.default.menu,B),"data-testid":F,onBlur:P,children:t.jsx("ul",{className:a.default.menu__bar,children:o.map(e=>{const n=u===e.id,r=`${g}-${e.id}`;return M(e)?t.jsxs("li",{className:a.default.menu__entry,onPointerEnter:s=>O(s,e),onPointerLeave:H,onKeyDown:s=>S(s,e),children:[t.jsxs("button",{type:"button","data-ui-mega-top":e.id,className:j.cx(a.default.top,e.isActive&&a.default["top--active"],n&&a.default["top--open"]),"aria-expanded":n,"aria-controls":r,onClick:()=>{window.clearTimeout(x.current),f(n?null:e.id)},children:[e.icon&&t.jsx("span",{"aria-hidden":!0,className:a.default.top__icon,children:e.icon}),e.label,t.jsx(X.ChevronDown,{"aria-hidden":!0,className:a.default.top__chevron})]}),t.jsxs("div",{id:r,className:a.default.panel,hidden:!n,style:{"--ui-mega-offset":`${n?U:0}px`,"--ui-mega-columns":T(e.columns)},children:[t.jsx("div",{className:a.default.panel__columns,children:C(e,"bar")}),e.feature&&t.jsx("div",{className:a.default.panel__feature,children:e.feature}),e.href&&t.jsx(_.default,{...e.linkProps,href:e.href,className:a.default.panel__all,children:b(e)})]})]},e.id):t.jsx("li",{className:a.default.menu__entry,onPointerEnter:s=>O(s,e),children:t.jsxs(_.default,{...e.linkProps,href:e.href??"#","data-ui-mega-top":e.id,className:j.cx(a.default.top,e.isActive&&a.default["top--active"]),"aria-current":e.isActive?"page":void 0,onKeyDown:s=>S(s,e),children:[e.icon&&t.jsx("span",{"aria-hidden":!0,className:a.default.top__icon,children:e.icon}),e.label]})},e.id)})})}),I&&t.jsx(Z.default,{isOpen:!0,onClose:N,title:L.resolveLabel("MegaMenu.labels.menu",c==null?void 0:c.menu,i==null?void 0:i.menu),side:"start",size:"sm",children:t.jsx("nav",{"aria-label":k,children:t.jsx("ul",{className:a.default.drawer,children:o.map(e=>M(e)?t.jsx("li",{children:t.jsx(V.default,{variant:"plain",summary:e.label,isDefaultOpen:e.isActive,children:t.jsxs("div",{className:a.default.drawer__section,children:[e.href&&t.jsx(_.default,{...e.linkProps,href:e.href,className:a.default.panel__all,onClick:N,children:b(e)}),C(e,"drawer",N)]})})},e.id):t.jsx("li",{children:t.jsx(_.default,{...e.linkProps,href:e.href??"#",className:a.default.drawer__link,"aria-current":e.isActive?"page":void 0,onClick:N,children:e.label})},e.id))})})})]})},le=d.memo(G.named(ae,"MegaMenu"));exports.default=le;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/MegaMenu/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FocusEvent,\n type KeyboardEvent,\n memo,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { ChevronDown } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { FOCUSABLE_SELECTOR } from '../../helpers/focus.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport type { Formatter } from '../../types/theme.type';\nimport Disclosure from '../Disclosure';\nimport Drawer from '../Drawer';\nimport UiLink from '../Link';\n\nimport styles from './index.module.scss';\n\n/** A sub-category link of a panel column. */\nexport type MegaMenuLink = {\n id: string;\n label: string;\n href: string;\n /** A small icon before the label. */\n icon?: ReactNode;\n /** A thumbnail before the label (an `<img alt=\"\">`); wins over `icon`. */\n image?: ReactNode;\n /** A short line under the label. */\n description?: string;\n linkProps?: UiLinkExtraProps;\n};\n\n/** One column of a panel: a titled group of links (\"Fren sistemi\"). */\nexport type MegaMenuColumn = {\n id: string;\n title?: string;\n /** Makes the title a link to the group's page. */\n href?: string;\n links: MegaMenuLink[];\n};\n\n/** A top-level category: a link, or a button that opens a panel when it has `columns`. */\nexport type MegaMenuItem = {\n id: string;\n label: string;\n /** The category's page: the item's link, or the panel's \"see all\" link. */\n href?: string;\n icon?: ReactNode;\n columns?: MegaMenuColumn[];\n /** A slot at the panel's end: a campaign card, a featured brand. */\n feature?: ReactNode;\n /** The current section of the site. */\n isActive?: boolean;\n linkProps?: UiLinkExtraProps;\n};\n\nexport type MegaMenuLabels = {\n navigation: string;\n menu: string;\n seeAll: Formatter<[label: string]>;\n};\n\ntype Props = {\n items: MegaMenuItem[];\n /** The landmark's name; `labels.megaMenu.navigation` by default. */\n label?: string;\n /**\n * Narrow screens: the categories in a `Drawer` from the start edge, each one a section that\n * opens in place. The bar itself is hidden at tablet width and below; the app's menu button\n * opens the drawer.\n */\n isDrawerOpen?: boolean;\n onDrawerClose?: () => void;\n labels?: Partial<MegaMenuLabels>;\n className?: string;\n testId?: string;\n};\n\n/* A pointer resting this long on a category opens it; leaving for this long closes it. */\nconst OPEN_DELAY = 120;\nconst CLOSE_DELAY = 200;\n\nconst hasPanel = (item: MegaMenuItem): boolean => (item.columns?.length ?? 0) > 0;\n\n/**\n * A storefront header's category navigation (3.4): top-level categories, a panel of sub-category\n * columns (with icons or thumbnails and a feature slot) under each, opened by click, keyboard or a\n * resting pointer; a drawer of sections on a narrow screen. A disclosure navigation, not an ARIA\n * menu: the links are links, Tab moves through them, ←/→ move along the bar, Escape closes.\n */\nconst MegaMenu = ({\n items,\n label,\n isDrawerOpen = false,\n onDrawerClose,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const text = config?.megaMenu;\n const baseId = useId();\n const navRef = useRef<HTMLElement>(null);\n const timerRef = useRef<number | undefined>(undefined);\n const [openId, setOpenId] = useState<string | null>(null);\n\n const navigation = resolveLabel(\n 'MegaMenu.label',\n label ?? labelProps?.navigation,\n text?.navigation,\n );\n const seeAll = (item: MegaMenuItem) =>\n resolveFormatter('MegaMenu.labels.seeAll', labelProps?.seeAll ?? text?.seeAll, item.label);\n\n const schedule = (next: string | null, delay: number) => {\n window.clearTimeout(timerRef.current);\n timerRef.current = window.setTimeout(() => setOpenId(next), delay);\n };\n\n useEffect(() => () => window.clearTimeout(timerRef.current), []);\n\n /* A press outside the bar closes the open panel. */\n useEffect(() => {\n if (openId === null) return;\n\n const handlePointerDown = (event: globalThis.PointerEvent) => {\n if (!navRef.current?.contains(event.target as Node)) setOpenId(null);\n };\n document.addEventListener('pointerdown', handlePointerDown);\n\n return () => document.removeEventListener('pointerdown', handlePointerDown);\n }, [openId]);\n\n const triggerOf = (id: string) =>\n navRef.current?.querySelector<HTMLElement>(`[data-ui-mega-top=\"${id}\"]`);\n\n const close = (id: string) => {\n window.clearTimeout(timerRef.current);\n setOpenId(null);\n triggerOf(id)?.focus();\n };\n\n /* ←/→/Home/End along the top level; ↓ opens a panel and enters it; Escape closes it. */\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>, item: MegaMenuItem) => {\n const target = event.target as HTMLElement;\n\n if (event.key === 'Escape' && openId === item.id) {\n event.preventDefault();\n close(item.id);\n return;\n }\n\n if (target.dataset.uiMegaTop === undefined) return;\n\n if (event.key === 'ArrowDown' && hasPanel(item)) {\n event.preventDefault();\n setOpenId(item.id);\n /* The panel is shown by this render: enter it once it is in the tree. */\n window.requestAnimationFrame(() =>\n document\n .getElementById(`${baseId}-${item.id}`)\n ?.querySelector<HTMLElement>(FOCUSABLE_SELECTOR)\n ?.focus(),\n );\n return;\n }\n\n /* The keys come from inside the navigation, so it is in the tree. */\n const nav = navRef.current as HTMLElement;\n const tops = [...nav.querySelectorAll<HTMLElement>('[data-ui-mega-top]')];\n const index = tops.indexOf(target);\n const forward = document.dir === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n const backward = document.dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n const next =\n event.key === forward\n ? (index + 1) % tops.length\n : event.key === backward\n ? (index - 1 + tops.length) % tops.length\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? tops.length - 1\n : -1;\n if (next === -1) return;\n\n event.preventDefault();\n if (openId !== null) setOpenId(null);\n tops[next].focus();\n };\n\n const handlePointerEnter = (event: PointerEvent<HTMLElement>, item: MegaMenuItem) => {\n if (event.pointerType !== 'mouse') return;\n schedule(hasPanel(item) ? item.id : null, OPEN_DELAY);\n };\n\n const handlePointerLeave = (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'mouse') schedule(null, CLOSE_DELAY);\n };\n\n /* Tabbing out of the navigation closes the panel behind it. */\n const handleBlur = (event: FocusEvent<HTMLElement>) => {\n if (!navRef.current?.contains(event.relatedTarget as Node | null)) setOpenId(null);\n };\n\n const renderLink = (link: MegaMenuLink, onNavigate?: () => void) => (\n <li key={link.id}>\n <UiLink {...link.linkProps} href={link.href} className={styles.link} onClick={onNavigate}>\n {(link.image ?? link.icon) && (\n <span\n aria-hidden\n className={cx(\n styles.link__media,\n link.image !== undefined && styles['link__media--image'],\n )}\n >\n {link.image ?? link.icon}\n </span>\n )}\n <span className={styles.link__text}>\n <span className={styles.link__label}>{link.label}</span>\n {link.description && <span className={styles.link__description}>{link.description}</span>}\n </span>\n </UiLink>\n </li>\n );\n\n /* `scope` keeps the ids of the bar's panel and the drawer's copy apart. */\n const renderColumns = (item: MegaMenuItem, scope: 'bar' | 'drawer', onNavigate?: () => void) =>\n item.columns?.map(column => {\n const headingId = `${baseId}-${scope}-${item.id}-${column.id}`;\n\n return (\n <div key={column.id} className={styles.column}>\n {column.title && (\n <p id={headingId} className={styles.column__title}>\n {column.href ? (\n <UiLink href={column.href} className={styles.column__link} onClick={onNavigate}>\n {column.title}\n </UiLink>\n ) : (\n column.title\n )}\n </p>\n )}\n <ul\n className={styles.column__list}\n aria-labelledby={column.title ? headingId : undefined}\n >\n {column.links.map(link => renderLink(link, onNavigate))}\n </ul>\n </div>\n );\n });\n\n const closeDrawer = () => onDrawerClose?.();\n\n return (\n <>\n <nav\n ref={navRef}\n aria-label={navigation}\n className={cx(styles.menu, className)}\n data-testid={testId}\n onBlur={handleBlur}\n >\n <ul className={styles.menu__bar}>\n {items.map(item => {\n const isOpen = openId === item.id;\n const panelId = `${baseId}-${item.id}`;\n\n if (!hasPanel(item))\n return (\n <li\n key={item.id}\n className={styles.menu__entry}\n onPointerEnter={event => handlePointerEnter(event, item)}\n >\n <UiLink\n {...item.linkProps}\n href={item.href ?? '#'}\n data-ui-mega-top={item.id}\n className={cx(styles.top, item.isActive && styles['top--active'])}\n aria-current={item.isActive ? 'page' : undefined}\n onKeyDown={(event: KeyboardEvent<HTMLElement>) => handleKeyDown(event, item)}\n >\n {item.icon && (\n <span aria-hidden className={styles.top__icon}>\n {item.icon}\n </span>\n )}\n {item.label}\n </UiLink>\n </li>\n );\n\n return (\n <li\n key={item.id}\n className={styles.menu__entry}\n onPointerEnter={event => handlePointerEnter(event, item)}\n onPointerLeave={handlePointerLeave}\n onKeyDown={event => handleKeyDown(event, item)}\n >\n <button\n type=\"button\"\n data-ui-mega-top={item.id}\n className={cx(\n styles.top,\n item.isActive && styles['top--active'],\n isOpen && styles['top--open'],\n )}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => {\n window.clearTimeout(timerRef.current);\n setOpenId(isOpen ? null : item.id);\n }}\n >\n {item.icon && (\n <span aria-hidden className={styles.top__icon}>\n {item.icon}\n </span>\n )}\n {item.label}\n <ChevronDown aria-hidden className={styles.top__chevron} />\n </button>\n\n <div id={panelId} className={styles.panel} hidden={!isOpen}>\n <div className={styles.panel__columns}>{renderColumns(item, 'bar')}</div>\n {item.feature && <div className={styles.panel__feature}>{item.feature}</div>}\n {item.href && (\n <UiLink {...item.linkProps} href={item.href} className={styles.panel__all}>\n {seeAll(item)}\n </UiLink>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n </nav>\n\n {/* Drawn only while open, like `FacetSidebar`'s drawer. */}\n {isDrawerOpen && (\n <Drawer\n isOpen\n onClose={closeDrawer}\n title={resolveLabel('MegaMenu.labels.menu', labelProps?.menu, text?.menu)}\n side=\"start\"\n size=\"sm\"\n >\n <nav aria-label={navigation}>\n <ul className={styles.drawer}>\n {items.map(item =>\n hasPanel(item) ? (\n <li key={item.id}>\n <Disclosure variant=\"plain\" summary={item.label} isDefaultOpen={item.isActive}>\n <div className={styles.drawer__section}>\n {item.href && (\n <UiLink\n {...item.linkProps}\n href={item.href}\n className={styles.panel__all}\n onClick={closeDrawer}\n >\n {seeAll(item)}\n </UiLink>\n )}\n {renderColumns(item, 'drawer', closeDrawer)}\n </div>\n </Disclosure>\n </li>\n ) : (\n <li key={item.id}>\n <UiLink\n {...item.linkProps}\n href={item.href ?? '#'}\n className={styles.drawer__link}\n aria-current={item.isActive ? 'page' : undefined}\n onClick={closeDrawer}\n >\n {item.label}\n </UiLink>\n </li>\n ),\n )}\n </ul>\n </nav>\n </Drawer>\n )}\n </>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(MegaMenu, 'MegaMenu')) as typeof MegaMenu;\n"],"names":["OPEN_DELAY","CLOSE_DELAY","hasPanel","item","_a","MegaMenu","items","label","isDrawerOpen","onDrawerClose","labelProps","className","testId","config","useUi","text","baseId","useId","navRef","useRef","timerRef","openId","setOpenId","useState","navigation","resolveLabel","seeAll","resolveFormatter","schedule","next","delay","useEffect","handlePointerDown","event","triggerOf","id","close","handleKeyDown","target","_b","FOCUSABLE_SELECTOR","tops","index","forward","backward","handlePointerEnter","handlePointerLeave","handleBlur","renderLink","link","onNavigate","jsx","UiLink","styles","cx","jsxs","renderColumns","scope","column","headingId","closeDrawer","Fragment","isOpen","panelId","ChevronDown","Drawer","Disclosure","memo","named"],"mappings":"4jBAyFMA,EAAa,IACbC,EAAc,IAEdC,EAAYC,UAAiC,SAAAC,EAAAD,EAAK,UAAL,YAAAC,EAAc,SAAU,GAAK,GAQ1EC,EAAW,CAAC,CAChB,MAAAC,EACA,MAAAC,EACA,aAAAC,EAAe,GACf,cAAAC,EACA,OAAQC,EACR,UAAAC,EACA,OAAAC,CACF,IAAa,CACX,KAAM,CAAE,OAAQC,CAAA,EAAWC,QAAA,EACrBC,EAAOF,GAAA,YAAAA,EAAQ,SACfG,EAASC,EAAAA,MAAA,EACTC,EAASC,EAAAA,OAAoB,IAAI,EACjCC,EAAWD,EAAAA,OAA2B,MAAS,EAC/C,CAACE,EAAQC,CAAS,EAAIC,EAAAA,SAA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AA,QAAA,CACE,GAAGjD,EAAK,UACT,KAAMA,EAAK,KACX,UAAWkD,EAAAA,QAAO,WAClB,QAASO,EAER,WAAOzD,CAAI,CAAA,CAAA,EAGfqD,EAAcrD,EAAM,SAAUyD,CAAW,CAAA,EAC5C,EACF,CAAA,EAfOzD,EAAK,EAgBd,QAEC,KAAA,CACC,SAAAgD,EAAAA,IAACC,EAAAA,QAAA,CACE,GAAGjD,EAAK,UACT,KAAMA,EAAK,MAAQ,IACnB,UAAWkD,EAAAA,QAAO,aAClB,eAAclD,EAAK,SAAW,OAAS,OACvC,QAASyD,EAER,SAAAzD,EAAK,KAAA,CAAA,CACR,EATOA,EAAK,EAUd,CAAA,EAGN,CAAA,CACF,CAAA,CAAA,CACF,EAEJ,CAEJ,EAEAuC,EAA6ByB,OAAmBC,EAAAA,MAAM/D,EAAU,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/MegaMenu/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n type FocusEvent,\n type KeyboardEvent,\n memo,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { ChevronDown } from 'react-bootstrap-icons';\n\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { FOCUSABLE_SELECTOR } from '../../helpers/focus.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { UiLinkExtraProps } from '../../types/link.type';\nimport type { Formatter } from '../../types/theme.type';\nimport Disclosure from '../Disclosure';\nimport Drawer from '../Drawer';\nimport UiLink from '../Link';\n\nimport styles from './index.module.scss';\n\n/** A sub-category link of a panel column. */\nexport type MegaMenuLink = {\n id: string;\n label: string;\n href: string;\n /** A small icon before the label. */\n icon?: ReactNode;\n /** A thumbnail before the label (an `<img alt=\"\">`); wins over `icon`. */\n image?: ReactNode;\n /** A short line under the label. */\n description?: string;\n /** Products in the sub-category (3.7): at the link's end in secondary tabular figures. */\n count?: number;\n linkProps?: UiLinkExtraProps;\n};\n\n/** One column of a panel: a titled group of links (\"Fren sistemi\"). */\nexport type MegaMenuColumn = {\n id: string;\n title?: string;\n /** Makes the title a link to the group's page. */\n href?: string;\n links: MegaMenuLink[];\n};\n\n/** A top-level category: a link, or a button that opens a panel when it has `columns`. */\nexport type MegaMenuItem = {\n id: string;\n label: string;\n /** The category's page: the item's link, or the panel's \"see all\" link. */\n href?: string;\n icon?: ReactNode;\n columns?: MegaMenuColumn[];\n /** A slot at the panel's end: a campaign card, a featured brand. */\n feature?: ReactNode;\n /** The current section of the site. */\n isActive?: boolean;\n linkProps?: UiLinkExtraProps;\n};\n\nexport type MegaMenuLabels = {\n navigation: string;\n menu: string;\n seeAll: Formatter<[label: string]>;\n};\n\ntype Props = {\n items: MegaMenuItem[];\n /** The landmark's name; `labels.megaMenu.navigation` by default. */\n label?: string;\n /**\n * Narrow screens: the categories in a `Drawer` from the start edge, each one a section that\n * opens in place. The bar itself is hidden at tablet width and below; the app's menu button\n * opens the drawer.\n */\n isDrawerOpen?: boolean;\n onDrawerClose?: () => void;\n labels?: Partial<MegaMenuLabels>;\n className?: string;\n testId?: string;\n};\n\n/* A pointer resting this long on a category opens it; leaving for this long closes it. */\nconst OPEN_DELAY = 120;\nconst CLOSE_DELAY = 200;\n\nconst hasPanel = (item: MegaMenuItem): boolean => (item.columns?.length ?? 0) > 0;\n\n/** A panel never has more than three columns; a lone group splits its links up to that. */\nconst MAX_COLUMNS = 3;\n/** Links per column before a lone group continues in the next column. */\nconst LINKS_PER_COLUMN = 8;\n\n/** How many columns a panel (at least one group) lays out: one per group, or a lone group split. */\nconst columnCountOf = (columns: MegaMenuColumn[]): number =>\n columns.length > 1\n ? Math.min(columns.length, MAX_COLUMNS)\n : Math.min(Math.ceil(columns[0].links.length / LINKS_PER_COLUMN), MAX_COLUMNS) || 1;\n\n/**\n * A storefront header's category navigation (3.4): top-level categories, a panel of sub-category\n * columns (with icons or thumbnails and a feature slot) under each, opened by click, keyboard or a\n * resting pointer; a drawer of sections on a narrow screen. 3.7: the panel is as wide as its\n * content (one to three columns, a lone long group split into them, never an empty column), hangs\n * under its category, and links carry their product `count`. A disclosure navigation, not an ARIA\n * menu: the links are links, Tab moves through them, ←/→ move along the bar, Escape closes.\n */\nconst MegaMenu = ({\n items,\n label,\n isDrawerOpen = false,\n onDrawerClose,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const text = config?.megaMenu;\n const baseId = useId();\n const navRef = useRef<HTMLElement>(null);\n const timerRef = useRef<number | undefined>(undefined);\n const [openId, setOpenId] = useState<string | null>(null);\n\n const navigation = resolveLabel(\n 'MegaMenu.label',\n label ?? labelProps?.navigation,\n text?.navigation,\n );\n const seeAll = (item: MegaMenuItem) =>\n resolveFormatter('MegaMenu.labels.seeAll', labelProps?.seeAll ?? text?.seeAll, item.label);\n\n const schedule = (next: string | null, delay: number) => {\n window.clearTimeout(timerRef.current);\n timerRef.current = window.setTimeout(() => setOpenId(next), delay);\n };\n\n useEffect(() => () => window.clearTimeout(timerRef.current), []);\n\n /* A press outside the bar closes the open panel. */\n useEffect(() => {\n if (openId === null) return;\n\n const handlePointerDown = (event: globalThis.PointerEvent) => {\n if (!navRef.current?.contains(event.target as Node)) setOpenId(null);\n };\n document.addEventListener('pointerdown', handlePointerDown);\n\n return () => document.removeEventListener('pointerdown', handlePointerDown);\n }, [openId]);\n\n const triggerOf = (id: string) =>\n navRef.current?.querySelector<HTMLElement>(`[data-ui-mega-top=\"${id}\"]`);\n\n /*\n * 3.7: the panel is as wide as its content and hangs under its own category, pushed back in when\n * it would pass the bar's end. Until 3.6 it spanned the whole bar: three links and 70% empty.\n */\n const [offset, setOffset] = useState(0);\n\n useLayoutEffect(() => {\n if (openId === null) return;\n\n /* Only a category with a panel opens; mounted, its trigger is the button before it. */\n const panel = document.getElementById(`${baseId}-${openId}`) as HTMLElement;\n const nav = navRef.current as HTMLElement;\n const trigger = panel.previousElementSibling as HTMLElement;\n\n const bar = nav.getBoundingClientRect();\n const start = trigger.getBoundingClientRect();\n const isRtl = getComputedStyle(nav).direction === 'rtl';\n const fromStart = isRtl ? bar.right - start.right : start.left - bar.left;\n setOffset(Math.max(0, Math.min(fromStart, bar.width - panel.offsetWidth)));\n }, [openId, baseId]);\n\n const close = (id: string) => {\n window.clearTimeout(timerRef.current);\n setOpenId(null);\n triggerOf(id)?.focus();\n };\n\n /* ←/→/Home/End along the top level; ↓ opens a panel and enters it; Escape closes it. */\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>, item: MegaMenuItem) => {\n const target = event.target as HTMLElement;\n\n if (event.key === 'Escape' && openId === item.id) {\n event.preventDefault();\n close(item.id);\n return;\n }\n\n if (target.dataset.uiMegaTop === undefined) return;\n\n if (event.key === 'ArrowDown' && hasPanel(item)) {\n event.preventDefault();\n setOpenId(item.id);\n /* The panel is shown by this render: enter it once it is in the tree. */\n window.requestAnimationFrame(() =>\n document\n .getElementById(`${baseId}-${item.id}`)\n ?.querySelector<HTMLElement>(FOCUSABLE_SELECTOR)\n ?.focus(),\n );\n return;\n }\n\n /* The keys come from inside the navigation, so it is in the tree. */\n const nav = navRef.current as HTMLElement;\n const tops = [...nav.querySelectorAll<HTMLElement>('[data-ui-mega-top]')];\n const index = tops.indexOf(target);\n const forward = document.dir === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n const backward = document.dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n const next =\n event.key === forward\n ? (index + 1) % tops.length\n : event.key === backward\n ? (index - 1 + tops.length) % tops.length\n : event.key === 'Home'\n ? 0\n : event.key === 'End'\n ? tops.length - 1\n : -1;\n if (next === -1) return;\n\n event.preventDefault();\n if (openId !== null) setOpenId(null);\n tops[next].focus();\n };\n\n const handlePointerEnter = (event: PointerEvent<HTMLElement>, item: MegaMenuItem) => {\n if (event.pointerType !== 'mouse') return;\n schedule(hasPanel(item) ? item.id : null, OPEN_DELAY);\n };\n\n const handlePointerLeave = (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'mouse') schedule(null, CLOSE_DELAY);\n };\n\n /* Tabbing out of the navigation closes the panel behind it. */\n const handleBlur = (event: FocusEvent<HTMLElement>) => {\n if (!navRef.current?.contains(event.relatedTarget as Node | null)) setOpenId(null);\n };\n\n const renderLink = (link: MegaMenuLink, onNavigate?: () => void) => (\n <li key={link.id}>\n <UiLink {...link.linkProps} href={link.href} className={styles.link} onClick={onNavigate}>\n {(link.image ?? link.icon) && (\n <span\n aria-hidden\n className={cx(\n styles.link__media,\n link.image !== undefined && styles['link__media--image'],\n )}\n >\n {link.image ?? link.icon}\n </span>\n )}\n <span className={styles.link__text}>\n <span className={styles.link__label}>{link.label}</span>\n {link.description && <span className={styles.link__description}>{link.description}</span>}\n </span>\n {link.count !== undefined && <span className={styles.link__count}>{link.count}</span>}\n </UiLink>\n </li>\n );\n\n /* `scope` keeps the ids of the bar's panel and the drawer's copy apart. */\n const renderColumns = (item: MegaMenuItem, scope: 'bar' | 'drawer', onNavigate?: () => void) =>\n item.columns?.map(column => {\n const headingId = `${baseId}-${scope}-${item.id}-${column.id}`;\n /* A lone long group flows into the panel's columns; several groups take one column each. */\n const isSplit = scope === 'bar' && item.columns?.length === 1 && columnCountOf([column]) > 1;\n\n return (\n <div key={column.id} className={cx(styles.column, isSplit && styles['column--split'])}>\n {column.title && (\n <p id={headingId} className={styles.column__title}>\n {column.href ? (\n <UiLink href={column.href} className={styles.column__link} onClick={onNavigate}>\n {column.title}\n </UiLink>\n ) : (\n column.title\n )}\n </p>\n )}\n <ul\n className={styles.column__list}\n aria-labelledby={column.title ? headingId : undefined}\n >\n {column.links.map(link => renderLink(link, onNavigate))}\n </ul>\n </div>\n );\n });\n\n const closeDrawer = () => onDrawerClose?.();\n\n return (\n <>\n <nav\n ref={navRef}\n aria-label={navigation}\n className={cx(styles.menu, className)}\n data-testid={testId}\n onBlur={handleBlur}\n >\n <ul className={styles.menu__bar}>\n {items.map(item => {\n const isOpen = openId === item.id;\n const panelId = `${baseId}-${item.id}`;\n\n if (!hasPanel(item))\n return (\n <li\n key={item.id}\n className={styles.menu__entry}\n onPointerEnter={event => handlePointerEnter(event, item)}\n >\n <UiLink\n {...item.linkProps}\n href={item.href ?? '#'}\n data-ui-mega-top={item.id}\n className={cx(styles.top, item.isActive && styles['top--active'])}\n aria-current={item.isActive ? 'page' : undefined}\n onKeyDown={(event: KeyboardEvent<HTMLElement>) => handleKeyDown(event, item)}\n >\n {item.icon && (\n <span aria-hidden className={styles.top__icon}>\n {item.icon}\n </span>\n )}\n {item.label}\n </UiLink>\n </li>\n );\n\n return (\n <li\n key={item.id}\n className={styles.menu__entry}\n onPointerEnter={event => handlePointerEnter(event, item)}\n onPointerLeave={handlePointerLeave}\n onKeyDown={event => handleKeyDown(event, item)}\n >\n <button\n type=\"button\"\n data-ui-mega-top={item.id}\n className={cx(\n styles.top,\n item.isActive && styles['top--active'],\n isOpen && styles['top--open'],\n )}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => {\n window.clearTimeout(timerRef.current);\n setOpenId(isOpen ? null : item.id);\n }}\n >\n {item.icon && (\n <span aria-hidden className={styles.top__icon}>\n {item.icon}\n </span>\n )}\n {item.label}\n <ChevronDown aria-hidden className={styles.top__chevron} />\n </button>\n\n <div\n id={panelId}\n className={styles.panel}\n hidden={!isOpen}\n style={\n {\n '--ui-mega-offset': `${isOpen ? offset : 0}px`,\n '--ui-mega-columns': columnCountOf(item.columns as MegaMenuColumn[]),\n } as CSSProperties\n }\n >\n <div className={styles.panel__columns}>{renderColumns(item, 'bar')}</div>\n {item.feature && <div className={styles.panel__feature}>{item.feature}</div>}\n {item.href && (\n <UiLink {...item.linkProps} href={item.href} className={styles.panel__all}>\n {seeAll(item)}\n </UiLink>\n )}\n </div>\n </li>\n );\n })}\n </ul>\n </nav>\n\n {/* Drawn only while open, like `FacetSidebar`'s drawer. */}\n {isDrawerOpen && (\n <Drawer\n isOpen\n onClose={closeDrawer}\n title={resolveLabel('MegaMenu.labels.menu', labelProps?.menu, text?.menu)}\n side=\"start\"\n size=\"sm\"\n >\n <nav aria-label={navigation}>\n <ul className={styles.drawer}>\n {items.map(item =>\n hasPanel(item) ? (\n <li key={item.id}>\n <Disclosure variant=\"plain\" summary={item.label} isDefaultOpen={item.isActive}>\n <div className={styles.drawer__section}>\n {item.href && (\n <UiLink\n {...item.linkProps}\n href={item.href}\n className={styles.panel__all}\n onClick={closeDrawer}\n >\n {seeAll(item)}\n </UiLink>\n )}\n {renderColumns(item, 'drawer', closeDrawer)}\n </div>\n </Disclosure>\n </li>\n ) : (\n <li key={item.id}>\n <UiLink\n {...item.linkProps}\n href={item.href ?? '#'}\n className={styles.drawer__link}\n aria-current={item.isActive ? 'page' : undefined}\n onClick={closeDrawer}\n >\n {item.label}\n </UiLink>\n </li>\n ),\n )}\n </ul>\n </nav>\n </Drawer>\n )}\n </>\n );\n};\n\nexport default /*#__PURE__*/ memo(/*#__PURE__*/ named(MegaMenu, 'MegaMenu')) as typeof MegaMenu;\n"],"names":["OPEN_DELAY","CLOSE_DELAY","hasPanel","item","_a","MAX_COLUMNS","LINKS_PER_COLUMN","columnCountOf","columns","MegaMenu","items","label","isDrawerOpen","onDrawerClose","labelProps","className","testId","config","useUi","text","baseId","useId","navRef","useRef","timerRef","openId","setOpenId","useState","navigation","resolveLabel","seeAll","resolveFormatter","schedule","next","delay","useEffect","handlePointerDown","event","triggerOf","id","offset","setOffset","useLayoutEffect","panel","nav","trigger","bar","start","fromStart","close","handleKeyDown","target","_b","FOCUSABLE_SELECTOR","tops","index","forward","backward","handlePointerEnter","handlePointerLeave","handleBlur","renderLink","link","onNavigate","jsx","UiLink","styles","cx","jsxs","renderColumns","scope","column","headingId","isSplit","closeDrawer","Fragment","isOpen","panelId","ChevronDown","Drawer","Disclosure","memo","named"],"mappings":"4jBA6FMA,GAAa,IACbC,GAAc,IAEdC,EAAYC,UAAi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AAxD,EAAM,IAAIP,GACTD,EAASC,CAAI,QACV,KAAA,CACC,SAAA6D,EAAAA,IAACgB,EAAAA,SAAW,QAAQ,QAAQ,QAAS7E,EAAK,MAAO,cAAeA,EAAK,SACnE,gBAAC,MAAA,CAAI,UAAW+D,UAAO,gBACpB,SAAA,CAAA/D,EAAK,MACJ6D,EAAAA,IAACC,EAAAA,QAAA,CACE,GAAG9D,EAAK,UACT,KAAMA,EAAK,KACX,UAAW+D,EAAAA,QAAO,WAClB,QAASQ,EAER,WAAOvE,CAAI,CAAA,CAAA,EAGfkE,EAAclE,EAAM,SAAUuE,CAAW,CAAA,EAC5C,EACF,CAAA,EAfOvE,EAAK,EAgBd,QAEC,KAAA,CACC,SAAA6D,EAAAA,IAACC,EAAAA,QAAA,CACE,GAAG9D,EAAK,UACT,KAAMA,EAAK,MAAQ,IACnB,UAAW+D,EAAAA,QAAO,aAClB,eAAc/D,EAAK,SAAW,OAAS,OACvC,QAASuE,EAER,SAAAvE,EAAK,KAAA,CAAA,CACR,EATOA,EAAK,EAUd,CAAA,EAGN,CAAA,CACF,CAAA,CAAA,CACF,EAEJ,CAEJ,EAEAoD,GAA6B0B,OAAmBC,EAAAA,MAAMzE,GAAU,UAAU,CAAC"}
|
|
@@ -12,6 +12,8 @@ export type MegaMenuLink = {
|
|
|
12
12
|
image?: ReactNode;
|
|
13
13
|
/** A short line under the label. */
|
|
14
14
|
description?: string;
|
|
15
|
+
/** Products in the sub-category (3.7): at the link's end in secondary tabular figures. */
|
|
16
|
+
count?: number;
|
|
15
17
|
linkProps?: UiLinkExtraProps;
|
|
16
18
|
};
|
|
17
19
|
/** One column of a panel: a titled group of links ("Fren sistemi"). */
|
|
@@ -59,7 +61,9 @@ type Props = {
|
|
|
59
61
|
/**
|
|
60
62
|
* A storefront header's category navigation (3.4): top-level categories, a panel of sub-category
|
|
61
63
|
* columns (with icons or thumbnails and a feature slot) under each, opened by click, keyboard or a
|
|
62
|
-
* resting pointer; a drawer of sections on a narrow screen.
|
|
64
|
+
* resting pointer; a drawer of sections on a narrow screen. 3.7: the panel is as wide as its
|
|
65
|
+
* content (one to three columns, a lone long group split into them, never an empty column), hangs
|
|
66
|
+
* under its category, and links carry their product `count`. A disclosure navigation, not an ARIA
|
|
63
67
|
* menu: the links are links, Tab moves through them, ←/→ move along the bar, Escape closes.
|
|
64
68
|
*/
|
|
65
69
|
declare const MegaMenu: ({ items, label, isDrawerOpen, onDrawerClose, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|
|
@@ -12,6 +12,8 @@ export type MegaMenuLink = {
|
|
|
12
12
|
image?: ReactNode;
|
|
13
13
|
/** A short line under the label. */
|
|
14
14
|
description?: string;
|
|
15
|
+
/** Products in the sub-category (3.7): at the link's end in secondary tabular figures. */
|
|
16
|
+
count?: number;
|
|
15
17
|
linkProps?: UiLinkExtraProps;
|
|
16
18
|
};
|
|
17
19
|
/** One column of a panel: a titled group of links ("Fren sistemi"). */
|
|
@@ -59,7 +61,9 @@ type Props = {
|
|
|
59
61
|
/**
|
|
60
62
|
* A storefront header's category navigation (3.4): top-level categories, a panel of sub-category
|
|
61
63
|
* columns (with icons or thumbnails and a feature slot) under each, opened by click, keyboard or a
|
|
62
|
-
* resting pointer; a drawer of sections on a narrow screen.
|
|
64
|
+
* resting pointer; a drawer of sections on a narrow screen. 3.7: the panel is as wide as its
|
|
65
|
+
* content (one to three columns, a lone long group split into them, never an empty column), hangs
|
|
66
|
+
* under its category, and links carry their product `count`. A disclosure navigation, not an ARIA
|
|
63
67
|
* menu: the links are links, Tab moves through them, ←/→ move along the bar, Escape closes.
|
|
64
68
|
*/
|
|
65
69
|
declare const MegaMenu: ({ items, label, isDrawerOpen, onDrawerClose, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|