@sonic-equipment/ui 135.0.0 → 137.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 (51) hide show
  1. package/dist/algolia/algolia-initialization.js +2 -1
  2. package/dist/algolia/algolia-insights-provider.js +3 -3
  3. package/dist/algolia/algolia-searchclient-offline.js +3 -2
  4. package/dist/algolia/use-algolia-insights.js +24 -23
  5. package/dist/buttons/link/link.d.ts +2 -1
  6. package/dist/buttons/link/link.js +4 -2
  7. package/dist/collapsables/accordion/accordion-item.d.ts +2 -1
  8. package/dist/collapsables/accordion/accordion-item.js +13 -4
  9. package/dist/config.js +2 -2
  10. package/dist/country-selector/country-select/country-select.d.ts +6 -0
  11. package/dist/country-selector/country-select/country-select.js +10 -4
  12. package/dist/exports.d.ts +5 -0
  13. package/dist/footer/footer.d.ts +9 -0
  14. package/dist/footer/footer.js +14 -0
  15. package/dist/footer/footer.model.d.ts +18 -0
  16. package/dist/footer/footer.module.css.js +3 -0
  17. package/dist/header/header.d.ts +1 -0
  18. package/dist/header/header.js +9 -0
  19. package/dist/index.js +5 -0
  20. package/dist/intl/utils.js +2 -1
  21. package/dist/logging/logger.d.ts +11 -0
  22. package/dist/logging/logger.js +22 -0
  23. package/dist/logging/use-log-error.d.ts +1 -0
  24. package/dist/logging/use-log-error.js +12 -0
  25. package/dist/media/image/image.js +11 -4
  26. package/dist/notifications/announcements/announcement-provider.js +3 -6
  27. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +7 -1
  28. package/dist/pages/checkout/payment-page/components/adyen-payment.js +40 -28
  29. package/dist/pages/checkout/payment-page/components/payment.js +26 -16
  30. package/dist/pages/checkout/shipping-page/components/edit-address.d.ts +4 -2
  31. package/dist/pages/checkout/shipping-page/components/edit-address.js +6 -5
  32. package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.d.ts +6 -2
  33. package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.js +27 -8
  34. package/dist/pages/checkout/shipping-page/shipping-page-content.d.ts +2 -1
  35. package/dist/pages/checkout/shipping-page/shipping-page-content.js +2 -2
  36. package/dist/pages/checkout/shipping-page/shipping-page.js +6 -6
  37. package/dist/pages/product/search-result-page/search-results-page.js +1 -1
  38. package/dist/shared/api/shared/hooks/use-awaitable-mutation.d.ts +21 -20
  39. package/dist/shared/api/storefront/hooks/cart/use-patch-cart.d.ts +1 -3
  40. package/dist/shared/api/storefront/hooks/cart/use-patch-cart.js +4 -6
  41. package/dist/shared/api/storefront/hooks/cart/use-place-order.d.ts +1 -1
  42. package/dist/shared/api/storefront/hooks/cart/use-place-order.js +6 -5
  43. package/dist/shared/api/storefront/services/cart-service.js +7 -7
  44. package/dist/shared/ga/data-layer.js +3 -2
  45. package/dist/shared/model/image.d.ts +1 -2
  46. package/dist/shared/providers/global-state-provider.js +3 -5
  47. package/dist/shared/utils/debug.d.ts +2 -0
  48. package/dist/shared/utils/debug.js +21 -0
  49. package/dist/shared/utils/environment.js +4 -2
  50. package/dist/styles.css +105 -12
  51. package/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
  import { config } from '../config.js';
3
3
  import Cookies from 'js-cookie';
4
4
  import aa from 'search-insights';
5
+ import { logger } from '../logging/logger.js';
5
6
  import { request } from '../shared/fetch/request.js';
6
7
  import { createUUID } from '../shared/utils/uuid.js';
7
8
 
@@ -14,7 +15,7 @@ aa('init', {
14
15
  });
15
16
  aa('getUserToken', {}, (err, value) => {
16
17
  if (err)
17
- return console.error(err);
18
+ return logger.error(err);
18
19
  userToken = value === undefined ? generateUserToken() : String(value);
19
20
  });
20
21
  aa('onUserTokenChange', value => {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { createContext, useContext } from 'react';
3
+ import { createContext, useContext, useMemo } from 'react';
4
4
  import { useCultureCode } from '../intl/use-culture-code.js';
5
5
  import { getLanguageCodeFromCultureCode } from '../intl/utils.js';
6
6
  import { environment } from '../shared/utils/environment.js';
@@ -13,12 +13,12 @@ function AlgoliaInsightsProvider({ children, value, }) {
13
13
  const algoliaIndex = getAlgoliaIndex(environment, getLanguageCodeFromCultureCode(cultureCode));
14
14
  const [globalState] = useAlgoliaInsightsGlobalState();
15
15
  const context = useContext(AlgoliaInsightsProviderContext);
16
- const combinedValue = {
16
+ const combinedValue = useMemo(() => ({
17
17
  index: algoliaIndex.default,
18
18
  ...globalState,
19
19
  ...context,
20
20
  ...value,
21
- };
21
+ }), [algoliaIndex.default, context, globalState, value]);
22
22
  return (jsx(AlgoliaInsightsProviderContext.Provider, { value: combinedValue, children: children }));
23
23
  }
24
24
 
@@ -1,11 +1,12 @@
1
1
  "use client";
2
+ import { logger } from '../logging/logger.js';
3
+
2
4
  const searchClientLogger = (searchClient) => {
3
5
  return {
4
6
  ...searchClient,
5
7
  search: (async (queries, requestOptions) => {
6
8
  const response = await searchClient.search(queries, requestOptions);
7
- // eslint-disable-next-line no-console
8
- console.log('Algolia::SearchClient::search', {
9
+ logger.info('Algolia::SearchClient::search', {
9
10
  args: { queries, requestOptions },
10
11
  response,
11
12
  });
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { useContext, useMemo } from 'react';
3
3
  import aa from 'search-insights';
4
+ import { logger } from '../logging/logger.js';
4
5
  import { currencySymbolToISO } from '../shared/model/currency.js';
5
6
  import { ensureArray } from '../shared/utils/array.js';
6
7
  import { userToken } from './algolia-initialization.js';
@@ -18,7 +19,7 @@ function useAlgoliaInsights() {
18
19
  context,
19
20
  sendAddToCartFromProductDetailsPageEvent({ cartLine }) {
20
21
  if (!context.index)
21
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
22
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
22
23
  if (context.queryId) {
23
24
  aa('addedToCartObjectIDsAfterSearch', {
24
25
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
@@ -55,9 +56,9 @@ function useAlgoliaInsights() {
55
56
  },
56
57
  sendAddToCartFromProductListPageEvent({ cartLine }) {
57
58
  if (!context.index)
58
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
59
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
59
60
  if (!context.queryId)
60
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
61
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
61
62
  aa('addedToCartObjectIDsAfterSearch', {
62
63
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
63
64
  eventName: 'PLP: AddToCart ClickedAfterSearch',
@@ -76,7 +77,7 @@ function useAlgoliaInsights() {
76
77
  },
77
78
  sendAddToCartFromSearchEvent({ cartLine, queryId }) {
78
79
  if (!context.index)
79
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
80
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
80
81
  aa('addedToCartObjectIDsAfterSearch', {
81
82
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
82
83
  eventName: 'SRP: AddToCart ClickedAfterSearch',
@@ -95,9 +96,9 @@ function useAlgoliaInsights() {
95
96
  },
96
97
  sendAddToCartFromSearchResultPageEvent({ cartLine }) {
97
98
  if (!context.index)
98
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
99
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
99
100
  if (!context.queryId)
100
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
101
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
101
102
  aa('addedToCartObjectIDsAfterSearch', {
102
103
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
103
104
  eventName: 'SRP: AddToCart ClickedAfterSearch',
@@ -116,10 +117,10 @@ function useAlgoliaInsights() {
116
117
  },
117
118
  sendAddToWishListFromProductDetailsPageEvent({ objectId, position }) {
118
119
  if (!context.index)
119
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
120
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
120
121
  if (context.queryId) {
121
122
  if (!position)
122
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no position', context, objectId);
123
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no position', context, objectId);
123
124
  aa('clickedObjectIDsAfterSearch', {
124
125
  eventName: 'PDP: Product Added to Wishlist',
125
126
  index: context.index,
@@ -140,9 +141,9 @@ function useAlgoliaInsights() {
140
141
  },
141
142
  sendAddToWishListFromProductListPageEvent({ objectId, position }) {
142
143
  if (!context.index)
143
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
144
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
144
145
  if (!context.queryId)
145
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
146
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
146
147
  aa('clickedObjectIDsAfterSearch', {
147
148
  eventName: 'PLP: Product Added to Wishlist',
148
149
  index: context.index,
@@ -154,7 +155,7 @@ function useAlgoliaInsights() {
154
155
  },
155
156
  sendAddToWishListFromSearchEvent({ objectId, position, queryId }) {
156
157
  if (!context.index)
157
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
158
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
158
159
  aa('clickedObjectIDsAfterSearch', {
159
160
  eventName: 'SRP: Product Added to Wishlist',
160
161
  index: context.index,
@@ -166,9 +167,9 @@ function useAlgoliaInsights() {
166
167
  },
167
168
  sendAddToWishListFromSearchResultPageEvent({ objectId, position, }) {
168
169
  if (!context.index)
169
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
170
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
170
171
  if (!context.queryId)
171
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
172
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
172
173
  aa('clickedObjectIDsAfterSearch', {
173
174
  eventName: 'SRP: Product Added to Wishlist',
174
175
  index: context.index,
@@ -180,11 +181,11 @@ function useAlgoliaInsights() {
180
181
  },
181
182
  sendProductClickFromProductListPageEvent({ objectId, position }) {
182
183
  if (!objectId)
183
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
184
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
184
185
  if (!context.index)
185
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
186
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
186
187
  if (!context.queryId)
187
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
188
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
188
189
  aa('clickedObjectIDsAfterSearch', {
189
190
  eventName: 'PLP: Product Clicked',
190
191
  index: context.index,
@@ -200,9 +201,9 @@ function useAlgoliaInsights() {
200
201
  },
201
202
  sendProductClickFromSearchEvent({ objectId, position, queryId }) {
202
203
  if (!objectId)
203
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
204
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
204
205
  if (!context.index)
205
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
206
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
206
207
  aa('clickedObjectIDsAfterSearch', {
207
208
  eventName: 'SRP: Product Clicked',
208
209
  index: context.index,
@@ -218,11 +219,11 @@ function useAlgoliaInsights() {
218
219
  },
219
220
  sendProductClickFromSearchResultPageEvent({ objectId, position }) {
220
221
  if (!objectId)
221
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
222
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
222
223
  if (!context.index)
223
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
224
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
224
225
  if (!context.queryId)
225
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
226
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
226
227
  aa('clickedObjectIDsAfterSearch', {
227
228
  eventName: 'SRP: Product Clicked',
228
229
  index: context.index,
@@ -238,9 +239,9 @@ function useAlgoliaInsights() {
238
239
  },
239
240
  sendPurchaseEventFromPaymentPage({ cart }) {
240
241
  if (!context.index)
241
- return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
242
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
242
243
  if (!cart.cartLines || cart.cartLines.length === 0)
243
- return console.warn('Unable to send purchasedObjectIDs event, no cartLines', cart);
244
+ return logger.warn('Unable to send purchasedObjectIDs event, no cartLines', cart);
244
245
  aa('purchasedObjectIDs', {
245
246
  currency: currencySymbolToISO[cart.currencySymbol],
246
247
  eventName: 'Purchase Successful',
@@ -2,8 +2,9 @@ import { AnchorHTMLAttributes } from 'react';
2
2
  export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
3
3
  areaSelected?: boolean;
4
4
  color?: 'primary' | 'secondary';
5
+ currentColor?: boolean;
5
6
  hasUnderline?: boolean;
6
7
  isDisabled?: boolean;
7
8
  role?: 'option';
8
9
  }
9
- export declare function Link({ children, className, color, hasUnderline, isDisabled, onClick, onKeyUp, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function Link({ children, className, color, currentColor, hasUnderline, isDisabled, onClick, onKeyUp, ...props }: LinkProps): import("react/jsx-runtime").JSX.Element;
@@ -3,11 +3,13 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import clsx from 'clsx';
4
4
  import styles from './link.module.css.js';
5
5
 
6
- function Link({ children, className, color = 'primary', hasUnderline, isDisabled, onClick, onKeyUp, ...props }) {
6
+ function Link({ children, className, color = 'primary', currentColor, hasUnderline, isDisabled, onClick, onKeyUp, ...props }) {
7
7
  return (jsx("a", { className: clsx({
8
8
  [styles.hover]: Boolean(props.href),
9
9
  [styles['has-underline']]: hasUnderline && props.href,
10
- }, styles['link'], styles[color], className), "data-disabled": isDisabled ? true : undefined, onClick: onClick, onKeyUp: onKeyUp, role: "link", tabIndex: isDisabled ? -1 : 0, ...props, children: children }));
10
+ [styles[color]]: !currentColor,
11
+ [styles['current-color']]: currentColor,
12
+ }, styles['link'], className), "data-disabled": isDisabled ? true : undefined, onClick: onClick, onKeyUp: onKeyUp, role: "link", tabIndex: isDisabled ? -1 : 0, ...props, children: children }));
11
13
  }
12
14
 
13
15
  export { Link };
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  export type BorderType = 'top' | 'middle' | 'middle-accentuated' | 'bottom';
3
3
  export interface AccordionItemProps {
4
4
  _pseudo?: 'none' | 'focus' | 'hover' | 'active';
5
+ allowCollapse?: boolean;
5
6
  allowToggle?: boolean;
6
7
  borderType?: BorderType | BorderType[];
7
8
  children: ReactNode;
@@ -12,4 +13,4 @@ export interface AccordionItemProps {
12
13
  size?: 'md' | 'lg';
13
14
  title: ReactNode;
14
15
  }
15
- export declare function AccordionItem({ _pseudo, allowToggle, borderType, children, className, id, initialIsOpen, isDisabled, size, title, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function AccordionItem({ _pseudo, allowCollapse, allowToggle, borderType, children, className, id, initialIsOpen, isDisabled, size, title, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useEffect } from 'react';
3
4
  import clsx from 'clsx';
4
5
  import { GlyphsChevronsBoldDownIcon } from '../../icons/glyph/glyphs-chevrons-bold-down-icon.js';
5
6
  import { GlyphsChevronsSlimDownIcon } from '../../icons/glyph/glyphs-chevrons-slim-down-icon.js';
@@ -7,16 +8,24 @@ import { useDisclosure } from '../../shared/hooks/use-disclosure.js';
7
8
  import { ensureArray } from '../../shared/utils/array.js';
8
9
  import styles from './accordion.module.css.js';
9
10
 
10
- function AccordionItem({ _pseudo = 'none', allowToggle = true, borderType = 'bottom', children, className, id, initialIsOpen = false, isDisabled = false, size, title, }) {
11
- const { isOpen, toggle } = useDisclosure(initialIsOpen);
11
+ function AccordionItem({ _pseudo = 'none', allowCollapse = true, allowToggle = true, borderType = 'bottom', children, className, id, initialIsOpen = false, isDisabled = false, size, title, }) {
12
+ const { close, isOpen, open, toggle } = useDisclosure(initialIsOpen);
13
+ useEffect(() => {
14
+ if (initialIsOpen) {
15
+ open();
16
+ }
17
+ else {
18
+ close();
19
+ }
20
+ }, [close, initialIsOpen, open]);
12
21
  const panelId = `panel-${id}`;
13
22
  return (jsxs("div", { className: clsx(className, ...ensureArray(borderType).map(type => styles[`border-type-${type}`]), styles['accordion-item'], {
14
23
  [styles['is-open']]: isOpen,
15
24
  [styles['allow-toggle']]: allowToggle,
16
- }), children: [jsx("h3", { children: jsxs("button", { "aria-controls": panelId, "aria-expanded": isOpen, className: clsx(styles.button, styles[_pseudo]), disabled: isDisabled, id: id, onClick: () => {
25
+ }), children: [jsx("h3", { children: allowCollapse ? (jsxs("button", { "aria-controls": panelId, "aria-expanded": isOpen, className: clsx(styles.button, styles[_pseudo]), disabled: isDisabled, id: id, onClick: () => {
17
26
  if (allowToggle)
18
27
  toggle();
19
- }, type: "button", children: [title, jsx("span", { className: styles.icon, children: size === 'lg' ? (jsx(GlyphsChevronsBoldDownIcon, {})) : (jsx(GlyphsChevronsSlimDownIcon, {})) })] }) }), jsx("div", { "aria-labelledby": id, className: styles.panel, id: panelId, role: "region", children: jsx("div", { className: styles.content, children: children }) })] }));
28
+ }, type: "button", children: [title, jsx("span", { className: styles.icon, children: size === 'lg' ? (jsx(GlyphsChevronsBoldDownIcon, {})) : (jsx(GlyphsChevronsSlimDownIcon, {})) })] })) : (jsx("span", { className: styles.button, children: title })) }), jsx("div", { "aria-labelledby": id, className: styles.panel, id: panelId, role: "region", children: jsx("div", { className: styles.content, children: children }) })] }));
20
29
  }
21
30
 
22
31
  export { AccordionItem };
package/dist/config.js CHANGED
@@ -13,8 +13,8 @@ const configPerEnvironment = {
13
13
  local: () => ({
14
14
  ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
15
15
  ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
16
- ALGOLIA_HOST: 'shop-accept.sonic-equipment.workers.dev',
17
- BFF_API_URL: 'https://shop-accept.sonic-equipment.workers.dev/api/v1/bff',
16
+ ALGOLIA_HOST: 'sonic.local.com:4443',
17
+ BFF_API_URL: '/api/v1/bff',
18
18
  COOKIE_DOMAIN: undefined,
19
19
  SHOP_API_URL:
20
20
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -8,14 +8,20 @@ interface CountrySelectProps<T extends Country | CountryModel> {
8
8
  name?: string;
9
9
  showLabel?: boolean;
10
10
  }
11
+ interface CountrySelectPropsWithDefaultSelectedCountry<T extends Country | CountryModel> extends CountrySelectProps<T> {
12
+ defaultSelectedCountry: T;
13
+ onCountryChange?: (country: T) => void;
14
+ }
11
15
  interface CountrySelectPropsWithSelectedCountry<T extends Country | CountryModel> extends CountrySelectProps<T> {
12
16
  onCountryChange?: (country: T) => void;
13
17
  selectedCountry: T;
14
18
  }
15
19
  interface CountrySelectPropsWithoutSelectedCountry<T extends Country | CountryModel> extends CountrySelectProps<T> {
20
+ defaultSelectedCountry?: T | undefined;
16
21
  onCountryChange?: (country: T | undefined) => void;
17
22
  selectedCountry?: T | undefined;
18
23
  }
24
+ export declare function CountrySelect<T extends Country | CountryModel>(props: CountrySelectPropsWithDefaultSelectedCountry<T>): JSX.Element;
19
25
  export declare function CountrySelect<T extends Country | CountryModel>(props: CountrySelectPropsWithSelectedCountry<T>): JSX.Element;
20
26
  export declare function CountrySelect<T extends Country | CountryModel>(props: CountrySelectPropsWithoutSelectedCountry<T>): JSX.Element;
21
27
  export {};
@@ -3,15 +3,21 @@ import { useMemo } from 'react';
3
3
  import { Select } from '../../forms/select/select.js';
4
4
  import { useFormattedMessage } from '../../intl/use-formatted-message.js';
5
5
 
6
- function CountrySelect({ countries, 'data-test-selector': dataTestSelector, isDisabled, isRequired, name, onCountryChange, selectedCountry, showLabel = true, }) {
6
+ function CountrySelect({ countries, 'data-test-selector': dataTestSelector, defaultSelectedCountry, isDisabled, isRequired, name, onCountryChange, selectedCountry, showLabel = true, }) {
7
7
  const t = useFormattedMessage();
8
- const countryOptions = useMemo(() => countries.reduce((acc, country) => ({
8
+ const countryOptions = useMemo(() => countries
9
+ .map((country) => [
10
+ country.id,
11
+ t(`clSelector.${country.abbreviation}`),
12
+ ])
13
+ .sort(([, labelA], [, labelB]) => labelA.localeCompare(labelB))
14
+ .reduce((acc, [id, label]) => ({
9
15
  ...acc,
10
- [country.id]: t(`clSelector.${country.abbreviation}`),
16
+ [id]: label,
11
17
  }), {}),
12
18
  // eslint-disable-next-line react-hooks/exhaustive-deps
13
19
  [countries]);
14
- return (jsx(Select, { "data-test-selector": dataTestSelector, isDisabled: isDisabled, isRequired: isRequired, label: t('Country'), name: name, onChange: value => onCountryChange?.(countries.find(country => country.id === value)), options: countryOptions, selectedOption: selectedCountry?.id, showLabel: showLabel, showPlaceholder: false, variant: "solid" }));
20
+ return (jsx(Select, { "data-test-selector": dataTestSelector, defaultSelectedOption: defaultSelectedCountry?.id, isDisabled: isDisabled, isRequired: isRequired, label: t('Country'), name: name, onChange: value => onCountryChange?.(countries.find(country => country.id === value)), options: countryOptions, selectedOption: selectedCountry?.id, showLabel: showLabel, showPlaceholder: false, variant: "solid" }));
15
21
  }
16
22
 
17
23
  export { CountrySelect };
package/dist/exports.d.ts CHANGED
@@ -73,6 +73,7 @@ export * from './display/product-sku/product-sku';
73
73
  export * from './filters/active-filters/active-filters';
74
74
  export * from './filters/multi-select/multi-select';
75
75
  export * from './filters/pagination/pagination';
76
+ export * from './footer/footer';
76
77
  export * from './forms/checkbox/checkbox';
77
78
  export * from './forms/color-checkbox/color-checkbox';
78
79
  export * from './forms/field-error/field-error';
@@ -109,6 +110,7 @@ export * from './global-search/search-section/search-section';
109
110
  export * from './global-search/types';
110
111
  export * from './header/cart-icon/connected-cart-icon';
111
112
  export * from './header/hamburger-button/hamburger-button';
113
+ export * from './header/header';
112
114
  export * from './header/header-layout/header-layout';
113
115
  export * from './header/sonic-logo/sonic-logo';
114
116
  export * from './info-icon-tooltip/info-icon-tooltip';
@@ -130,6 +132,8 @@ export * from './lists/ul/list';
130
132
  export * from './loading/blank-page-spacer';
131
133
  export * from './loading/loading-overlay';
132
134
  export * from './loading/progress-circle';
135
+ export * from './logging/logger';
136
+ export * from './logging/use-log-error';
133
137
  export * from './media/image-grid/images-grid';
134
138
  export * from './media/image-lightbox/image-lightbox';
135
139
  export * from './media/image/image';
@@ -290,6 +294,7 @@ export * from './shared/routing/with-routing';
290
294
  export * from './shared/utils/array';
291
295
  export * from './shared/utils/breakpoints';
292
296
  export * from './shared/utils/date';
297
+ export * from './shared/utils/debug';
293
298
  export * from './shared/utils/environment';
294
299
  export * from './shared/utils/event-emitter';
295
300
  export * from './shared/utils/merge';
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { FooterLink, LinkBlock } from './footer.model';
3
+ export interface FooterProps {
4
+ bottomLinks: FooterLink[];
5
+ copyright: string;
6
+ countrySelector: ReactNode;
7
+ linkBlocks: LinkBlock[];
8
+ }
9
+ export declare function Footer({ bottomLinks, copyright, countrySelector, linkBlocks, }: FooterProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { Accordion } from '../collapsables/accordion/accordion.js';
4
+ import { AccordionItem } from '../collapsables/accordion/accordion-item.js';
5
+ import { useIsBreakpoint } from '../shared/hooks/use-is-breakpoint.js';
6
+ import { RouteLink } from '../shared/routing/route-link.js';
7
+ import styles from './footer.module.css.js';
8
+
9
+ function Footer({ bottomLinks, copyright, countrySelector, linkBlocks, }) {
10
+ const isXl = useIsBreakpoint('xl');
11
+ return (jsxs("footer", { className: styles.footer, children: [jsx("div", { className: styles['main-links'], children: linkBlocks.map(linkBlock => (jsx("div", { className: styles['link-block'], children: jsx(Accordion, { color: "white", hasLineSeparator: false, size: "lg", children: jsx(AccordionItem, { allowCollapse: !isXl, id: `link-block-${linkBlock.key}`, initialIsOpen: isXl, title: linkBlock.header, children: jsx("ul", { className: styles['list'], children: linkBlock.links.map(link => (jsx("li", { children: jsx(RouteLink, { currentColor: true, href: link.externalLink || link.internalLink, target: link.openInNewTab ? '_blank' : undefined, children: link.title }) }, link.key))) }) }) }) }, linkBlock.key))) }), jsxs("div", { className: styles['bottom-section'], children: [jsx("p", { className: styles.copyright, children: copyright }), jsx("div", { className: styles['bottom-links'], children: bottomLinks.map(link => (jsx(RouteLink, { className: styles['bottom-link'], currentColor: true, href: link.externalLink || link.internalLink, target: link.openInNewTab ? '_blank' : undefined, children: link.title }, link.key))) }), countrySelector] })] }));
12
+ }
13
+
14
+ export { Footer };
@@ -0,0 +1,18 @@
1
+ export interface FooterLink {
2
+ externalLink?: string;
3
+ internalLink?: string;
4
+ isButton: boolean;
5
+ key: string;
6
+ openInNewTab: boolean;
7
+ title?: string;
8
+ }
9
+ export interface LinkBlock {
10
+ header: string;
11
+ key: string;
12
+ links: FooterLink[];
13
+ }
14
+ export interface FooterModel {
15
+ bottomLinks: FooterLink[];
16
+ copyright: string;
17
+ linkBlocks: LinkBlock[];
18
+ }
@@ -0,0 +1,3 @@
1
+ var styles = {"footer":"footer-module-YzJ68","main-links":"footer-module-rFBXC","link-block":"footer-module-P5FXP","link-block-heading":"footer-module-umuTh","list":"footer-module-FM4hU","bottom-section":"footer-module-TZq-4","copyright":"footer-module-qlHSS","bottom-links":"footer-module-5eyFH","bottom-link":"footer-module-0gJpF"};
2
+
3
+ export { styles as default };
@@ -0,0 +1 @@
1
+ export declare function Header(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { HeaderLayout } from './header-layout/header-layout.js';
3
+ import { SonicLogo } from './sonic-logo/sonic-logo.js';
4
+
5
+ function Header() {
6
+ return (jsx(HeaderLayout, { hamburgerButton: null, logo: jsx(SonicLogo, { href: "/" }), mainNavigation: null, navigationActions: null, search: null }));
7
+ }
8
+
9
+ export { Header };
package/dist/index.js CHANGED
@@ -78,6 +78,7 @@ export { ProductSku } from './display/product-sku/product-sku.js';
78
78
  export { ActiveFilters } from './filters/active-filters/active-filters.js';
79
79
  export { MultiSelect } from './filters/multi-select/multi-select.js';
80
80
  export { Pagination } from './filters/pagination/pagination.js';
81
+ export { Footer } from './footer/footer.js';
81
82
  export { Checkbox } from './forms/checkbox/checkbox.js';
82
83
  export { ColorCheckbox } from './forms/color-checkbox/color-checkbox.js';
83
84
  export { FieldError } from './forms/field-error/field-error.js';
@@ -113,6 +114,7 @@ export { SearchListItem } from './global-search/search-section/search-list-item.
113
114
  export { SearchSection } from './global-search/search-section/search-section.js';
114
115
  export { ConnectedCartIcon } from './header/cart-icon/connected-cart-icon.js';
115
116
  export { HamburgerButton } from './header/hamburger-button/hamburger-button.js';
117
+ export { Header } from './header/header.js';
116
118
  export { HeaderLayout } from './header/header-layout/header-layout.js';
117
119
  export { SonicLogo } from './header/sonic-logo/sonic-logo.js';
118
120
  export { InfoIconTooltip } from './info-icon-tooltip/info-icon-tooltip.js';
@@ -133,6 +135,8 @@ export { List, ListItem } from './lists/ul/list.js';
133
135
  export { BlankPageSpacer } from './loading/blank-page-spacer.js';
134
136
  export { LoadingOverlay } from './loading/loading-overlay.js';
135
137
  export { ProgressCircle } from './loading/progress-circle.js';
138
+ export { consoleLogger, initLogger, logger } from './logging/logger.js';
139
+ export { useLogError } from './logging/use-log-error.js';
136
140
  export { ImagesGrid } from './media/image-grid/images-grid.js';
137
141
  export { ImageLightbox } from './media/image-lightbox/image-lightbox.js';
138
142
  export { Image } from './media/image/image.js';
@@ -290,6 +294,7 @@ export { withRouting } from './shared/routing/with-routing.js';
290
294
  export { ensureArray } from './shared/utils/array.js';
291
295
  export { breakpoints, getCurrentBreakpoints } from './shared/utils/breakpoints.js';
292
296
  export { convertDateUnitToPluralOrSingle, formatDateToLocaleString, getDateUnitObject } from './shared/utils/date.js';
297
+ export { trackPropertyChange } from './shared/utils/debug.js';
293
298
  export { environment, environments } from './shared/utils/environment.js';
294
299
  export { EventEmitter } from './shared/utils/event-emitter.js';
295
300
  export { clone, deepMerge, isPlainObject, default as main, merge } from './shared/utils/merge.js';
@@ -1,3 +1,4 @@
1
+ import { logger } from '../logging/logger.js';
1
2
  import { isLanguageCode } from './types.js';
2
3
 
3
4
  function getLanguageCodeFromCultureCode(cultureCode) {
@@ -21,7 +22,7 @@ function spireTranslateAdapter(translate) {
21
22
  }, [])
22
23
  : []));
23
24
  if (optional && message === undefined)
24
- console.warn(`Missing translation with id: ${id}`);
25
+ logger.warn(`Missing translation with id: ${id}`);
25
26
  return message || fallbackValue || id;
26
27
  };
27
28
  }
@@ -0,0 +1,11 @@
1
+ export interface Logger {
2
+ debug(message: unknown, ...args: unknown[]): void;
3
+ error(message: unknown, error: unknown): void;
4
+ error(message: unknown, error: unknown, ...args: unknown[]): void;
5
+ error(error: unknown): void;
6
+ info(message: unknown, ...args: unknown[]): void;
7
+ warn(message: unknown, ...args: unknown[]): void;
8
+ }
9
+ export declare const consoleLogger: Logger;
10
+ export declare let logger: Logger;
11
+ export declare function initLogger(replacementLogger: Logger): Logger;
@@ -0,0 +1,22 @@
1
+ const consoleLogger = {
2
+ debug(...args) {
3
+ // eslint-disable-next-line no-console
4
+ return console.debug('⚡️', ...args);
5
+ },
6
+ error(...args) {
7
+ return console.error('❌', ...args);
8
+ },
9
+ info(...args) {
10
+ // eslint-disable-next-line no-console
11
+ return console.log('✅', ...args);
12
+ },
13
+ warn(...args) {
14
+ return console.warn('⚠️', ...args);
15
+ },
16
+ };
17
+ let logger = consoleLogger;
18
+ function initLogger(replacementLogger) {
19
+ return (logger = replacementLogger);
20
+ }
21
+
22
+ export { consoleLogger, initLogger, logger };
@@ -0,0 +1 @@
1
+ export declare function useLogError(error?: unknown): void;
@@ -0,0 +1,12 @@
1
+ import { useEffect } from 'react';
2
+ import { logger } from './logger.js';
3
+
4
+ function useLogError(error) {
5
+ return useEffect(() => {
6
+ if (!error)
7
+ return;
8
+ logger.error(error);
9
+ }, [error]);
10
+ }
11
+
12
+ export { useLogError };
@@ -25,12 +25,19 @@ function Image({ className, fallbackSrc = 'https://res.cloudinary.com/dkz9eknwh/
25
25
  }
26
26
  return jsx(ImageComponent, { ...props, hasError: hasError, image: image });
27
27
  }
28
+ function createSrcSet(image) {
29
+ return ([
30
+ image[1] && `${image[1]} 1x`,
31
+ image[2] && `${image[2]} 2x`,
32
+ image[3] && `${image[3]} 3x`,
33
+ ]
34
+ .filter(Boolean)
35
+ .join(', ') || undefined);
36
+ }
28
37
  function ImageComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
29
38
  if (!image)
30
39
  return (jsx("img", { alt: "Missing", className: clsx(styles.image, className, styles[fit], styles['has-error']), src: fallbackSrc, ...rest }));
31
- const srcSet = hasError
32
- ? undefined
33
- : `${image[1]} 1x, ${image[2]} 2x, ${image[3]} 3x`;
40
+ const srcSet = hasError ? undefined : createSrcSet(image);
34
41
  return (jsx("img", { alt: image.altText, className: clsx(styles.image, className, styles[fit], {
35
42
  [styles['has-error']]: hasError,
36
43
  }), src: hasError ? fallbackSrc : image[3], srcSet: srcSet, ...rest }));
@@ -38,7 +45,7 @@ function ImageComponent({ className, fallbackSrc, fit = 'cover', hasError, image
38
45
  function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
39
46
  if (!image)
40
47
  return (jsx("picture", { className: clsx(styles.picture, className), children: jsx("img", { alt: "Missing", className: clsx(styles.image, styles[fit], styles['has-error']), src: fallbackSrc, ...rest }) }));
41
- return (jsxs("picture", { className: clsx(styles.picture, className), children: [jsx("source", { media: "(max-width: 768px)", srcSet: `${image.sm[1]} 1x, ${image.sm[2]} 2x, ${image.sm[3]} 3x` }), jsx("source", { media: "(max-width: 1439px)", srcSet: `${image.md[1]} 1x, ${image.md[2]} 2x, ${image.md[3]} 3x` }), jsx("source", { media: "(min-width: 1440px)", srcSet: `${image.lg[1]} 1x, ${image.lg[2]} 2x, ${image.lg[3]} 3x` }), jsx("img", { alt: image.altText, className: clsx(styles.image, styles[fit], {
48
+ return (jsxs("picture", { className: clsx(styles.picture, className), children: [jsx("source", { media: "(max-width: 768px)", srcSet: createSrcSet(image.sm) }), jsx("source", { media: "(max-width: 1439px)", srcSet: createSrcSet(image.md) }), jsx("source", { media: "(min-width: 1440px)", srcSet: createSrcSet(image.lg) }), jsx("img", { alt: image.altText, className: clsx(styles.image, styles[fit], {
42
49
  [styles['has-error']]: hasError,
43
50
  }), src: hasError ? fallbackSrc : image.lg[3], ...rest })] }));
44
51
  }
@@ -1,8 +1,9 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useRef, useEffect } from 'react';
3
+ import { useRef } from 'react';
4
4
  import { TransitionGroup, CSSTransition } from 'react-transition-group';
5
5
  import { useCultureCode } from '../../intl/use-culture-code.js';
6
+ import { useLogError } from '../../logging/use-log-error.js';
6
7
  import { useFetchAnnouncements } from '../../shared/api/bff/hooks/use-fetch-announcements.js';
7
8
  import { useLocalStorage } from '../../shared/hooks/use-local-storage.js';
8
9
  import { ConnectedAnnouncement } from './connected-announcement.js';
@@ -14,11 +15,7 @@ function AnnouncementProvider() {
14
15
  const { data: announcements, error } = useFetchAnnouncements({
15
16
  cultureCode,
16
17
  });
17
- useEffect(() => {
18
- if (!error)
19
- return;
20
- console.error(error);
21
- }, [error]);
18
+ useLogError(error);
22
19
  const [dismissedIds, setDismissedIds] = useLocalStorage('dismissedAnnouncementIds', []);
23
20
  const filteredAnnouncements = announcements?.filter(({ id }) => !dismissedIds.includes(id));
24
21
  return (jsx(TransitionGroup, { className: styles['announcement-provider'], children: filteredAnnouncements?.map(announcement => (jsx(CSSTransition, { classNames: {
@@ -39,7 +39,13 @@ function OrderConfirmationPageContent({ cart, }) {
39
39
  });
40
40
  },
41
41
  });
42
- return (jsx(Page, { breadCrumb: [{ href: CHECKOUT_PATHS.HOME, label: t('Home') }], title: t('Order confirmation'), children: jsx(CheckoutPageLayout, { actions: {
42
+ return (jsx(Page, { breadCrumb: [
43
+ { href: CHECKOUT_PATHS.HOME, label: t('Home') },
44
+ {
45
+ href: `${CHECKOUT_PATHS.ORDER_CONFIRMATION}?cartId=${cart.id}`,
46
+ label: t('Order confirmation'),
47
+ },
48
+ ], title: t('Order confirmation'), children: jsx(CheckoutPageLayout, { actions: {
43
49
  primary: (jsx(RouteButton, { withArrow: true, "data-test-selector": "checkoutReviewAndSubmit_continueShopping", href: "/", children: jsx(FormattedMessage, { id: "Continue shopping" }) })),
44
50
  secondary: (jsxs(Fragment, { children: [cart.canSaveOrder && (jsx(RouteButton, { color: "secondary", onClick: () => {
45
51
  saveCartForLater.mutate({ cart });