@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.
Files changed (41) hide show
  1. package/cjs/dist/react/ProductList.d.ts +31 -3
  2. package/cjs/dist/react/ProductList.js +33 -5
  3. package/cjs/dist/react/ProductListFilters.d.ts +100 -111
  4. package/cjs/dist/react/ProductListFilters.js +105 -115
  5. package/cjs/dist/react/ProductListPagination.d.ts +89 -96
  6. package/cjs/dist/react/ProductListPagination.js +96 -104
  7. package/cjs/dist/react/ProductListSort.d.ts +26 -57
  8. package/cjs/dist/react/ProductListSort.js +26 -58
  9. package/cjs/dist/services/index.d.ts +1 -3
  10. package/cjs/dist/services/index.js +1 -3
  11. package/cjs/dist/services/products-list-search-service.d.ts +220 -0
  12. package/cjs/dist/services/products-list-search-service.js +813 -0
  13. package/cjs/dist/services/products-list-service.d.ts +28 -11
  14. package/cjs/dist/services/products-list-service.js +26 -6
  15. package/dist/react/ProductList.d.ts +31 -3
  16. package/dist/react/ProductList.js +33 -5
  17. package/dist/react/ProductListFilters.d.ts +100 -111
  18. package/dist/react/ProductListFilters.js +105 -115
  19. package/dist/react/ProductListPagination.d.ts +89 -96
  20. package/dist/react/ProductListPagination.js +96 -104
  21. package/dist/react/ProductListSort.d.ts +26 -57
  22. package/dist/react/ProductListSort.js +26 -58
  23. package/dist/services/index.d.ts +1 -3
  24. package/dist/services/index.js +1 -3
  25. package/dist/services/products-list-search-service.d.ts +220 -0
  26. package/dist/services/products-list-search-service.js +813 -0
  27. package/dist/services/products-list-service.d.ts +28 -11
  28. package/dist/services/products-list-service.js +26 -6
  29. package/package.json +2 -2
  30. package/cjs/dist/services/products-list-filters-service.d.ts +0 -309
  31. package/cjs/dist/services/products-list-filters-service.js +0 -504
  32. package/cjs/dist/services/products-list-pagination-service.d.ts +0 -186
  33. package/cjs/dist/services/products-list-pagination-service.js +0 -179
  34. package/cjs/dist/services/products-list-sort-service.d.ts +0 -117
  35. package/cjs/dist/services/products-list-sort-service.js +0 -144
  36. package/dist/services/products-list-filters-service.d.ts +0 -309
  37. package/dist/services/products-list-filters-service.js +0 -504
  38. package/dist/services/products-list-pagination-service.d.ts +0 -186
  39. package/dist/services/products-list-pagination-service.js +0 -179
  40. package/dist/services/products-list-sort-service.d.ts +0 -117
  41. package/dist/services/products-list-sort-service.js +0 -144
@@ -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 the ProductList service context to its children.
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 "@wix/headless-stores/services";
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 the ProductList service context to its children.
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().addService(ProductsListServiceDefinition, ProductListService, props.productsListConfig), children: props.children }));
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 { InventoryStatusType, type ProductOption, ProductsListFiltersServiceConfig } from "../services/products-list-filters-service.js";
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";
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
- * <ProductListFilters.InventoryStatus>
72
- * {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
73
- * <div>
74
- * <h4>Inventory Status:</h4>
75
- * {availableInventoryStatuses.map(status => (
76
- * <label key={status}>
77
- * <input
78
- * type="checkbox"
79
- * checked={selectedInventoryStatuses.includes(status)}
80
- * onChange={() => toggleInventoryStatus(status)}
81
- * />
82
- * {status}
83
- * </label>
84
- * ))}
85
- * </div>
86
- * )}
87
- * </ProductListFilters.InventoryStatus>
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
- * <ProductListFilters.ResetTrigger>
120
- * {({ resetFilters, isFiltered }) => (
121
- * <button
122
- * onClick={resetFilters}
123
- * disabled={!isFiltered}
124
- * className={isFiltered ? 'active' : 'disabled'}
125
- * >
126
- * {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
127
- * </button>
128
- * )}
129
- * </ProductListFilters.ResetTrigger>
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
- * <ProductListFilters.PriceRange>
170
- * {({ minPrice, maxPrice, setSelectedMinPrice, setSelectedMaxPrice }) => (
171
- * <div className="price-range">
172
- * <h4>Price Range:</h4>
173
- * <div className="price-inputs">
174
- * <input
175
- * type="number"
176
- * value={minPrice}
177
- * onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
178
- * placeholder="Min"
179
- * />
180
- * <span>to</span>
181
- * <input
182
- * type="number"
183
- * value={maxPrice}
184
- * onChange={(e) => setSelectedMaxPrice(Number(e.target.value))}
185
- * placeholder="Max"
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
- * </div>
189
- * )}
190
- * </ProductListFilters.PriceRange>
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
- * <ProductListFilters.ProductOptions>
228
- * {({ option, selectedChoices, toggleChoice }) => (
229
- * <div key={option.id}>
230
- * <h4>{option.name}</h4>
231
- * {option.choices.map(choice => (
232
- * <label key={choice.id}>
233
- * <input
234
- * type="checkbox"
235
- * checked={selectedChoices.includes(choice.id)}
236
- * onChange={() => toggleChoice(choice.id)}
237
- * />
238
- * {choice.name}
239
- * </label>
240
- * ))}
241
- * </div>
242
- * )}
243
- * </ProductListFilters.ProductOptions>
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
  * ```