@wix/headless-stores 0.0.41 → 0.0.43
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/cjs/dist/react/ProductList.d.ts +31 -3
- package/cjs/dist/react/ProductList.js +33 -5
- package/cjs/dist/react/ProductListFilters.d.ts +100 -111
- package/cjs/dist/react/ProductListFilters.js +105 -115
- package/cjs/dist/react/ProductListPagination.d.ts +89 -96
- package/cjs/dist/react/ProductListPagination.js +96 -104
- package/cjs/dist/react/ProductListSort.d.ts +26 -57
- package/cjs/dist/react/ProductListSort.js +26 -58
- package/cjs/dist/services/index.d.ts +1 -3
- package/cjs/dist/services/index.js +1 -3
- package/cjs/dist/services/products-list-search-service.d.ts +220 -0
- package/cjs/dist/services/products-list-search-service.js +813 -0
- package/cjs/dist/services/products-list-service.d.ts +28 -11
- package/cjs/dist/services/products-list-service.js +26 -6
- package/dist/react/ProductList.d.ts +31 -3
- package/dist/react/ProductList.js +33 -5
- package/dist/react/ProductListFilters.d.ts +100 -111
- package/dist/react/ProductListFilters.js +105 -115
- package/dist/react/ProductListPagination.d.ts +89 -96
- package/dist/react/ProductListPagination.js +96 -104
- package/dist/react/ProductListSort.d.ts +26 -57
- package/dist/react/ProductListSort.js +26 -58
- package/dist/services/index.d.ts +1 -3
- package/dist/services/index.js +1 -3
- package/dist/services/products-list-search-service.d.ts +220 -0
- package/dist/services/products-list-search-service.js +813 -0
- package/dist/services/products-list-service.d.ts +28 -11
- package/dist/services/products-list-service.js +26 -6
- package/package.json +2 -2
- package/cjs/dist/services/products-list-filters-service.d.ts +0 -309
- package/cjs/dist/services/products-list-filters-service.js +0 -504
- package/cjs/dist/services/products-list-pagination-service.d.ts +0 -186
- package/cjs/dist/services/products-list-pagination-service.js +0 -179
- package/cjs/dist/services/products-list-sort-service.d.ts +0 -117
- package/cjs/dist/services/products-list-sort-service.js +0 -144
- package/dist/services/products-list-filters-service.d.ts +0 -309
- package/dist/services/products-list-filters-service.js +0 -504
- package/dist/services/products-list-pagination-service.d.ts +0 -186
- package/dist/services/products-list-pagination-service.js +0 -179
- package/dist/services/products-list-sort-service.d.ts +0 -117
- package/dist/services/products-list-sort-service.js +0 -144
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
+
export declare const DEFAULT_QUERY_LIMIT = 100;
|
|
3
4
|
/**
|
|
4
5
|
* Configuration interface for the Products List service.
|
|
5
6
|
* Contains the initial products data, search options, and metadata.
|
|
@@ -10,7 +11,7 @@ export type ProductsListServiceConfig = {
|
|
|
10
11
|
/** Array of product objects to initialize the service with */
|
|
11
12
|
products: productsV3.V3Product[];
|
|
12
13
|
/** Search options used to fetch the products */
|
|
13
|
-
searchOptions:
|
|
14
|
+
searchOptions: productsV3.V3ProductSearch;
|
|
14
15
|
/** Pagination metadata from the search response */
|
|
15
16
|
pagingMetadata: productsV3.CommonCursorPagingMetadata;
|
|
16
17
|
/** Aggregation data containing filters, facets, and counts */
|
|
@@ -21,7 +22,7 @@ export type ProductsListServiceConfig = {
|
|
|
21
22
|
* This function is designed to be used during Server-Side Rendering (SSR) to preload
|
|
22
23
|
* a list of products based on search criteria.
|
|
23
24
|
*
|
|
24
|
-
* @param {
|
|
25
|
+
* @param {productsV3.V3ProductSearch} searchOptions - The search options for querying products
|
|
25
26
|
* @returns {Promise<ProductsListServiceConfig>} Promise that resolves to the products list configuration
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
@@ -99,7 +100,7 @@ export type ProductsListServiceConfig = {
|
|
|
99
100
|
* }
|
|
100
101
|
* ```
|
|
101
102
|
*/
|
|
102
|
-
export declare function loadProductsListServiceConfig(searchOptions:
|
|
103
|
+
export declare function loadProductsListServiceConfig(searchOptions: productsV3.V3ProductSearch): Promise<ProductsListServiceConfig>;
|
|
103
104
|
/**
|
|
104
105
|
* Service definition for the Products List service.
|
|
105
106
|
* This defines the reactive API contract for managing a list of products with search, pagination, and filtering capabilities.
|
|
@@ -115,13 +116,17 @@ export declare const ProductsListServiceDefinition: string & {
|
|
|
115
116
|
/** Reactive signal containing pagination metadata */
|
|
116
117
|
pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
|
|
117
118
|
/** Reactive signal containing current search options */
|
|
118
|
-
searchOptions: Signal<
|
|
119
|
+
searchOptions: Signal<productsV3.V3ProductSearch>;
|
|
119
120
|
/** Reactive signal indicating if products are currently being loaded */
|
|
120
121
|
isLoading: Signal<boolean>;
|
|
121
122
|
/** Reactive signal containing any error message, or null if no error */
|
|
122
123
|
error: Signal<string | null>;
|
|
123
124
|
/** Function to update search options and trigger a new search */
|
|
124
|
-
setSearchOptions: (searchOptions:
|
|
125
|
+
setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
|
|
126
|
+
/** Function to update only the sort part of search options */
|
|
127
|
+
setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
|
|
128
|
+
/** Function to update only the filter part of search options */
|
|
129
|
+
setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
|
|
125
130
|
};
|
|
126
131
|
__config: ProductsListServiceConfig;
|
|
127
132
|
isServiceDefinition?: boolean;
|
|
@@ -133,13 +138,17 @@ export declare const ProductsListServiceDefinition: string & {
|
|
|
133
138
|
/** Reactive signal containing pagination metadata */
|
|
134
139
|
pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
|
|
135
140
|
/** Reactive signal containing current search options */
|
|
136
|
-
searchOptions: Signal<
|
|
141
|
+
searchOptions: Signal<productsV3.V3ProductSearch>;
|
|
137
142
|
/** Reactive signal indicating if products are currently being loaded */
|
|
138
143
|
isLoading: Signal<boolean>;
|
|
139
144
|
/** Reactive signal containing any error message, or null if no error */
|
|
140
145
|
error: Signal<string | null>;
|
|
141
146
|
/** Function to update search options and trigger a new search */
|
|
142
|
-
setSearchOptions: (searchOptions:
|
|
147
|
+
setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
|
|
148
|
+
/** Function to update only the sort part of search options */
|
|
149
|
+
setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
|
|
150
|
+
/** Function to update only the filter part of search options */
|
|
151
|
+
setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
|
|
143
152
|
};
|
|
144
153
|
/**
|
|
145
154
|
* Implementation of the Products List service that manages reactive products data.
|
|
@@ -204,13 +213,17 @@ export declare const ProductListService: import("@wix/services-definitions").Ser
|
|
|
204
213
|
/** Reactive signal containing pagination metadata */
|
|
205
214
|
pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
|
|
206
215
|
/** Reactive signal containing current search options */
|
|
207
|
-
searchOptions: Signal<
|
|
216
|
+
searchOptions: Signal<productsV3.V3ProductSearch>;
|
|
208
217
|
/** Reactive signal indicating if products are currently being loaded */
|
|
209
218
|
isLoading: Signal<boolean>;
|
|
210
219
|
/** Reactive signal containing any error message, or null if no error */
|
|
211
220
|
error: Signal<string | null>;
|
|
212
221
|
/** Function to update search options and trigger a new search */
|
|
213
|
-
setSearchOptions: (searchOptions:
|
|
222
|
+
setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
|
|
223
|
+
/** Function to update only the sort part of search options */
|
|
224
|
+
setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
|
|
225
|
+
/** Function to update only the filter part of search options */
|
|
226
|
+
setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
|
|
214
227
|
};
|
|
215
228
|
__config: ProductsListServiceConfig;
|
|
216
229
|
isServiceDefinition?: boolean;
|
|
@@ -222,11 +235,15 @@ export declare const ProductListService: import("@wix/services-definitions").Ser
|
|
|
222
235
|
/** Reactive signal containing pagination metadata */
|
|
223
236
|
pagingMetadata: Signal<productsV3.CommonCursorPagingMetadata>;
|
|
224
237
|
/** Reactive signal containing current search options */
|
|
225
|
-
searchOptions: Signal<
|
|
238
|
+
searchOptions: Signal<productsV3.V3ProductSearch>;
|
|
226
239
|
/** Reactive signal indicating if products are currently being loaded */
|
|
227
240
|
isLoading: Signal<boolean>;
|
|
228
241
|
/** Reactive signal containing any error message, or null if no error */
|
|
229
242
|
error: Signal<string | null>;
|
|
230
243
|
/** Function to update search options and trigger a new search */
|
|
231
|
-
setSearchOptions: (searchOptions:
|
|
244
|
+
setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
|
|
245
|
+
/** Function to update only the sort part of search options */
|
|
246
|
+
setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
|
|
247
|
+
/** Function to update only the filter part of search options */
|
|
248
|
+
setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
|
|
232
249
|
}, ProductsListServiceConfig>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { defineService, implementService } from "@wix/services-definitions";
|
|
2
2
|
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
3
|
import { productsV3, readOnlyVariantsV3 } from "@wix/stores";
|
|
4
|
+
export const DEFAULT_QUERY_LIMIT = 100;
|
|
4
5
|
/**
|
|
5
6
|
* Loads products list service configuration from the Wix Stores API for SSR initialization.
|
|
6
7
|
* This function is designed to be used during Server-Side Rendering (SSR) to preload
|
|
7
8
|
* a list of products based on search criteria.
|
|
8
9
|
*
|
|
9
|
-
* @param {
|
|
10
|
+
* @param {productsV3.V3ProductSearch} searchOptions - The search options for querying products
|
|
10
11
|
* @returns {Promise<ProductsListServiceConfig>} Promise that resolves to the products list configuration
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
@@ -85,12 +86,17 @@ import { productsV3, readOnlyVariantsV3 } from "@wix/stores";
|
|
|
85
86
|
* ```
|
|
86
87
|
*/
|
|
87
88
|
export async function loadProductsListServiceConfig(searchOptions) {
|
|
88
|
-
const
|
|
89
|
+
const searchWithoutFilter = { ...searchOptions, filter: {} };
|
|
90
|
+
const [resultWithoutFilter, resultWithFilter] = await Promise.all([
|
|
91
|
+
fetchProducts(searchWithoutFilter),
|
|
92
|
+
fetchProducts(searchOptions),
|
|
93
|
+
]);
|
|
94
|
+
const products = resultWithFilter?.products ?? resultWithoutFilter?.products ?? [];
|
|
89
95
|
return {
|
|
90
|
-
products
|
|
96
|
+
products,
|
|
91
97
|
searchOptions,
|
|
92
|
-
pagingMetadata:
|
|
93
|
-
aggregations:
|
|
98
|
+
pagingMetadata: resultWithFilter.pagingMetadata,
|
|
99
|
+
aggregations: resultWithoutFilter.aggregationData ?? {},
|
|
94
100
|
};
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
@@ -136,7 +142,7 @@ const fetchMissingVariants = async (products) => {
|
|
|
136
142
|
const res = await readOnlyVariantsV3
|
|
137
143
|
.queryVariants({})
|
|
138
144
|
.in("productData.productId", productIds)
|
|
139
|
-
.limit(
|
|
145
|
+
.limit(DEFAULT_QUERY_LIMIT)
|
|
140
146
|
.find();
|
|
141
147
|
items.push(...res.items);
|
|
142
148
|
let nextRes = res;
|
|
@@ -284,6 +290,20 @@ export const ProductListService = implementService.withConfig()(ProductsListServ
|
|
|
284
290
|
pagingMetadata: pagingMetadataSignal,
|
|
285
291
|
aggregations: aggregationsSignal,
|
|
286
292
|
setSearchOptions: (searchOptions) => searchOptionsSignal.set(searchOptions),
|
|
293
|
+
setSort: (sort) => {
|
|
294
|
+
const currentOptions = searchOptionsSignal.peek();
|
|
295
|
+
searchOptionsSignal.set({
|
|
296
|
+
...currentOptions,
|
|
297
|
+
sort,
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
setFilter: (filter) => {
|
|
301
|
+
const currentOptions = searchOptionsSignal.peek();
|
|
302
|
+
searchOptionsSignal.set({
|
|
303
|
+
...currentOptions,
|
|
304
|
+
filter,
|
|
305
|
+
});
|
|
306
|
+
},
|
|
287
307
|
isLoading: isLoadingSignal,
|
|
288
308
|
error: errorSignal,
|
|
289
309
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ProductsListServiceConfig } from "../services/products-list-service.js";
|
|
2
2
|
import { productsV3 } from "@wix/stores";
|
|
3
|
+
import { ProductsListSearchServiceConfig } from "../services/products-list-search-service.js";
|
|
3
4
|
/**
|
|
4
5
|
* Props for Root headless component
|
|
5
6
|
*/
|
|
@@ -8,16 +9,19 @@ export interface RootProps {
|
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
/** Configuration for the ProductList service */
|
|
10
11
|
productsListConfig: ProductsListServiceConfig;
|
|
12
|
+
/** Configuration for the ProductListSearch service */
|
|
13
|
+
productsListSearchConfig?: ProductsListSearchServiceConfig;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
|
-
* Root component that provides
|
|
14
|
-
* This component sets up the necessary services for managing products list state
|
|
16
|
+
* Root component that provides both ProductList and ProductListSearch service contexts to its children.
|
|
17
|
+
* This component sets up the necessary services for managing products list state, including search,
|
|
18
|
+
* filtering, sorting, and pagination functionality.
|
|
15
19
|
*
|
|
16
20
|
* @order 1
|
|
17
21
|
* @component
|
|
18
22
|
* @example
|
|
19
23
|
* ```tsx
|
|
20
|
-
* import { ProductList } from '@wix/stores/components';
|
|
24
|
+
* import { ProductList, ProductListFilters, ProductListSort, ProductListPagination } from '@wix/stores/components';
|
|
21
25
|
*
|
|
22
26
|
* function ProductListPage() {
|
|
23
27
|
* return (
|
|
@@ -28,7 +32,25 @@ export interface RootProps {
|
|
|
28
32
|
* pagingMetadata: { count: 10, hasNext: true },
|
|
29
33
|
* aggregations: {}
|
|
30
34
|
* }}
|
|
35
|
+
* productsListSearchConfig={{
|
|
36
|
+
* customizations: [],
|
|
37
|
+
* initialSearchState: { sort: 'name_asc', limit: 20 }
|
|
38
|
+
* }}
|
|
31
39
|
* >
|
|
40
|
+
* <ProductListSort.Options>
|
|
41
|
+
* {({ selectedSortOption, updateSortOption, sortOptions }) => (
|
|
42
|
+
* <select value={selectedSortOption} onChange={(e) => updateSortOption(e.target.value)}>
|
|
43
|
+
* {sortOptions.map(option => <option key={option} value={option}>{option}</option>)}
|
|
44
|
+
* </select>
|
|
45
|
+
* )}
|
|
46
|
+
* </ProductListSort.Options>
|
|
47
|
+
*
|
|
48
|
+
* <ProductListFilters.PriceRange>
|
|
49
|
+
* {({ selectedMinPrice, setSelectedMinPrice }) => (
|
|
50
|
+
* <input value={selectedMinPrice} onChange={(e) => setSelectedMinPrice(Number(e.target.value))} />
|
|
51
|
+
* )}
|
|
52
|
+
* </ProductListFilters.PriceRange>
|
|
53
|
+
*
|
|
32
54
|
* <ProductList.ItemContent>
|
|
33
55
|
* {({ product }) => (
|
|
34
56
|
* <div key={product._id}>
|
|
@@ -37,6 +59,12 @@ export interface RootProps {
|
|
|
37
59
|
* </div>
|
|
38
60
|
* )}
|
|
39
61
|
* </ProductList.ItemContent>
|
|
62
|
+
*
|
|
63
|
+
* <ProductListPagination.NextPageTrigger>
|
|
64
|
+
* {({ nextPage, hasNextPage }) => (
|
|
65
|
+
* <button onClick={nextPage} disabled={!hasNextPage}>Next</button>
|
|
66
|
+
* )}
|
|
67
|
+
* </ProductListPagination.NextPageTrigger>
|
|
40
68
|
* </ProductList.Root>
|
|
41
69
|
* );
|
|
42
70
|
* }
|
|
@@ -2,16 +2,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useService, WixServices } from "@wix/services-manager-react";
|
|
3
3
|
import { createServicesMap } from "@wix/services-manager";
|
|
4
4
|
import { ProductListService, ProductsListServiceDefinition, } from "../services/products-list-service.js";
|
|
5
|
-
import { ProductService, ProductServiceDefinition, } from "
|
|
5
|
+
import { ProductService, ProductServiceDefinition, } from "../services/product-service.js";
|
|
6
|
+
import { ProductsListSearchService, ProductsListSearchServiceDefinition, } from "../services/products-list-search-service.js";
|
|
6
7
|
/**
|
|
7
|
-
* Root component that provides
|
|
8
|
-
* This component sets up the necessary services for managing products list state
|
|
8
|
+
* Root component that provides both ProductList and ProductListSearch service contexts to its children.
|
|
9
|
+
* This component sets up the necessary services for managing products list state, including search,
|
|
10
|
+
* filtering, sorting, and pagination functionality.
|
|
9
11
|
*
|
|
10
12
|
* @order 1
|
|
11
13
|
* @component
|
|
12
14
|
* @example
|
|
13
15
|
* ```tsx
|
|
14
|
-
* import { ProductList } from '@wix/stores/components';
|
|
16
|
+
* import { ProductList, ProductListFilters, ProductListSort, ProductListPagination } from '@wix/stores/components';
|
|
15
17
|
*
|
|
16
18
|
* function ProductListPage() {
|
|
17
19
|
* return (
|
|
@@ -22,7 +24,25 @@ import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/
|
|
|
22
24
|
* pagingMetadata: { count: 10, hasNext: true },
|
|
23
25
|
* aggregations: {}
|
|
24
26
|
* }}
|
|
27
|
+
* productsListSearchConfig={{
|
|
28
|
+
* customizations: [],
|
|
29
|
+
* initialSearchState: { sort: 'name_asc', limit: 20 }
|
|
30
|
+
* }}
|
|
25
31
|
* >
|
|
32
|
+
* <ProductListSort.Options>
|
|
33
|
+
* {({ selectedSortOption, updateSortOption, sortOptions }) => (
|
|
34
|
+
* <select value={selectedSortOption} onChange={(e) => updateSortOption(e.target.value)}>
|
|
35
|
+
* {sortOptions.map(option => <option key={option} value={option}>{option}</option>)}
|
|
36
|
+
* </select>
|
|
37
|
+
* )}
|
|
38
|
+
* </ProductListSort.Options>
|
|
39
|
+
*
|
|
40
|
+
* <ProductListFilters.PriceRange>
|
|
41
|
+
* {({ selectedMinPrice, setSelectedMinPrice }) => (
|
|
42
|
+
* <input value={selectedMinPrice} onChange={(e) => setSelectedMinPrice(Number(e.target.value))} />
|
|
43
|
+
* )}
|
|
44
|
+
* </ProductListFilters.PriceRange>
|
|
45
|
+
*
|
|
26
46
|
* <ProductList.ItemContent>
|
|
27
47
|
* {({ product }) => (
|
|
28
48
|
* <div key={product._id}>
|
|
@@ -31,13 +51,21 @@ import { ProductService, ProductServiceDefinition, } from "@wix/headless-stores/
|
|
|
31
51
|
* </div>
|
|
32
52
|
* )}
|
|
33
53
|
* </ProductList.ItemContent>
|
|
54
|
+
*
|
|
55
|
+
* <ProductListPagination.NextPageTrigger>
|
|
56
|
+
* {({ nextPage, hasNextPage }) => (
|
|
57
|
+
* <button onClick={nextPage} disabled={!hasNextPage}>Next</button>
|
|
58
|
+
* )}
|
|
59
|
+
* </ProductListPagination.NextPageTrigger>
|
|
34
60
|
* </ProductList.Root>
|
|
35
61
|
* );
|
|
36
62
|
* }
|
|
37
63
|
* ```
|
|
38
64
|
*/
|
|
39
65
|
export function Root(props) {
|
|
40
|
-
return (_jsx(WixServices, { servicesMap: createServicesMap()
|
|
66
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap()
|
|
67
|
+
.addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig)
|
|
68
|
+
.addService(ProductsListSearchServiceDefinition, ProductsListSearchService, props.productsListSearchConfig), children: props.children }));
|
|
41
69
|
}
|
|
42
70
|
/**
|
|
43
71
|
* Component that renders content when the products list is empty.
|
|
@@ -1,45 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/** Child components that will have access to the ProductListFilters service */
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
/** Configuration for the ProductListFilters service */
|
|
7
|
-
productsListFiltersConfig: ProductsListFiltersServiceConfig;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Root component that provides the ProductListFilters service context to its children.
|
|
11
|
-
* This component sets up the necessary services for managing products list filters.
|
|
12
|
-
*
|
|
13
|
-
* @order 1
|
|
14
|
-
* @component
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
18
|
-
*
|
|
19
|
-
* function FiltersSection() {
|
|
20
|
-
* return (
|
|
21
|
-
* <ProductListFilters.Root
|
|
22
|
-
* productsListFiltersConfig={{
|
|
23
|
-
* minPrice: 0,
|
|
24
|
-
* maxPrice: 1000
|
|
25
|
-
* }}
|
|
26
|
-
* >
|
|
27
|
-
* <ProductListFilters.MinPrice>
|
|
28
|
-
* {({ minPrice, setSelectedMinPrice }) => (
|
|
29
|
-
* <input
|
|
30
|
-
* type="number"
|
|
31
|
-
* value={minPrice}
|
|
32
|
-
* onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
|
|
33
|
-
* placeholder="Min price"
|
|
34
|
-
* />
|
|
35
|
-
* )}
|
|
36
|
-
* </ProductListFilters.MinPrice>
|
|
37
|
-
* </ProductListFilters.Root>
|
|
38
|
-
* );
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function Root(props: RootProps): React.ReactNode;
|
|
2
|
+
import { type ProductOption, InventoryStatusType } from "../services/products-list-search-service.js";
|
|
3
|
+
import { Category } from "@wix/auto_sdk_categories_categories";
|
|
43
4
|
/**
|
|
44
5
|
* Props for InventoryStatus headless component
|
|
45
6
|
*/
|
|
@@ -64,27 +25,32 @@ export interface InventoryStatusRenderProps {
|
|
|
64
25
|
* @component
|
|
65
26
|
* @example
|
|
66
27
|
* ```tsx
|
|
67
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
28
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
68
29
|
*
|
|
69
30
|
* function InventoryStatusFilter() {
|
|
70
31
|
* return (
|
|
71
|
-
* <
|
|
72
|
-
* {
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
32
|
+
* <ProductList.Root
|
|
33
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
34
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
35
|
+
* >
|
|
36
|
+
* <ProductListFilters.InventoryStatus>
|
|
37
|
+
* {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
|
|
38
|
+
* <div>
|
|
39
|
+
* <h4>Inventory Status:</h4>
|
|
40
|
+
* {availableInventoryStatuses.map(status => (
|
|
41
|
+
* <label key={status}>
|
|
42
|
+
* <input
|
|
43
|
+
* type="checkbox"
|
|
44
|
+
* checked={selectedInventoryStatuses.includes(status)}
|
|
45
|
+
* onChange={() => toggleInventoryStatus(status)}
|
|
46
|
+
* />
|
|
47
|
+
* {status}
|
|
48
|
+
* </label>
|
|
49
|
+
* ))}
|
|
50
|
+
* </div>
|
|
51
|
+
* )}
|
|
52
|
+
* </ProductListFilters.InventoryStatus>
|
|
53
|
+
* </ProductList.Root>
|
|
88
54
|
* );
|
|
89
55
|
* }
|
|
90
56
|
* ```
|
|
@@ -112,21 +78,26 @@ export interface ResetTriggerRenderProps {
|
|
|
112
78
|
* @component
|
|
113
79
|
* @example
|
|
114
80
|
* ```tsx
|
|
115
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
81
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
116
82
|
*
|
|
117
83
|
* function ResetFiltersButton() {
|
|
118
84
|
* return (
|
|
119
|
-
* <
|
|
120
|
-
* {
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
85
|
+
* <ProductList.Root
|
|
86
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
87
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
88
|
+
* >
|
|
89
|
+
* <ProductListFilters.ResetTrigger>
|
|
90
|
+
* {({ resetFilters, isFiltered }) => (
|
|
91
|
+
* <button
|
|
92
|
+
* onClick={resetFilters}
|
|
93
|
+
* disabled={!isFiltered}
|
|
94
|
+
* className={isFiltered ? 'active' : 'disabled'}
|
|
95
|
+
* >
|
|
96
|
+
* {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
|
|
97
|
+
* </button>
|
|
98
|
+
* )}
|
|
99
|
+
* </ProductListFilters.ResetTrigger>
|
|
100
|
+
* </ProductList.Root>
|
|
130
101
|
* );
|
|
131
102
|
* }
|
|
132
103
|
* ```
|
|
@@ -162,37 +133,50 @@ export interface PriceRangeRenderProps {
|
|
|
162
133
|
* @component
|
|
163
134
|
* @example
|
|
164
135
|
* ```tsx
|
|
165
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
136
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
166
137
|
*
|
|
167
138
|
* function PriceRangeFilter() {
|
|
168
139
|
* return (
|
|
169
|
-
* <
|
|
170
|
-
* {
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
140
|
+
* <ProductList.Root
|
|
141
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
142
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
143
|
+
* >
|
|
144
|
+
* <ProductListFilters.PriceRange>
|
|
145
|
+
* {({ minPrice, maxPrice, setSelectedMinPrice, setSelectedMaxPrice }) => (
|
|
146
|
+
* <div className="price-range">
|
|
147
|
+
* <h4>Price Range:</h4>
|
|
148
|
+
* <div className="price-inputs">
|
|
149
|
+
* <input
|
|
150
|
+
* type="number"
|
|
151
|
+
* value={minPrice}
|
|
152
|
+
* onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
|
|
153
|
+
* placeholder="Min"
|
|
154
|
+
* />
|
|
155
|
+
* <span>to</span>
|
|
156
|
+
* <input
|
|
157
|
+
* type="number"
|
|
158
|
+
* value={maxPrice}
|
|
159
|
+
* onChange={(e) => setSelectedMaxPrice(Number(e.target.value))}
|
|
160
|
+
* placeholder="Max"
|
|
161
|
+
* />
|
|
162
|
+
* </div>
|
|
187
163
|
* </div>
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* </
|
|
164
|
+
* )}
|
|
165
|
+
* </ProductListFilters.PriceRange>
|
|
166
|
+
* </ProductList.Root>
|
|
191
167
|
* );
|
|
192
168
|
* }
|
|
193
169
|
* ```
|
|
194
170
|
*/
|
|
195
171
|
export declare function PriceRange(props: PriceRangeProps): ReactNode;
|
|
172
|
+
export interface CategoryFilterRenderProps {
|
|
173
|
+
selectedCategory: Category | null;
|
|
174
|
+
}
|
|
175
|
+
export interface CategoryFilterProps {
|
|
176
|
+
/** Content to display (can be a render function receiving category data or ReactNode) */
|
|
177
|
+
children: ((props: CategoryFilterRenderProps) => ReactNode) | ReactNode;
|
|
178
|
+
}
|
|
179
|
+
export declare function CategoryFilter(props: CategoryFilterProps): ReactNode;
|
|
196
180
|
/**
|
|
197
181
|
* Props for ProductOptions headless component
|
|
198
182
|
*/
|
|
@@ -220,27 +204,32 @@ export interface ProductOptionRenderProps {
|
|
|
220
204
|
* @component
|
|
221
205
|
* @example
|
|
222
206
|
* ```tsx
|
|
223
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
207
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
224
208
|
*
|
|
225
209
|
* function ProductOptionsFilter() {
|
|
226
210
|
* return (
|
|
227
|
-
* <
|
|
228
|
-
* {
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
211
|
+
* <ProductList.Root
|
|
212
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
213
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
214
|
+
* >
|
|
215
|
+
* <ProductListFilters.ProductOptions>
|
|
216
|
+
* {({ option, selectedChoices, toggleChoice }) => (
|
|
217
|
+
* <div key={option.id}>
|
|
218
|
+
* <h4>{option.name}</h4>
|
|
219
|
+
* {option.choices.map(choice => (
|
|
220
|
+
* <label key={choice.id}>
|
|
221
|
+
* <input
|
|
222
|
+
* type="checkbox"
|
|
223
|
+
* checked={selectedChoices.includes(choice.id)}
|
|
224
|
+
* onChange={() => toggleChoice(choice.id)}
|
|
225
|
+
* />
|
|
226
|
+
* {choice.name}
|
|
227
|
+
* </label>
|
|
228
|
+
* ))}
|
|
229
|
+
* </div>
|
|
230
|
+
* )}
|
|
231
|
+
* </ProductListFilters.ProductOptions>
|
|
232
|
+
* </ProductList.Root>
|
|
244
233
|
* );
|
|
245
234
|
* }
|
|
246
235
|
* ```
|