@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,309 +0,0 @@
|
|
|
1
|
-
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
|
-
import { customizationsV3 } from "@wix/stores";
|
|
3
|
-
/**
|
|
4
|
-
* Interface representing a product option (like Size, Color, etc.).
|
|
5
|
-
* Contains the option metadata and available choices.
|
|
6
|
-
*
|
|
7
|
-
* @interface ProductOption
|
|
8
|
-
*/
|
|
9
|
-
export interface ProductOption {
|
|
10
|
-
/** Unique identifier for the product option */
|
|
11
|
-
id: string;
|
|
12
|
-
/** Display name of the option (e.g., "Size", "Color") */
|
|
13
|
-
name: string;
|
|
14
|
-
/** Array of available choices for this option */
|
|
15
|
-
choices: ProductChoice[];
|
|
16
|
-
/** Optional render type for UI display purposes */
|
|
17
|
-
optionRenderType?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Interface representing a choice within a product option.
|
|
21
|
-
* For example, "Red" would be a choice within a "Color" option.
|
|
22
|
-
*
|
|
23
|
-
* @interface ProductChoice
|
|
24
|
-
*/
|
|
25
|
-
export interface ProductChoice {
|
|
26
|
-
/** Unique identifier for the choice */
|
|
27
|
-
id: string;
|
|
28
|
-
/** Display name of the choice (e.g., "Red", "Large") */
|
|
29
|
-
name: string;
|
|
30
|
-
/** Optional color code for color-based choices */
|
|
31
|
-
colorCode?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Enumeration of inventory status types available for filtering.
|
|
35
|
-
* Maps to the Wix Stores API inventory availability statuses.
|
|
36
|
-
*
|
|
37
|
-
* @enum {string}
|
|
38
|
-
*/
|
|
39
|
-
export declare enum InventoryStatusType {
|
|
40
|
-
/** Product is in stock and available for purchase */
|
|
41
|
-
IN_STOCK = "IN_STOCK",
|
|
42
|
-
/** Product is out of stock */
|
|
43
|
-
OUT_OF_STOCK = "OUT_OF_STOCK",
|
|
44
|
-
/** Product is partially out of stock (some variants available) */
|
|
45
|
-
PARTIALLY_OUT_OF_STOCK = "PARTIALLY_OUT_OF_STOCK"
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Configuration interface for the Products List Filters service.
|
|
49
|
-
* Contains customizations data used to build filter options.
|
|
50
|
-
*
|
|
51
|
-
* @interface ProductsListFiltersServiceConfig
|
|
52
|
-
*/
|
|
53
|
-
export type ProductsListFiltersServiceConfig = {
|
|
54
|
-
/** Array of product customizations for building filter options */
|
|
55
|
-
customizations: customizationsV3.Customization[];
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Loads products list filters service configuration from the Wix Stores API for SSR initialization.
|
|
59
|
-
* This function fetches customization data that will be used to build product filter options.
|
|
60
|
-
*
|
|
61
|
-
* @returns {Promise<ProductsListFiltersServiceConfig>} Promise that resolves to the filters configuration
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```astro
|
|
65
|
-
* ---
|
|
66
|
-
* // Astro page example - pages/products.astro
|
|
67
|
-
* import { loadProductsListFiltersServiceConfig } from '@wix/stores/services';
|
|
68
|
-
* import { ProductsListFilters } from '@wix/stores/components';
|
|
69
|
-
*
|
|
70
|
-
* // Load filters configuration during SSR
|
|
71
|
-
* const filtersConfig = await loadProductsListFiltersServiceConfig();
|
|
72
|
-
* ---
|
|
73
|
-
*
|
|
74
|
-
* <ProductsListFilters.Root filtersConfig={filtersConfig}>
|
|
75
|
-
* <ProductsListFilters.MinPrice>
|
|
76
|
-
* {({ minPrice, setMinPrice }) => (
|
|
77
|
-
* <input
|
|
78
|
-
* type="number"
|
|
79
|
-
* value={minPrice}
|
|
80
|
-
* onChange={(e) => setMinPrice(parseFloat(e.target.value))}
|
|
81
|
-
* placeholder="Min Price"
|
|
82
|
-
* />
|
|
83
|
-
* )}
|
|
84
|
-
* </ProductsListFilters.MinPrice>
|
|
85
|
-
* </ProductsListFilters.Root>
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```tsx
|
|
90
|
-
* // Next.js page example
|
|
91
|
-
* import { GetServerSideProps } from 'next';
|
|
92
|
-
* import { loadProductsListFiltersServiceConfig } from '@wix/stores/services';
|
|
93
|
-
*
|
|
94
|
-
* export const getServerSideProps: GetServerSideProps = async () => {
|
|
95
|
-
* const filtersConfig = await loadProductsListFiltersServiceConfig();
|
|
96
|
-
*
|
|
97
|
-
* return {
|
|
98
|
-
* props: {
|
|
99
|
-
* filtersConfig,
|
|
100
|
-
* },
|
|
101
|
-
* };
|
|
102
|
-
* };
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
export declare function loadProductsListFiltersServiceConfig(): Promise<ProductsListFiltersServiceConfig>;
|
|
106
|
-
/**
|
|
107
|
-
* Service definition for the Products List Filters service.
|
|
108
|
-
* This defines the reactive API contract for managing product list filtering capabilities
|
|
109
|
-
* including price, inventory status, and product option filters.
|
|
110
|
-
*
|
|
111
|
-
* @constant
|
|
112
|
-
*/
|
|
113
|
-
export declare const ProductsListFiltersServiceDefinition: string & {
|
|
114
|
-
__api: {
|
|
115
|
-
/** Reactive signal containing the user's selected minimum price filter value */
|
|
116
|
-
selectedMinPrice: Signal<number>;
|
|
117
|
-
/** Reactive signal containing the user's selected maximum price filter value */
|
|
118
|
-
selectedMaxPrice: Signal<number>;
|
|
119
|
-
/** Reactive signal containing the catalog minimum price (for UI bounds) */
|
|
120
|
-
availableMinPrice: Signal<number>;
|
|
121
|
-
/** Reactive signal containing the catalog maximum price (for UI bounds) */
|
|
122
|
-
availableMaxPrice: Signal<number>;
|
|
123
|
-
/** Reactive signal containing available inventory status options */
|
|
124
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
125
|
-
/** Reactive signal containing selected inventory status filters */
|
|
126
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
127
|
-
/** Reactive signal containing available product options for filtering */
|
|
128
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
129
|
-
/** Reactive signal containing selected product option filters */
|
|
130
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
131
|
-
/** Function to set the minimum price filter */
|
|
132
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
133
|
-
/** Function to set the maximum price filter */
|
|
134
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
135
|
-
/** Function to toggle an inventory status filter */
|
|
136
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
137
|
-
/** Function to toggle a product option choice filter */
|
|
138
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
139
|
-
/** Reactive signal indicating if any filters are currently applied */
|
|
140
|
-
isFiltered: Signal<boolean>;
|
|
141
|
-
/** Function to reset all filters to their default state */
|
|
142
|
-
reset: () => void;
|
|
143
|
-
};
|
|
144
|
-
__config: {};
|
|
145
|
-
isServiceDefinition?: boolean;
|
|
146
|
-
} & {
|
|
147
|
-
/** Reactive signal containing the user's selected minimum price filter value */
|
|
148
|
-
selectedMinPrice: Signal<number>;
|
|
149
|
-
/** Reactive signal containing the user's selected maximum price filter value */
|
|
150
|
-
selectedMaxPrice: Signal<number>;
|
|
151
|
-
/** Reactive signal containing the catalog minimum price (for UI bounds) */
|
|
152
|
-
availableMinPrice: Signal<number>;
|
|
153
|
-
/** Reactive signal containing the catalog maximum price (for UI bounds) */
|
|
154
|
-
availableMaxPrice: Signal<number>;
|
|
155
|
-
/** Reactive signal containing available inventory status options */
|
|
156
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
157
|
-
/** Reactive signal containing selected inventory status filters */
|
|
158
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
159
|
-
/** Reactive signal containing available product options for filtering */
|
|
160
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
161
|
-
/** Reactive signal containing selected product option filters */
|
|
162
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
163
|
-
/** Function to set the minimum price filter */
|
|
164
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
165
|
-
/** Function to set the maximum price filter */
|
|
166
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
167
|
-
/** Function to toggle an inventory status filter */
|
|
168
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
169
|
-
/** Function to toggle a product option choice filter */
|
|
170
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
171
|
-
/** Reactive signal indicating if any filters are currently applied */
|
|
172
|
-
isFiltered: Signal<boolean>;
|
|
173
|
-
/** Function to reset all filters to their default state */
|
|
174
|
-
reset: () => void;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Implementation of the Products List Filters service that manages reactive filtering state.
|
|
178
|
-
* This service provides signals for all filter types (price, inventory, product options) and
|
|
179
|
-
* automatically updates the products list search options when filters change.
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```tsx
|
|
183
|
-
* import { ProductsListFiltersService, ProductsListFiltersServiceDefinition } from '@wix/stores/services';
|
|
184
|
-
* import { useService } from '@wix/services-manager-react';
|
|
185
|
-
*
|
|
186
|
-
* function FiltersComponent({ filtersConfig }) {
|
|
187
|
-
* return (
|
|
188
|
-
* <ServiceProvider services={createServicesMap([
|
|
189
|
-
* [ProductsListFiltersServiceDefinition, ProductsListFiltersService.withConfig(filtersConfig)]
|
|
190
|
-
* ])}>
|
|
191
|
-
* <FilterControls />
|
|
192
|
-
* </ServiceProvider>
|
|
193
|
-
* );
|
|
194
|
-
* }
|
|
195
|
-
*
|
|
196
|
-
* function FilterControls() {
|
|
197
|
-
* const filtersService = useService(ProductsListFiltersServiceDefinition);
|
|
198
|
-
* const minPrice = filtersService.minPrice.get();
|
|
199
|
-
* const maxPrice = filtersService.maxPrice.get();
|
|
200
|
-
* const selectedInventoryStatuses = filtersService.selectedInventoryStatuses.get();
|
|
201
|
-
* const availableProductOptions = filtersService.availableProductOptions.get();
|
|
202
|
-
* const isFiltered = filtersService.isFiltered.get();
|
|
203
|
-
*
|
|
204
|
-
* return (
|
|
205
|
-
* <div>
|
|
206
|
-
* <div>
|
|
207
|
-
* <input
|
|
208
|
-
* type="number"
|
|
209
|
-
* value={minPrice}
|
|
210
|
-
* onChange={(e) => filtersService.setMinPrice(parseFloat(e.target.value))}
|
|
211
|
-
* placeholder="Min Price"
|
|
212
|
-
* />
|
|
213
|
-
* <input
|
|
214
|
-
* type="number"
|
|
215
|
-
* value={maxPrice}
|
|
216
|
-
* onChange={(e) => filtersService.setMaxPrice(parseFloat(e.target.value))}
|
|
217
|
-
* placeholder="Max Price"
|
|
218
|
-
* />
|
|
219
|
-
* </div>
|
|
220
|
-
*
|
|
221
|
-
* {availableProductOptions.map(option => (
|
|
222
|
-
* <div key={option.id}>
|
|
223
|
-
* <h4>{option.name}</h4>
|
|
224
|
-
* {option.choices.map(choice => (
|
|
225
|
-
* <label key={choice.id}>
|
|
226
|
-
* <input
|
|
227
|
-
* type="checkbox"
|
|
228
|
-
* onChange={() => filtersService.toggleProductOption(option.id, choice.id)}
|
|
229
|
-
* />
|
|
230
|
-
* {choice.name}
|
|
231
|
-
* </label>
|
|
232
|
-
* ))}
|
|
233
|
-
* </div>
|
|
234
|
-
* ))}
|
|
235
|
-
*
|
|
236
|
-
* {isFiltered && (
|
|
237
|
-
* <button onClick={() => filtersService.reset()}>
|
|
238
|
-
* Clear All Filters
|
|
239
|
-
* </button>
|
|
240
|
-
* )}
|
|
241
|
-
* </div>
|
|
242
|
-
* );
|
|
243
|
-
* }
|
|
244
|
-
* }
|
|
245
|
-
* ```
|
|
246
|
-
*/
|
|
247
|
-
export declare const ProductsListFiltersService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
248
|
-
__api: {
|
|
249
|
-
/** Reactive signal containing the user's selected minimum price filter value */
|
|
250
|
-
selectedMinPrice: Signal<number>;
|
|
251
|
-
/** Reactive signal containing the user's selected maximum price filter value */
|
|
252
|
-
selectedMaxPrice: Signal<number>;
|
|
253
|
-
/** Reactive signal containing the catalog minimum price (for UI bounds) */
|
|
254
|
-
availableMinPrice: Signal<number>;
|
|
255
|
-
/** Reactive signal containing the catalog maximum price (for UI bounds) */
|
|
256
|
-
availableMaxPrice: Signal<number>;
|
|
257
|
-
/** Reactive signal containing available inventory status options */
|
|
258
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
259
|
-
/** Reactive signal containing selected inventory status filters */
|
|
260
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
261
|
-
/** Reactive signal containing available product options for filtering */
|
|
262
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
263
|
-
/** Reactive signal containing selected product option filters */
|
|
264
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
265
|
-
/** Function to set the minimum price filter */
|
|
266
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
267
|
-
/** Function to set the maximum price filter */
|
|
268
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
269
|
-
/** Function to toggle an inventory status filter */
|
|
270
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
271
|
-
/** Function to toggle a product option choice filter */
|
|
272
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
273
|
-
/** Reactive signal indicating if any filters are currently applied */
|
|
274
|
-
isFiltered: Signal<boolean>;
|
|
275
|
-
/** Function to reset all filters to their default state */
|
|
276
|
-
reset: () => void;
|
|
277
|
-
};
|
|
278
|
-
__config: {};
|
|
279
|
-
isServiceDefinition?: boolean;
|
|
280
|
-
} & {
|
|
281
|
-
/** Reactive signal containing the user's selected minimum price filter value */
|
|
282
|
-
selectedMinPrice: Signal<number>;
|
|
283
|
-
/** Reactive signal containing the user's selected maximum price filter value */
|
|
284
|
-
selectedMaxPrice: Signal<number>;
|
|
285
|
-
/** Reactive signal containing the catalog minimum price (for UI bounds) */
|
|
286
|
-
availableMinPrice: Signal<number>;
|
|
287
|
-
/** Reactive signal containing the catalog maximum price (for UI bounds) */
|
|
288
|
-
availableMaxPrice: Signal<number>;
|
|
289
|
-
/** Reactive signal containing available inventory status options */
|
|
290
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
291
|
-
/** Reactive signal containing selected inventory status filters */
|
|
292
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
293
|
-
/** Reactive signal containing available product options for filtering */
|
|
294
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
295
|
-
/** Reactive signal containing selected product option filters */
|
|
296
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
297
|
-
/** Function to set the minimum price filter */
|
|
298
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
299
|
-
/** Function to set the maximum price filter */
|
|
300
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
301
|
-
/** Function to toggle an inventory status filter */
|
|
302
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
303
|
-
/** Function to toggle a product option choice filter */
|
|
304
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
305
|
-
/** Reactive signal indicating if any filters are currently applied */
|
|
306
|
-
isFiltered: Signal<boolean>;
|
|
307
|
-
/** Function to reset all filters to their default state */
|
|
308
|
-
reset: () => void;
|
|
309
|
-
}, ProductsListFiltersServiceConfig>;
|