@sonic-equipment/ui 0.0.76 → 0.0.77

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/index.d.ts CHANGED
@@ -4213,7 +4213,7 @@ interface ImageSource {
4213
4213
  fallbackSrc?: string
4214
4214
  fit?: 'contain' | 'cover'
4215
4215
  height?: number
4216
- image: Image$1 | ResponsiveImage
4216
+ image: Image$1 | ResponsiveImage | undefined
4217
4217
  loading?: 'lazy' | 'eager'
4218
4218
  onError?: () => void
4219
4219
  title: string
@@ -4542,7 +4542,17 @@ interface ProgressCircleProps {
4542
4542
  }
4543
4543
  declare function ProgressCircle({ className }: ProgressCircleProps): react_jsx_runtime.JSX.Element;
4544
4544
 
4545
- type ImageProps = ImageSource;
4545
+ interface ImageProps {
4546
+ className?: string;
4547
+ fallbackSrc?: string;
4548
+ fit?: 'contain' | 'cover';
4549
+ height?: number;
4550
+ image: Image$1 | ResponsiveImage | undefined;
4551
+ loading?: 'lazy' | 'eager';
4552
+ onError?: () => void;
4553
+ title: string;
4554
+ width?: number;
4555
+ }
4546
4556
  declare function Image({ className, fallbackSrc, fit, height, image, loading, title, width, }: ImageProps): react_jsx_runtime.JSX.Element;
4547
4557
 
4548
4558
  declare function PageContainer({ children, className, }: {
package/dist/index.js CHANGED
@@ -1597,7 +1597,7 @@ function ProductSku({ sku }) {
1597
1597
  }
1598
1598
 
1599
1599
  function isResponsiveImage(image) {
1600
- return Boolean(image.lg);
1600
+ return Boolean(image?.lg);
1601
1601
  }
1602
1602
 
1603
1603
  var styles$K = {"image":"image-module-lg7Kj","contain":"image-module-KFEgG","cover":"image-module-tVKFe","has-error":"image-module-LM93B","picture":"image-module-pNYjR"};
@@ -1612,18 +1612,19 @@ function Image({ className, fallbackSrc = 'https://res.cloudinary.com/dkz9eknwh/
1612
1612
  fallbackSrc,
1613
1613
  fit,
1614
1614
  height,
1615
- image,
1616
1615
  loading,
1617
1616
  onError: handleError,
1618
1617
  title,
1619
1618
  width,
1620
1619
  };
1621
1620
  if (isResponsiveImage(image)) {
1622
- return jsx(PictureComponent, { ...props, hasError: hasError });
1621
+ return jsx(PictureComponent, { ...props, hasError: hasError, image: image });
1623
1622
  }
1624
- return jsx(ImageComponent, { ...props, hasError: hasError });
1623
+ return jsx(ImageComponent, { ...props, hasError: hasError, image: image });
1625
1624
  }
1626
1625
  function ImageComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
1626
+ if (!image)
1627
+ return (jsx("img", { className: clsx(styles$K.image, className, styles$K[fit], styles$K['has-error']), src: fallbackSrc, ...rest }));
1627
1628
  const srcSet = !hasError
1628
1629
  ? `${image[1]} 1x, ${image[2]} 2x, ${image[3]} 3x`
1629
1630
  : undefined;
@@ -1632,8 +1633,8 @@ function ImageComponent({ className, fallbackSrc, fit = 'cover', hasError, image
1632
1633
  }), src: !hasError ? image[3] : fallbackSrc, srcSet: srcSet, ...rest }));
1633
1634
  }
1634
1635
  function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, image, ...rest }) {
1635
- if (!isResponsiveImage(image))
1636
- return null;
1636
+ if (!image)
1637
+ return (jsx("picture", { className: clsx(styles$K.picture, className), children: jsx("img", { className: clsx(styles$K[fit], styles$K['has-error']), src: fallbackSrc, ...rest }) }));
1637
1638
  return (jsxs("picture", { className: clsx(styles$K.picture, className), children: [jsx("source", { media: "(max-width: 768px)", srcSet: `${image.sm[1]} 1x, ${image.sm[2]} 2x, ${image.sm[3]} 3x` }), jsx("source", { media: "(max-width: 1439px)", srcSet: `${image.md[1]} 1x, ${image.md[2]} 2x, ${image.md[3]} 3x` }), jsx("source", { media: "(min-width: 1440px)", srcSet: `${image.lg[1]} 1x, ${image.lg[2]} 2x, ${image.lg[3]} 3x` }), jsx("img", { className: clsx(styles$K[fit], {
1638
1639
  [styles$K['has-error']]: hasError,
1639
1640
  }), src: !hasError ? image.lg[3] : fallbackSrc, ...rest })] }));
@@ -7604,12 +7605,12 @@ function ProductDetailsPage({ pageUrl }) {
7604
7605
  Boolean(included.length) && (jsxs(Fragment, { children: [jsx(Heading, { size: "s", tag: "h2", children: jsx(FormattedMessage, { id: "Includes" }) }), jsx(ProductCarousel, { allowExpandToGrid: true, hasOverflow: true, productCards: included.map(product => (jsx(ConnectedProductCard, { href: product.href, image: {
7605
7606
  fit: 'contain',
7606
7607
  image: product.image,
7607
- title: product.image.altText,
7608
+ title: product.image?.altText || product.title,
7608
7609
  }, price: product.price, productId: product.productId, sku: product.sku, tags: product.tags, title: product.title }, product.storefrontId))) })] })), productInformation: jsx(ProductDetailsPanel, { product: product }), recentlyViewed: recentlyViewed !== undefined &&
7609
7610
  Boolean(recentlyViewed.length) && (jsxs(Fragment, { children: [jsx(Heading, { size: "s", tag: "h2", children: jsx(FormattedMessage, { id: "Recently viewed" }) }), jsx(ProductCarousel, { hasOverflow: true, productCards: recentlyViewed.map(product => (jsx(ConnectedProductCard, { href: product.href, image: {
7610
7611
  fit: 'contain',
7611
7612
  image: product.image,
7612
- title: product.image.altText,
7613
+ title: product.image?.altText || product.title,
7613
7614
  }, price: product.price, productId: product.productId, sku: product.sku, tags: product.tags, title: product.title }, product.storefrontId))) })] })), usp: jsx("div", { style: {
7614
7615
  backgroundColor: '#bcbcbc',
7615
7616
  display: 'grid',
@@ -1,4 +1,14 @@
1
- import { type ImageSource } from 'shared/model/image';
2
- type ImageProps = ImageSource;
1
+ import { type Image as ImageType, ResponsiveImage } from 'shared/model/image';
2
+ interface ImageProps {
3
+ className?: string;
4
+ fallbackSrc?: string;
5
+ fit?: 'contain' | 'cover';
6
+ height?: number;
7
+ image: ImageType | ResponsiveImage | undefined;
8
+ loading?: 'lazy' | 'eager';
9
+ onError?: () => void;
10
+ title: string;
11
+ width?: number;
12
+ }
3
13
  export declare function Image({ className, fallbackSrc, fit, height, image, loading, title, width, }: ImageProps): import("react/jsx-runtime").JSX.Element;
4
14
  export {};
@@ -58,7 +58,7 @@ interface ProductPrice {
58
58
  }
59
59
  interface ProductSummary {
60
60
  href: string;
61
- image: Image;
61
+ image: Image | undefined;
62
62
  price: ProductPrice;
63
63
  productId: string;
64
64
  sku: string;
@@ -11,7 +11,7 @@ export interface ImageSource {
11
11
  fallbackSrc?: string;
12
12
  fit?: 'contain' | 'cover';
13
13
  height?: number;
14
- image: Image | ResponsiveImage;
14
+ image: Image | ResponsiveImage | undefined;
15
15
  loading?: 'lazy' | 'eager';
16
16
  onError?: () => void;
17
17
  title: string;
@@ -23,5 +23,5 @@ export interface ResponsiveImage {
23
23
  md: DPRSrcSet;
24
24
  sm: DPRSrcSet;
25
25
  }
26
- export declare function isResponsiveImage(image: Image | ResponsiveImage): image is ResponsiveImage;
26
+ export declare function isResponsiveImage(image: Image | ResponsiveImage | undefined): image is ResponsiveImage;
27
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {