@sonic-equipment/ui 138.0.0 → 139.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/collapsables/accordion/accordion-item.d.ts +2 -1
- package/dist/collapsables/accordion/accordion-item.js +2 -2
- package/dist/index.js +1 -1
- package/dist/media/image/image.js +14 -4
- package/dist/modals/dialog/dialog.js +2 -2
- package/dist/pages/checkout/payment-page/components/payment.js +1 -1
- package/dist/shared/ga/google-analytics-provider.d.ts +2 -1
- package/dist/shared/ga/google-analytics-provider.js +9 -8
- package/dist/shared/model/image.d.ts +1 -1
- package/dist/shared/model/image.js +3 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
|
@@ -7,10 +7,11 @@ export interface AccordionItemProps {
|
|
|
7
7
|
borderType?: BorderType | BorderType[];
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
className?: string;
|
|
10
|
+
'data-test-selector'?: string;
|
|
10
11
|
id: string;
|
|
11
12
|
initialIsOpen?: boolean;
|
|
12
13
|
isDisabled?: boolean;
|
|
13
14
|
size?: 'md' | 'lg';
|
|
14
15
|
title: ReactNode;
|
|
15
16
|
}
|
|
16
|
-
export declare function AccordionItem({ _pseudo, allowCollapse, allowToggle, borderType, children, className, id, initialIsOpen, isDisabled, size, title, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function AccordionItem({ _pseudo, allowCollapse, allowToggle, borderType, children, className, 'data-test-selector': dataTestSelector, id, initialIsOpen, isDisabled, size, title, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { useDisclosure } from '../../shared/hooks/use-disclosure.js';
|
|
|
8
8
|
import { ensureArray } from '../../shared/utils/array.js';
|
|
9
9
|
import styles from './accordion.module.css.js';
|
|
10
10
|
|
|
11
|
-
function AccordionItem({ _pseudo = 'none', allowCollapse = true, allowToggle = true, borderType = 'bottom', children, className, id, initialIsOpen = false, isDisabled = false, size, title, }) {
|
|
11
|
+
function AccordionItem({ _pseudo = 'none', allowCollapse = true, allowToggle = true, borderType = 'bottom', children, className, 'data-test-selector': dataTestSelector, id, initialIsOpen = false, isDisabled = false, size, title, }) {
|
|
12
12
|
const { close, isOpen, open, toggle } = useDisclosure(initialIsOpen);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (initialIsOpen) {
|
|
@@ -22,7 +22,7 @@ function AccordionItem({ _pseudo = 'none', allowCollapse = true, allowToggle = t
|
|
|
22
22
|
return (jsxs("div", { className: clsx(className, ...ensureArray(borderType).map(type => styles[`border-type-${type}`]), styles['accordion-item'], isDisabled && styles.disabled, {
|
|
23
23
|
[styles['is-open']]: isOpen,
|
|
24
24
|
[styles['allow-toggle']]: allowToggle,
|
|
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: () => {
|
|
25
|
+
}), "data-test-selector": dataTestSelector, children: [jsx("h3", { children: allowCollapse ? (jsxs("button", { "aria-controls": panelId, "aria-expanded": isOpen, className: clsx(styles.button, styles[_pseudo]), disabled: isDisabled, id: id, onClick: () => {
|
|
26
26
|
if (allowToggle)
|
|
27
27
|
toggle();
|
|
28
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 }) })] }));
|
package/dist/index.js
CHANGED
|
@@ -261,7 +261,7 @@ export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishLi
|
|
|
261
261
|
export { useFeatureFlags } from './shared/feature-flags/use-feature-flags.js';
|
|
262
262
|
export { BadRequestError, ForbiddenRequestError, InternalServerErrorRequestError, NotFoundRequestError, RequestError, TimeoutRequestError, UnauthorizedRequestError, UnprocessableContentRequestError, isFormData, isJsonBody, isRequestError, request } from './shared/fetch/request.js';
|
|
263
263
|
export { dataLayer } from './shared/ga/data-layer.js';
|
|
264
|
-
export { GoogleAnalyticsProvider, useGoogleAnalyticsProvider } from './shared/ga/google-analytics-provider.js';
|
|
264
|
+
export { GoogleAnalyticsProvider, InitializeGoogleAnalyticsProvider, useGoogleAnalyticsProvider } from './shared/ga/google-analytics-provider.js';
|
|
265
265
|
export { isGAEvent } from './shared/ga/types.js';
|
|
266
266
|
export { useDataLayer } from './shared/ga/use-data-layer.js';
|
|
267
267
|
export { useBreakpoint } from './shared/hooks/use-breakpoint.js';
|
|
@@ -34,20 +34,30 @@ function createSrcSet(image) {
|
|
|
34
34
|
.filter(Boolean)
|
|
35
35
|
.join(', ') || undefined);
|
|
36
36
|
}
|
|
37
|
+
function getPrimarySrc(image) {
|
|
38
|
+
if (image === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
if (isResponsiveImage(image)) {
|
|
41
|
+
return (getPrimarySrc(image.sm) ||
|
|
42
|
+
getPrimarySrc(image.md) ||
|
|
43
|
+
getPrimarySrc(image.lg));
|
|
44
|
+
}
|
|
45
|
+
return image[3] || image[2] || image[1];
|
|
46
|
+
}
|
|
37
47
|
function ImageComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
|
|
38
|
-
if (!image)
|
|
48
|
+
if (!image || (!image[1] && !image[2] && !image[3]))
|
|
39
49
|
return (jsx("img", { alt: "Missing", className: clsx(styles.image, className, styles[fit], styles['has-error']), src: fallbackSrc, ...rest }));
|
|
40
50
|
const srcSet = hasError ? undefined : createSrcSet(image);
|
|
41
51
|
return (jsx("img", { alt: image.altText, className: clsx(styles.image, className, styles[fit], {
|
|
42
52
|
[styles['has-error']]: hasError,
|
|
43
|
-
}), src: fallbackSrc, srcSet: srcSet, ...rest }));
|
|
53
|
+
}), src: hasError ? fallbackSrc : getPrimarySrc(image), srcSet: srcSet, ...rest }));
|
|
44
54
|
}
|
|
45
55
|
function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
|
|
46
|
-
if (!image)
|
|
56
|
+
if (!image || (!image.sm && !image.md && !image.lg))
|
|
47
57
|
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 }) }));
|
|
48
58
|
return (jsxs("picture", { className: clsx(styles.picture, className), children: [image.sm && (jsx("source", { media: "(max-width: 768px)", srcSet: createSrcSet(image.sm) })), image.md && (jsx("source", { media: "(max-width: 1439px)", srcSet: createSrcSet(image.md) })), image.lg && (jsx("source", { media: "(min-width: 1440px)", srcSet: createSrcSet(image.lg) })), jsx("img", { alt: image.altText, className: clsx(styles.image, styles[fit], {
|
|
49
59
|
[styles['has-error']]: hasError,
|
|
50
|
-
}), src: fallbackSrc, ...rest })] }));
|
|
60
|
+
}), src: hasError ? fallbackSrc : getPrimarySrc(image), ...rest })] }));
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
export { Image };
|
|
@@ -11,10 +11,10 @@ import { Modal } from '../modal/modal.js';
|
|
|
11
11
|
import styles from './dialog.module.css.js';
|
|
12
12
|
|
|
13
13
|
function Footer({ cancelLabel, close, submitLabel }) {
|
|
14
|
-
return (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, color: "primary", size: "md", type: "submit", children: jsx(FormattedMessage, { id: submitLabel }) }), jsx(Button, { color: "secondary", onClick: close, size: "md", variant: "outline", children: jsx(FormattedMessage, { id: cancelLabel }) })] }));
|
|
14
|
+
return (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, color: "primary", "data-test-selector": "dialogSubmit", size: "md", type: "submit", children: jsx(FormattedMessage, { id: submitLabel }) }), jsx(Button, { color: "secondary", "data-test-selector": "dialogCancel", onClick: close, size: "md", variant: "outline", children: jsx(FormattedMessage, { id: cancelLabel }) })] }));
|
|
15
15
|
}
|
|
16
16
|
function Dialog({ allowClose = true, cancelLabel = 'Close', children, className, footer = Footer, hasCloseButton = true, hideTitle, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, onOpenChange, onSubmit, shouldCloseOnInteractOutside, submitLabel = 'Submit', title, validationErrors, }) {
|
|
17
|
-
return (jsx(Modal, { className: clsx(styles['modal-overlay'], typeof className === 'string' ? className : className?.modal), hasCloseButton: false, isDismissable: isDismissable, isFullScreen: isFullScreen, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, children: jsx(Dialog$1, { "aria-label": title, className: clsx(styles.dialog, typeof className === 'string' ? undefined : className?.dialog), children: ({ close }) => (jsxs(Form, { className: clsx(styles.form, typeof className === 'string' ? undefined : className?.form), onSubmit: e => {
|
|
17
|
+
return (jsx(Modal, { className: clsx(styles['modal-overlay'], typeof className === 'string' ? className : className?.modal), hasCloseButton: false, isDismissable: isDismissable, isFullScreen: isFullScreen, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, children: jsx(Dialog$1, { "aria-label": title, className: clsx(styles.dialog, typeof className === 'string' ? undefined : className?.dialog), "data-test-selector": "dialog", children: ({ close }) => (jsxs(Form, { className: clsx(styles.form, typeof className === 'string' ? undefined : className?.form), onSubmit: e => {
|
|
18
18
|
e.preventDefault();
|
|
19
19
|
e.stopPropagation();
|
|
20
20
|
onSubmit?.(e);
|
|
@@ -273,7 +273,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, isValidatingVAT, onErro
|
|
|
273
273
|
/* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
|
|
274
274
|
typeof window === 'undefined'
|
|
275
275
|
? ''
|
|
276
|
-
: `${window.location.pathname}${window.location.search}` })), Boolean(paymentError) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An error occurred while processing your payment. Please try again." }) })), jsx(InfoDisplay, { id: "shipping-and-invoice-information", label: t('Billing and shipping address'), value: jsx(Accordion, { variant: "select", children: jsx(AccordionItem, { id: "invoice-and-shipping", isDisabled: isDisabled, title:
|
|
276
|
+
: `${window.location.pathname}${window.location.search}` })), Boolean(paymentError) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An error occurred while processing your payment. Please try again." }) })), jsx(InfoDisplay, { id: "shipping-and-invoice-information", label: t('Billing and shipping address'), value: jsx(Accordion, { variant: "select", children: jsx(AccordionItem, { "data-test-selector": "billingAndShippingInformation", id: "invoice-and-shipping", isDisabled: isDisabled, title: t('Billing and shipping information'), children: jsx(BillingAndInvoiceInformation, { billToAddress: {
|
|
277
277
|
address1: cart.billTo?.address1,
|
|
278
278
|
address2: cart.billTo?.address2,
|
|
279
279
|
address3: cart.billTo?.address3,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export declare function useGoogleAnalyticsProvider(): {
|
|
3
3
|
customerNumber: string | undefined;
|
|
4
|
-
|
|
4
|
+
isLoading: boolean;
|
|
5
5
|
};
|
|
6
|
+
export declare function InitializeGoogleAnalyticsProvider(): null;
|
|
6
7
|
export declare function GoogleAnalyticsProvider({ children }?: {
|
|
7
8
|
children?: ReactNode;
|
|
8
9
|
}): JSX.Element | null;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useFetchSession } from '../api/storefront/hooks/authentication/use-fetch-session.js';
|
|
4
4
|
|
|
5
5
|
function useGoogleAnalyticsProvider() {
|
|
6
|
-
const { data: session,
|
|
7
|
-
return { customerNumber: session?.billTo?.customerNumber,
|
|
6
|
+
const { data: session, isLoading } = useFetchSession();
|
|
7
|
+
return { customerNumber: session?.billTo?.customerNumber, isLoading };
|
|
8
|
+
}
|
|
9
|
+
function InitializeGoogleAnalyticsProvider() {
|
|
10
|
+
useGoogleAnalyticsProvider();
|
|
11
|
+
return null;
|
|
8
12
|
}
|
|
9
13
|
function GoogleAnalyticsProvider({ children = null } = { children: null }) {
|
|
10
|
-
|
|
11
|
-
if (isFetching)
|
|
12
|
-
return null;
|
|
13
|
-
return jsx(Fragment, { children: children });
|
|
14
|
+
return (jsxs(Fragment, { children: [jsx(InitializeGoogleAnalyticsProvider, {}), children] }));
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export { GoogleAnalyticsProvider, useGoogleAnalyticsProvider };
|
|
17
|
+
export { GoogleAnalyticsProvider, InitializeGoogleAnalyticsProvider, useGoogleAnalyticsProvider };
|
|
@@ -23,4 +23,4 @@ export interface ResponsiveImageType {
|
|
|
23
23
|
md?: DPRSrcSet;
|
|
24
24
|
sm?: DPRSrcSet;
|
|
25
25
|
}
|
|
26
|
-
export declare function isResponsiveImage(image:
|
|
26
|
+
export declare function isResponsiveImage(image: unknown): image is ResponsiveImageType;
|
package/dist/styles.css
CHANGED
|
@@ -5768,11 +5768,11 @@ button.swiper-pagination-bullet {
|
|
|
5768
5768
|
display: grid;
|
|
5769
5769
|
overflow: clip;
|
|
5770
5770
|
font-family: var(--font-family-sonic);
|
|
5771
|
+
grid-template: minmax(0, min-content) 1fr minmax(0, min-content) / 100%;
|
|
5771
5772
|
grid-template-areas:
|
|
5772
5773
|
'page-header'
|
|
5773
5774
|
'page-main'
|
|
5774
5775
|
'page-footer';
|
|
5775
|
-
grid-template-rows: minmax(0, min-content) 1fr minmax(0, min-content);
|
|
5776
5776
|
}
|
|
5777
5777
|
|
|
5778
5778
|
/* main area, between page header and footer */
|
|
@@ -5782,11 +5782,11 @@ button.swiper-pagination-bullet {
|
|
|
5782
5782
|
box-sizing: border-box;
|
|
5783
5783
|
margin: 0 auto;
|
|
5784
5784
|
grid-area: page-main;
|
|
5785
|
+
grid-template: minmax(0, max-content) minmax(0, max-content) 1fr / 100%;
|
|
5785
5786
|
grid-template-areas:
|
|
5786
5787
|
'breadcrumbs'
|
|
5787
5788
|
'title'
|
|
5788
5789
|
'content';
|
|
5789
|
-
grid-template-rows: minmax(0, max-content) minmax(0, max-content) 1fr;
|
|
5790
5790
|
inline-size: 100%;
|
|
5791
5791
|
max-inline-size: var(--page-container-max-width);
|
|
5792
5792
|
padding-inline: var(--page-container-padding-inline);
|