@sonic-equipment/ui 168.0.0 → 170.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 (75) hide show
  1. package/dist/algolia/algolia-active-categories.js +2 -2
  2. package/dist/breadcrumbs/breadcrumb.js +4 -4
  3. package/dist/buttons/button/button.d.ts +5 -2
  4. package/dist/buttons/button/button.js +22 -11
  5. package/dist/buttons/icon-button/icon-button.d.ts +6 -3
  6. package/dist/buttons/icon-button/icon-button.js +12 -5
  7. package/dist/buttons/link/link.d.ts +2 -0
  8. package/dist/buttons/link/link.js +13 -9
  9. package/dist/cards/category-card/category-card.d.ts +3 -1
  10. package/dist/cards/category-card/category-card.js +4 -4
  11. package/dist/cards/orderline-card/orderline-card.js +2 -2
  12. package/dist/cards/product-card/connected-product-card.d.ts +2 -0
  13. package/dist/cards/product-card/product-card.d.ts +3 -1
  14. package/dist/cards/product-card/product-card.js +3 -3
  15. package/dist/collapsables/show-all/show-all.js +2 -2
  16. package/dist/country-selector/connected-country-selector.d.ts +6 -6
  17. package/dist/exports.d.ts +2 -3
  18. package/dist/filters/active-filters/active-filters.js +2 -2
  19. package/dist/footer/connected-footer.d.ts +3 -1
  20. package/dist/footer/connected-footer.js +2 -2
  21. package/dist/footer/footer.js +6 -6
  22. package/dist/global-search/search-result-panel/sections/no-search.js +2 -2
  23. package/dist/global-search/search-result-panel/sections/with-results.js +2 -2
  24. package/dist/header/buttons/account/connected-account-button.js +2 -2
  25. package/dist/header/buttons/cart/connected-cart-button.js +2 -2
  26. package/dist/header/buttons/favorites/connected-favorites-button.js +2 -2
  27. package/dist/header/buttons/search/search-button.js +2 -2
  28. package/dist/header/connected-header.d.ts +2 -1
  29. package/dist/header/connected-header.js +3 -4
  30. package/dist/header/header.d.ts +2 -1
  31. package/dist/header/header.js +2 -2
  32. package/dist/header/link-list/navigation-link-list.js +3 -3
  33. package/dist/header/sonic-logo/sonic-logo.js +2 -3
  34. package/dist/index.js +2 -3
  35. package/dist/lists/menu-list/menu-list-header.js +2 -2
  36. package/dist/lists/menu-list/menu-list-item.js +2 -2
  37. package/dist/modals/signin/sign-in-dialog.js +2 -2
  38. package/dist/navigation/cart-icon/cart-icon.js +1 -1
  39. package/dist/notifications/announcements/announcement.js +2 -2
  40. package/dist/notifications/announcements/connected-announcement-list.d.ts +3 -1
  41. package/dist/notifications/announcements/connected-announcement-list.js +2 -2
  42. package/dist/pages/account/components/sign-in-form/sign-in-form.js +1 -2
  43. package/dist/pages/account/create-account-page/create-account-page.js +2 -2
  44. package/dist/pages/checkout/cart-page/cart-page.js +4 -6
  45. package/dist/pages/checkout/layouts/checkout-page-layout/checkout-page-layout.js +1 -1
  46. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +3 -3
  47. package/dist/pages/checkout/shipping-page/components/currency-change-dialog.js +2 -2
  48. package/dist/pages/checkout/shipping-page/components/readonly-address.js +3 -3
  49. package/dist/pages/product/components/product-overview.d.ts +2 -0
  50. package/dist/pages/product/components/product-overview.js +1 -1
  51. package/dist/pages/product/product-listing-page/no-results/no-results.js +2 -2
  52. package/dist/pages/product/product-listing-page/product-listing-page-category-carousel/product-listing-page-category-carousel.js +1 -1
  53. package/dist/pages/product/product-listing-page/product-listing-product-overview/product-listing-product-overview.js +1 -1
  54. package/dist/promos/promo-banner/promo-banner.js +2 -2
  55. package/dist/promos/promo-card/promo-card.js +2 -2
  56. package/dist/shared/hooks/use-watch-css-property.js +1 -1
  57. package/dist/shared/routing/route-provider.d.ts +4 -3
  58. package/dist/shared/routing/route-provider.js +4 -2
  59. package/dist/shared/routing/route-utils.d.ts +4 -0
  60. package/dist/shared/routing/route-utils.js +8 -0
  61. package/dist/shared/routing/types.d.ts +7 -0
  62. package/dist/shared/routing/use-route-link-element.d.ts +1 -0
  63. package/dist/shared/routing/use-route-link-element.js +11 -0
  64. package/dist/shared/routing/with-routing.d.ts +3 -6
  65. package/dist/shared/routing/with-routing.js +6 -6
  66. package/dist/shared/utils/css.js +53 -0
  67. package/dist/shared/utils/price.d.ts +1 -1
  68. package/dist/styles.css +190 -188
  69. package/package.json +1 -1
  70. package/dist/shared/routing/route-button.d.ts +0 -1
  71. package/dist/shared/routing/route-button.js +0 -7
  72. package/dist/shared/routing/route-icon-button.d.ts +0 -1
  73. package/dist/shared/routing/route-icon-button.js +0 -7
  74. package/dist/shared/routing/route-link.d.ts +0 -1
  75. package/dist/shared/routing/route-link.js +0 -7
@@ -1,8 +1,9 @@
1
- import { ReactNode } from 'react';
2
- import { NavigateFunction } from './types';
1
+ import { ElementType, ReactNode } from 'react';
2
+ import { NavigateFunction, RouteLinkElementProps } from './types';
3
3
  export interface RouteProviderProps {
4
+ Link?: ElementType<RouteLinkElementProps>;
4
5
  basePath?: string;
5
6
  children: ReactNode;
6
7
  navigate: NavigateFunction;
7
8
  }
8
- export declare function RouteProvider({ basePath, children, navigate, }: RouteProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function RouteProvider({ basePath, children, Link, navigate, }: RouteProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,12 @@
1
1
  "use client";
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
3
  import { useGlobalState } from '../providers/global-state-provider.js';
4
+ import { withRouting } from './with-routing.js';
4
5
 
5
- function RouteProvider({ basePath, children, navigate, }) {
6
- useGlobalState('routing', { basePath, navigate });
6
+ function RouteProvider({ basePath, children, Link = FallbackRouteLink, navigate, }) {
7
+ useGlobalState('routing', { Link, basePath, navigate });
7
8
  return jsx(Fragment, { children: children });
8
9
  }
10
+ const FallbackRouteLink = withRouting('a');
9
11
 
10
12
  export { RouteProvider };
@@ -0,0 +1,4 @@
1
+ export declare function buildHref({ basePath, href, }: {
2
+ basePath?: string;
3
+ href: string;
4
+ }): string;
@@ -0,0 +1,8 @@
1
+ function buildHref({ basePath, href, }) {
2
+ if (basePath && href.startsWith('/') && !href.startsWith(`/${basePath}`)) {
3
+ return `/${basePath}${href}`;
4
+ }
5
+ return href;
6
+ }
7
+
8
+ export { buildHref };
@@ -1,10 +1,17 @@
1
+ import { ElementType } from 'react';
1
2
  export interface RouteContext {
3
+ Link?: ElementType<RouteLinkElementProps>;
2
4
  basePath?: string;
3
5
  navigate: NavigateFunction;
4
6
  }
7
+ export interface RouteLinkElementProps extends React.HTMLProps<HTMLAnchorElement> {
8
+ href: string;
9
+ route?: NavigateOptions;
10
+ }
5
11
  export interface NavigateOptions {
6
12
  prefetch?: boolean;
7
13
  reload?: boolean;
8
14
  replace?: boolean;
15
+ scroll?: boolean;
9
16
  }
10
17
  export type NavigateFunction = (href: string, options?: NavigateOptions) => void;
@@ -0,0 +1 @@
1
+ export declare function useRouteLinkElement(): React.ElementType<import("./types").RouteLinkElementProps> | undefined;
@@ -0,0 +1,11 @@
1
+ import { useGlobalState } from '../providers/global-state-provider.js';
2
+
3
+ function useRouteLinkElement() {
4
+ const [state] = useGlobalState('routing');
5
+ if (!state) {
6
+ throw new Error('RouteProvider not found');
7
+ }
8
+ return state.Link;
9
+ }
10
+
11
+ export { useRouteLinkElement };
@@ -1,10 +1,7 @@
1
- import { ComponentProps, ComponentType, MouseEventHandler } from 'react';
2
- import { NavigateOptions } from './types';
1
+ import { ElementType } from 'react';
2
+ import { NavigateOptions, RouteLinkElementProps } from './types';
3
3
  export interface WithRoutingProps {
4
4
  href?: string;
5
5
  route?: NavigateOptions;
6
6
  }
7
- export declare function withRouting<TComponent extends ComponentType<TProps>, TProps extends {
8
- children: React.ReactNode;
9
- onClick?: MouseEventHandler<TElement> | undefined;
10
- }, TElement extends HTMLElement>(component: TComponent): React.ForwardRefExoticComponent<React.PropsWithoutRef<ComponentProps<TComponent> & WithRoutingProps> & React.RefAttributes<HTMLElement>>;
7
+ export declare function withRouting(component: ElementType<RouteLinkElementProps>): React.FunctionComponent<RouteLinkElementProps>;
@@ -1,9 +1,9 @@
1
- import { forwardRef, createElement } from 'react';
1
+ import { 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 = forwardRef(({ href, onClick, route, ...rest }, ref) => {
6
+ const Component = ({ href, onClick, route, ...rest }) => {
7
7
  const { navigate } = useNavigate();
8
8
  const basePath = useBasePath();
9
9
  if (basePath &&
@@ -15,7 +15,7 @@ function withRouting(component) {
15
15
  const props = {
16
16
  ...rest,
17
17
  href,
18
- onClick(e) {
18
+ onClick: (e) => {
19
19
  onClick?.(e);
20
20
  if (!href)
21
21
  return;
@@ -28,11 +28,11 @@ function withRouting(component) {
28
28
  }
29
29
  return navigate(href, route);
30
30
  },
31
- ref,
31
+ route,
32
32
  };
33
33
  return createElement(component, props);
34
- });
35
- Component.displayName = `WithRouting(${component.displayName || component.name})`;
34
+ };
35
+ Component.displayName = `WithRouting(${component.toString()})`;
36
36
  return Component;
37
37
  }
38
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))