@sonic-equipment/ui 255.0.0 → 256.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/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,
|