@sonic-equipment/ui 0.0.24 → 0.0.25

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.
@@ -8,7 +8,7 @@ interface AlgoliaContextType {
8
8
  toggleOnline: VoidFunction;
9
9
  }
10
10
  interface AlgoliaProviderProps {
11
- category: string;
11
+ category: string[];
12
12
  children: ReactNode;
13
13
  offlineSearchClient?: SearchClient;
14
14
  online?: boolean;
package/dist/index.d.ts CHANGED
@@ -524,7 +524,7 @@ interface Filters {
524
524
  };
525
525
  }
526
526
  type ProductListingPageProps = {
527
- category: string;
527
+ category: string[];
528
528
  isLoading?: boolean;
529
529
  };
530
530
  declare function ProductListingPage({ category, isLoading, }: ProductListingPageProps): react_jsx_runtime.JSX.Element;
@@ -576,7 +576,7 @@ interface AlgoliaContextType {
576
576
  toggleOnline: VoidFunction;
577
577
  }
578
578
  interface AlgoliaProviderProps {
579
- category: string;
579
+ category: string[];
580
580
  children: ReactNode;
581
581
  offlineSearchClient?: SearchClient;
582
582
  online?: boolean;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ const useBreakpoint = () => {
27
27
  return Object.entries(breakpoints$1)
28
28
  .sort(([, minA], [, minB]) => minA - minB)
29
29
  .reduce((acc, [breakpoint, min]) => {
30
- const inRange = min <= window.innerWidth;
30
+ const inRange = min <= (typeof window === 'undefined' ? 0 : window.innerWidth);
31
31
  const current = inRange
32
32
  ? breakpoint
33
33
  : acc.current;
@@ -40,10 +40,10 @@ const useBreakpoint = () => {
40
40
  };
41
41
  const [device, setDevice] = useState(getBreakpoints());
42
42
  useEffect(() => {
43
- const handleResize = () => setDevice(getBreakpoints());
44
- handleResize();
45
43
  if (typeof window === 'undefined')
46
44
  return;
45
+ const handleResize = () => setDevice(getBreakpoints());
46
+ handleResize();
47
47
  window.addEventListener('resize', handleResize);
48
48
  return () => window.removeEventListener('resize', handleResize);
49
49
  }, []);
@@ -5990,13 +5990,8 @@ function AlgoliaSortBy() {
5990
5990
  return (jsx(Select, { label: "Sort", onChange: value => refine(String(value)), options: options, selectedOption: currentRefinement, showLabel: false }));
5991
5991
  }
5992
5992
 
5993
- function ConnectedFavoriteButton({ productId }) {
5994
- const { isFavorite, toggle } = useFavorite(productId);
5995
- return jsx(FavoriteButton, { isFavorite: isFavorite, onPress: toggle });
5996
- }
5997
-
5998
5993
  function ConnectedProductCart({ productId, ...props }) {
5999
- return (jsx(ProductCard, { ...props, addToCartButton: jsx(ConnectedAddToCartButton, { productId: productId }), favoriteButton: jsx(ConnectedFavoriteButton, { productId: productId }) }));
5994
+ return (jsx(ProductCard, { ...props, addToCartButton: jsx(ConnectedAddToCartButton, { productId: productId }) }));
6000
5995
  }
6001
5996
 
6002
5997
  const SidebarContext = createContext({
@@ -6050,7 +6045,7 @@ const categories = Array.from({ length: 20 }, () => ({
6050
6045
  function ProductListingPage({ category, isLoading = false, }) {
6051
6046
  const { toggle } = useSidebar();
6052
6047
  const { hits: productHits } = useHits();
6053
- return (jsxs(Page, { className: styles$1['product-listing'], title: category, children: [categories?.length > 0 && (jsx("section", { className: styles$1.categories, children: jsx(CategoryCarousel, { categories: categories }) })), jsxs("section", { className: styles$1['action-bar'], children: [jsx(ToggleSidebarButton, {}), jsx("span", { className: styles$1.count, children: jsx(AlgoliaResultsCount, {}) }), jsx(AlgoliaSortBy, {})] }), jsx("section", { children: isLoading ? (jsx("p", { children: "Loading..." })) : (jsxs("div", { className: styles$1['product-grid-container'], children: [jsx(Sidebar, { children: jsx(AlgoliaFilterPanel, { onShowProducts: toggle }) }), jsxs("div", { className: styles$1['product-grid'], children: [jsx(ProductOverviewGrid, { children: productHits.map(productHit => (jsx(ConnectedProductCart, { href: `${location.href}/${productHit.id}-${productHit.name.replace(/ /g, '-')}`, image: {
6048
+ return (jsxs(Page, { className: styles$1['product-listing'], title: category.slice().pop(), children: [categories?.length > 0 && (jsx("section", { className: styles$1.categories, children: jsx(CategoryCarousel, { categories: categories }) })), jsxs("section", { className: styles$1['action-bar'], children: [jsx(ToggleSidebarButton, {}), jsx("span", { className: styles$1.count, children: jsx(AlgoliaResultsCount, {}) }), jsx(AlgoliaSortBy, {})] }), jsx("section", { children: isLoading ? (jsx("p", { children: "Loading..." })) : (jsxs("div", { className: styles$1['product-grid-container'], children: [jsx(Sidebar, { children: jsx(AlgoliaFilterPanel, { onShowProducts: toggle }) }), jsxs("div", { className: styles$1['product-grid'], children: [jsx(ProductOverviewGrid, { children: productHits.map(productHit => (jsx(ConnectedProductCart, { href: `${location.href}/${productHit.id}-${productHit.name.replace(/ /g, '-')}`, image: {
6054
6049
  alt: productHit.name,
6055
6050
  fit: 'contain',
6056
6051
  sizes: { lg: 288, md: 204, sm: 122 },
@@ -6181,7 +6176,9 @@ function AlgoliaProvider({ category, children, offlineSearchClient, online: _onl
6181
6176
  }, children: jsxs(InstantSearch, { future: {
6182
6177
  persistHierarchicalRootCount: true,
6183
6178
  preserveSharedStateOnUnmount: true,
6184
- }, indexName: "dev_sonic_products_en", routing: routing, searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters: `categoryPages: ${category}`, hitsPerPage: 9, maxValuesPerFacet: 100, ruleContexts: ['storefront'] }), children] }) }));
6179
+ }, indexName: "dev_sonic_products_en", routing: routing, searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters: category && category.length
6180
+ ? `categoryPages: '${category.join(' > ')}'`
6181
+ : undefined, hitsPerPage: 9, maxValuesPerFacet: 100, ruleContexts: ['storefront'] }), children] }) }));
6185
6182
  }
6186
6183
  function useAlgolia() {
6187
6184
  return useContext(AlgoliaContext);
@@ -8,7 +8,7 @@ export interface Filters {
8
8
  };
9
9
  }
10
10
  export type ProductListingPageProps = {
11
- category: string;
11
+ category: string[];
12
12
  isLoading?: boolean;
13
13
  };
14
14
  export declare function ProductListingPage({ category, isLoading, }: ProductListingPageProps): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { StoryObj } from '@storybook/react';
3
3
  import { ProductListingPage } from './product-listing-page';
4
4
  declare const meta: {
5
5
  args: {
6
- category: string;
6
+ category: string[];
7
7
  isLoading: false;
8
8
  online: false;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -15,10 +15,7 @@
15
15
  "default": "./dist/index.js"
16
16
  }
17
17
  },
18
- "files": [
19
- "dist",
20
- "README.md"
21
- ],
18
+ "files": ["dist", "README.md"],
22
19
  "main": "dist/index.js",
23
20
  "types": "./dist/index.d.ts",
24
21
  "scripts": {