@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,76 +1,44 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { createServicesMap } from "@wix/services-manager";
3
- import { useService, WixServices } from "@wix/services-manager-react";
4
- import { ProductsListFiltersService, ProductsListFiltersServiceDefinition, } from "../services/products-list-filters-service.js";
5
- /**
6
- * Root component that provides the ProductListFilters service context to its children.
7
- * This component sets up the necessary services for managing products list filters.
8
- *
9
- * @order 1
10
- * @component
11
- * @example
12
- * ```tsx
13
- * import { ProductListFilters } from '@wix/stores/components';
14
- *
15
- * function FiltersSection() {
16
- * return (
17
- * <ProductListFilters.Root
18
- * productsListFiltersConfig={{
19
- * minPrice: 0,
20
- * maxPrice: 1000
21
- * }}
22
- * >
23
- * <ProductListFilters.MinPrice>
24
- * {({ minPrice, setSelectedMinPrice }) => (
25
- * <input
26
- * type="number"
27
- * value={minPrice}
28
- * onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
29
- * placeholder="Min price"
30
- * />
31
- * )}
32
- * </ProductListFilters.MinPrice>
33
- * </ProductListFilters.Root>
34
- * );
35
- * }
36
- * ```
37
- */
38
- export function Root(props) {
39
- return (_jsx(WixServices, { servicesMap: createServicesMap().addService(ProductsListFiltersServiceDefinition, ProductsListFiltersService, props.productsListFiltersConfig), children: props.children }));
40
- }
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useService } from "@wix/services-manager-react";
3
+ import { ProductsListSearchServiceDefinition, } from "../services/products-list-search-service.js";
41
4
  /**
42
5
  * Headless component for managing inventory status filters
43
6
  *
44
7
  * @component
45
8
  * @example
46
9
  * ```tsx
47
- * import { ProductListFilters } from '@wix/stores/components';
10
+ * import { ProductList, ProductListFilters } from '@wix/stores/components';
48
11
  *
49
12
  * function InventoryStatusFilter() {
50
13
  * return (
51
- * <ProductListFilters.InventoryStatus>
52
- * {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
53
- * <div>
54
- * <h4>Inventory Status:</h4>
55
- * {availableInventoryStatuses.map(status => (
56
- * <label key={status}>
57
- * <input
58
- * type="checkbox"
59
- * checked={selectedInventoryStatuses.includes(status)}
60
- * onChange={() => toggleInventoryStatus(status)}
61
- * />
62
- * {status}
63
- * </label>
64
- * ))}
65
- * </div>
66
- * )}
67
- * </ProductListFilters.InventoryStatus>
14
+ * <ProductList.Root
15
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
16
+ * productsListSearchConfig={{ customizations: [] }}
17
+ * >
18
+ * <ProductListFilters.InventoryStatus>
19
+ * {({ availableInventoryStatuses, selectedInventoryStatuses, toggleInventoryStatus }) => (
20
+ * <div>
21
+ * <h4>Inventory Status:</h4>
22
+ * {availableInventoryStatuses.map(status => (
23
+ * <label key={status}>
24
+ * <input
25
+ * type="checkbox"
26
+ * checked={selectedInventoryStatuses.includes(status)}
27
+ * onChange={() => toggleInventoryStatus(status)}
28
+ * />
29
+ * {status}
30
+ * </label>
31
+ * ))}
32
+ * </div>
33
+ * )}
34
+ * </ProductListFilters.InventoryStatus>
35
+ * </ProductList.Root>
68
36
  * );
69
37
  * }
70
38
  * ```
71
39
  */
72
40
  export function InventoryStatus(props) {
73
- const service = useService(ProductsListFiltersServiceDefinition);
41
+ const service = useService(ProductsListSearchServiceDefinition);
74
42
  const availableInventoryStatuses = service.availableInventoryStatuses.get();
75
43
  const selectedInventoryStatuses = service.selectedInventoryStatuses.get();
76
44
  const toggleInventoryStatus = service.toggleInventoryStatus;
@@ -88,27 +56,32 @@ export function InventoryStatus(props) {
88
56
  * @component
89
57
  * @example
90
58
  * ```tsx
91
- * import { ProductListFilters } from '@wix/stores/components';
59
+ * import { ProductList, ProductListFilters } from '@wix/stores/components';
92
60
  *
93
61
  * function ResetFiltersButton() {
94
62
  * return (
95
- * <ProductListFilters.ResetTrigger>
96
- * {({ resetFilters, isFiltered }) => (
97
- * <button
98
- * onClick={resetFilters}
99
- * disabled={!isFiltered}
100
- * className={isFiltered ? 'active' : 'disabled'}
101
- * >
102
- * {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
103
- * </button>
104
- * )}
105
- * </ProductListFilters.ResetTrigger>
63
+ * <ProductList.Root
64
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
65
+ * productsListSearchConfig={{ customizations: [] }}
66
+ * >
67
+ * <ProductListFilters.ResetTrigger>
68
+ * {({ resetFilters, isFiltered }) => (
69
+ * <button
70
+ * onClick={resetFilters}
71
+ * disabled={!isFiltered}
72
+ * className={isFiltered ? 'active' : 'disabled'}
73
+ * >
74
+ * {isFiltered ? 'Clear Filters' : 'No Filters Applied'}
75
+ * </button>
76
+ * )}
77
+ * </ProductListFilters.ResetTrigger>
78
+ * </ProductList.Root>
106
79
  * );
107
80
  * }
108
81
  * ```
109
82
  */
110
83
  export function ResetTrigger(props) {
111
- const service = useService(ProductsListFiltersServiceDefinition);
84
+ const service = useService(ProductsListSearchServiceDefinition);
112
85
  const resetFilters = service.reset;
113
86
  const isFiltered = service.isFiltered.get();
114
87
  return typeof props.children === "function"
@@ -121,41 +94,46 @@ export function ResetTrigger(props) {
121
94
  * @component
122
95
  * @example
123
96
  * ```tsx
124
- * import { ProductListFilters } from '@wix/stores/components';
97
+ * import { ProductList, ProductListFilters } from '@wix/stores/components';
125
98
  *
126
99
  * function PriceRangeFilter() {
127
100
  * return (
128
- * <ProductListFilters.PriceRange>
129
- * {({ minPrice, maxPrice, setSelectedMinPrice, setSelectedMaxPrice }) => (
130
- * <div className="price-range">
131
- * <h4>Price Range:</h4>
132
- * <div className="price-inputs">
133
- * <input
134
- * type="number"
135
- * value={minPrice}
136
- * onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
137
- * placeholder="Min"
138
- * />
139
- * <span>to</span>
140
- * <input
141
- * type="number"
142
- * value={maxPrice}
143
- * onChange={(e) => setSelectedMaxPrice(Number(e.target.value))}
144
- * placeholder="Max"
145
- * />
101
+ * <ProductList.Root
102
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
103
+ * productsListSearchConfig={{ customizations: [] }}
104
+ * >
105
+ * <ProductListFilters.PriceRange>
106
+ * {({ minPrice, maxPrice, setSelectedMinPrice, setSelectedMaxPrice }) => (
107
+ * <div className="price-range">
108
+ * <h4>Price Range:</h4>
109
+ * <div className="price-inputs">
110
+ * <input
111
+ * type="number"
112
+ * value={minPrice}
113
+ * onChange={(e) => setSelectedMinPrice(Number(e.target.value))}
114
+ * placeholder="Min"
115
+ * />
116
+ * <span>to</span>
117
+ * <input
118
+ * type="number"
119
+ * value={maxPrice}
120
+ * onChange={(e) => setSelectedMaxPrice(Number(e.target.value))}
121
+ * placeholder="Max"
122
+ * />
123
+ * </div>
146
124
  * </div>
147
- * </div>
148
- * )}
149
- * </ProductListFilters.PriceRange>
125
+ * )}
126
+ * </ProductListFilters.PriceRange>
127
+ * </ProductList.Root>
150
128
  * );
151
129
  * }
152
130
  * ```
153
131
  */
154
132
  export function PriceRange(props) {
155
- const service = useService(ProductsListFiltersServiceDefinition);
133
+ const service = useService(ProductsListSearchServiceDefinition);
156
134
  const selectedMinPrice = service.selectedMinPrice.get();
157
- const availableMinPrice = service.availableMinPrice.get();
158
135
  const selectedMaxPrice = service.selectedMaxPrice.get();
136
+ const availableMinPrice = service.availableMinPrice.get();
159
137
  const availableMaxPrice = service.availableMaxPrice.get();
160
138
  const setSelectedMinPrice = service.setSelectedMinPrice;
161
139
  const setSelectedMaxPrice = service.setSelectedMaxPrice;
@@ -170,6 +148,13 @@ export function PriceRange(props) {
170
148
  })
171
149
  : props.children;
172
150
  }
151
+ export function CategoryFilter(props) {
152
+ const service = useService(ProductsListSearchServiceDefinition);
153
+ const selectedCategory = service.selectedCategory.get();
154
+ return typeof props.children === "function"
155
+ ? props.children({ selectedCategory })
156
+ : props.children;
157
+ }
173
158
  /**
174
159
  * Headless component that renders content for each product option in the list.
175
160
  * Maps over all available product options and provides each option through a render prop.
@@ -179,33 +164,38 @@ export function PriceRange(props) {
179
164
  * @component
180
165
  * @example
181
166
  * ```tsx
182
- * import { ProductListFilters } from '@wix/stores/components';
167
+ * import { ProductList, ProductListFilters } from '@wix/stores/components';
183
168
  *
184
169
  * function ProductOptionsFilter() {
185
170
  * return (
186
- * <ProductListFilters.ProductOptions>
187
- * {({ option, selectedChoices, toggleChoice }) => (
188
- * <div key={option.id}>
189
- * <h4>{option.name}</h4>
190
- * {option.choices.map(choice => (
191
- * <label key={choice.id}>
192
- * <input
193
- * type="checkbox"
194
- * checked={selectedChoices.includes(choice.id)}
195
- * onChange={() => toggleChoice(choice.id)}
196
- * />
197
- * {choice.name}
198
- * </label>
199
- * ))}
200
- * </div>
201
- * )}
202
- * </ProductListFilters.ProductOptions>
171
+ * <ProductList.Root
172
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
173
+ * productsListSearchConfig={{ customizations: [] }}
174
+ * >
175
+ * <ProductListFilters.ProductOptions>
176
+ * {({ option, selectedChoices, toggleChoice }) => (
177
+ * <div key={option.id}>
178
+ * <h4>{option.name}</h4>
179
+ * {option.choices.map(choice => (
180
+ * <label key={choice.id}>
181
+ * <input
182
+ * type="checkbox"
183
+ * checked={selectedChoices.includes(choice.id)}
184
+ * onChange={() => toggleChoice(choice.id)}
185
+ * />
186
+ * {choice.name}
187
+ * </label>
188
+ * ))}
189
+ * </div>
190
+ * )}
191
+ * </ProductListFilters.ProductOptions>
192
+ * </ProductList.Root>
203
193
  * );
204
194
  * }
205
195
  * ```
206
196
  */
207
197
  export function ProductOptions(props) {
208
- const service = useService(ProductsListFiltersServiceDefinition);
198
+ const service = useService(ProductsListSearchServiceDefinition);
209
199
  const availableOptions = service.availableProductOptions.get();
210
200
  const selectedProductOptions = service.selectedProductOptions.get();
211
201
  // Don't render if no options are available
@@ -1,35 +1,3 @@
1
- export interface RootProps {
2
- children: React.ReactNode;
3
- }
4
- /**
5
- * Root component that provides the ProductListPagination service context to its children.
6
- * This component sets up the necessary services for managing products list pagination.
7
- *
8
- * @order 1
9
- * @component
10
- * @example
11
- * ```tsx
12
- * import { ProductListPagination } from '@wix/stores/components';
13
- *
14
- * function PaginationSection() {
15
- * return (
16
- * <ProductListPagination.Root>
17
- * <ProductListPagination.NextPageTrigger>
18
- * {({ nextPage, hasNextPage }) => (
19
- * <button
20
- * onClick={nextPage}
21
- * disabled={!hasNextPage}
22
- * >
23
- * Next Page
24
- * </button>
25
- * )}
26
- * </ProductListPagination.NextPageTrigger>
27
- * </ProductListPagination.Root>
28
- * );
29
- * }
30
- * ```
31
- */
32
- export declare function Root(props: RootProps): React.ReactNode;
33
1
  /**
34
2
  * Props for PageSize headless component
35
3
  */
@@ -52,25 +20,30 @@ export interface PageSizeRenderProps {
52
20
  * @component
53
21
  * @example
54
22
  * ```tsx
55
- * import { ProductListPagination } from '@wix/stores/components';
23
+ * import { ProductList, ProductListPagination } from '@wix/stores/components';
56
24
  *
57
25
  * function PageSizeSelector() {
58
26
  * return (
59
- * <ProductListPagination.PageSize>
60
- * {({ currentLimit, setLimit }) => (
61
- * <div>
62
- * <label>Items per page:</label>
63
- * <select
64
- * value={currentLimit}
65
- * onChange={(e) => setLimit(Number(e.target.value))}
66
- * >
67
- * <option value={10}>10</option>
68
- * <option value={20}>20</option>
69
- * <option value={50}>50</option>
70
- * </select>
71
- * </div>
72
- * )}
73
- * </ProductListPagination.PageSize>
27
+ * <ProductList.Root
28
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
29
+ * productsListSearchConfig={{ customizations: [] }}
30
+ * >
31
+ * <ProductListPagination.PageSize>
32
+ * {({ currentLimit, setLimit }) => (
33
+ * <div>
34
+ * <label>Items per page:</label>
35
+ * <select
36
+ * value={currentLimit}
37
+ * onChange={(e) => setLimit(Number(e.target.value))}
38
+ * >
39
+ * <option value={10}>10</option>
40
+ * <option value={20}>20</option>
41
+ * <option value={50}>50</option>
42
+ * </select>
43
+ * </div>
44
+ * )}
45
+ * </ProductListPagination.PageSize>
46
+ * </ProductList.Root>
74
47
  * );
75
48
  * }
76
49
  * ```
@@ -98,21 +71,26 @@ export interface NextPageTriggerRenderProps {
98
71
  * @component
99
72
  * @example
100
73
  * ```tsx
101
- * import { ProductListPagination } from '@wix/stores/components';
74
+ * import { ProductList, ProductListPagination } from '@wix/stores/components';
102
75
  *
103
76
  * function NextPageButton() {
104
77
  * return (
105
- * <ProductListPagination.NextPageTrigger>
106
- * {({ nextPage, hasNextPage }) => (
107
- * <button
108
- * onClick={nextPage}
109
- * disabled={!hasNextPage}
110
- * className={hasNextPage ? 'enabled' : 'disabled'}
111
- * >
112
- * Next →
113
- * </button>
114
- * )}
115
- * </ProductListPagination.NextPageTrigger>
78
+ * <ProductList.Root
79
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
80
+ * productsListSearchConfig={{ customizations: [] }}
81
+ * >
82
+ * <ProductListPagination.NextPageTrigger>
83
+ * {({ nextPage, hasNextPage }) => (
84
+ * <button
85
+ * onClick={nextPage}
86
+ * disabled={!hasNextPage}
87
+ * className={hasNextPage ? 'enabled' : 'disabled'}
88
+ * >
89
+ * Next →
90
+ * </button>
91
+ * )}
92
+ * </ProductListPagination.NextPageTrigger>
93
+ * </ProductList.Root>
116
94
  * );
117
95
  * }
118
96
  * ```
@@ -140,21 +118,26 @@ export interface PreviousPageTriggerRenderProps {
140
118
  * @component
141
119
  * @example
142
120
  * ```tsx
143
- * import { ProductListPagination } from '@wix/stores/components';
121
+ * import { ProductList, ProductListPagination } from '@wix/stores/components';
144
122
  *
145
123
  * function PrevPageButton() {
146
124
  * return (
147
- * <ProductListPagination.PreviousPageTrigger>
148
- * {({ prevPage, hasPrevPage }) => (
149
- * <button
150
- * onClick={prevPage}
151
- * disabled={!hasPrevPage}
152
- * className={hasPrevPage ? 'enabled' : 'disabled'}
153
- * >
154
- * ← Previous
155
- * </button>
156
- * )}
157
- * </ProductListPagination.PreviousPageTrigger>
125
+ * <ProductList.Root
126
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
127
+ * productsListSearchConfig={{ customizations: [] }}
128
+ * >
129
+ * <ProductListPagination.PreviousPageTrigger>
130
+ * {({ prevPage, hasPrevPage }) => (
131
+ * <button
132
+ * onClick={prevPage}
133
+ * disabled={!hasPrevPage}
134
+ * className={hasPrevPage ? 'enabled' : 'disabled'}
135
+ * >
136
+ * ← Previous
137
+ * </button>
138
+ * )}
139
+ * </ProductListPagination.PreviousPageTrigger>
140
+ * </ProductList.Root>
158
141
  * );
159
142
  * }
160
143
  * ```
@@ -182,21 +165,26 @@ export interface FirstPageTriggerRenderProps {
182
165
  * @component
183
166
  * @example
184
167
  * ```tsx
185
- * import { ProductListPagination } from '@wix/stores/components';
168
+ * import { ProductList, ProductListPagination } from '@wix/stores/components';
186
169
  *
187
170
  * function FirstPageButton() {
188
171
  * return (
189
- * <ProductListPagination.FirstPageTrigger>
190
- * {({ navigateToFirstPage, hasPrevPage }) => (
191
- * <button
192
- * onClick={navigateToFirstPage}
193
- * disabled={!hasPrevPage}
194
- * title="Go to first page"
195
- * >
196
- * ⏮ First
197
- * </button>
198
- * )}
199
- * </ProductListPagination.FirstPageTrigger>
172
+ * <ProductList.Root
173
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
174
+ * productsListSearchConfig={{ customizations: [] }}
175
+ * >
176
+ * <ProductListPagination.FirstPageTrigger>
177
+ * {({ navigateToFirstPage, hasPrevPage }) => (
178
+ * <button
179
+ * onClick={navigateToFirstPage}
180
+ * disabled={!hasPrevPage}
181
+ * title="Go to first page"
182
+ * >
183
+ * ⏮ First
184
+ * </button>
185
+ * )}
186
+ * </ProductListPagination.FirstPageTrigger>
187
+ * </ProductList.Root>
200
188
  * );
201
189
  * }
202
190
  * ```
@@ -226,21 +214,26 @@ export interface LoadMoreTriggerRenderProps {
226
214
  * @component
227
215
  * @example
228
216
  * ```tsx
229
- * import { ProductListPagination } from '@wix/stores/components';
217
+ * import { ProductList, ProductListPagination } from '@wix/stores/components';
230
218
  *
231
219
  * function LoadMoreButton() {
232
220
  * return (
233
- * <ProductListPagination.LoadMoreTrigger>
234
- * {({ loadMore, hasMoreProducts, isLoading }) => (
235
- * <button
236
- * onClick={() => loadMore(10)}
237
- * disabled={!hasMoreProducts || isLoading}
238
- * className="load-more-btn"
239
- * >
240
- * {isLoading ? 'Loading...' : hasMoreProducts ? 'Load More' : 'No More Products'}
241
- * </button>
242
- * )}
243
- * </ProductListPagination.LoadMoreTrigger>
221
+ * <ProductList.Root
222
+ * productsListConfig={{ products: [], searchOptions: {}, pagingMetadata: {}, aggregations: {} }}
223
+ * productsListSearchConfig={{ customizations: [] }}
224
+ * >
225
+ * <ProductListPagination.LoadMoreTrigger>
226
+ * {({ loadMore, hasMoreProducts, isLoading }) => (
227
+ * <button
228
+ * onClick={() => loadMore(10)}
229
+ * disabled={!hasMoreProducts || isLoading}
230
+ * className="load-more-btn"
231
+ * >
232
+ * {isLoading ? 'Loading...' : hasMoreProducts ? 'Load More' : 'No More Products'}
233
+ * </button>
234
+ * )}
235
+ * </ProductListPagination.LoadMoreTrigger>
236
+ * </ProductList.Root>
244
237
  * );
245
238
  * }
246
239
  * ```