@wix/headless-stores 0.0.57 → 0.0.59
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 +0 -2
- package/cjs/dist/react/ProductList.js +3 -2
- package/cjs/dist/react/ProductListSort.d.ts +14 -0
- package/cjs/dist/react/ProductListSort.js +14 -0
- package/cjs/dist/react/core/ProductList.d.ts +3 -3
- package/cjs/dist/react/core/ProductList.js +3 -3
- package/cjs/dist/react/core/ProductListFilters.d.ts +8 -180
- package/cjs/dist/react/core/ProductListFilters.js +137 -171
- package/cjs/dist/react/core/ProductListPagination.d.ts +0 -192
- package/cjs/dist/react/core/ProductListPagination.js +2 -160
- package/cjs/dist/react/core/ProductListSort.d.ts +9 -57
- package/cjs/dist/react/core/ProductListSort.js +32 -52
- package/cjs/dist/services/index.d.ts +1 -2
- package/cjs/dist/services/index.js +1 -2
- package/cjs/dist/services/products-list-search-service.d.ts +1 -287
- package/cjs/dist/services/products-list-search-service.js +1 -900
- package/cjs/dist/services/products-list-service.d.ts +150 -4
- package/cjs/dist/services/products-list-service.js +537 -4
- package/dist/react/ProductList.d.ts +0 -2
- package/dist/react/ProductList.js +3 -2
- package/dist/react/ProductListSort.d.ts +14 -0
- package/dist/react/ProductListSort.js +14 -0
- package/dist/react/core/ProductList.d.ts +3 -3
- package/dist/react/core/ProductList.js +3 -3
- package/dist/react/core/ProductListFilters.d.ts +8 -180
- package/dist/react/core/ProductListFilters.js +137 -171
- package/dist/react/core/ProductListPagination.d.ts +0 -192
- package/dist/react/core/ProductListPagination.js +2 -160
- package/dist/react/core/ProductListSort.d.ts +9 -57
- package/dist/react/core/ProductListSort.js +32 -52
- package/dist/services/index.d.ts +1 -2
- package/dist/services/index.js +1 -2
- package/dist/services/products-list-search-service.d.ts +0 -287
- package/dist/services/products-list-search-service.js +1 -900
- package/dist/services/products-list-service.d.ts +150 -4
- package/dist/services/products-list-service.js +537 -4
- package/package.json +5 -4
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import type { Signal } from '@wix/services-definitions/core-services/signals';
|
|
2
|
-
import { productsV3, customizationsV3 } from '@wix/stores';
|
|
3
|
-
import { type Category } from './category-service.js';
|
|
4
|
-
import { SortType } from './../enums/sort-enums.js';
|
|
5
|
-
export { SortType } from './../enums/sort-enums.js';
|
|
6
|
-
/**
|
|
7
|
-
* Enumeration of inventory status types available for filtering.
|
|
8
|
-
* Re-exports the Wix inventory availability status enum values.
|
|
9
|
-
*/
|
|
10
|
-
export declare const InventoryStatusType: typeof productsV3.InventoryAvailabilityStatus;
|
|
11
|
-
/**
|
|
12
|
-
* Type for inventory status values.
|
|
13
|
-
* Re-exports the Wix inventory availability status enum type.
|
|
14
|
-
*/
|
|
15
|
-
export type InventoryStatusType = productsV3.InventoryAvailabilityStatus;
|
|
16
|
-
/**
|
|
17
|
-
* Interface representing a product option (like Size, Color, etc.).
|
|
18
|
-
*/
|
|
19
|
-
export interface ProductOption {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
choices: ProductChoice[];
|
|
23
|
-
optionRenderType?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Interface representing a choice within a product option.
|
|
27
|
-
*/
|
|
28
|
-
export interface ProductChoice {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
colorCode?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Initial search state that can be loaded from URL parameters.
|
|
35
|
-
*/
|
|
36
|
-
export type InitialSearchState = {
|
|
37
|
-
sort?: SortType;
|
|
38
|
-
limit?: number;
|
|
39
|
-
cursor?: string | null;
|
|
40
|
-
priceRange?: {
|
|
41
|
-
min?: number;
|
|
42
|
-
max?: number;
|
|
43
|
-
};
|
|
44
|
-
inventoryStatuses?: InventoryStatusType[];
|
|
45
|
-
productOptions?: Record<string, string[]>;
|
|
46
|
-
category?: Category;
|
|
47
|
-
visible?: boolean;
|
|
48
|
-
productType?: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Configuration interface for the Products List Search service.
|
|
52
|
-
*/
|
|
53
|
-
export type ProductsListSearchServiceConfig = {
|
|
54
|
-
customizations: customizationsV3.Customization[];
|
|
55
|
-
initialSearchState?: InitialSearchState;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Service definition for the Products List Search service.
|
|
59
|
-
* This consolidates sort, pagination, and filtering functionality.
|
|
60
|
-
*/
|
|
61
|
-
export declare const ProductsListSearchServiceDefinition: string & {
|
|
62
|
-
__api: {
|
|
63
|
-
selectedSortOption: Signal<string>;
|
|
64
|
-
sortOptions: SortType[];
|
|
65
|
-
setSelectedSortOption: (sort: string) => void;
|
|
66
|
-
currentLimit: Signal<number>;
|
|
67
|
-
currentCursor: Signal<string | null>;
|
|
68
|
-
hasNextPage: {
|
|
69
|
-
get: () => boolean;
|
|
70
|
-
};
|
|
71
|
-
hasPrevPage: {
|
|
72
|
-
get: () => boolean;
|
|
73
|
-
};
|
|
74
|
-
setLimit: (limit: number) => void;
|
|
75
|
-
nextPage: () => void;
|
|
76
|
-
prevPage: () => void;
|
|
77
|
-
navigateToFirstPage: () => void;
|
|
78
|
-
loadMore: (count: number) => void;
|
|
79
|
-
selectedMinPrice: Signal<number>;
|
|
80
|
-
selectedMaxPrice: Signal<number>;
|
|
81
|
-
availableMinPrice: Signal<number>;
|
|
82
|
-
availableMaxPrice: Signal<number>;
|
|
83
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
84
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
85
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
86
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
87
|
-
selectedCategory: Signal<Category | null>;
|
|
88
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
89
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
90
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
91
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
92
|
-
setSelectedCategory: (category: Category | null) => void;
|
|
93
|
-
isFiltered: {
|
|
94
|
-
get: () => boolean;
|
|
95
|
-
};
|
|
96
|
-
reset: () => void;
|
|
97
|
-
};
|
|
98
|
-
__config: {};
|
|
99
|
-
isServiceDefinition?: boolean;
|
|
100
|
-
} & {
|
|
101
|
-
selectedSortOption: Signal<string>;
|
|
102
|
-
sortOptions: SortType[];
|
|
103
|
-
setSelectedSortOption: (sort: string) => void;
|
|
104
|
-
currentLimit: Signal<number>;
|
|
105
|
-
currentCursor: Signal<string | null>;
|
|
106
|
-
hasNextPage: {
|
|
107
|
-
get: () => boolean;
|
|
108
|
-
};
|
|
109
|
-
hasPrevPage: {
|
|
110
|
-
get: () => boolean;
|
|
111
|
-
};
|
|
112
|
-
setLimit: (limit: number) => void;
|
|
113
|
-
nextPage: () => void;
|
|
114
|
-
prevPage: () => void;
|
|
115
|
-
navigateToFirstPage: () => void;
|
|
116
|
-
loadMore: (count: number) => void;
|
|
117
|
-
selectedMinPrice: Signal<number>;
|
|
118
|
-
selectedMaxPrice: Signal<number>;
|
|
119
|
-
availableMinPrice: Signal<number>;
|
|
120
|
-
availableMaxPrice: Signal<number>;
|
|
121
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
122
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
123
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
124
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
125
|
-
selectedCategory: Signal<Category | null>;
|
|
126
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
127
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
128
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
129
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
130
|
-
setSelectedCategory: (category: Category | null) => void;
|
|
131
|
-
isFiltered: {
|
|
132
|
-
get: () => boolean;
|
|
133
|
-
};
|
|
134
|
-
reset: () => void;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Convert URL sort format to SortType enum
|
|
138
|
-
*/
|
|
139
|
-
export declare function convertUrlSortToSortType(urlSort: string): SortType | null;
|
|
140
|
-
/**
|
|
141
|
-
* Parse URL and build complete search options with all filters, sort, and pagination.
|
|
142
|
-
* This function extracts search parameters, filters, sorting, and pagination from a URL
|
|
143
|
-
* and converts them into the format expected by the Wix Stores API.
|
|
144
|
-
*
|
|
145
|
-
* @param {string} url - The URL to parse search parameters from
|
|
146
|
-
* @param {Category[]} categoriesList - List of available categories for category slug resolution
|
|
147
|
-
* @param {productsV3.V3ProductSearch} [defaultSearchOptions] - Default search options to merge with parsed URL parameters
|
|
148
|
-
* @returns {Promise<{searchOptions: productsV3.V3ProductSearch, initialSearchState: InitialSearchState}>}
|
|
149
|
-
* Object containing both API-ready search options and UI-ready initial state
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* ```tsx
|
|
153
|
-
* // Parse URL with filters, sort, and pagination
|
|
154
|
-
* const categories = await loadCategoriesListServiceConfig();
|
|
155
|
-
* const { searchOptions, initialSearchState } = await parseUrlToSearchOptions(
|
|
156
|
-
* 'https://example.com/products?sort=price:desc&Color=red,blue&minPrice=50',
|
|
157
|
-
* categories.categories
|
|
158
|
-
* );
|
|
159
|
-
*
|
|
160
|
-
* // Use searchOptions for API calls
|
|
161
|
-
* const products = await productsV3.searchProducts(searchOptions);
|
|
162
|
-
*
|
|
163
|
-
* // Use initialSearchState for UI initialization
|
|
164
|
-
* const filterState = initialSearchState.productOptions; // { colorId: ['red-id', 'blue-id'] }
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
export declare function parseUrlToSearchOptions(url: string, categoriesList: Category[], defaultSearchOptions?: productsV3.V3ProductSearch): Promise<{
|
|
168
|
-
searchOptions: productsV3.V3ProductSearch;
|
|
169
|
-
initialSearchState: InitialSearchState;
|
|
170
|
-
}>;
|
|
171
|
-
/**
|
|
172
|
-
* Load search service configuration from URL or parsed URL result.
|
|
173
|
-
* This function provides the configuration for the Products List Search service,
|
|
174
|
-
* including customizations and initial search state.
|
|
175
|
-
*
|
|
176
|
-
* @param {string | { searchOptions: productsV3.V3ProductSearch; initialSearchState: InitialSearchState }} input - Either a URL to parse or parsed URL result from parseUrlToSearchOptions
|
|
177
|
-
* @returns {Promise<ProductsListSearchServiceConfig>} Promise that resolves to the search service configuration
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```tsx
|
|
181
|
-
* // Option 1: Load from URL (will parse filters, sort, pagination from URL params)
|
|
182
|
-
* const searchConfig = await loadProductsListSearchServiceConfig(window.location.href);
|
|
183
|
-
*
|
|
184
|
-
* // Option 2: Custom parsing with defaults
|
|
185
|
-
* const categories = await loadCategoriesListServiceConfig();
|
|
186
|
-
* const parsed = await parseUrlToSearchOptions(
|
|
187
|
-
* window.location.href,
|
|
188
|
-
* categories.categories,
|
|
189
|
-
* {
|
|
190
|
-
* cursorPaging: { limit: 12 },
|
|
191
|
-
* filter: { 'categoryIds': ['123'] },
|
|
192
|
-
* sort: [{ fieldName: 'name' as const, order: 'ASC' as const }]
|
|
193
|
-
* }
|
|
194
|
-
* );
|
|
195
|
-
* const searchConfig = await loadProductsListSearchServiceConfig(parsed);
|
|
196
|
-
*
|
|
197
|
-
* // Option 3: Performance optimization - use parsed result for both services (no duplicate parsing)
|
|
198
|
-
* const categories = await loadCategoriesListServiceConfig();
|
|
199
|
-
* const parsed = await parseUrlToSearchOptions(url, categories.categories);
|
|
200
|
-
* const [productsConfig, searchConfig] = await Promise.all([
|
|
201
|
-
* loadProductsListServiceConfig(parsed),
|
|
202
|
-
* loadProductsListSearchServiceConfig(parsed),
|
|
203
|
-
* ]);
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
export declare function loadProductsListSearchServiceConfig(input: string | {
|
|
207
|
-
searchOptions: productsV3.V3ProductSearch;
|
|
208
|
-
initialSearchState: InitialSearchState;
|
|
209
|
-
}): Promise<ProductsListSearchServiceConfig>;
|
|
210
|
-
/**
|
|
211
|
-
* Implementation of the Products List Search service
|
|
212
|
-
*/
|
|
213
|
-
export declare const ProductsListSearchService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
214
|
-
__api: {
|
|
215
|
-
selectedSortOption: Signal<string>;
|
|
216
|
-
sortOptions: SortType[];
|
|
217
|
-
setSelectedSortOption: (sort: string) => void;
|
|
218
|
-
currentLimit: Signal<number>;
|
|
219
|
-
currentCursor: Signal<string | null>;
|
|
220
|
-
hasNextPage: {
|
|
221
|
-
get: () => boolean;
|
|
222
|
-
};
|
|
223
|
-
hasPrevPage: {
|
|
224
|
-
get: () => boolean;
|
|
225
|
-
};
|
|
226
|
-
setLimit: (limit: number) => void;
|
|
227
|
-
nextPage: () => void;
|
|
228
|
-
prevPage: () => void;
|
|
229
|
-
navigateToFirstPage: () => void;
|
|
230
|
-
loadMore: (count: number) => void;
|
|
231
|
-
selectedMinPrice: Signal<number>;
|
|
232
|
-
selectedMaxPrice: Signal<number>;
|
|
233
|
-
availableMinPrice: Signal<number>;
|
|
234
|
-
availableMaxPrice: Signal<number>;
|
|
235
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
236
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
237
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
238
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
239
|
-
selectedCategory: Signal<Category | null>;
|
|
240
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
241
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
242
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
243
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
244
|
-
setSelectedCategory: (category: Category | null) => void;
|
|
245
|
-
isFiltered: {
|
|
246
|
-
get: () => boolean;
|
|
247
|
-
};
|
|
248
|
-
reset: () => void;
|
|
249
|
-
};
|
|
250
|
-
__config: {};
|
|
251
|
-
isServiceDefinition?: boolean;
|
|
252
|
-
} & {
|
|
253
|
-
selectedSortOption: Signal<string>;
|
|
254
|
-
sortOptions: SortType[];
|
|
255
|
-
setSelectedSortOption: (sort: string) => void;
|
|
256
|
-
currentLimit: Signal<number>;
|
|
257
|
-
currentCursor: Signal<string | null>;
|
|
258
|
-
hasNextPage: {
|
|
259
|
-
get: () => boolean;
|
|
260
|
-
};
|
|
261
|
-
hasPrevPage: {
|
|
262
|
-
get: () => boolean;
|
|
263
|
-
};
|
|
264
|
-
setLimit: (limit: number) => void;
|
|
265
|
-
nextPage: () => void;
|
|
266
|
-
prevPage: () => void;
|
|
267
|
-
navigateToFirstPage: () => void;
|
|
268
|
-
loadMore: (count: number) => void;
|
|
269
|
-
selectedMinPrice: Signal<number>;
|
|
270
|
-
selectedMaxPrice: Signal<number>;
|
|
271
|
-
availableMinPrice: Signal<number>;
|
|
272
|
-
availableMaxPrice: Signal<number>;
|
|
273
|
-
availableInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
274
|
-
selectedInventoryStatuses: Signal<InventoryStatusType[]>;
|
|
275
|
-
availableProductOptions: Signal<ProductOption[]>;
|
|
276
|
-
selectedProductOptions: Signal<Record<string, string[]>>;
|
|
277
|
-
selectedCategory: Signal<Category | null>;
|
|
278
|
-
setSelectedMinPrice: (minPrice: number) => void;
|
|
279
|
-
setSelectedMaxPrice: (maxPrice: number) => void;
|
|
280
|
-
toggleInventoryStatus: (status: InventoryStatusType) => void;
|
|
281
|
-
toggleProductOption: (optionId: string, choiceId: string) => void;
|
|
282
|
-
setSelectedCategory: (category: Category | null) => void;
|
|
283
|
-
isFiltered: {
|
|
284
|
-
get: () => boolean;
|
|
285
|
-
};
|
|
286
|
-
reset: () => void;
|
|
287
|
-
}, ProductsListSearchServiceConfig>;
|