@phillips/seldon 1.164.2 → 1.165.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.
@@ -1,6 +1,7 @@
1
+ import { default as React } from 'react';
1
2
  declare const meta: {
2
3
  title: string;
3
- component: import('react').ForwardRefExoticComponent<Omit<import('./Navigation').NavigationProps, "ref"> & import('react').RefAttributes<HTMLElement>>;
4
+ component: React.ForwardRefExoticComponent<Omit<import('./Navigation').NavigationProps, "ref"> & React.RefAttributes<HTMLElement>>;
4
5
  tags: string[];
5
6
  parameters: {
6
7
  docs: {
@@ -4,6 +4,10 @@ export interface NavigationItemTriggerProps extends ComponentProps<'li'> {
4
4
  * Label for the navigation item
5
5
  */
6
6
  label: string;
7
+ /**
8
+ * ID for the trigger - required for context-based submenu management
9
+ */
10
+ id?: string;
7
11
  }
8
12
  /**
9
13
  * ## Overview
@@ -1,62 +1,73 @@
1
- import { jsx as n, Fragment as _, jsxs as f } from "react/jsx-runtime";
2
- import k from "../../../node_modules/classnames/index.js";
3
- import i, { forwardRef as $, useState as I } from "react";
4
- import M from "../../../node_modules/react-remove-scroll/dist/es2015/Combination.js";
5
- import { SSRMediaQuery as g } from "../../../providers/SeldonProvider/utils.js";
6
- import { HeaderContext as v } from "../../../site-furniture/Header/Header.js";
7
- import { getCommonProps as O, findChildrenOfType as S, focusElementById as y, px as h } from "../../../utils/index.js";
8
- import E from "../../Accordion/Accordion.js";
9
- import R from "../../Accordion/AccordionItem.js";
10
- import { AccordionItemVariant as w } from "../../Accordion/types.js";
11
- import { TextVariants as C } from "../../Text/types.js";
1
+ import { jsx as o, Fragment as $, jsxs as h } from "react/jsx-runtime";
2
+ import M from "../../../node_modules/classnames/index.js";
3
+ import t, { forwardRef as y, useEffect as E } from "react";
4
+ import O from "../../../node_modules/react-remove-scroll/dist/es2015/Combination.js";
5
+ import { SSRMediaQuery as v } from "../../../providers/SeldonProvider/utils.js";
6
+ import { HeaderContext as C } from "../../../site-furniture/Header/Header.js";
7
+ import { getCommonProps as w, findChildrenOfType as A, focusElementById as L, px as T } from "../../../utils/index.js";
8
+ import H from "../../Accordion/Accordion.js";
9
+ import P from "../../Accordion/AccordionItem.js";
10
+ import { AccordionItemVariant as j } from "../../Accordion/types.js";
11
+ import { TextVariants as b } from "../../Text/types.js";
12
12
  import N from "../../Text/Text.js";
13
- import L from "../NavigationList/NavigationList.js";
14
- const A = ({ id: a, label: o, children: l }) => {
15
- const { isMenuOpen: c } = i.useContext(v);
16
- return /* @__PURE__ */ n(E, { children: /* @__PURE__ */ n(
17
- R,
13
+ import B from "../NavigationList/NavigationList.js";
14
+ const V = ({ id: r, label: i, children: s }) => {
15
+ const { isMenuOpen: u } = t.useContext(C);
16
+ return /* @__PURE__ */ o(H, { children: /* @__PURE__ */ o(
17
+ P,
18
18
  {
19
19
  hasTransition: !0,
20
- id: `accordion-item-${a}`,
21
- label: /* @__PURE__ */ n(N, { variant: C.snwHeaderLink, children: o }),
22
- variant: w.lg,
23
- children: l
20
+ id: `accordion-item-${r}`,
21
+ label: /* @__PURE__ */ o(N, { variant: b.snwHeaderLink, children: i }),
22
+ variant: j.lg,
23
+ children: s
24
24
  },
25
- `accordion-key-${o}`
26
- ) }, `accordion-key-${o}-${c}`);
27
- }, H = $(
28
- ({ id: a, label: o, children: l, className: c, onClick: b, ...x }, t) => {
29
- const { className: m, ...u } = O({ id: a }, "NavigationItemTrigger"), [d, s] = I(!1), e = S(l, L), { closeMenu: p } = i.useContext(v), T = i.useCallback(() => {
30
- s(!0), e && e[0]?.props?.id && y(e[0].props.id, !0);
31
- const r = t && "current" in t ? t.current : null;
32
- r && r.focus();
33
- }, [e, t]);
34
- return /* @__PURE__ */ n(_, { children: /* @__PURE__ */ f(M, { enabled: d, allowPinchZoom: !0, removeScrollBar: !1, children: [
35
- /* @__PURE__ */ n(g.Media, { lessThan: "md", children: /* @__PURE__ */ n(A, { id: a, label: o, ...u, children: e ? i.cloneElement(e[0], {
25
+ `accordion-key-${i}`
26
+ ) }, `accordion-key-${i}-${u}`);
27
+ }, q = y(
28
+ ({ id: r, label: i, children: s, className: u, onClick: x, ...k }, c) => {
29
+ const { className: m, ...f } = w({ id: r }, "NavigationItemTrigger"), e = A(s, B), {
30
+ closeMenu: g,
31
+ activeSubmenuId: R,
32
+ setActiveSubmenuId: l,
33
+ closeTimeoutRef: d
34
+ } = t.useContext(C), _ = t.useRef(null), n = d || _, p = R === r, I = t.useCallback(() => {
35
+ n.current && (clearTimeout(n.current), n.current = null), l?.(r || null), e && e[0]?.props?.id && L(e[0].props.id, !0);
36
+ const a = c && "current" in c ? c.current : null;
37
+ a && a.focus();
38
+ }, [e, c, r, l, n]), S = t.useCallback(() => {
39
+ n.current = setTimeout(() => {
40
+ l?.(null), n.current = null;
41
+ }, 200);
42
+ }, [l, n]);
43
+ return E(() => () => {
44
+ !d && n.current && clearTimeout(n.current);
45
+ }, [d, n]), /* @__PURE__ */ o($, { children: /* @__PURE__ */ h(O, { enabled: p, allowPinchZoom: !0, removeScrollBar: !1, children: [
46
+ /* @__PURE__ */ o(v.Media, { lessThan: "md", children: /* @__PURE__ */ o(V, { id: r, label: i, ...f, children: e ? t.cloneElement(e[0], {
36
47
  className: `${m}__submenu--mobile`,
37
- onClick: (r) => {
38
- e[0].props?.onClick?.(r), s?.(!1), p?.();
48
+ onClick: (a) => {
49
+ e[0].props?.onClick?.(a), l?.(null), g?.();
39
50
  }
40
51
  }) : null }) }),
41
- /* @__PURE__ */ n(g.Media, { greaterThanOrEqual: "md", children: /* @__PURE__ */ f(
52
+ /* @__PURE__ */ o(v.Media, { greaterThanOrEqual: "md", children: /* @__PURE__ */ h(
42
53
  "li",
43
54
  {
44
- ...u,
45
- ref: t,
46
- "aria-expanded": d,
47
- className: k(c, m, `${h}-nav__item`, {
48
- [`${m}--hovered`]: d
55
+ ...f,
56
+ ref: c,
57
+ "aria-expanded": p,
58
+ className: M(u, m, `${T}-nav__item`, {
59
+ [`${m}--hovered`]: p
49
60
  }),
50
- onClick: b,
51
- onMouseOver: T,
52
- onMouseOut: () => s(!1),
53
- ...x,
61
+ onClick: x,
62
+ onMouseOver: I,
63
+ onMouseOut: S,
64
+ ...k,
54
65
  children: [
55
- /* @__PURE__ */ n("button", { className: `${h}-nav__item-trigger`, type: "button", children: /* @__PURE__ */ n(N, { variant: C.snwHeaderLink, children: o }) }),
56
- e ? i.cloneElement(e[0], {
66
+ /* @__PURE__ */ o("button", { className: `${T}-nav__item-trigger`, type: "button", children: /* @__PURE__ */ o(N, { variant: b.snwHeaderLink, children: i }) }),
67
+ e ? t.cloneElement(e[0], {
57
68
  className: `${m}__submenu`,
58
- onClick: (r) => {
59
- e[0].props?.onClick?.(r), s?.(!1), p?.();
69
+ onClick: (a) => {
70
+ e[0].props?.onClick?.(a), l?.(null), g?.();
60
71
  }
61
72
  }) : null
62
73
  ]
@@ -65,7 +76,7 @@ const A = ({ id: a, label: o, children: l }) => {
65
76
  ] }) });
66
77
  }
67
78
  );
68
- H.displayName = "NavigationItemTrigger";
79
+ q.displayName = "NavigationItemTrigger";
69
80
  export {
70
- H as default
81
+ q as default
71
82
  };
@@ -40,6 +40,7 @@
40
40
 
41
41
  &-title {
42
42
  margin: 0;
43
+ text-transform: none;
43
44
  }
44
45
 
45
46
  &-description {
@@ -42,6 +42,18 @@ export type HeaderContextType = {
42
42
  * Close the mobile menu
43
43
  * */
44
44
  closeMenu?: () => void;
45
+ /**
46
+ * Active submenu ID for navigation
47
+ */
48
+ activeSubmenuId: string | null;
49
+ /**
50
+ * Set the active submenu ID
51
+ */
52
+ setActiveSubmenuId: (id: string | null) => void;
53
+ /**
54
+ * Reference to timeout for submenu closing
55
+ */
56
+ closeTimeoutRef: React.MutableRefObject<NodeJS.Timeout | null>;
45
57
  };
46
58
  export declare const HeaderContext: React.Context<HeaderContextType>;
47
59
  /**
@@ -1,85 +1,88 @@
1
- import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
- import r, { createContext as j, forwardRef as R, useState as V } from "react";
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
+ import e, { createContext as w, forwardRef as A, useState as g } from "react";
3
3
  import l from "../../node_modules/classnames/index.js";
4
- import { findChildrenOfType as s, findChildrenExcludingTypes as w, px as e } from "../../utils/index.js";
5
- import u from "../../patterns/UserManagement/UserManagement.js";
6
- import f from "../../patterns/LanguageSelector/LanguageSelector.js";
7
- import _ from "../../components/Navigation/Navigation.js";
8
- import { defaultHeaderContext as I } from "./utils.js";
9
- import { SSRMediaQuery as L } from "../../providers/SeldonProvider/utils.js";
10
- import { useMobileMenu as k } from "./hooks.js";
11
- import q from "../../components/Icon/Icon.js";
12
- const A = j(I), Q = R(
4
+ import { findChildrenOfType as d, findChildrenExcludingTypes as L, px as a } from "../../utils/index.js";
5
+ import f from "../../patterns/UserManagement/UserManagement.js";
6
+ import _ from "../../patterns/LanguageSelector/LanguageSelector.js";
7
+ import v from "../../components/Navigation/Navigation.js";
8
+ import { defaultHeaderContext as k } from "./utils.js";
9
+ import { SSRMediaQuery as q } from "../../providers/SeldonProvider/utils.js";
10
+ import { useMobileMenu as Q } from "./hooks.js";
11
+ import U from "../../components/Icon/Icon.js";
12
+ const z = w(k), B = A(
13
13
  ({
14
- logo: i = /* @__PURE__ */ a(q, { icon: "PhillipsLogo" }),
14
+ logo: i = /* @__PURE__ */ t(U, { icon: "PhillipsLogo" }),
15
15
  logoHref: E = "/",
16
- className: v,
17
- children: t,
18
- toggleOpenText: C = "Open Menu",
19
- toggleCloseText: M = "Close Menu",
20
- logoText: x = "Home Page",
16
+ className: C,
17
+ children: n,
18
+ toggleOpenText: M = "Open Menu",
19
+ toggleCloseText: x = "Close Menu",
20
+ logoText: b = "Home Page",
21
21
  disabled: m,
22
- ...y
23
- }, $) => {
24
- const c = s(t, u), b = r.isValidElement(c?.[0]) ? r.cloneElement(c[0], { disabled: m }) : "", h = s(t, f), p = r.isValidElement(h?.[0]) ? r.cloneElement(h[0], { disabled: m }) : "", [g, N] = V(!1), S = s(t, _), H = w(t, [_, u, f]), { closeMenu: T, handleMenuToggle: O, isMenuOpen: d, toggleText: P } = k({ toggleOpenText: C, toggleCloseText: M });
25
- return /* @__PURE__ */ o("header", { ...y, className: l(`${e}-header`, v), ref: $, children: [
26
- /* @__PURE__ */ o("div", { className: `${e}-header__top-row`, children: [
27
- /* @__PURE__ */ a(L.Media, { greaterThanOrEqual: "md", children: p }),
22
+ ...S
23
+ }, y) => {
24
+ const c = d(n, f), $ = e.isValidElement(c?.[0]) ? e.cloneElement(c[0], { disabled: m }) : "", h = d(n, _), u = e.isValidElement(h?.[0]) ? e.cloneElement(h[0], { disabled: m }) : "", [p, N] = g(!1), T = d(n, v), H = L(n, [v, f, _]), { closeMenu: R, handleMenuToggle: I, isMenuOpen: s, toggleText: O } = Q({ toggleOpenText: M, toggleCloseText: x }), [P, j] = g(null), V = e.useRef(null);
25
+ return /* @__PURE__ */ o("header", { ...S, className: l(`${a}-header`, C), ref: y, children: [
26
+ /* @__PURE__ */ o("div", { className: `${a}-header__top-row`, children: [
27
+ /* @__PURE__ */ t(q.Media, { greaterThanOrEqual: "md", children: u }),
28
28
  /* @__PURE__ */ o(
29
29
  "button",
30
30
  {
31
- "aria-label": P,
31
+ "aria-label": O,
32
32
  "data-testid": "mobile-menu-toggle",
33
33
  type: "button",
34
- onClick: O,
35
- className: l(`${e}-header__toggle-btn`, {
36
- [`${e}-header__toggle-btn--open`]: d
34
+ onClick: I,
35
+ className: l(`${a}-header__toggle-btn`, {
36
+ [`${a}-header__toggle-btn--open`]: s
37
37
  }),
38
38
  children: [
39
- /* @__PURE__ */ a("span", {}),
39
+ /* @__PURE__ */ t("span", {}),
40
40
  " "
41
41
  ]
42
42
  }
43
43
  ),
44
- /* @__PURE__ */ a("h1", { "data-testid": "header-logo", className: `${e}-header__logo`, children: /* @__PURE__ */ a("a", { href: E, "aria-label": x, children: typeof i == "object" ? i : /* @__PURE__ */ a("img", { alt: "Phillips", "data-testid": "header-logo-img", src: i }) }) }),
45
- b
44
+ /* @__PURE__ */ t("h1", { "data-testid": "header-logo", className: `${a}-header__logo`, children: /* @__PURE__ */ t("a", { href: E, "aria-label": b, children: typeof i == "object" ? i : /* @__PURE__ */ t("img", { alt: "Phillips", "data-testid": "header-logo-img", src: i }) }) }),
45
+ $
46
46
  ] }),
47
- /* @__PURE__ */ a("div", { className: l(`${e}-header__nav`, { [`${e}-header__nav--closed`]: !d }), children: /* @__PURE__ */ o(
48
- A.Provider,
47
+ /* @__PURE__ */ t("div", { className: l(`${a}-header__nav`, { [`${a}-header__nav--closed`]: !s }), children: /* @__PURE__ */ o(
48
+ z.Provider,
49
49
  {
50
50
  value: {
51
- isMenuOpen: d,
52
- isSearchExpanded: g,
51
+ activeSubmenuId: P,
52
+ setActiveSubmenuId: j,
53
+ closeTimeoutRef: V,
54
+ isMenuOpen: s,
55
+ isSearchExpanded: p,
53
56
  setIsSearchExpanded: N,
54
- closeMenu: T
57
+ closeMenu: R
55
58
  },
56
59
  children: [
57
- r.Children.map(
58
- S,
59
- (n) => r.isValidElement(n) ? r.cloneElement(n, {
60
+ e.Children.map(
61
+ T,
62
+ (r) => e.isValidElement(r) ? e.cloneElement(r, {
60
63
  children: [
61
- ...r.Children.toArray(n.props.children),
62
- p
64
+ ...e.Children.toArray(r.props.children),
65
+ u
63
66
  ]
64
- }) : n
67
+ }) : r
65
68
  ),
66
69
  H
67
70
  ]
68
71
  }
69
72
  ) }),
70
- /* @__PURE__ */ a(
73
+ /* @__PURE__ */ t(
71
74
  "div",
72
75
  {
73
- className: l(`${e}-header__overlay`, {
74
- [`${e}-header__overlay--active`]: g
76
+ className: l(`${a}-header__overlay`, {
77
+ [`${a}-header__overlay--active`]: p
75
78
  })
76
79
  }
77
80
  )
78
81
  ] });
79
82
  }
80
83
  );
81
- Q.displayName = "Header";
84
+ B.displayName = "Header";
82
85
  export {
83
- A as HeaderContext,
84
- Q as default
86
+ z as HeaderContext,
87
+ B as default
85
88
  };
@@ -1,10 +1,13 @@
1
1
  import { noOp as e } from "../../utils/index.js";
2
- const n = {
2
+ const t = {
3
3
  isMenuOpen: !1,
4
4
  isSearchExpanded: !1,
5
5
  setIsSearchExpanded: e,
6
- closeMenu: e
6
+ closeMenu: e,
7
+ activeSubmenuId: null,
8
+ setActiveSubmenuId: e,
9
+ closeTimeoutRef: { current: null }
7
10
  };
8
11
  export {
9
- n as defaultHeaderContext
12
+ t as defaultHeaderContext
10
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.164.2",
3
+ "version": "1.165.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"