@sonic-equipment/ui 164.0.0 → 166.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.
- package/dist/algolia/algolia-categories-filters.js +9 -7
- package/dist/background-overlay/background-overlay-manager.d.ts +178 -0
- package/dist/background-overlay/background-overlay-manager.js +291 -0
- package/dist/background-overlay/background-overlay.d.ts +12 -2
- package/dist/background-overlay/background-overlay.js +28 -27
- package/dist/badges/badge/badge.d.ts +2 -1
- package/dist/badges/badge/badge.js +2 -2
- package/dist/badges/badge/icon-with-badge/icon-with-badge.d.ts +2 -1
- package/dist/badges/badge/icon-with-badge/icon-with-badge.js +2 -2
- package/dist/cards/orderline-card/orderline-card.js +5 -1
- package/dist/cards/product-card/product-card.js +5 -1
- package/dist/collapsables/cascading-component/cascading-component.d.ts +6 -2
- package/dist/collapsables/cascading-component/cascading-component.js +5 -5
- package/dist/collapsables/unmounter/unmounter.js +2 -2
- package/dist/drawer/drawer.d.ts +26 -0
- package/dist/drawer/drawer.js +37 -0
- package/dist/drawer/drawer.module.css.js +3 -0
- package/dist/drawer/use-drawer.d.ts +17 -0
- package/dist/drawer/use-drawer.js +71 -0
- package/dist/exports.d.ts +12 -0
- package/dist/global-search/global-search-provider/global-search-provider.js +1 -2
- package/dist/global-search/global-search.module.css.js +1 -1
- package/dist/header/cart-icon/connected-cart-icon.js +4 -4
- package/dist/icons/solid/solid-login-icon.js +7 -0
- package/dist/index.js +12 -0
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/layout/center.d.ts +5 -0
- package/dist/layout/center.js +9 -0
- package/dist/layout/center.module.css.js +3 -0
- package/dist/lists/menu-list/menu-list.d.ts +4 -2
- package/dist/lists/menu-list/menu-list.js +2 -2
- package/dist/lists/menu-list/menu-list.module.css.js +1 -1
- package/dist/lists/orderline-list/orderline-list.js +1 -2
- package/dist/navigation/account-icon/account-icon.d.ts +5 -0
- package/dist/navigation/account-icon/account-icon.js +12 -0
- package/dist/navigation/cart-icon/cart-icon.d.ts +5 -0
- package/dist/navigation/cart-icon/cart-icon.js +12 -0
- package/dist/navigation/favorite-icon/favorite-icon.d.ts +5 -0
- package/dist/navigation/favorite-icon/favorite-icon.js +12 -0
- package/dist/navigation/mobile-navigation/mobile-navigation.d.ts +5 -0
- package/dist/navigation/mobile-navigation/mobile-navigation.js +20 -0
- package/dist/navigation/panel-navigation/panel-navigation.d.ts +28 -0
- package/dist/navigation/panel-navigation/panel-navigation.js +69 -0
- package/dist/navigation/panel-navigation/panel-navigation.module.css.js +3 -0
- package/dist/pages/checkout/payment-page/components/payment.js +1 -1
- package/dist/pages/paths.d.ts +1 -0
- package/dist/pages/paths.js +1 -0
- package/dist/shared/hooks/use-global-disclosure.d.ts +10 -0
- package/dist/shared/hooks/use-global-disclosure.js +25 -0
- package/dist/shared/hooks/use-watch-css-property.d.ts +1 -1
- package/dist/shared/hooks/use-watch-css-property.js +2 -3
- package/dist/shared/model/category.d.ts +5 -0
- package/dist/shared/model/category.js +7 -1
- package/dist/shared/model/price.d.ts +2 -2
- package/dist/shared/utils/css.d.ts +1 -0
- package/dist/shared/utils/css.js +15 -0
- package/dist/shared/utils/refs.d.ts +2 -0
- package/dist/shared/utils/refs.js +14 -0
- package/dist/sidebar/sidebar-provider.js +1 -1
- package/dist/styles.css +264 -67
- package/package.json +1 -1
- package/dist/background-overlay/background-overlay.module.css.js +0 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
3
|
+
import { MenuList } from '../../lists/menu-list/menu-list.js';
|
|
4
|
+
import { MenuListItem } from '../../lists/menu-list/menu-list-item.js';
|
|
5
|
+
import { PATHS } from '../../pages/paths.js';
|
|
6
|
+
import { useFetchSession } from '../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
|
|
7
|
+
import { useFetchCurrentCartCount } from '../../shared/api/storefront/hooks/cart/use-fetch-current-cart-count.js';
|
|
8
|
+
import { AccountIcon } from '../account-icon/account-icon.js';
|
|
9
|
+
import { CartIcon } from '../cart-icon/cart-icon.js';
|
|
10
|
+
import { FavoriteIcon } from '../favorite-icon/favorite-icon.js';
|
|
11
|
+
import { PanelNavigation } from '../panel-navigation/panel-navigation.js';
|
|
12
|
+
|
|
13
|
+
function MobileNavigation({ links }) {
|
|
14
|
+
const t = useFormattedMessage();
|
|
15
|
+
const { data: { isAuthenticated } = {} } = useFetchSession();
|
|
16
|
+
const cartCount = useFetchCurrentCartCount();
|
|
17
|
+
return (jsx(PanelNavigation, { allowBack: true, isNarrow: true, links: links, variant: "primary", children: jsxs(MenuList, { header: t('My Sonic'), scrollable: false, children: [jsx(MenuListItem, { badge: jsx(AccountIcon, { isAuthenticated: isAuthenticated }), href: PATHS.ACCOUNT, children: isAuthenticated ? t('My account') : t('Sign in or create account') }), jsx(MenuListItem, { badge: jsx(FavoriteIcon, {}), href: PATHS.FAVORITES, children: t('Favorites') }), jsx(MenuListItem, { badge: jsx(CartIcon, { count: cartCount }), href: PATHS.CART, children: t('Shopping cart') })] }) }));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { MobileNavigation };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ImageType } from '../../shared/model/image';
|
|
3
|
+
import { NavigationLink } from '../../shared/model/link';
|
|
4
|
+
interface NavigationMenuLinkBase extends Omit<NavigationLink, 'external' | 'openInNewTab' | 'type' | 'url' | 'links'> {
|
|
5
|
+
image?: ImageType;
|
|
6
|
+
}
|
|
7
|
+
interface MenuListItemWithChildrenProps {
|
|
8
|
+
links: NavigationMenuLink[];
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
interface MenuListItemWithoutChildrenProps {
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
export type NavigationMenuLink = NavigationMenuLinkBase & (MenuListItemWithChildrenProps | MenuListItemWithoutChildrenProps);
|
|
15
|
+
export interface PanelNavigationProps {
|
|
16
|
+
allowBack?: boolean;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
header?: string | {
|
|
20
|
+
href: string;
|
|
21
|
+
title: string;
|
|
22
|
+
};
|
|
23
|
+
isNarrow?: boolean;
|
|
24
|
+
links?: NavigationMenuLink[];
|
|
25
|
+
variant?: 'primary';
|
|
26
|
+
}
|
|
27
|
+
export declare function PanelNavigation({ allowBack, children, className, header, isNarrow, links, variant, }: PanelNavigationProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useRef, useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { CascadingComponent } from '../../collapsables/cascading-component/cascading-component.js';
|
|
5
|
+
import { CascadingComponentContainer } from '../../collapsables/cascading-component/cascading-component-container.js';
|
|
6
|
+
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
7
|
+
import { MenuList } from '../../lists/menu-list/menu-list.js';
|
|
8
|
+
import { MenuListItem } from '../../lists/menu-list/menu-list-item.js';
|
|
9
|
+
import { multiRef } from '../../shared/utils/refs.js';
|
|
10
|
+
import styles from './panel-navigation.module.css.js';
|
|
11
|
+
|
|
12
|
+
const focusableSelectors = [
|
|
13
|
+
'a[href]',
|
|
14
|
+
'button:not([disabled])',
|
|
15
|
+
'textarea:not([disabled])',
|
|
16
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
17
|
+
'select:not([disabled])',
|
|
18
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
19
|
+
].join(',');
|
|
20
|
+
const NavigationMenu = forwardRef(({ allowBack, back, children, className, header, id, isNarrow, links, scrollable, variant, }, ref) => {
|
|
21
|
+
const menuRef = useRef();
|
|
22
|
+
const submenuRef = useRef(null);
|
|
23
|
+
const [selectedNavigationLink, setSelectedNavigationLink] = useState();
|
|
24
|
+
const [selectedNavigationVisible, setSelectedNavigationVisible] = useState(false);
|
|
25
|
+
const onUnmounted = useCallback(() => {
|
|
26
|
+
setSelectedNavigationLink(undefined);
|
|
27
|
+
}, []);
|
|
28
|
+
const onFocus = useCallback((ref) => () => {
|
|
29
|
+
if (!ref.current)
|
|
30
|
+
return;
|
|
31
|
+
const focusable = ref.current.querySelector(focusableSelectors);
|
|
32
|
+
focusable?.focus();
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
36
|
+
setSelectedNavigationVisible(Boolean(selectedNavigationLink));
|
|
37
|
+
}, [selectedNavigationLink]);
|
|
38
|
+
const t = useFormattedMessage();
|
|
39
|
+
return (jsxs(Fragment, { children: [jsxs("div", { ref: multiRef(ref, menuRef), className: clsx(styles['panel'], isNarrow && styles['narrow'], className), id: id, children: [jsx(MenuList, { back: back, header: header, scrollable: scrollable, variant: variant, children: links?.map(link => 'links' in link ? (jsx(MenuListItem, { hasChildren: true, "aria-controls": `menu-${link.key}`, image: link.image, isSelected: selectedNavigationLink?.key === link.key, onClick: () => setSelectedNavigationLink(selectedNavigationLink?.key === link.key
|
|
40
|
+
? undefined
|
|
41
|
+
: link), children: link.title }, link.key)) : (jsx(MenuListItem, { href: link.url, image: link.image, children: link.title }, link.key))) }), children] }), jsx(CascadingComponent, { isVisible: selectedNavigationVisible, nodeRef: submenuRef, onEntered: onFocus(submenuRef), onExited: onFocus(menuRef), onUnmounted: onUnmounted, children: jsx(NavigationMenu, { ref: submenuRef, allowBack: allowBack, back: allowBack
|
|
42
|
+
? {
|
|
43
|
+
onClick: () => {
|
|
44
|
+
setSelectedNavigationVisible(false);
|
|
45
|
+
},
|
|
46
|
+
title: header
|
|
47
|
+
? typeof header === 'string'
|
|
48
|
+
? header
|
|
49
|
+
: header.title
|
|
50
|
+
: t('Main menu'),
|
|
51
|
+
}
|
|
52
|
+
: undefined, header: selectedNavigationLink?.url
|
|
53
|
+
? {
|
|
54
|
+
href: selectedNavigationLink.url,
|
|
55
|
+
title: selectedNavigationLink.title,
|
|
56
|
+
}
|
|
57
|
+
: selectedNavigationLink?.title, id: selectedNavigationLink?.key
|
|
58
|
+
? `menu-${selectedNavigationLink.key}`
|
|
59
|
+
: undefined, isNarrow: isNarrow, links: selectedNavigationLink && 'links' in selectedNavigationLink
|
|
60
|
+
? selectedNavigationLink.links
|
|
61
|
+
: [] }, selectedNavigationLink?.key) })] }));
|
|
62
|
+
});
|
|
63
|
+
NavigationMenu.displayName = 'NavigationMenu';
|
|
64
|
+
function PanelNavigation({ allowBack, children, className, header, isNarrow, links, variant, }) {
|
|
65
|
+
const t = useFormattedMessage();
|
|
66
|
+
return (jsx("section", { "aria-label": t('Navigation'), className: clsx(styles['panel-navigation'], className), children: jsx(CascadingComponentContainer, { children: jsx("div", { className: clsx(styles['panels'], isNarrow && styles['narrow']), children: jsx(NavigationMenu, { allowBack: allowBack, className: children ? styles['top-panel'] : undefined, header: header, id: "panel-navigation-first-level", isNarrow: isNarrow, links: links, scrollable: children ? false : undefined, variant: variant, children: children }) }) }) }));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { PanelNavigation };
|
|
@@ -304,7 +304,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
|
|
|
304
304
|
setAsSoonAsPossible(checked);
|
|
305
305
|
if (checked)
|
|
306
306
|
setDeliveryDate('');
|
|
307
|
-
}, children: t('As soon as possible') }), jsx(InfoIconTooltip, { variant: "stroke", children: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry, isDisabled: isDisabled, label: t('Industry'), name: "industry", options: {
|
|
307
|
+
}, children: t('As soon as possible') }), jsx(InfoIconTooltip, { variant: "stroke", children: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, showLabel: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry, isDisabled: isDisabled, label: t('Industry'), name: "industry", options: {
|
|
308
308
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
309
309
|
PP: t('industry.PP'),
|
|
310
310
|
AU: t('industry.AU'),
|
package/dist/pages/paths.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const PATHS: {
|
|
|
5
5
|
readonly CART: "/Cart";
|
|
6
6
|
readonly CHECKOUT_SHIPPING: "/CheckoutShipping";
|
|
7
7
|
readonly CHECKOUT_SHIPPING_VIA_SIGNIN: "/SignIn?returnUrl=/CheckoutShipping";
|
|
8
|
+
readonly FAVORITES: "/MyAccount/MyLists";
|
|
8
9
|
readonly HOME: "/";
|
|
9
10
|
readonly ORDER_CONFIRMATION: "/OrderConfirmation";
|
|
10
11
|
readonly REVIEW_AND_SUBMIT: "/CheckoutReviewAndSubmit";
|
package/dist/pages/paths.js
CHANGED
|
@@ -5,6 +5,7 @@ const PATHS = {
|
|
|
5
5
|
CART: '/Cart',
|
|
6
6
|
CHECKOUT_SHIPPING: '/CheckoutShipping',
|
|
7
7
|
CHECKOUT_SHIPPING_VIA_SIGNIN: '/SignIn?returnUrl=/CheckoutShipping',
|
|
8
|
+
FAVORITES: '/MyAccount/MyLists',
|
|
8
9
|
HOME: '/',
|
|
9
10
|
ORDER_CONFIRMATION: '/OrderConfirmation',
|
|
10
11
|
REVIEW_AND_SUBMIT: '/CheckoutReviewAndSubmit',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface UseDisclosureReturnType {
|
|
2
|
+
close: VoidFunction;
|
|
3
|
+
isClosed: boolean;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
open: VoidFunction;
|
|
6
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
7
|
+
toggle: VoidFunction;
|
|
8
|
+
}
|
|
9
|
+
export declare const useGlobalDisclosure: (key: string, isInitialOpen?: boolean) => UseDisclosureReturnType;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useGlobalState } from '../providers/global-state-provider.js';
|
|
3
|
+
|
|
4
|
+
const useGlobalDisclosure = (key, isInitialOpen = false) => {
|
|
5
|
+
const [isOpen, setIsOpen] = useGlobalState(key, isInitialOpen);
|
|
6
|
+
const open = useCallback(() => {
|
|
7
|
+
setIsOpen(true);
|
|
8
|
+
}, [setIsOpen]);
|
|
9
|
+
const close = useCallback(() => {
|
|
10
|
+
setIsOpen(false);
|
|
11
|
+
}, [setIsOpen]);
|
|
12
|
+
const toggle = useCallback(() => {
|
|
13
|
+
setIsOpen(prevIsOpen => !prevIsOpen);
|
|
14
|
+
}, [setIsOpen]);
|
|
15
|
+
return {
|
|
16
|
+
close,
|
|
17
|
+
isClosed: !isOpen,
|
|
18
|
+
isOpen,
|
|
19
|
+
open,
|
|
20
|
+
setIsOpen,
|
|
21
|
+
toggle,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { useGlobalDisclosure };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useWatchCssProperty(property: string): string | undefined;
|
|
1
|
+
export declare function useWatchCssProperty(property: string): string | number | undefined;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { getCssPropertyValue } from '../utils/css.js';
|
|
2
3
|
|
|
3
4
|
function useWatchCssProperty(property) {
|
|
4
|
-
const [value, setValue] = useState(
|
|
5
|
-
? getComputedStyle?.(document.body).getPropertyValue(property)
|
|
6
|
-
: undefined);
|
|
5
|
+
const [value, setValue] = useState(() => getCssPropertyValue(property));
|
|
7
6
|
useEffect(() => {
|
|
8
7
|
if (typeof MutationObserver === 'undefined' ||
|
|
9
8
|
typeof document === 'undefined')
|
|
@@ -6,6 +6,7 @@ export interface Category {
|
|
|
6
6
|
title: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function transformAlgoliaCategoryData(categories: RefinementListItem[]): {
|
|
9
|
+
count: number;
|
|
9
10
|
href: string;
|
|
10
11
|
image: {
|
|
11
12
|
1: string;
|
|
@@ -13,6 +14,10 @@ export declare function transformAlgoliaCategoryData(categories: RefinementListI
|
|
|
13
14
|
3: string;
|
|
14
15
|
altText: string;
|
|
15
16
|
} | undefined;
|
|
17
|
+
isRefined: boolean;
|
|
18
|
+
label: string;
|
|
16
19
|
name: string;
|
|
17
20
|
path: string[];
|
|
21
|
+
sortOrder: number;
|
|
22
|
+
value: string;
|
|
18
23
|
}[];
|
|
@@ -3,6 +3,7 @@ function transformAlgoliaCategoryData(categories) {
|
|
|
3
3
|
.map(item => {
|
|
4
4
|
const data = JSON.parse(item.value);
|
|
5
5
|
return {
|
|
6
|
+
count: item.count,
|
|
6
7
|
href: data.href,
|
|
7
8
|
image: data.images.length > 0
|
|
8
9
|
? {
|
|
@@ -15,11 +16,16 @@ function transformAlgoliaCategoryData(categories) {
|
|
|
15
16
|
altText: data.name,
|
|
16
17
|
}
|
|
17
18
|
: undefined,
|
|
19
|
+
isRefined: item.isRefined,
|
|
20
|
+
label: item.label,
|
|
18
21
|
name: data.name,
|
|
19
22
|
path: data.path.split(' > '),
|
|
23
|
+
sortOrder: data.sortOrder,
|
|
24
|
+
value: item.value,
|
|
20
25
|
};
|
|
21
26
|
})
|
|
22
|
-
.sort((a, b) => a.
|
|
27
|
+
.sort((a, b) => (a.sortOrder || 100_000) - (b.sortOrder || 100_000) ||
|
|
28
|
+
a.name.localeCompare(b.name));
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
export { transformAlgoliaCategoryData };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CurrencyCode } from '../../intl/types';
|
|
2
2
|
export interface ProductPriceType {
|
|
3
|
-
currencyCode
|
|
3
|
+
currencyCode?: CurrencyCode;
|
|
4
4
|
isVatIncluded: boolean;
|
|
5
5
|
originalPrice?: number;
|
|
6
6
|
price: number;
|
|
7
7
|
}
|
|
8
8
|
export interface ProductTotalPriceType {
|
|
9
|
-
currencyCode
|
|
9
|
+
currencyCode?: CurrencyCode;
|
|
10
10
|
originalTotalPrice?: number;
|
|
11
11
|
pricePerUnit?: number;
|
|
12
12
|
totalPrice: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCssPropertyValue(property: string): string | number | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function getCssPropertyValue(property) {
|
|
2
|
+
if (typeof document === 'undefined')
|
|
3
|
+
return;
|
|
4
|
+
const rawValue = getComputedStyle?.(document.body).getPropertyValue(property);
|
|
5
|
+
if (!rawValue)
|
|
6
|
+
return undefined;
|
|
7
|
+
if (rawValue && !/\D/.test(rawValue)) {
|
|
8
|
+
const valueAsNumber = Number.parseFloat(rawValue);
|
|
9
|
+
if (!Number.isNaN(valueAsNumber))
|
|
10
|
+
return valueAsNumber;
|
|
11
|
+
}
|
|
12
|
+
return rawValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { getCssPropertyValue };
|
|
@@ -43,7 +43,7 @@ function SidebarProvider({ children }) {
|
|
|
43
43
|
[styles['transition']]: transition,
|
|
44
44
|
[styles['docked']]: isDocked,
|
|
45
45
|
[styles['open']]: isOpen,
|
|
46
|
-
}), children: [jsx(SidebarDetectBreakpoint, {}), children,
|
|
46
|
+
}), children: [jsx(SidebarDetectBreakpoint, {}), children, jsx(BackgroundOverlay, { isOpen: isDocked && isOpen, onClick: close })] }));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export { SidebarDetectBreakpoint, SidebarProvider };
|