@sonic-equipment/ui 0.0.61 → 0.0.63

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.js CHANGED
@@ -778,9 +778,10 @@ async function getWishListItemsByWishListId({ wishListId, }) {
778
778
  });
779
779
  }
780
780
 
781
- function useFetchAllWishListsItems() {
781
+ function useFetchAllWishListsItems({ enabled = true } = { enabled: true }) {
782
782
  const queryClient = useQueryClient();
783
783
  return useQuery({
784
+ enabled,
784
785
  queryFn: async () => {
785
786
  const body =
786
787
  // Reuse existing data if available
@@ -817,8 +818,8 @@ function useFavorite() {
817
818
  return { signInUrl: state.signInUrl };
818
819
  }
819
820
  function useFavoriteProduct(productId) {
820
- const { data: entries, isFetching: isFetchingWishListItems } = useFetchAllWishListsItems();
821
821
  const isAuthenticated = useIsAuthenticated();
822
+ const { data: entries, isFetching: isFetchingWishListItems } = useFetchAllWishListsItems({ enabled: Boolean(isAuthenticated) });
822
823
  const entry = entries?.find(({ wishListItem }) => wishListItem.productId === productId);
823
824
  return {
824
825
  isFavorite: Boolean(entry),
@@ -1261,7 +1262,7 @@ function ProductPrice({ className, isVatIncluded, originalPrice, price, }) {
1261
1262
  var styles$F = {"product-sku":"product-sku-module-ITb8x"};
1262
1263
 
1263
1264
  function ProductSku({ sku }) {
1264
- return jsx("p", { className: styles$F['product-sku'], children: sku });
1265
+ return (jsx("p", { className: styles$F['product-sku'], "data-test-selector": "productNumber", children: sku }));
1265
1266
  }
1266
1267
 
1267
1268
  function isResponsiveImage(image) {
@@ -1310,7 +1311,7 @@ function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, ima
1310
1311
  var styles$D = {"product-card":"product-card-module-pLaiB","favorite-button":"product-card-module-tvEdz","content":"product-card-module-e0kMu","top":"product-card-module-Q0VvF","tag":"product-card-module-HkWBE","title":"product-card-module-CStNi","bottom":"product-card-module-kD2tU","image":"product-card-module-p-zoi","price":"product-card-module-irW0D","add-to-cart-button":"product-card-module-SnCvX"};
1311
1312
 
1312
1313
  function ProductCard({ addToCartButton: AddToCartButton, areaSelected, favoriteButton: FavoriteButton, href, id, image, onClick, onMouseDown, onMouseMove, onPress, price, role, sku, tags, title, }) {
1313
- return (jsxs(RouteLink, { "aria-selected": areaSelected, className: styles$D['product-card'], href: href, id: id, onClick: onClick, onMouseDown: onMouseDown, onMouseMove: onMouseMove, onPress: onPress, role: role, children: [jsx("div", { className: styles$D.image, children: jsx(Image, { ...image }) }), jsx("div", { className: styles$D['favorite-button'], children: FavoriteButton && FavoriteButton }), jsxs("div", { className: styles$D.content, children: [jsxs("div", { className: styles$D.top, children: [jsx("div", { className: styles$D.tag, children: tags?.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { optional: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) }), jsx("h2", { className: styles$D.title, children: title }), jsx(ProductSku, { sku: sku })] }), jsxs("div", { className: styles$D.bottom, children: [jsx("div", { className: styles$D.price, children: jsx(ProductPrice, { isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price }) }), jsx("div", { className: styles$D['add-to-cart-button'], children: AddToCartButton })] })] })] }));
1314
+ return (jsxs(RouteLink, { "aria-selected": areaSelected, className: styles$D['product-card'], "data-product-id": sku, href: href, id: id, onClick: onClick, onMouseDown: onMouseDown, onMouseMove: onMouseMove, onPress: onPress, role: role, children: [jsx("div", { className: styles$D.image, children: jsx(Image, { ...image }) }), jsx("div", { className: styles$D['favorite-button'], children: FavoriteButton && FavoriteButton }), jsxs("div", { className: styles$D.content, children: [jsxs("div", { className: styles$D.top, children: [jsx("div", { className: styles$D.tag, children: tags?.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { optional: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) }), jsx("h2", { className: styles$D.title, children: title }), jsx(ProductSku, { sku: sku })] }), jsxs("div", { className: styles$D.bottom, children: [jsx("div", { className: styles$D.price, children: jsx(ProductPrice, { isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price }) }), jsx("div", { className: styles$D['add-to-cart-button'], children: AddToCartButton })] })] })] }));
1314
1315
  }
1315
1316
 
1316
1317
  /**
@@ -7584,10 +7585,10 @@ function AlgoliaSortBy() {
7584
7585
 
7585
7586
  var styles$i = {"category-card":"category-card-module-4NUjH","title":"category-card-module-LEhh3","arrow":"category-card-module-hL4-A","is-selected":"category-card-module-vJ7vB","image-container":"category-card-module-oNTrK"};
7586
7587
 
7587
- function CategoryCard({ href, image, isSelected = false, title, withArrow = false, }) {
7588
+ function CategoryCard({ href, image, isSelected = false, onClick, title, withArrow = false, }) {
7588
7589
  return (jsxs(RouteLink, { className: clsx({
7589
7590
  [styles$i['is-selected']]: isSelected,
7590
- }, styles$i['category-card']), href: href, children: [jsx("div", { className: styles$i['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsxs("p", { className: styles$i.title, children: [jsx("span", { children: title }), withArrow && jsx(GlyphsArrowBoldCapsRightIcon, { className: styles$i.arrow })] })] }));
7591
+ }, styles$i['category-card']), href: href, onClick: onClick, children: [jsx("div", { className: styles$i['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsxs("p", { className: styles$i.title, children: [jsx("span", { children: title }), withArrow && jsx(GlyphsArrowBoldCapsRightIcon, { className: styles$i.arrow })] })] }));
7591
7592
  }
7592
7593
 
7593
7594
  const ProductListingPageContext = createContext({
@@ -8155,12 +8156,12 @@ function ConnectedSearchInput() {
8155
8156
 
8156
8157
  var styles$8 = {"categories-grid":"categories-grid-module-C751R","category":"categories-grid-module-7OZS1"};
8157
8158
 
8158
- function CategoriesGrid({ categories }) {
8159
+ function CategoriesGrid({ categories, onItemClick, }) {
8159
8160
  return (jsx("div", { className: styles$8['categories-grid'], children: categories.map(category => (jsx("div", { className: styles$8['category'], children: jsx(CategoryCard, { withArrow: true, href: category.href, image: {
8160
8161
  fit: 'contain',
8161
8162
  image: category.image,
8162
8163
  title: category.title,
8163
- }, title: category.title }, category.title) }, category.title))) }));
8164
+ }, onClick: onItemClick, title: category.title }, category.title) }, category.title))) }));
8164
8165
  }
8165
8166
 
8166
8167
  var styles$7 = {"search-section":"search-section-module-qaTiw","header":"search-section-module-E--U2","title":"search-section-module-AHlDR","content":"search-section-module-VZlvZ"};
@@ -8186,10 +8187,11 @@ function NotFound() {
8186
8187
  function PopularCategoriesSection() {
8187
8188
  const { popularCategories: collection } = useAlgoliaSearch();
8188
8189
  const t = useFormattedMessage();
8190
+ const { close } = useGlobalSearchDisclosure();
8189
8191
  if (!collection)
8190
8192
  return null;
8191
8193
  const { items } = collection;
8192
- return (jsx(SearchSection, { title: t('Explore by categories'), children: jsx("div", { className: styles$6['categories-grid-container'], children: jsx(CategoriesGrid, { categories: items }) }) }));
8194
+ return (jsx(SearchSection, { title: t('Explore by categories'), children: jsx("div", { className: styles$6['categories-grid-container'], children: jsx(CategoriesGrid, { categories: items, onItemClick: close }) }) }));
8193
8195
  }
8194
8196
 
8195
8197
  function Highlight({ attribute, hit, tagName = 'mark', }) {
@@ -8245,11 +8247,12 @@ function RecentSearchesSection() {
8245
8247
  }
8246
8248
  function QuickAccessSection() {
8247
8249
  const { quickAccess: collection } = useAlgoliaSearch();
8250
+ const { close } = useGlobalSearchDisclosure();
8248
8251
  const t = useFormattedMessage();
8249
8252
  if (!collection)
8250
8253
  return;
8251
8254
  const { items } = collection;
8252
- return (jsx(SearchSection, { title: t('Quick access'), children: jsx("div", { className: styles$3['quick-access-section'], children: jsx(Carousel, { className: styles$3['quick-access-carousel'], hasNavigation: false, hasOverflow: false, navigationButtonsPosition: "center", slides: items.map((item, index) => (jsx(RouteLink, { className: styles$3['quick-access-card'], href: item.action.url, children: jsx(Image, { height: 343, image: item.image, title: item.image.altText, width: 192 }) }, index))), spaceBetween: 16 }) }) }));
8255
+ return (jsx(SearchSection, { title: t('Quick access'), children: jsx("div", { className: styles$3['quick-access-section'], children: jsx(Carousel, { className: styles$3['quick-access-carousel'], hasNavigation: false, hasOverflow: false, navigationButtonsPosition: "center", slides: items.map((item, index) => (jsx(RouteLink, { className: styles$3['quick-access-card'], href: item.action.url, onClick: close, children: jsx(Image, { height: 343, image: item.image, title: item.image.altText, width: 192 }) }, index))), spaceBetween: 16 }) }) }));
8253
8256
  }
8254
8257
 
8255
8258
  var styles$2 = {"slide":"product-carousel-module-XVTB1"};
@@ -8265,7 +8268,7 @@ function StrokeRecentIcon(props) {
8265
8268
  function WithResults() {
8266
8269
  const { state } = useAlgoliaSearch();
8267
8270
  const { close } = useGlobalSearchDisclosure();
8268
- return (jsx("div", { children: jsx(SectionContainer, { buttons: jsxs(RouteButton, { className: clsx(styles$6['show-all-button'], buttonStyles.button, buttonStyles.secondary, buttonStyles.outline, buttonStyles.md), href: `/search?keyword=${state.query}`, onPress: close, children: [jsx(FormattedMessage, { id: "See all results" }), ")", jsx(GlyphsArrowBoldCapsRightIcon, { className: buttonStyles['right-arrow-icon'] })] }), leftContent: jsx(SuggestionsSection, {}), rightContent: jsx(ProductResultsSection, {}) }) }));
8271
+ return (jsx("div", { children: jsx(SectionContainer, { buttons: jsxs(RouteButton, { className: clsx(styles$6['show-all-button'], buttonStyles.button, buttonStyles.secondary, buttonStyles.outline, buttonStyles.md), href: `/search?keyword=${state.query}`, onPress: close, children: [jsx(FormattedMessage, { id: "See all results" }), jsx(GlyphsArrowBoldCapsRightIcon, { className: buttonStyles['right-arrow-icon'] })] }), leftContent: jsx(SuggestionsSection, {}), rightContent: jsx(ProductResultsSection, {}) }) }));
8269
8272
  }
8270
8273
  function SuggestionsSection() {
8271
8274
  const { autocomplete, categories, querySuggestions, recentSearches } = useAlgoliaSearch();
@@ -3,7 +3,8 @@ export interface CategoryCardProps {
3
3
  href: string;
4
4
  image: ImageSource;
5
5
  isSelected?: boolean;
6
+ onClick?: VoidFunction;
6
7
  title: string;
7
8
  withArrow?: boolean;
8
9
  }
9
- export declare function CategoryCard({ href, image, isSelected, title, withArrow, }: CategoryCardProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function CategoryCard({ href, image, isSelected, onClick, title, withArrow, }: CategoryCardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { Category } from 'shared/model/category';
2
2
  export interface CategoriesGridProps {
3
3
  categories: Category[];
4
+ onItemClick?: VoidFunction;
4
5
  }
5
- export declare function CategoriesGrid({ categories }: CategoriesGridProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function CategoriesGrid({ categories, onItemClick, }: CategoriesGridProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,9 @@
1
1
  import { WishListLineModel, WishListModel } from 'shared/api/shop/model/shop.model';
2
- export declare function useFetchAllWishListsItems(): import("@tanstack/react-query").UseQueryResult<{
2
+ interface UseFetchAllWishListsItemsArgs {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useFetchAllWishListsItems({ enabled }?: UseFetchAllWishListsItemsArgs): import("@tanstack/react-query").UseQueryResult<{
3
6
  wishList: WishListModel;
4
7
  wishListItem: WishListLineModel;
5
8
  }[], Error>;
9
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {