@sonic-equipment/ui 167.0.0 → 169.0.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.
Files changed (151) hide show
  1. package/dist/algolia/algolia-sonic-searchclient.d.ts +2 -1
  2. package/dist/algolia/algolia-sonic-searchclient.js +2 -2
  3. package/dist/background-overlay/background-overlay-manager.js +6 -0
  4. package/dist/background-overlay/background-overlay.d.ts +1 -1
  5. package/dist/base.css +59 -1
  6. package/dist/buttons/link/link.d.ts +1 -1
  7. package/dist/buttons/link/link.js +6 -4
  8. package/dist/cart-totals/cart-totals.js +1 -0
  9. package/dist/collapsables/accordion/accordion-item.js +3 -2
  10. package/dist/collapsables/cascading-component/cascading-component-container-context.js +1 -0
  11. package/dist/collapsables/cascading-component/cascading-component-container-provider.js +1 -0
  12. package/dist/collapsables/cascading-component/cascading-component-container.js +1 -0
  13. package/dist/collapsables/cascading-component/cascading-component.js +1 -0
  14. package/dist/collapsables/unmounter/unmounter.js +1 -0
  15. package/dist/config.js +12 -11
  16. package/dist/country-select/country-select.js +1 -0
  17. package/dist/country-selector/connected-country-selector.d.ts +6 -6
  18. package/dist/display/price/price.js +1 -0
  19. package/dist/drawer/drawer.d.ts +3 -2
  20. package/dist/drawer/drawer.js +15 -3
  21. package/dist/drawer/drawer.module.css.js +1 -1
  22. package/dist/drawer/use-drawer.js +1 -6
  23. package/dist/exports.d.ts +15 -5
  24. package/dist/footer/connected-footer.d.ts +6 -0
  25. package/dist/footer/connected-footer.js +13 -0
  26. package/dist/footer/footer.d.ts +8 -4
  27. package/dist/footer/footer.js +23 -2
  28. package/dist/footer/footer.model.d.ts +3 -15
  29. package/dist/forms/form/form.js +1 -0
  30. package/dist/forms/text-field/password-reveal-toggle/password-reveal-toggle.js +1 -0
  31. package/dist/global-search/global-search-provider/global-search-provider.d.ts +0 -6
  32. package/dist/global-search/global-search-provider/global-search-provider.js +3 -9
  33. package/dist/global-search/global-search-provider/use-search-disclosure.d.ts +1 -6
  34. package/dist/global-search/global-search-provider/use-search-disclosure.js +5 -9
  35. package/dist/global-search/global-search.d.ts +3 -1
  36. package/dist/global-search/global-search.js +7 -6
  37. package/dist/header/buttons/account/connected-account-button.d.ts +7 -0
  38. package/dist/header/buttons/account/connected-account-button.js +14 -0
  39. package/dist/header/buttons/cart/connected-cart-button.d.ts +7 -0
  40. package/dist/header/buttons/cart/connected-cart-button.js +14 -0
  41. package/dist/header/buttons/favorites/connected-favorites-button.d.ts +7 -0
  42. package/dist/header/buttons/favorites/connected-favorites-button.js +13 -0
  43. package/dist/header/{hamburger-button → buttons/hamburger}/hamburger-button.d.ts +2 -1
  44. package/dist/header/buttons/hamburger/hamburger-button.js +13 -0
  45. package/dist/header/buttons/hamburger/hamburger-button.module.css.js +3 -0
  46. package/dist/header/buttons/search/search-button.d.ts +7 -0
  47. package/dist/header/buttons/search/search-button.js +12 -0
  48. package/dist/header/connected-header.d.ts +5 -0
  49. package/dist/header/connected-header.js +12 -0
  50. package/dist/header/drawers/desktop-navigation-drawer.d.ts +8 -0
  51. package/dist/header/drawers/desktop-navigation-drawer.js +12 -0
  52. package/dist/header/drawers/desktop-navigation-drawer.module.css.js +3 -0
  53. package/dist/header/drawers/mobile-navigation-drawer.d.ts +7 -0
  54. package/dist/header/drawers/mobile-navigation-drawer.js +10 -0
  55. package/dist/header/drawers/mobile-navigation-drawer.module.css.js +3 -0
  56. package/dist/header/drawers/search-drawer.d.ts +5 -0
  57. package/dist/header/drawers/search-drawer.js +9 -0
  58. package/dist/header/header-layout/header-layout.d.ts +2 -1
  59. package/dist/header/header-layout/header-layout.js +3 -2
  60. package/dist/header/header-layout/header-layout.module.css.js +1 -1
  61. package/dist/header/header.d.ts +4 -2
  62. package/dist/header/header.js +64 -5
  63. package/dist/header/header.module.css.js +3 -0
  64. package/dist/header/link-list/navigation-link-list.d.ts +3 -2
  65. package/dist/header/link-list/navigation-link-list.js +3 -3
  66. package/dist/header/link-list/navigation-link-list.module.css.js +1 -1
  67. package/dist/header/sonic-logo/sonic-logo.d.ts +2 -1
  68. package/dist/header/sonic-logo/sonic-logo.js +4 -2
  69. package/dist/index.js +17 -6
  70. package/dist/intl/missing-translation-provider.js +1 -0
  71. package/dist/intl/translation-id.d.ts +1 -1
  72. package/dist/lists/menu-list/menu-list-back-button.js +1 -0
  73. package/dist/lists/menu-list/menu-list-item.d.ts +9 -21
  74. package/dist/lists/menu-list/menu-list-item.js +3 -8
  75. package/dist/lists/menu-list/menu-list.js +1 -0
  76. package/dist/lists/orderline-list/orderline-list.js +2 -2
  77. package/dist/media/zoom-image/zoom-image.js +1 -0
  78. package/dist/navigation/account-icon/account-icon.js +1 -0
  79. package/dist/navigation/cart-icon/cart-icon.js +2 -1
  80. package/dist/navigation/favorite-icon/favorite-icon.js +1 -0
  81. package/dist/navigation/mobile-navigation/mobile-navigation.d.ts +6 -3
  82. package/dist/navigation/mobile-navigation/mobile-navigation.js +8 -3
  83. package/dist/navigation/mobile-navigation/mobile-navigation.module.css.js +3 -0
  84. package/dist/navigation/panel-navigation/panel-navigation.d.ts +4 -16
  85. package/dist/navigation/panel-navigation/panel-navigation.js +5 -5
  86. package/dist/notifications/announcements/announcement-list.d.ts +7 -0
  87. package/dist/notifications/announcements/announcement-list.js +26 -0
  88. package/dist/notifications/announcements/announcement-list.module.css.js +3 -0
  89. package/dist/notifications/announcements/announcement.d.ts +2 -1
  90. package/dist/notifications/announcements/announcement.js +7 -3
  91. package/dist/notifications/announcements/announcement.module.css.js +1 -1
  92. package/dist/notifications/announcements/connected-announcement-list.d.ts +3 -0
  93. package/dist/notifications/announcements/connected-announcement-list.js +22 -0
  94. package/dist/notifications/announcements/use-filter-announcements.d.ts +2 -0
  95. package/dist/notifications/announcements/use-filter-announcements.js +35 -0
  96. package/dist/observers/intersection-observer.js +1 -0
  97. package/dist/pages/account/create-account-page/create-account-page.js +1 -0
  98. package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.js +1 -0
  99. package/dist/pages/account/sign-in-page/sign-in-page.js +1 -0
  100. package/dist/pages/checkout/cart-page/cart-page.js +2 -1
  101. package/dist/pages/checkout/cart-page/components/empty-cart-page.js +1 -0
  102. package/dist/pages/checkout/components/billing-and-invoice-information.js +1 -0
  103. package/dist/pages/checkout/layouts/checkout-page-layout/checkout-page-layout.js +2 -1
  104. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +1 -0
  105. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.js +1 -0
  106. package/dist/pages/checkout/payment-page/components/adyen-payment.js +1 -0
  107. package/dist/pages/checkout/payment-page/components/payment.js +1 -0
  108. package/dist/pages/checkout/payment-page/payment-page-content.js +2 -1
  109. package/dist/pages/checkout/payment-page/payment-page.js +1 -0
  110. package/dist/pages/checkout/shipping-page/components/currency-change-dialog.js +1 -0
  111. package/dist/pages/checkout/shipping-page/components/edit-address-form.js +1 -0
  112. package/dist/pages/checkout/shipping-page/components/readonly-address.js +1 -0
  113. package/dist/pages/checkout/shipping-page/components/sonic-address.js +1 -0
  114. package/dist/pages/checkout/shipping-page/shipping-page-content.js +2 -1
  115. package/dist/pages/checkout/shipping-page/shipping-page.js +1 -0
  116. package/dist/pages/components/page-meta-data/page-meta-data.js +4 -0
  117. package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.js +1 -0
  118. package/dist/shared/api/bff/hooks/use-fetch-navigation-links.d.ts +2 -0
  119. package/dist/shared/api/bff/hooks/use-fetch-navigation-links.js +15 -0
  120. package/dist/shared/api/bff/model/bff.model.d.ts +30 -0
  121. package/dist/shared/api/bff/services/bff-service.d.ts +7 -1
  122. package/dist/shared/api/bff/services/bff-service.js +8 -1
  123. package/dist/shared/feature-flags/use-feature-flags.d.ts +1 -0
  124. package/dist/shared/feature-flags/use-feature-flags.js +1 -0
  125. package/dist/shared/ga/data-layer.js +4 -3
  126. package/dist/shared/hooks/use-mutation-observer.d.ts +3 -0
  127. package/dist/shared/hooks/use-mutation-observer.js +27 -0
  128. package/dist/shared/hooks/use-resize-observer.js +7 -1
  129. package/dist/shared/hooks/use-watch-css-property.js +1 -1
  130. package/dist/shared/routing/route-button.d.ts +1 -1
  131. package/dist/shared/routing/route-icon-button.d.ts +1 -1
  132. package/dist/shared/routing/route-link.d.ts +1 -1
  133. package/dist/shared/routing/with-routing.d.ts +2 -2
  134. package/dist/shared/routing/with-routing.js +5 -4
  135. package/dist/shared/utils/css.js +53 -0
  136. package/dist/styles.css +696 -476
  137. package/dist/toast/toast-provider.js +1 -0
  138. package/dist/tooltip/tooltip.js +1 -0
  139. package/dist/typography/heading/heading.js +1 -0
  140. package/package.json +1 -1
  141. package/dist/header/cart-icon/connected-cart-icon.d.ts +0 -3
  142. package/dist/header/cart-icon/connected-cart-icon.js +0 -14
  143. package/dist/header/hamburger-button/hamburger-button.js +0 -14
  144. package/dist/header/hamburger-button/hamburger-button.module.css.js +0 -3
  145. package/dist/notifications/announcements/announcement-provider.d.ts +0 -1
  146. package/dist/notifications/announcements/announcement-provider.js +0 -29
  147. package/dist/notifications/announcements/announcement-provider.module.css.js +0 -3
  148. package/dist/notifications/announcements/connected-announcement.d.ts +0 -5
  149. package/dist/notifications/announcements/connected-announcement.js +0 -27
  150. package/dist/shared/api/bff/model/announcement.model.d.ts +0 -12
  151. package/dist/shared/model/link.d.ts +0 -15
@@ -1,4 +1,5 @@
1
1
  import { CurrencyCode } from '../../../../intl/types';
2
+ import { ImageType } from '../../../model/image';
2
3
  export interface PageModel {
3
4
  alternateLanguageUrls: {
4
5
  [key: string]: string;
@@ -175,4 +176,33 @@ export interface Country {
175
176
  languages: Language[];
176
177
  name: string;
177
178
  }
179
+ interface Announcement {
180
+ endDate?: string;
181
+ href: string;
182
+ id: string;
183
+ startDate?: string;
184
+ subType: string;
185
+ text: string;
186
+ title: string;
187
+ type: string;
188
+ }
189
+ export type AnnouncementResponse = Announcement[];
190
+ export interface NavigationLink {
191
+ external?: boolean;
192
+ image?: ImageType;
193
+ key: string;
194
+ links?: NavigationLink[];
195
+ openInNewTab?: boolean;
196
+ title: string;
197
+ type: 'link' | 'category' | 'section';
198
+ url?: string;
199
+ }
200
+ export interface NavigationLinkResponse {
201
+ footer: {
202
+ bottomLinks: NavigationLink[];
203
+ copyright: string;
204
+ linkBlocks: NavigationLink[];
205
+ };
206
+ header: NavigationLink[];
207
+ }
178
208
  export {};
@@ -1,7 +1,7 @@
1
1
  import { CultureCode } from '../../../../intl/types';
2
2
  import { ProductListingPageData } from '../../../../pages/product/product-listing-page/product-listing-page-data-types';
3
3
  import { AnnouncementObject } from '../../../model/announcement';
4
- import { ProductDetailsPageDataResponse } from '../model/bff.model';
4
+ import { NavigationLinkResponse, ProductDetailsPageDataResponse } from '../model/bff.model';
5
5
  export interface FetchAnnouncementsArgs {
6
6
  cultureCode: CultureCode;
7
7
  }
@@ -12,3 +12,9 @@ export interface FetchProductPageDataArgs {
12
12
  }
13
13
  export declare function fetchProductDetailsPageData({ cultureCode, pageUrl, }: FetchProductPageDataArgs): Promise<ProductDetailsPageDataResponse>;
14
14
  export declare function fetchProductListingPageData({ cultureCode, pageUrl, }: FetchProductPageDataArgs): Promise<ProductListingPageData>;
15
+ export type NavigationLinkSource = 'shop' | 'marketing';
16
+ export interface FetchNavigationLinksArgs {
17
+ cultureCode: CultureCode;
18
+ source: NavigationLinkSource;
19
+ }
20
+ export declare function fetchNavigationLinks({ cultureCode, source, }: FetchNavigationLinksArgs): Promise<NavigationLinkResponse>;
@@ -70,5 +70,12 @@ async function fetchProductListingPageData({ cultureCode, pageUrl, }) {
70
70
  })),
71
71
  };
72
72
  }
73
+ async function fetchNavigationLinks({ cultureCode, source, }) {
74
+ const { body } = await request({
75
+ headers: { 'Current-Language-Id': cultureCode, Source: source },
76
+ url: `${config.BFF_API_URL}/navigation`,
77
+ });
78
+ return body;
79
+ }
73
80
 
74
- export { fetchAnnouncements, fetchProductDetailsPageData, fetchProductListingPageData };
81
+ export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData };
@@ -3,6 +3,7 @@ declare const features: {
3
3
  readonly checkoutv1: "checkoutV1";
4
4
  readonly languagev1: "languageV1";
5
5
  readonly missing: "missing";
6
+ readonly navigation: "navigationV2";
6
7
  readonly pdpv1: "pdpV1";
7
8
  readonly plpv1: "plpV1";
8
9
  readonly searchv1: "searchV1";
@@ -6,6 +6,7 @@ const features = {
6
6
  checkoutv1: 'checkoutV1',
7
7
  languagev1: 'languageV1',
8
8
  missing: 'missing',
9
+ navigation: 'navigationV2',
9
10
  pdpv1: 'pdpV1',
10
11
  plpv1: 'plpV1',
11
12
  searchv1: 'searchV1',
@@ -7,8 +7,9 @@ _dataLayer.push = (function (_push) {
7
7
  return _push(...items);
8
8
  };
9
9
  })(_dataLayer.push.bind(_dataLayer));
10
- const dataLayer =
11
- // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
12
- typeof window === 'undefined' ? _dataLayer : (window.dataLayer ?? _dataLayer);
10
+ const dataLayer = typeof window === 'undefined'
11
+ ? _dataLayer
12
+ : // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
13
+ (window.dataLayer = window.dataLayer || _dataLayer);
13
14
 
14
15
  export { dataLayer };
@@ -0,0 +1,3 @@
1
+ export declare function useMutationObserver<T extends Node>(onChange: MutationCallback, options: MutationObserverInit): {
2
+ ref: (el: T | null) => void;
3
+ };
@@ -0,0 +1,27 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ function useMutationObserver(onChange, options) {
4
+ const mutationObserver = useRef(typeof MutationObserver === 'undefined'
5
+ ? undefined
6
+ : new MutationObserver(onChange));
7
+ const ref = useRef(document?.body);
8
+ useEffect(() => {
9
+ if (ref.current)
10
+ mutationObserver.current?.observe(ref.current, options);
11
+ return () => {
12
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13
+ mutationObserver.current?.disconnect();
14
+ };
15
+ }, [options]);
16
+ return {
17
+ ref: (el) => {
18
+ ref.current = el;
19
+ mutationObserver.current?.disconnect();
20
+ if (!ref.current)
21
+ return;
22
+ mutationObserver.current?.observe(ref.current, options);
23
+ },
24
+ };
25
+ }
26
+
27
+ export { useMutationObserver };
@@ -1,4 +1,4 @@
1
- import { useRef } from 'react';
1
+ import { useRef, useEffect } from 'react';
2
2
 
3
3
  function useResizeObserver(resizeCallback) {
4
4
  let size;
@@ -15,6 +15,12 @@ function useResizeObserver(resizeCallback) {
15
15
  ? undefined
16
16
  : new ResizeObserver(onResize));
17
17
  const ref = useRef(null);
18
+ useEffect(() => {
19
+ return () => {
20
+ // eslint-disable-next-line react-hooks/exhaustive-deps
21
+ resizeObserver.current?.disconnect();
22
+ };
23
+ }, []);
18
24
  return {
19
25
  ref: (el) => {
20
26
  ref.current = el;
@@ -10,7 +10,7 @@ function useWatchCssProperty(property) {
10
10
  const mutationObserver = new MutationObserver(() => {
11
11
  if (typeof document === 'undefined')
12
12
  return;
13
- const propertyValue = getComputedStyle?.(document.body).getPropertyValue(property);
13
+ const propertyValue = getCssPropertyValue(property);
14
14
  setValue(propertyValue);
15
15
  });
16
16
  mutationObserver.observe(document.body, {
@@ -1 +1 @@
1
- export declare const RouteButton: React.FC<import("../../buttons/button/button").ButtonProps & import("./with-routing").WithRoutingProps>;
1
+ export declare const RouteButton: React.ForwardRefExoticComponent<import("../../buttons/button/button").ButtonProps & import("./with-routing").WithRoutingProps & React.RefAttributes<HTMLElement>>;
@@ -1 +1 @@
1
- export declare const RouteIconButton: React.FC<import("../../buttons/icon-button/icon-button").IconButtonProps & import("./with-routing").WithRoutingProps>;
1
+ export declare const RouteIconButton: React.ForwardRefExoticComponent<import("../../buttons/icon-button/icon-button").IconButtonProps & import("./with-routing").WithRoutingProps & React.RefAttributes<HTMLElement>>;
@@ -1 +1 @@
1
- export declare const RouteLink: React.FC<import("../../buttons/link/link").LinkProps & import("./with-routing").WithRoutingProps>;
1
+ export declare const RouteLink: React.ForwardRefExoticComponent<Omit<import("../../buttons/link/link").LinkProps & React.RefAttributes<HTMLElement> & import("./with-routing").WithRoutingProps, "ref"> & React.RefAttributes<HTMLElement>>;
@@ -1,4 +1,4 @@
1
- import { ComponentProps, ComponentType, FC, MouseEventHandler } from 'react';
1
+ import { ComponentProps, ComponentType, MouseEventHandler } from 'react';
2
2
  import { NavigateOptions } from './types';
3
3
  export interface WithRoutingProps {
4
4
  href?: string;
@@ -7,4 +7,4 @@ export interface WithRoutingProps {
7
7
  export declare function withRouting<TComponent extends ComponentType<TProps>, TProps extends {
8
8
  children: React.ReactNode;
9
9
  onClick?: MouseEventHandler<TElement> | undefined;
10
- }, TElement extends HTMLElement>(component: TComponent): FC<ComponentProps<TComponent> & WithRoutingProps>;
10
+ }, TElement extends HTMLElement>(component: TComponent): React.ForwardRefExoticComponent<React.PropsWithoutRef<ComponentProps<TComponent> & WithRoutingProps> & React.RefAttributes<HTMLElement>>;
@@ -1,9 +1,9 @@
1
- import { createElement } from 'react';
1
+ import { forwardRef, createElement } from 'react';
2
2
  import { useBasePath } from './use-base-path.js';
3
3
  import { useNavigate } from './use-navigate.js';
4
4
 
5
5
  function withRouting(component) {
6
- const Component = ({ href, onClick, route, ...rest }) => {
6
+ const Component = forwardRef(({ href, onClick, route, ...rest }, ref) => {
7
7
  const { navigate } = useNavigate();
8
8
  const basePath = useBasePath();
9
9
  if (basePath &&
@@ -28,10 +28,11 @@ function withRouting(component) {
28
28
  }
29
29
  return navigate(href, route);
30
30
  },
31
+ ref,
31
32
  };
32
33
  return createElement(component, props);
33
- };
34
- Component.displayName = component.displayName;
34
+ });
35
+ Component.displayName = `WithRouting(${component.displayName || component.name})`;
35
36
  return Component;
36
37
  }
37
38
 
@@ -1,9 +1,62 @@
1
+ function evaluateCssCalc(expression, options = {}) {
2
+ const baseFontSize = options.baseFontSize ?? 16;
3
+ const percentBase = options.percentBase ?? 100;
4
+ const expr = expression
5
+ .replace(/^calc\(/, '')
6
+ .replace(/\)$/, '')
7
+ .trim();
8
+ const tokens = expr.split(/([*+/-])/).map(token => token.trim());
9
+ const toPx = (value = '0px') => {
10
+ const match = value.match(/^([+-]?[\d.]+)(px|rem|em|%)?$/);
11
+ if (!match)
12
+ throw new Error(`Unsupported or invalid token: "${value}"`);
13
+ const num = Number.parseFloat(match[1] || '0');
14
+ const unit = match[2] || 'px';
15
+ switch (unit) {
16
+ case 'px':
17
+ return num;
18
+ case 'rem':
19
+ case 'em':
20
+ return num * baseFontSize;
21
+ case '%':
22
+ return (num / 100) * percentBase;
23
+ default:
24
+ throw new Error(`Unsupported unit: ${unit}`);
25
+ }
26
+ };
27
+ // Evaluate left-to-right (no operator precedence)
28
+ let result = toPx(tokens[0]);
29
+ for (let i = 1; i < tokens.length; i += 2) {
30
+ const operator = tokens[i];
31
+ const nextValue = toPx(tokens[i + 1]);
32
+ switch (operator) {
33
+ case '+':
34
+ result += nextValue;
35
+ break;
36
+ case '-':
37
+ result -= nextValue;
38
+ break;
39
+ case '*':
40
+ result *= nextValue;
41
+ break;
42
+ case '/':
43
+ result /= nextValue;
44
+ break;
45
+ default:
46
+ throw new Error(`Unsupported operator: ${operator}`);
47
+ }
48
+ }
49
+ return result;
50
+ }
1
51
  function getCssPropertyValue(property) {
2
52
  if (typeof document === 'undefined')
3
53
  return;
4
54
  const rawValue = getComputedStyle?.(document.body).getPropertyValue(property);
5
55
  if (!rawValue)
6
56
  return undefined;
57
+ if (/calc/i.test(rawValue)) {
58
+ return `${evaluateCssCalc(rawValue, { baseFontSize: 16, percentBase: 100 })}px`;
59
+ }
7
60
  if (rawValue && !/\D/.test(rawValue)) {
8
61
  const valueAsNumber = Number.parseFloat(rawValue);
9
62
  if (!Number.isNaN(valueAsNumber))