@sonic-equipment/ui 260.0.6 → 260.0.7

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.
@@ -23,7 +23,10 @@ function OrderLineList({ children, onRemoveAll }) {
23
23
  // eslint-disable-next-line @eslint-react/no-children-map
24
24
  Children.map(children, (child, index) => (
25
25
  // eslint-disable-next-line @eslint-react/no-array-index-key
26
- jsx("li", { className: styles.item, children: child }, index))) })] }), onRemoveAll && (jsx(ConfirmationDialog, { isOpen: isOpen, onCancel: close, onConfirm: onRemoveAll, title: t('Are you sure you want to remove all items from your cart?') }))] }));
26
+ jsx("li", { className: styles.item, children: child }, index))) })] }), onRemoveAll && (jsx(ConfirmationDialog, { isOpen: isOpen, onCancel: close, onConfirm: () => {
27
+ close();
28
+ onRemoveAll();
29
+ }, title: t('Are you sure you want to remove all items from your cart?') }))] }));
27
30
  }
28
31
 
29
32
  export { OrderLineList };
@@ -15,4 +15,4 @@ export interface ModalProps {
15
15
  onOpenChange?: (isOpen: boolean) => void;
16
16
  shouldCloseOnInteractOutside?: boolean;
17
17
  }
18
- export declare function Modal({ children, className, hasCloseButton, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, onOpenChange, shouldCloseOnInteractOutside, }: ModalProps): import("react/jsx-runtime").JSX.Element | undefined;
18
+ export declare function Modal({ children, className, hasCloseButton, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, onOpenChange, shouldCloseOnInteractOutside, }: ModalProps): import("react/jsx-runtime").JSX.Element;
@@ -7,28 +7,9 @@ import { useFormattedMessage } from '../../intl/use-formatted-message.js';
7
7
  import resetStyles from '../../shared/reset.module.css.js';
8
8
  import styles from './modal.module.css.js';
9
9
 
10
- const getDocument = () => typeof window === 'undefined' ? undefined : window.document;
11
10
  function Modal({ children, className, hasCloseButton, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, onOpenChange, shouldCloseOnInteractOutside = true, }) {
12
11
  const t = useFormattedMessage();
13
- const document = getDocument();
14
- if (!document)
15
- return;
16
- return (jsx(ModalOverlay, { ref: ref => {
17
- ref?.addEventListener('click', e => {
18
- if ((!e.target || ref.contains(e.target)) &&
19
- ref !== e.target)
20
- return;
21
- e.preventDefault();
22
- e.stopPropagation();
23
- });
24
- ref?.addEventListener('touchend', e => {
25
- if ((!e.target || ref.contains(e.target)) &&
26
- ref !== e.target)
27
- return;
28
- e.preventDefault();
29
- e.stopPropagation();
30
- });
31
- }, className: clsx(styles['modal-overlay'], resetStyles.reset, typeof className === 'string' ? className : className?.overlay), isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: () => shouldCloseOnInteractOutside, UNSTABLE_portalContainer: document.body, children: jsxs(Modal$1, { className: clsx(styles.modal, {
12
+ return (jsx(ModalOverlay, { className: clsx(styles['modal-overlay'], resetStyles.reset, typeof className === 'string' ? className : className?.overlay), isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: () => shouldCloseOnInteractOutside, children: jsxs(Modal$1, { className: clsx(styles.modal, {
32
13
  [styles['is-full-screen']]: isFullScreen,
33
14
  }, typeof className === 'string' ? undefined : className?.modal), children: [hasCloseButton && (jsx(IconButton, { className: styles.close, icon: "Close", isDisabled: !isDismissable, label: t('Close'), onClick: () => onOpenChange?.(false), theme: "secondary" })), jsx("div", { className: clsx(styles.content, typeof className === 'string' ? className : className?.content), children: children })] }) }));
34
15
  }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef, useState, useEffect, useCallback } from 'react';
3
+ import { useRef, useState, useEffect, useMemo, useCallback } from 'react';
4
4
  import { Form } from 'react-aria-components';
5
5
  import { useAlgoliaInsights } from '../../../../algolia/use-algolia-insights.js';
6
6
  import { Accordion } from '../../../../collapsables/accordion/accordion.js';
@@ -57,16 +57,29 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
57
57
  cartRef.current = _cart;
58
58
  }, [_cart]);
59
59
  const [validationErrors, setValidationErrors] = useState({});
60
- const atpSelectOptions = atp
60
+ const atpSelectOptions = useMemo(() => atp
61
61
  .filter(atp => Boolean(atp.date))
62
62
  .reduce((acc, atp) => ({
63
63
  ...acc,
64
64
  [atp.date || '']: atp.displayDate,
65
- }), {});
66
- const paymentMethodOptions = cart.paymentOptions?.paymentMethods?.reduce((acc, method) => {
65
+ }), {}), [atp]);
66
+ const paymentMethodOptions = useMemo(() => cart.paymentOptions?.paymentMethods?.reduce((acc, method) => {
67
67
  acc[method.name] = t(`paymentMethod.${method.description}`);
68
68
  return acc;
69
- }, {});
69
+ }, {}), [cart.paymentOptions?.paymentMethods, t]);
70
+ const industryOptions = useMemo(() => ({
71
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
72
+ PP: t('industry.PP'),
73
+ AU: t('industry.AU'),
74
+ MC: t('industry.MC'),
75
+ BC: t('industry.BC'),
76
+ TR: t('industry.TR'),
77
+ AG: t('industry.AG'),
78
+ AV: t('industry.AV'),
79
+ MA: t('industry.MA'),
80
+ OT: t('industry.OT'),
81
+ /* eslint-enable sort-keys-fix/sort-keys-fix */
82
+ }), [t]);
70
83
  const onPlaceOrderCompleted = useCallback(({ cart, payment_type }) => {
71
84
  dataLayer.push(createEcommerceEvent({
72
85
  cart,
@@ -231,19 +244,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
231
244
  setAsSoonAsPossible(checked);
232
245
  if (checked)
233
246
  setDeliveryDate('');
234
- }, children: t('As soon as possible') }), jsx(InfoIconTooltip, { size: "sm", 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: {
235
- /* eslint-disable sort-keys-fix/sort-keys-fix */
236
- PP: t('industry.PP'),
237
- AU: t('industry.AU'),
238
- MC: t('industry.MC'),
239
- BC: t('industry.BC'),
240
- TR: t('industry.TR'),
241
- AG: t('industry.AG'),
242
- AV: t('industry.AV'),
243
- MA: t('industry.MA'),
244
- OT: t('industry.OT'),
245
- /* eslint-enable sort-keys-fix/sort-keys-fix */
246
- }, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: isProductionEnvironment ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
247
+ }, children: t('As soon as possible') }), jsx(InfoIconTooltip, { size: "sm", 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 || 'AU', isDisabled: isDisabled, label: t('Industry'), name: "industry", options: industryOptions, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { showLabel: true, defaultValue: cart.customerVatNumber, isDisabled: isDisabled, label: t('VAT Number'), minLength: 8, name: "customerVatNumber" }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: isProductionEnvironment ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
247
248
  /* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
248
249
  typeof window === 'undefined'
249
250
  ? ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "260.0.6",
3
+ "version": "260.0.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {