@sonic-equipment/ui 255.0.0 → 257.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/cards/product-card/connected-product-card.d.ts +3 -1
- package/dist/cards/product-card/connected-product-card.js +2 -2
- package/dist/cards/product-card/product-card.d.ts +1 -1
- package/dist/cards/product-card/product-card.js +1 -1
- package/dist/global-search/search-result-panel/sections/with-results.js +3 -1
- package/dist/media/image/image.js +4 -4
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@ import { AddToCartHandler } from '../../buttons/add-to-cart-button/connected-add
|
|
|
2
2
|
import { NavigateOptions } from '../../shared/routing/types';
|
|
3
3
|
import { ProductCardProps } from './product-card';
|
|
4
4
|
export interface ConnectedProductCardProps extends Omit<ProductCardProps, 'addToCartButton' | 'favoriteButton'> {
|
|
5
|
+
addToCartEnabled?: boolean;
|
|
6
|
+
addToFavoritesEnabled?: boolean;
|
|
5
7
|
onAddToCart?: AddToCartHandler;
|
|
6
8
|
onFavorited?: VoidFunction;
|
|
7
9
|
onFavoriting?: VoidFunction;
|
|
8
10
|
route?: NavigateOptions;
|
|
9
11
|
}
|
|
10
|
-
export declare function ConnectedProductCard({ id, onAddToCart, onFavorited, onFavoriting, ...props }: ConnectedProductCardProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function ConnectedProductCard({ addToCartEnabled, addToFavoritesEnabled, id, onAddToCart, onFavorited, onFavoriting, ...props }: ConnectedProductCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,8 +4,8 @@ import { ConnectedAddToCartButton } from '../../buttons/add-to-cart-button/conne
|
|
|
4
4
|
import { ConnectedFavoriteButton } from '../../buttons/favorite/connected-favorite-button.js';
|
|
5
5
|
import { ProductCard } from './product-card.js';
|
|
6
6
|
|
|
7
|
-
function ConnectedProductCard({ id, onAddToCart, onFavorited, onFavoriting, ...props }) {
|
|
8
|
-
return (jsx(ProductCard, { id: id, ...props, addToCartButton: jsx(ConnectedAddToCartButton, { onAddToCart: onAddToCart, productId: id }), favoriteButton: jsx(ConnectedFavoriteButton, { onFavorited: onFavorited, onFavoriting: onFavoriting, productId: id }) }));
|
|
7
|
+
function ConnectedProductCard({ addToCartEnabled = true, addToFavoritesEnabled = true, id, onAddToCart, onFavorited, onFavoriting, ...props }) {
|
|
8
|
+
return (jsx(ProductCard, { id: id, ...props, addToCartButton: addToCartEnabled ? (jsx(ConnectedAddToCartButton, { onAddToCart: onAddToCart, productId: id })) : undefined, favoriteButton: addToFavoritesEnabled ? (jsx(ConnectedFavoriteButton, { onFavorited: onFavorited, onFavoriting: onFavoriting, productId: id })) : undefined }));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export { ConnectedProductCard };
|
|
@@ -3,7 +3,7 @@ import type { ImageSourceType } from '../../shared/model/image';
|
|
|
3
3
|
import type { ProductPriceType } from '../../shared/model/price';
|
|
4
4
|
import { NavigateOptions } from '../../shared/routing/types';
|
|
5
5
|
export interface ProductCardProps {
|
|
6
|
-
addToCartButton
|
|
6
|
+
addToCartButton?: ReactElement;
|
|
7
7
|
favoriteButton?: ReactElement;
|
|
8
8
|
href: string;
|
|
9
9
|
id: string;
|
|
@@ -16,7 +16,7 @@ function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: Favorit
|
|
|
16
16
|
return;
|
|
17
17
|
logger.error(`Product '${sku}' does not have a currency code`);
|
|
18
18
|
}, [price.currencyCode, sku]);
|
|
19
|
-
return (jsx("div", { className: styles['product-card-container'], children: jsxs("article", { "aria-labelledby": `title-${id}`, className: styles['product-card'], "data-product-id": sku, id: id, children: [jsx(Link, { className: styles.title, href: href, id: `title-${id}`, onClick: onClick, route: route, children: title }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { noTranslationId: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(ProductSku, { className: styles.sku, sku: sku }), price.currencyCode && (jsx(Price, { className: styles.price, currencyCode: price.currencyCode, isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price, variant: "sonic" })), jsx("div", { className: styles['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsx("div", { className: styles['add-to-cart-button'], children: AddToCartButton }), jsx("div", { className: styles['favorite-button'], children: FavoriteButton && FavoriteButton })] }) }));
|
|
19
|
+
return (jsx("div", { className: styles['product-card-container'], children: jsxs("article", { "aria-labelledby": `title-${id}`, className: styles['product-card'], "data-product-id": sku, id: id, children: [jsx(Link, { className: styles.title, href: href, id: `title-${id}`, onClick: onClick, route: route, children: title }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { noTranslationId: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(ProductSku, { className: styles.sku, sku: sku }), price.currencyCode && (jsx(Price, { className: styles.price, currencyCode: price.currencyCode, isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price, variant: "sonic" })), jsx("div", { className: styles['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsx("div", { className: styles['add-to-cart-button'], children: AddToCartButton && AddToCartButton }), jsx("div", { className: styles['favorite-button'], children: FavoriteButton && FavoriteButton })] }) }));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export { ProductCard };
|
|
@@ -52,12 +52,14 @@ function SuggestionsSection() {
|
|
|
52
52
|
}), icon: jsx(StrokeSearchIcon, { role: "presentation" }), text: jsxs("span", { children: [jsx("span", { children: item.listCategories.at(-1) }), jsx("span", { children: item.listCategories.slice(0, -1).join(' > ') })] }) }, item.objectID))) }))] }));
|
|
53
53
|
}
|
|
54
54
|
function ProductHitCard({ autocomplete, hit, index, source, }) {
|
|
55
|
+
// TODO: re-enable addToCart and addToFavorites when authentication problems are solved (or we got rid of the split domains)
|
|
56
|
+
// It is just a boolean prop defaulting to true
|
|
55
57
|
const { close } = useGlobalSearchDisclosure();
|
|
56
58
|
const { sendAddToCartFromSearchEvent, sendAddToWishListFromSearchEvent, sendProductClickFromSearchEvent, } = useAlgoliaInsights();
|
|
57
59
|
return (jsx(ConnectedProductCard, { ...autocomplete.getItemProps({
|
|
58
60
|
item: hit.hit,
|
|
59
61
|
source,
|
|
60
|
-
}), href: hit.storefrontSlug, id: hit.storefrontId, image: {
|
|
62
|
+
}), addToCartEnabled: false, addToFavoritesEnabled: false, href: hit.storefrontSlug, id: hit.storefrontId, image: {
|
|
61
63
|
fit: 'contain',
|
|
62
64
|
image: hit.image,
|
|
63
65
|
title: hit.name,
|
|
@@ -27,9 +27,9 @@ function Image({ className, 'data-test-selector': dataTestSelector, fallbackSrc
|
|
|
27
27
|
}
|
|
28
28
|
function createSrcSet(image) {
|
|
29
29
|
return ([
|
|
30
|
-
image[1] && `${encodeURI(image[1])} 1x`,
|
|
31
|
-
image[2] && `${encodeURI(image[2])} 2x`,
|
|
32
|
-
image[3] && `${encodeURI(image[3])} 3x`,
|
|
30
|
+
image[1] && `${encodeURI(decodeURI(image[1]))} 1x`,
|
|
31
|
+
image[2] && `${encodeURI(decodeURI(image[2]))} 2x`,
|
|
32
|
+
image[3] && `${encodeURI(decodeURI(image[3]))} 3x`,
|
|
33
33
|
]
|
|
34
34
|
.filter(Boolean)
|
|
35
35
|
.join(', ') || undefined);
|
|
@@ -57,7 +57,7 @@ function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, ima
|
|
|
57
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 }) }));
|
|
58
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], {
|
|
59
59
|
[styles['has-error']]: hasError,
|
|
60
|
-
}), src: encodeURI((hasError ? fallbackSrc : getPrimarySrc(image)) || ''), ...rest })] }));
|
|
60
|
+
}), src: encodeURI(decodeURI((hasError ? fallbackSrc : getPrimarySrc(image)) || '')), ...rest })] }));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export { Image };
|