@sonic-equipment/ui 150.0.0 → 152.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.
@@ -32,7 +32,7 @@ function InternalAddToCartButton({ initialState = 'initial', isDisabled = false,
32
32
  _onChange(quantity);
33
33
  setQuantity(quantity);
34
34
  }, [_onChange]);
35
- return (jsxs("div", { "data-test-selector": "addToCartButton", children: [currentState === 'initial' && (jsx(InitialState, { isDisabled: isDisabled, onAddToCart: () => onChange(1) })), currentState === 'spinner' && (jsx(SpinnerState, { isDisabled: isDisabled, onChange: onChange, onManualInput: value => {
35
+ return (jsxs("div", { className: styles['add-to-cart-button'], "data-test-selector": "addToCartButton", children: [currentState === 'initial' && (jsx(InitialState, { isDisabled: isDisabled, onAddToCart: () => onChange(1) })), currentState === 'spinner' && (jsx(SpinnerState, { isDisabled: isDisabled, onChange: onChange, onManualInput: value => {
36
36
  setManualInputQuantity(value);
37
37
  setState('manual-input');
38
38
  }, quantity: quantity }, quantity)), currentState === 'manual-input' && (jsx(ManualInputState, { isDisabled: isDisabled, onCancel: () => setState('spinner'), onConfirm: onChange, quantity: manualInputQuantity || '' }))] }));
@@ -78,18 +78,18 @@ function ManualInputState({ isDisabled, onCancel, onConfirm, quantity, }) {
78
78
  const [updatedQuantity, setQuantity] = useState(quantity);
79
79
  const onKeyUp = (e) => {
80
80
  if (e.key === 'Enter')
81
- onConfirm(ensureNumber(updatedQuantity));
81
+ onConfirm(ensureNumber(updatedQuantity, 0));
82
82
  if (e.key === 'Escape')
83
83
  onCancel();
84
84
  };
85
- return (jsxs("div", { className: styles['manual-input-container'], children: [jsx("div", { className: styles['left-button-spacer'] }), jsx(NumberField, { autoFocus: true, autoGrow: true, "data-test-selector": "quantity", defaultValue: quantity ? ensureNumber(quantity) : undefined, formatOptions: {
85
+ return (jsxs("div", { className: styles['manual-input-container'], children: [jsx("div", { className: styles['left-button-spacer'] }), jsx(NumberField, { autoFocus: true, autoGrow: true, "data-test-selector": "quantity", defaultValue: quantity ? ensureNumber(quantity, 0) : undefined, formatOptions: {
86
86
  maximumFractionDigits: 0,
87
87
  style: 'decimal',
88
88
  useGrouping: false,
89
89
  }, isDisabled: isDisabled, label: "Quantity", maxLength: 4, maxValue: 9999, minValue: 0, name: "quantity", onChange: value => setQuantity(String(value)), onKeyUp: onKeyUp, showLabel: false, size: "md" }), jsx(Button, { condensed: true, "data-test-selector": "confirm", isDisabled: isDisabled, onClick: e => {
90
90
  e.preventDefault();
91
91
  e.stopPropagation();
92
- onConfirm(ensureNumber(updatedQuantity));
92
+ onConfirm(ensureNumber(updatedQuantity, 0));
93
93
  }, size: "md", children: "OK" })] }));
94
94
  }
95
95
 
@@ -1,3 +1,3 @@
1
- var styles = {"manual-input-container":"add-to-cart-button-module-AWFvQ","left-button-spacer":"add-to-cart-button-module-SS7WM"};
1
+ var styles = {"add-to-cart-button":"add-to-cart-button-module-GdrDp","manual-input-container":"add-to-cart-button-module-AWFvQ","left-button-spacer":"add-to-cart-button-module-SS7WM"};
2
2
 
3
3
  export { styles as default };
@@ -12,7 +12,7 @@ import styles from './orderline-card.module.css.js';
12
12
 
13
13
  function OrderLineCard(props) {
14
14
  const { deliveryDate, href, image, isReadonly, price, productId, sku, tags, title, } = props;
15
- return (jsxs(RouteLink, { className: clsx(styles['orderline-card'], isReadonly && styles.readonly), href: href, id: productId, isDisabled: isReadonly, children: [jsx("div", { className: styles['image-container'], role: "presentation", children: jsx(Image, { ...image }) }), jsx(Heading, { className: styles.title, size: "xxxs", tag: "h3", children: title }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(ProductSku, { className: styles.sku, sku: sku }), isReadonly ? (jsx("p", { className: styles.amount, children: jsx(FormattedMessage, { id: "Amount: {0}", replacementValues: { '0': props.quantity.toString() } }) })) : (jsx("div", { className: styles['add-to-cart-button'], children: props.addToCartButton })), jsx(Price, { className: styles.price, currencyCode: price.currencyCode, originalPrice: price.originalTotalPrice, price: price.totalPrice, pricePerUnit: price.pricePerUnit, variant: "sonic" }), deliveryDate && (jsx(DeliveryTime, { className: styles.delivery, deliveryDate: deliveryDate })), !isReadonly && jsx("div", { className: styles.remove, children: props.removeButton })] }));
15
+ return (jsxs(RouteLink, { className: clsx(styles['orderline-card'], isReadonly && styles.readonly), href: href, id: productId, isDisabled: isReadonly, children: [jsx("div", { className: styles['image-container'], role: "presentation", children: jsx(Image, { ...image, fit: "contain" }) }), jsx(Heading, { className: styles.title, size: "xxxs", tag: "h3", children: title }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(ProductSku, { className: styles.sku, sku: sku }), isReadonly ? (jsx("p", { className: styles.amount, children: jsx(FormattedMessage, { id: "Amount: {0}", replacementValues: { '0': props.quantity.toString() } }) })) : (jsx("div", { className: styles['add-to-cart-button'], children: props.addToCartButton })), jsx(Price, { className: styles.price, currencyCode: price.currencyCode, originalPrice: price.originalTotalPrice, price: price.totalPrice, pricePerUnit: price.pricePerUnit, variant: "sonic" }), deliveryDate && (jsx(DeliveryTime, { className: styles.delivery, deliveryDate: deliveryDate })), !isReadonly && jsx("div", { className: styles.remove, children: props.removeButton })] }));
16
16
  }
17
17
 
18
18
  export { OrderLineCard };
@@ -10,7 +10,7 @@ import { Heading } from '../../typography/heading/heading.js';
10
10
  import styles from './product-card.module.css.js';
11
11
 
12
12
  function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, href, id, image, onClick, price, sku, tags, title, }) {
13
- return (jsx("div", { className: styles['product-card-container'], children: jsxs(RouteLink, { className: styles['product-card'], "data-product-id": sku, href: href, id: id, onClick: onClick, children: [jsx("div", { className: styles['image-container'], children: jsx(Image, { ...image }) }), jsx("div", { className: styles['favorite-button'], children: FavoriteButton && FavoriteButton }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(Heading, { className: styles.title, size: "xxxs", tag: "h2", children: title }), jsx(ProductSku, { className: styles.sku, sku: sku }), jsx(Price, { className: styles.price, currencyCode: price.currencyCode, isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price, variant: "sonic" }), jsx("div", { className: styles['add-to-cart-button'], children: AddToCartButton })] }) }));
13
+ return (jsx("div", { className: styles['product-card-container'], children: jsxs(RouteLink, { className: styles['product-card'], "data-product-id": sku, href: href, id: id, onClick: onClick, children: [jsx("div", { className: styles['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsx("div", { className: styles['favorite-button'], children: FavoriteButton && FavoriteButton }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(Heading, { className: styles.title, size: "xxxs", tag: "h2", children: title }), jsx(ProductSku, { className: styles.sku, sku: sku }), jsx(Price, { className: styles.price, currencyCode: price.currencyCode, isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price, variant: "sonic" }), jsx("div", { className: styles['add-to-cart-button'], children: AddToCartButton })] }) }));
14
14
  }
15
15
 
16
16
  export { ProductCard };
@@ -18,6 +18,7 @@ import { useToast } from '../../../toast/use-toast.js';
18
18
  import { useFetchCurrentCartLinesWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-lines-with-atp.js';
19
19
  import { useFetchCurrentCartWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.js';
20
20
  import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
21
+ import { ensureNumber } from '../../../shared/utils/number.js';
21
22
  import { PATHS } from '../../paths.js';
22
23
  import { EmptyCart } from './components/empty-cart-page.js';
23
24
 
@@ -96,7 +97,7 @@ function CartContent({ cartLines }) {
96
97
  title: cartLine.altText,
97
98
  }, isReadonly: false, onRemove: () => deleteCartLine.mutate({ cartLineId: cartLine.id }), orderLineId: cartLine.id, price: {
98
99
  currencyCode,
99
- originalTotalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
100
+ originalTotalPrice: ensureNumber(cartLine.properties.totalListPrice),
100
101
  pricePerUnit: cartLine.pricing?.unitNetPrice || 0,
101
102
  totalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
102
103
  }, productId: cartLine.productId || '', sku: cartLine.erpNumber || '', tags: [], title: cartLine.productName }, cartLine.id))) }) }));
@@ -11,6 +11,7 @@ import { useSaveCartForLater } from '../../../shared/api/storefront/hooks/cart/u
11
11
  import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
12
12
  import { RouteButton } from '../../../shared/routing/route-button.js';
13
13
  import { formatDateToLocaleString } from '../../../shared/utils/date.js';
14
+ import { ensureNumber } from '../../../shared/utils/number.js';
14
15
  import { useToast } from '../../../toast/use-toast.js';
15
16
  import { Page } from '../../components/page/page.js';
16
17
  import { PATHS } from '../../paths.js';
@@ -85,7 +86,7 @@ function OrderConfirmationPageContent({ cart, }) {
85
86
  title: cartLine.altText,
86
87
  }, isReadonly: true, price: {
87
88
  currencyCode,
88
- originalTotalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
89
+ originalTotalPrice: ensureNumber(cartLine.properties.totalListPrice),
89
90
  pricePerUnit: cartLine.pricing?.unitNetPrice || 0,
90
91
  totalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
91
92
  }, productId: cartLine.productId || '', quantity: cartLine.qtyOrdered || 1, sku: cartLine.erpNumber || '', tags: [], title: cartLine.productName }, cartLine.id))) }) }) })] }) }) }));
@@ -7,6 +7,7 @@ import { FormattedMessage } from '../../../intl/formatted-message.js';
7
7
  import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
8
8
  import { OrderLineList } from '../../../lists/orderline-list/orderline-list.js';
9
9
  import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
10
+ import { ensureNumber } from '../../../shared/utils/number.js';
10
11
  import { Page } from '../../components/page/page.js';
11
12
  import { PATHS } from '../../paths.js';
12
13
  import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
@@ -39,7 +40,7 @@ function PaymentPageContent({ atp, cart, formId, hasAtp, isProcessing, isValidat
39
40
  title: cartLine.altText,
40
41
  }, isReadonly: true, price: {
41
42
  currencyCode,
42
- originalTotalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
43
+ originalTotalPrice: ensureNumber(cartLine.properties.totalListPrice),
43
44
  pricePerUnit: cartLine.pricing?.unitNetPrice || 0,
44
45
  totalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
45
46
  }, productId: cartLine.productId || '', quantity: cartLine.qtyOrdered || 1, sku: cartLine.erpNumber || '', tags: [], title: cartLine.productName }, cartLine.id))) }) }) })] }) }));
@@ -861,6 +861,10 @@ export interface CartLineModel extends BaseModel {
861
861
  productName: string;
862
862
  productSubscription: ProductSubscriptionDto | null;
863
863
  productUri: string;
864
+ properties: {
865
+ [key: string]: string;
866
+ totalListPrice: string;
867
+ };
864
868
  qtyLeft: number;
865
869
  qtyOnHand: number;
866
870
  qtyOrdered: number | null;
@@ -257,7 +257,7 @@ const cart = {
257
257
  subscriptionTotalCycles: 0,
258
258
  },
259
259
  productUri: '/Product/4311165-High-leverage-combination-pliers-6',
260
- properties: {},
260
+ properties: { totalListPrice: '30.32' },
261
261
  qtyLeft: 0,
262
262
  qtyOnHand: 0,
263
263
  qtyOrdered: 1,
@@ -1,7 +1,7 @@
1
1
  import { useState, useRef, useEffect } from 'react';
2
2
 
3
3
  function useIntersectionObserver({ isDisabled, observables, onIntersectingChange, }) {
4
- const [isIntersecting, setIntersecting] = useState(false);
4
+ const [isIntersecting, setIntersecting] = useState(true);
5
5
  const state = useRef([]);
6
6
  function disconnectObservers() {
7
7
  state.current.forEach(entry => entry.observer.disconnect());
@@ -1,3 +1,5 @@
1
+ import { ensureNumber } from '../utils/number.js';
2
+
1
3
  function transformAlgoliaPromoHitToPromoHit(algoliaPromoHit) {
2
4
  return {
3
5
  hit: algoliaPromoHit,
@@ -27,9 +29,7 @@ function transformAlgoliaProductHitToProductHit(algoliaProductHit) {
27
29
  name: algoliaProductHit.name,
28
30
  objectId: algoliaProductHit.objectID,
29
31
  originalPrice: algoliaProductHit.originalPrice,
30
- position: Number.isNaN(Number.parseFloat(String(algoliaProductHit.__position)))
31
- ? 0
32
- : Number.parseFloat(String(algoliaProductHit.__position)),
32
+ position: ensureNumber(String(algoliaProductHit.__position), 0),
33
33
  price: algoliaProductHit.price,
34
34
  queryId: algoliaProductHit.__autocomplete_queryID === undefined
35
35
  ? undefined
@@ -1 +1,2 @@
1
- export declare const ensureNumber: (value: unknown, defaultNumber?: number) => number;
1
+ export declare function ensureNumber(value: unknown, defaultNumber: number): number;
2
+ export declare function ensureNumber(value: unknown): number | undefined;
@@ -1,10 +1,10 @@
1
- const ensureNumber = (value, defaultNumber = 0) => {
1
+ function ensureNumber(value, defaultNumber) {
2
2
  if (typeof value === 'number')
3
3
  return value;
4
4
  if (typeof value !== 'string')
5
5
  return defaultNumber;
6
6
  const numberValue = Number.parseFloat(value);
7
7
  return Number.isNaN(numberValue) ? defaultNumber : numberValue;
8
- };
8
+ }
9
9
 
10
10
  export { ensureNumber };
package/dist/styles.css CHANGED
@@ -1710,6 +1710,10 @@
1710
1710
  }
1711
1711
  }
1712
1712
 
1713
+ .add-to-cart-button-module-GdrDp {
1714
+ display: flex;
1715
+ }
1716
+
1713
1717
  .add-to-cart-button-module-AWFvQ {
1714
1718
  display: inline-flex;
1715
1719
  flex-direction: row;
@@ -2896,11 +2900,12 @@
2896
2900
  }
2897
2901
 
2898
2902
  .orderline-card-module-AMTMm .orderline-card-module-TlhUg {
2903
+ display: flex;
2899
2904
  aspect-ratio: 1;
2905
+ block-size: 100%;
2900
2906
  grid-area: image;
2901
2907
  justify-self: center;
2902
- max-block-size: 100%;
2903
- max-inline-size: 100%;
2908
+ place-items: center;
2904
2909
  }
2905
2910
 
2906
2911
  .orderline-card-module-AMTMm .orderline-card-module-ZjAaX {
@@ -2946,6 +2951,11 @@
2946
2951
  'image amount price'
2947
2952
  'image info info'
2948
2953
  }
2954
+
2955
+ .orderline-card-module-AMTMm .orderline-card-module-TlhUg {
2956
+ block-size: auto;
2957
+ inline-size: 100%;
2958
+ }
2949
2959
  }
2950
2960
 
2951
2961
  @container (inline-size >= 700px) {.orderline-card-module-AMTMm {
@@ -3054,15 +3064,16 @@
3054
3064
  }
3055
3065
 
3056
3066
  .product-card-module-pLaiB .product-card-module-65ZVi {
3067
+ display: flex;
3068
+ overflow: hidden;
3057
3069
  aspect-ratio: 1;
3070
+ block-size: 100%;
3058
3071
  grid-area: image;
3059
- justify-self: center;
3060
- max-block-size: 100%;
3061
- max-inline-size: 100%;
3072
+ place-items: center;
3073
+ place-self: center;
3062
3074
  }
3063
3075
 
3064
3076
  .product-card-module-pLaiB .product-card-module-irW0D {
3065
- overflow: hidden;
3066
3077
  grid-area: price;
3067
3078
  margin-block-end: var(--space-8);
3068
3079
  place-self: flex-end flex-end;
@@ -3091,7 +3102,7 @@
3091
3102
  1fr
3092
3103
  )
3093
3104
  minmax(0, min-content)
3094
- / 1fr auto;
3105
+ / 1fr minmax(0, min-content);
3095
3106
  grid-template-areas:
3096
3107
  'image image'
3097
3108
  '. .'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "150.0.0",
3
+ "version": "152.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {