@sonic-equipment/ui 0.0.24 → 0.0.26
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
|
@@ -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 })
|
|
5994
|
+
return (jsx(ProductCard, { ...props, addToCartButton: jsx(ConnectedAddToCartButton, { productId: productId }) }));
|
|
6000
5995
|
}
|
|
6001
5996
|
|
|
6002
5997
|
const SidebarContext = createContext({
|
|
@@ -6050,7 +6045,8 @@ 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
|
-
|
|
6048
|
+
const baseUrl = location.href.split('?')[0];
|
|
6049
|
+
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: `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${productHit.id}-${productHit.name.replace(/ /g, '-')}`, image: {
|
|
6054
6050
|
alt: productHit.name,
|
|
6055
6051
|
fit: 'contain',
|
|
6056
6052
|
sizes: { lg: 288, md: 204, sm: 122 },
|
|
@@ -6181,7 +6177,9 @@ function AlgoliaProvider({ category, children, offlineSearchClient, online: _onl
|
|
|
6181
6177
|
}, children: jsxs(InstantSearch, { future: {
|
|
6182
6178
|
persistHierarchicalRootCount: true,
|
|
6183
6179
|
preserveSharedStateOnUnmount: true,
|
|
6184
|
-
}, indexName: "dev_sonic_products_en", routing: routing, searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters:
|
|
6180
|
+
}, indexName: "dev_sonic_products_en", routing: routing, searchClient: online ? searchClient : offlineSearchClient || searchClient, children: [jsx(Configure, { analytics: false, filters: category && category.length
|
|
6181
|
+
? `categoryPages: '${category.join(' > ')}'`
|
|
6182
|
+
: undefined, hitsPerPage: 9, maxValuesPerFacet: 100, ruleContexts: ['storefront'] }), children] }) }));
|
|
6185
6183
|
}
|
|
6186
6184
|
function useAlgolia() {
|
|
6187
6185
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonic-equipment/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
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": {
|