@wix/headless-stores 0.0.41 → 0.0.42
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 +91 -111
- package/cjs/dist/react/ProductListFilters.js +98 -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 +219 -0
- package/cjs/dist/services/products-list-search-service.js +794 -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 +91 -111
- package/dist/react/ProductListFilters.js +98 -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 +219 -0
- package/dist/services/products-list-search-service.js +794 -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,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface RootProps {
|
|
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";
|
|
43
3
|
/**
|
|
44
4
|
* Props for InventoryStatus headless component
|
|
45
5
|
*/
|
|
@@ -64,27 +24,32 @@ export interface InventoryStatusRenderProps {
|
|
|
64
24
|
* @component
|
|
65
25
|
* @example
|
|
66
26
|
* ```tsx
|
|
67
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
27
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
68
28
|
*
|
|
69
29
|
* function InventoryStatusFilter() {
|
|
70
30
|
* return (
|
|
71
|
-
* <
|
|
72
|
-
* {
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
31
|
+
* <ProductList.Root
|
|
32
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
33
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
34
|
+
* >
|
|
35
|
+
* <ProductListFilters.InventoryStatus>
|
|
36
|
+
* {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
|
|
37
|
+
* <div>
|
|
38
|
+
* <h4>Inventory Status:</h4>
|
|
39
|
+
* {availableInventoryStatuses.map(status => (
|
|
40
|
+
* <label key={status}>
|
|
41
|
+
* <input
|
|
42
|
+
* type="checkbox"
|
|
43
|
+
* checked={selectedInventoryStatuses.includes(status)}
|
|
44
|
+
* onChange={() => toggleInventoryStatus(status)}
|
|
45
|
+
* />
|
|
46
|
+
* {status}
|
|
47
|
+
* </label>
|
|
48
|
+
* ))}
|
|
49
|
+
* </div>
|
|
50
|
+
* )}
|
|
51
|
+
* </ProductListFilters.InventoryStatus>
|
|
52
|
+
* </ProductList.Root>
|
|
88
53
|
* );
|
|
89
54
|
* }
|
|
90
55
|
* ```
|
|
@@ -112,21 +77,26 @@ export interface ResetTriggerRenderProps {
|
|
|
112
77
|
* @component
|
|
113
78
|
* @example
|
|
114
79
|
* ```tsx
|
|
115
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
80
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
116
81
|
*
|
|
117
82
|
* function ResetFiltersButton() {
|
|
118
83
|
* return (
|
|
119
|
-
* <
|
|
120
|
-
* {
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
84
|
+
* <ProductList.Root
|
|
85
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
86
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
87
|
+
* >
|
|
88
|
+
* <ProductListFilters.ResetTrigger>
|
|
89
|
+
* {({ resetFilters, isFiltered }) => (
|
|
90
|
+
* <button
|
|
91
|
+
* onClick={resetFilters}
|
|
92
|
+
* disabled={!isFiltered}
|
|
93
|
+
* className={isFiltered ? 'active' : 'disabled'}
|
|
94
|
+
* >
|
|
95
|
+
* {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
|
|
96
|
+
* </button>
|
|
97
|
+
* )}
|
|
98
|
+
* </ProductListFilters.ResetTrigger>
|
|
99
|
+
* </ProductList.Root>
|
|
130
100
|
* );
|
|
131
101
|
* }
|
|
132
102
|
* ```
|
|
@@ -162,32 +132,37 @@ export interface PriceRangeRenderProps {
|
|
|
162
132
|
* @component
|
|
163
133
|
* @example
|
|
164
134
|
* ```tsx
|
|
165
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
135
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
166
136
|
*
|
|
167
137
|
* function PriceRangeFilter() {
|
|
168
138
|
* return (
|
|
169
|
-
* <
|
|
170
|
-
* {
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
139
|
+
* <ProductList.Root
|
|
140
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
141
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
142
|
+
* >
|
|
143
|
+
* <ProductListFilters.PriceRange>
|
|
144
|
+
* {({ minPrice, maxPrice, setSelectedMinPrice, setSelectedMaxPrice }) => (
|
|
145
|
+
* <div className="price-range">
|
|
146
|
+
* <h4>Price Range:</h4>
|
|
147
|
+
* <div className="price-inputs">
|
|
148
|
+
* <input
|
|
149
|
+
* type="number"
|
|
150
|
+
* value={minPrice}
|
|
151
|
+
* onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
|
|
152
|
+
* placeholder="Min"
|
|
153
|
+
* />
|
|
154
|
+
* <span>to</span>
|
|
155
|
+
* <input
|
|
156
|
+
* type="number"
|
|
157
|
+
* value={maxPrice}
|
|
158
|
+
* onChange={(e) => setSelectedMaxPrice(Number(e.target.value))}
|
|
159
|
+
* placeholder="Max"
|
|
160
|
+
* />
|
|
161
|
+
* </div>
|
|
187
162
|
* </div>
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* </
|
|
163
|
+
* )}
|
|
164
|
+
* </ProductListFilters.PriceRange>
|
|
165
|
+
* </ProductList.Root>
|
|
191
166
|
* );
|
|
192
167
|
* }
|
|
193
168
|
* ```
|
|
@@ -220,27 +195,32 @@ export interface ProductOptionRenderProps {
|
|
|
220
195
|
* @component
|
|
221
196
|
* @example
|
|
222
197
|
* ```tsx
|
|
223
|
-
* import { ProductListFilters } from '@wix/stores/components';
|
|
198
|
+
* import { ProductList, ProductListFilters } from '@wix/stores/components';
|
|
224
199
|
*
|
|
225
200
|
* function ProductOptionsFilter() {
|
|
226
201
|
* return (
|
|
227
|
-
* <
|
|
228
|
-
* {
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
202
|
+
* <ProductList.Root
|
|
203
|
+
* productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
|
|
204
|
+
* productsListSearchConfig={{ customizations: [] }}
|
|
205
|
+
* >
|
|
206
|
+
* <ProductListFilters.ProductOptions>
|
|
207
|
+
* {({ option, selectedChoices, toggleChoice }) => (
|
|
208
|
+
* <div key={option.id}>
|
|
209
|
+
* <h4>{option.name}</h4>
|
|
210
|
+
* {option.choices.map(choice => (
|
|
211
|
+
* <label key={choice.id}>
|
|
212
|
+
* <input
|
|
213
|
+
* type="checkbox"
|
|
214
|
+
* checked={selectedChoices.includes(choice.id)}
|
|
215
|
+
* onChange={() => toggleChoice(choice.id)}
|
|
216
|
+
* />
|
|
217
|
+
* {choice.name}
|
|
218
|
+
* </label>
|
|
219
|
+
* ))}
|
|
220
|
+
* </div>
|
|
221
|
+
* )}
|
|
222
|
+
* </ProductListFilters.ProductOptions>
|
|
223
|
+
* </ProductList.Root>
|
|
244
224
|
* );
|
|
245
225
|
* }
|
|
246
226
|
* ```
|