@wix/headless-stores 0.0.35 → 0.0.37
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/Category.d.ts +83 -31
- package/cjs/dist/react/Category.js +68 -35
- package/cjs/dist/react/CategoryList.d.ts +184 -0
- package/cjs/dist/react/CategoryList.js +174 -0
- package/cjs/dist/react/Product.d.ts +3 -3
- package/cjs/dist/react/Product.js +6 -6
- package/cjs/dist/react/ProductActions.d.ts +1 -1
- package/cjs/dist/react/ProductActions.js +2 -2
- package/{dist/react/ProductsList.d.ts → cjs/dist/react/ProductList.d.ts} +71 -38
- package/{dist/react/ProductsList.js → cjs/dist/react/ProductList.js} +30 -26
- package/cjs/dist/react/ProductListFilters.d.ts +244 -0
- package/cjs/dist/react/ProductListFilters.js +216 -0
- package/cjs/dist/react/ProductListPagination.d.ts +246 -0
- package/cjs/dist/react/ProductListPagination.js +207 -0
- package/cjs/dist/react/ProductListSort.d.ts +87 -0
- package/cjs/dist/react/ProductListSort.js +85 -0
- package/cjs/dist/react/ProductModifiers.d.ts +5 -5
- package/cjs/dist/react/ProductModifiers.js +10 -10
- package/cjs/dist/react/ProductVariantSelector.d.ts +5 -5
- package/cjs/dist/react/ProductVariantSelector.js +13 -10
- package/cjs/dist/react/SelectedVariant.d.ts +3 -3
- package/cjs/dist/react/SelectedVariant.js +6 -6
- package/cjs/dist/react/index.d.ts +7 -9
- package/cjs/dist/react/index.js +7 -9
- package/cjs/dist/services/buy-now-service.d.ts +208 -0
- package/cjs/dist/services/buy-now-service.js +132 -1
- package/cjs/dist/services/categories-list-service.d.ts +163 -0
- package/cjs/dist/services/categories-list-service.js +148 -0
- package/cjs/dist/services/category-service.d.ts +115 -70
- package/cjs/dist/services/category-service.js +101 -110
- package/cjs/dist/services/index.d.ts +6 -7
- package/cjs/dist/services/index.js +5 -16
- package/cjs/dist/services/pay-now-service.d.ts +146 -0
- package/cjs/dist/services/pay-now-service.js +112 -1
- package/cjs/dist/services/product-service.d.ts +71 -0
- package/cjs/dist/services/product-service.js +47 -0
- package/cjs/dist/services/products-list-filters-service.d.ts +292 -0
- package/cjs/dist/services/products-list-filters-service.js +446 -0
- package/cjs/dist/services/products-list-pagination-service.d.ts +186 -0
- package/cjs/dist/services/products-list-pagination-service.js +179 -0
- package/cjs/dist/services/products-list-service.d.ts +138 -52
- package/cjs/dist/services/products-list-service.js +98 -51
- package/cjs/dist/services/products-list-sort-service.d.ts +117 -0
- package/cjs/dist/services/products-list-sort-service.js +144 -0
- package/cjs/dist/services/selected-variant-service.js +0 -1
- package/cjs/dist/utils/url-params.d.ts +68 -0
- package/cjs/dist/utils/url-params.js +72 -4
- package/dist/react/Category.d.ts +83 -31
- package/dist/react/Category.js +68 -35
- package/dist/react/CategoryList.d.ts +184 -0
- package/dist/react/CategoryList.js +174 -0
- package/dist/react/Product.d.ts +3 -3
- package/dist/react/Product.js +6 -6
- package/dist/react/ProductActions.d.ts +1 -1
- package/dist/react/ProductActions.js +2 -2
- package/{cjs/dist/react/ProductsList.d.ts → dist/react/ProductList.d.ts} +71 -38
- package/{cjs/dist/react/ProductsList.js → dist/react/ProductList.js} +30 -26
- package/dist/react/ProductListFilters.d.ts +244 -0
- package/dist/react/ProductListFilters.js +216 -0
- package/dist/react/ProductListPagination.d.ts +246 -0
- package/dist/react/ProductListPagination.js +207 -0
- package/dist/react/ProductListSort.d.ts +87 -0
- package/dist/react/ProductListSort.js +85 -0
- package/dist/react/ProductModifiers.d.ts +5 -5
- package/dist/react/ProductModifiers.js +10 -10
- package/dist/react/ProductVariantSelector.d.ts +5 -5
- package/dist/react/ProductVariantSelector.js +13 -10
- package/dist/react/SelectedVariant.d.ts +3 -3
- package/dist/react/SelectedVariant.js +6 -6
- package/dist/react/index.d.ts +7 -9
- package/dist/react/index.js +7 -9
- package/dist/services/buy-now-service.d.ts +208 -0
- package/dist/services/buy-now-service.js +132 -1
- package/dist/services/categories-list-service.d.ts +163 -0
- package/dist/services/categories-list-service.js +148 -0
- package/dist/services/category-service.d.ts +115 -70
- package/dist/services/category-service.js +101 -110
- package/dist/services/index.d.ts +6 -7
- package/dist/services/index.js +5 -16
- package/dist/services/pay-now-service.d.ts +146 -0
- package/dist/services/pay-now-service.js +112 -1
- package/dist/services/product-service.d.ts +71 -0
- package/dist/services/product-service.js +47 -0
- package/dist/services/products-list-filters-service.d.ts +292 -0
- package/dist/services/products-list-filters-service.js +446 -0
- package/dist/services/products-list-pagination-service.d.ts +186 -0
- package/dist/services/products-list-pagination-service.js +179 -0
- package/dist/services/products-list-service.d.ts +138 -52
- package/dist/services/products-list-service.js +98 -51
- package/dist/services/products-list-sort-service.d.ts +117 -0
- package/dist/services/products-list-sort-service.js +144 -0
- package/dist/services/selected-variant-service.js +0 -1
- package/dist/utils/url-params.d.ts +68 -0
- package/dist/utils/url-params.js +72 -4
- package/package.json +3 -3
- package/cjs/dist/react/Collection.d.ts +0 -294
- package/cjs/dist/react/Collection.js +0 -345
- package/cjs/dist/react/FilteredCollection.d.ts +0 -216
- package/cjs/dist/react/FilteredCollection.js +0 -256
- package/cjs/dist/react/RelatedProducts.d.ts +0 -169
- package/cjs/dist/react/RelatedProducts.js +0 -180
- package/cjs/dist/react/Sort.d.ts +0 -37
- package/cjs/dist/react/Sort.js +0 -36
- package/cjs/dist/services/catalog-service.d.ts +0 -36
- package/cjs/dist/services/catalog-service.js +0 -193
- package/cjs/dist/services/collection-service.d.ts +0 -124
- package/cjs/dist/services/collection-service.js +0 -628
- package/cjs/dist/services/filter-service.d.ts +0 -35
- package/cjs/dist/services/filter-service.js +0 -119
- package/cjs/dist/services/related-products-service.d.ts +0 -100
- package/cjs/dist/services/related-products-service.js +0 -127
- package/cjs/dist/services/sort-service.d.ts +0 -20
- package/cjs/dist/services/sort-service.js +0 -27
- package/dist/react/Collection.d.ts +0 -294
- package/dist/react/Collection.js +0 -345
- package/dist/react/FilteredCollection.d.ts +0 -216
- package/dist/react/FilteredCollection.js +0 -256
- package/dist/react/RelatedProducts.d.ts +0 -169
- package/dist/react/RelatedProducts.js +0 -180
- package/dist/react/Sort.d.ts +0 -37
- package/dist/react/Sort.js +0 -36
- package/dist/services/catalog-service.d.ts +0 -36
- package/dist/services/catalog-service.js +0 -193
- package/dist/services/collection-service.d.ts +0 -124
- package/dist/services/collection-service.js +0 -628
- package/dist/services/filter-service.d.ts +0 -35
- package/dist/services/filter-service.js +0 -119
- package/dist/services/related-products-service.d.ts +0 -100
- package/dist/services/related-products-service.js +0 -127
- package/dist/services/sort-service.d.ts +0 -20
- package/dist/services/sort-service.js +0 -27
package/dist/react/Collection.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import { useService } from "@wix/services-manager-react";
|
|
2
|
-
import { CollectionServiceDefinition } from "../services/collection-service.js";
|
|
3
|
-
import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3";
|
|
4
|
-
/**
|
|
5
|
-
* Headless component for product grid
|
|
6
|
-
*
|
|
7
|
-
* @component
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* import { Collection } from '@wix/stores/components';
|
|
11
|
-
*
|
|
12
|
-
* function ProductGrid() {
|
|
13
|
-
* return (
|
|
14
|
-
* <Collection.Grid>
|
|
15
|
-
* {({ products, isLoading, error, isEmpty, totalProducts, hasProducts }) => (
|
|
16
|
-
* <div>
|
|
17
|
-
* {isLoading && <div>Loading products...</div>}
|
|
18
|
-
* {error && <div>Error: {error}</div>}
|
|
19
|
-
* {isEmpty && <div>No products found</div>}
|
|
20
|
-
* {hasProducts && (
|
|
21
|
-
* <div>
|
|
22
|
-
* <p>Showing {products.length} of {totalProducts} products</p>
|
|
23
|
-
* <div className="product-grid">
|
|
24
|
-
* {products.map(product => (
|
|
25
|
-
* <div key={product.id} className="product-card">
|
|
26
|
-
* <h3>{product.name}</h3>
|
|
27
|
-
* <p>{product.price?.price} {product.price?.currency}</p>
|
|
28
|
-
* </div>
|
|
29
|
-
* ))}
|
|
30
|
-
* </div>
|
|
31
|
-
* </div>
|
|
32
|
-
* )}
|
|
33
|
-
* </div>
|
|
34
|
-
* )}
|
|
35
|
-
* </Collection.Grid>
|
|
36
|
-
* );
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export const Grid = (props) => {
|
|
41
|
-
const service = useService(CollectionServiceDefinition);
|
|
42
|
-
// Debug logging to help identify service issues
|
|
43
|
-
if (!service) {
|
|
44
|
-
console.error("CollectionService is undefined");
|
|
45
|
-
return props.children({
|
|
46
|
-
products: [],
|
|
47
|
-
isLoading: false,
|
|
48
|
-
error: "Service not available",
|
|
49
|
-
isEmpty: true,
|
|
50
|
-
totalProducts: 0,
|
|
51
|
-
hasProducts: false,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// Safely access service properties with error handling
|
|
55
|
-
try {
|
|
56
|
-
const productList = service.products?.get() || [];
|
|
57
|
-
const isLoading = service.isLoading?.get() || false;
|
|
58
|
-
const error = service.error?.get() || null;
|
|
59
|
-
const totalProducts = service.totalProducts?.get() || 0;
|
|
60
|
-
const hasProducts = service.hasProducts?.get() || false;
|
|
61
|
-
return props.children({
|
|
62
|
-
products: productList,
|
|
63
|
-
isLoading,
|
|
64
|
-
error,
|
|
65
|
-
isEmpty: !hasProducts && !isLoading,
|
|
66
|
-
totalProducts,
|
|
67
|
-
hasProducts,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
console.error("Error accessing service properties:", err);
|
|
72
|
-
return props.children({
|
|
73
|
-
products: [],
|
|
74
|
-
isLoading: false,
|
|
75
|
-
error: "Failed to load products",
|
|
76
|
-
isEmpty: true,
|
|
77
|
-
totalProducts: 0,
|
|
78
|
-
hasProducts: false,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Headless component for individual product item
|
|
84
|
-
*
|
|
85
|
-
* @component
|
|
86
|
-
* @example
|
|
87
|
-
* ```tsx
|
|
88
|
-
* import { Collection } from '@wix/stores/components';
|
|
89
|
-
*
|
|
90
|
-
* function ProductCard({ product }) {
|
|
91
|
-
* return (
|
|
92
|
-
* <Collection.Item product={product}>
|
|
93
|
-
* {({ id, title, slug, image, price, compareAtPrice, description, available }) => (
|
|
94
|
-
* <div className={`product-card ${!available ? 'unavailable' : ''}`}>
|
|
95
|
-
* {image && <img src={image} alt={title} />}
|
|
96
|
-
* <h3>{title}</h3>
|
|
97
|
-
* <p>{description}</p>
|
|
98
|
-
* <div className="pricing">
|
|
99
|
-
* <span className="price">{price}</span>
|
|
100
|
-
* {compareAtPrice && (
|
|
101
|
-
* <span className="compare-price"><s>{compareAtPrice}</s></span>
|
|
102
|
-
* )}
|
|
103
|
-
* </div>
|
|
104
|
-
* {!available && <div className="badge">Out of Stock</div>}
|
|
105
|
-
* <a href={`/products/${slug}`}>View Product</a>
|
|
106
|
-
* </div>
|
|
107
|
-
* )}
|
|
108
|
-
* </Collection.Item>
|
|
109
|
-
* );
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export const Item = (props) => {
|
|
114
|
-
const { product } = props;
|
|
115
|
-
// Use actual v3 API structure based on real data
|
|
116
|
-
// Images are in media.main.image, not media.itemsInfo.items
|
|
117
|
-
const image = product?.media?.main?.image || null;
|
|
118
|
-
// Create formatted price since formattedAmount is not available
|
|
119
|
-
const rawAmount = product.actualPriceRange?.minValue?.amount;
|
|
120
|
-
const price = rawAmount ? `$${rawAmount}` : "$0.00";
|
|
121
|
-
// Create formatted compare-at price
|
|
122
|
-
const rawCompareAmount = product.compareAtPriceRange?.minValue?.amount;
|
|
123
|
-
const compareAtPrice = rawCompareAmount ? `$${rawCompareAmount}` : null;
|
|
124
|
-
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
125
|
-
const available = availabilityStatus === InventoryAvailabilityStatus.IN_STOCK ||
|
|
126
|
-
availabilityStatus === InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK;
|
|
127
|
-
const description = typeof product.description === "string" ? product.description : "";
|
|
128
|
-
return props.children({
|
|
129
|
-
id: product._id || "",
|
|
130
|
-
title: product.name || "",
|
|
131
|
-
slug: product.slug || "",
|
|
132
|
-
image,
|
|
133
|
-
price,
|
|
134
|
-
compareAtPrice,
|
|
135
|
-
description,
|
|
136
|
-
available,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Headless component for load more products functionality
|
|
141
|
-
* Note: V3 API uses simplified loading without traditional pagination
|
|
142
|
-
*
|
|
143
|
-
* @component
|
|
144
|
-
* @example
|
|
145
|
-
* ```tsx
|
|
146
|
-
* import { Collection } from '@wix/stores/components';
|
|
147
|
-
*
|
|
148
|
-
* function LoadMoreButton() {
|
|
149
|
-
* return (
|
|
150
|
-
* <Collection.LoadMore>
|
|
151
|
-
* {({ loadMore, refresh, isLoading, hasProducts, totalProducts, hasMoreProducts }) => (
|
|
152
|
-
* <div className="load-more-section">
|
|
153
|
-
* {hasProducts && (
|
|
154
|
-
* <div>
|
|
155
|
-
* <p>Loaded {totalProducts} products</p>
|
|
156
|
-
* <div className="actions">
|
|
157
|
-
* {hasMoreProducts && (
|
|
158
|
-
* <button
|
|
159
|
-
* onClick={loadMore}
|
|
160
|
-
* disabled={isLoading}
|
|
161
|
-
* >
|
|
162
|
-
* {isLoading ? 'Loading...' : 'Load More Products'}
|
|
163
|
-
* </button>
|
|
164
|
-
* )}
|
|
165
|
-
* <button onClick={refresh}>Refresh Collection</button>
|
|
166
|
-
* </div>
|
|
167
|
-
* </div>
|
|
168
|
-
* )}
|
|
169
|
-
* </div>
|
|
170
|
-
* )}
|
|
171
|
-
* </Collection.LoadMore>
|
|
172
|
-
* );
|
|
173
|
-
* }
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
export const LoadMore = (props) => {
|
|
177
|
-
const service = useService(CollectionServiceDefinition);
|
|
178
|
-
// Error handling for undefined service
|
|
179
|
-
if (!service) {
|
|
180
|
-
console.error("CollectionService is undefined in LoadMore");
|
|
181
|
-
return props.children({
|
|
182
|
-
loadMore: async () => { },
|
|
183
|
-
refresh: async () => { },
|
|
184
|
-
isLoading: false,
|
|
185
|
-
hasProducts: false,
|
|
186
|
-
totalProducts: 0,
|
|
187
|
-
hasMoreProducts: false,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
try {
|
|
191
|
-
const isLoading = service.isLoading?.get() || false;
|
|
192
|
-
const hasProducts = service.hasProducts?.get() || false;
|
|
193
|
-
const totalProducts = service.totalProducts?.get() || 0;
|
|
194
|
-
const hasMoreProducts = service.hasMoreProducts?.get() || false;
|
|
195
|
-
return props.children({
|
|
196
|
-
loadMore: service.loadMore || (async () => { }),
|
|
197
|
-
refresh: service.refresh || (async () => { }),
|
|
198
|
-
isLoading,
|
|
199
|
-
hasProducts,
|
|
200
|
-
totalProducts,
|
|
201
|
-
hasMoreProducts,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
console.error("Error in LoadMore:", err);
|
|
206
|
-
return props.children({
|
|
207
|
-
loadMore: async () => { },
|
|
208
|
-
refresh: async () => { },
|
|
209
|
-
isLoading: false,
|
|
210
|
-
hasProducts: false,
|
|
211
|
-
totalProducts: 0,
|
|
212
|
-
hasMoreProducts: false,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Headless component for collection header with product count
|
|
218
|
-
*
|
|
219
|
-
* @component
|
|
220
|
-
* @example
|
|
221
|
-
* ```tsx
|
|
222
|
-
* import { Collection } from '@wix/stores/components';
|
|
223
|
-
*
|
|
224
|
-
* function CollectionHeader() {
|
|
225
|
-
* return (
|
|
226
|
-
* <Collection.Header>
|
|
227
|
-
* {({ totalProducts, isLoading, hasProducts }) => (
|
|
228
|
-
* <div className="collection-header">
|
|
229
|
-
* {isLoading && <div>Loading collection...</div>}
|
|
230
|
-
* {hasProducts && !isLoading && (
|
|
231
|
-
* <h2>Products ({totalProducts} items)</h2>
|
|
232
|
-
* )}
|
|
233
|
-
* {!hasProducts && !isLoading && (
|
|
234
|
-
* <h2>No products found</h2>
|
|
235
|
-
* )}
|
|
236
|
-
* </div>
|
|
237
|
-
* )}
|
|
238
|
-
* </Collection.Header>
|
|
239
|
-
* );
|
|
240
|
-
* }
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
export const Header = (props) => {
|
|
244
|
-
const service = useService(CollectionServiceDefinition);
|
|
245
|
-
// Error handling for undefined service
|
|
246
|
-
if (!service) {
|
|
247
|
-
console.error("CollectionService is undefined in Header");
|
|
248
|
-
return props.children({
|
|
249
|
-
totalProducts: 0,
|
|
250
|
-
isLoading: false,
|
|
251
|
-
hasProducts: false,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
const totalProducts = service.totalProducts?.get() || 0;
|
|
256
|
-
const isLoading = service.isLoading?.get() || false;
|
|
257
|
-
const hasProducts = service.hasProducts?.get() || false;
|
|
258
|
-
return props.children({
|
|
259
|
-
totalProducts,
|
|
260
|
-
isLoading,
|
|
261
|
-
hasProducts,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
catch (err) {
|
|
265
|
-
console.error("Error in Header:", err);
|
|
266
|
-
return props.children({
|
|
267
|
-
totalProducts: 0,
|
|
268
|
-
isLoading: false,
|
|
269
|
-
hasProducts: false,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Headless component for collection actions (refresh, load more)
|
|
275
|
-
* Replaces traditional pagination for V3 API
|
|
276
|
-
*
|
|
277
|
-
* @component
|
|
278
|
-
* @example
|
|
279
|
-
* ```tsx
|
|
280
|
-
* import { Collection } from '@wix/stores/components';
|
|
281
|
-
*
|
|
282
|
-
* function CollectionActions() {
|
|
283
|
-
* return (
|
|
284
|
-
* <Collection.Actions>
|
|
285
|
-
* {({ refresh, loadMore, isLoading, error }) => (
|
|
286
|
-
* <div className="collection-actions">
|
|
287
|
-
* {error && (
|
|
288
|
-
* <div className="error">
|
|
289
|
-
* Error: {error}
|
|
290
|
-
* <button onClick={refresh}>Retry</button>
|
|
291
|
-
* </div>
|
|
292
|
-
* )}
|
|
293
|
-
* <div className="action-buttons">
|
|
294
|
-
* <button
|
|
295
|
-
* onClick={refresh}
|
|
296
|
-
* disabled={isLoading}
|
|
297
|
-
* >
|
|
298
|
-
* {isLoading ? 'Refreshing...' : 'Refresh'}
|
|
299
|
-
* </button>
|
|
300
|
-
* <button
|
|
301
|
-
* onClick={loadMore}
|
|
302
|
-
* disabled={isLoading}
|
|
303
|
-
* >
|
|
304
|
-
* Load More
|
|
305
|
-
* </button>
|
|
306
|
-
* </div>
|
|
307
|
-
* </div>
|
|
308
|
-
* )}
|
|
309
|
-
* </Collection.Actions>
|
|
310
|
-
* );
|
|
311
|
-
* }
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
export const Actions = (props) => {
|
|
315
|
-
const service = useService(CollectionServiceDefinition);
|
|
316
|
-
// Error handling for undefined service
|
|
317
|
-
if (!service) {
|
|
318
|
-
console.error("CollectionService is undefined in Actions");
|
|
319
|
-
return props.children({
|
|
320
|
-
refresh: async () => { },
|
|
321
|
-
loadMore: async () => { },
|
|
322
|
-
isLoading: false,
|
|
323
|
-
error: "Service not available",
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
const isLoading = service.isLoading?.get() || false;
|
|
328
|
-
const error = service.error?.get() || null;
|
|
329
|
-
return props.children({
|
|
330
|
-
refresh: service.refresh || (async () => { }),
|
|
331
|
-
loadMore: service.loadMore || (async () => { }),
|
|
332
|
-
isLoading,
|
|
333
|
-
error,
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
catch (err) {
|
|
337
|
-
console.error("Error in Actions:", err);
|
|
338
|
-
return props.children({
|
|
339
|
-
refresh: async () => { },
|
|
340
|
-
loadMore: async () => { },
|
|
341
|
-
isLoading: false,
|
|
342
|
-
error: "Failed to load actions",
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import React, { type ReactNode } from "react";
|
|
2
|
-
import { type AvailableOptions, type FilterServiceAPI, type Filter } from "../services/filter-service.js";
|
|
3
|
-
import { type V3Product } from "@wix/auto_sdk_stores_products-v-3";
|
|
4
|
-
export type { AvailableOptions, Filter, FilterServiceAPI };
|
|
5
|
-
export interface FiltersLoadingProps {
|
|
6
|
-
children: (data: {
|
|
7
|
-
isFullyLoaded: boolean;
|
|
8
|
-
}) => ReactNode;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Headless component for displaying a loading state for filters
|
|
12
|
-
*
|
|
13
|
-
* @component
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* import { FilteredCollection } from '@wix/stores/components';
|
|
17
|
-
*
|
|
18
|
-
* function FiltersLoadingIndicator() {
|
|
19
|
-
* return (
|
|
20
|
-
* <FilteredCollection.FiltersLoading>
|
|
21
|
-
* {({ isFullyLoaded }) => (
|
|
22
|
-
* <div>
|
|
23
|
-
* {!isFullyLoaded && (
|
|
24
|
-
* <div className="loading-pulse">
|
|
25
|
-
* Loading filters...
|
|
26
|
-
* </div>
|
|
27
|
-
* )}
|
|
28
|
-
* </div>
|
|
29
|
-
* )}
|
|
30
|
-
* </FilteredCollection.FiltersLoading>
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
|
|
36
|
-
export interface FilteredGridProps {
|
|
37
|
-
children: (data: {
|
|
38
|
-
products: V3Product[];
|
|
39
|
-
totalProducts: number;
|
|
40
|
-
isLoading: boolean;
|
|
41
|
-
error: string | null;
|
|
42
|
-
isEmpty: boolean;
|
|
43
|
-
hasMoreProducts: boolean;
|
|
44
|
-
}) => ReactNode;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Headless component for displaying a grid of filtered products
|
|
48
|
-
*
|
|
49
|
-
* @component
|
|
50
|
-
* @example
|
|
51
|
-
* ```tsx
|
|
52
|
-
* import { FilteredCollection } from '@wix/stores/components';
|
|
53
|
-
*
|
|
54
|
-
* function FilteredProductsGrid() {
|
|
55
|
-
* return (
|
|
56
|
-
* <FilteredCollection.Grid>
|
|
57
|
-
* {({ products, isLoading, error, isEmpty, totalProducts, hasMoreProducts }) => (
|
|
58
|
-
* <div>
|
|
59
|
-
* {isLoading && <div>Loading filtered products...</div>}
|
|
60
|
-
* {error && <div>Error: {error}</div>}
|
|
61
|
-
* {isEmpty && <div>No products match your filters</div>}
|
|
62
|
-
* {products.length > 0 && (
|
|
63
|
-
* <div>
|
|
64
|
-
* <p>Showing {products.length} of {totalProducts} products</p>
|
|
65
|
-
* <div className="filtered-grid">
|
|
66
|
-
* {products.map(product => (
|
|
67
|
-
* <div key={product.id}>{product.name}</div>
|
|
68
|
-
* ))}
|
|
69
|
-
* </div>
|
|
70
|
-
* {hasMoreProducts && <button>Load More</button>}
|
|
71
|
-
* </div>
|
|
72
|
-
* )}
|
|
73
|
-
* </div>
|
|
74
|
-
* )}
|
|
75
|
-
* </FilteredCollection.Grid>
|
|
76
|
-
* );
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare const Grid: React.FC<FilteredGridProps>;
|
|
81
|
-
export interface FilteredItemProps {
|
|
82
|
-
product: V3Product;
|
|
83
|
-
children: (data: {
|
|
84
|
-
title: string;
|
|
85
|
-
image: string | null;
|
|
86
|
-
imageAltText: string | null;
|
|
87
|
-
price: string;
|
|
88
|
-
compareAtPrice: string | null;
|
|
89
|
-
available: boolean;
|
|
90
|
-
slug: string;
|
|
91
|
-
description?: string;
|
|
92
|
-
}) => ReactNode;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Headless component for displaying a filtered product item
|
|
96
|
-
*
|
|
97
|
-
* @component
|
|
98
|
-
* @example
|
|
99
|
-
* ```tsx
|
|
100
|
-
* import { FilteredCollection } from '@wix/stores/components';
|
|
101
|
-
*
|
|
102
|
-
* function FilteredProductItem({ product }) {
|
|
103
|
-
* return (
|
|
104
|
-
* <FilteredCollection.Item product={product}>
|
|
105
|
-
* {({ title, image, price, compareAtPrice, available, slug, description }) => (
|
|
106
|
-
* <div className={`product-item ${!available ? 'unavailable' : ''}`}>
|
|
107
|
-
* {image && <img src={image} alt={title} />}
|
|
108
|
-
* <h3>{title}</h3>
|
|
109
|
-
* {description && <p>{description}</p>}
|
|
110
|
-
* <div className="price">
|
|
111
|
-
* <span className="current">{price}</span>
|
|
112
|
-
* {compareAtPrice && <span className="compare"><s>{compareAtPrice}</s></span>}
|
|
113
|
-
* </div>
|
|
114
|
-
* {!available && <div className="out-of-stock">Out of Stock</div>}
|
|
115
|
-
* <a href={`/product/${slug}`}>View Details</a>
|
|
116
|
-
* </div>
|
|
117
|
-
* )}
|
|
118
|
-
* </FilteredCollection.Item>
|
|
119
|
-
* );
|
|
120
|
-
* }
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
export declare const Item: React.FC<FilteredItemProps>;
|
|
124
|
-
export interface FilteredLoadMoreProps {
|
|
125
|
-
children: (data: {
|
|
126
|
-
loadMore: () => Promise<void>;
|
|
127
|
-
refresh: () => Promise<void>;
|
|
128
|
-
isLoading: boolean;
|
|
129
|
-
hasProducts: boolean;
|
|
130
|
-
totalProducts: number;
|
|
131
|
-
hasMoreProducts: boolean;
|
|
132
|
-
}) => ReactNode;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Headless component for load more filtered products functionality
|
|
136
|
-
*
|
|
137
|
-
* @component
|
|
138
|
-
* @example
|
|
139
|
-
* ```tsx
|
|
140
|
-
* import { FilteredCollection } from '@wix/stores/components';
|
|
141
|
-
*
|
|
142
|
-
* function LoadMoreProducts() {
|
|
143
|
-
* return (
|
|
144
|
-
* <FilteredCollection.LoadMore>
|
|
145
|
-
* {({ loadMore, refresh, isLoading, hasProducts, totalProducts, hasMoreProducts }) => (
|
|
146
|
-
* <div>
|
|
147
|
-
* {hasProducts && (
|
|
148
|
-
* <div>
|
|
149
|
-
* <p>Showing products ({totalProducts} total)</p>
|
|
150
|
-
* {hasMoreProducts && (
|
|
151
|
-
* <button
|
|
152
|
-
* onClick={loadMore}
|
|
153
|
-
* disabled={isLoading}
|
|
154
|
-
* >
|
|
155
|
-
* {isLoading ? 'Loading...' : 'Load More'}
|
|
156
|
-
* </button>
|
|
157
|
-
* )}
|
|
158
|
-
* <button onClick={refresh}>Refresh</button>
|
|
159
|
-
* </div>
|
|
160
|
-
* )}
|
|
161
|
-
* </div>
|
|
162
|
-
* )}
|
|
163
|
-
* </FilteredCollection.LoadMore>
|
|
164
|
-
* );
|
|
165
|
-
* }
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
|
|
169
|
-
export interface FilteredFiltersProps {
|
|
170
|
-
children: (data: {
|
|
171
|
-
applyFilters: (filters: Filter) => void;
|
|
172
|
-
clearFilters: () => void;
|
|
173
|
-
currentFilters: Filter;
|
|
174
|
-
allProducts: V3Product[];
|
|
175
|
-
availableOptions: AvailableOptions;
|
|
176
|
-
isFiltered: boolean;
|
|
177
|
-
}) => ReactNode;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Headless component for product filters with available options
|
|
181
|
-
*
|
|
182
|
-
* @component
|
|
183
|
-
* @example
|
|
184
|
-
* ```tsx
|
|
185
|
-
* import { FilteredCollection } from '@wix/stores/components';
|
|
186
|
-
*
|
|
187
|
-
* function ProductFilters() {
|
|
188
|
-
* return (
|
|
189
|
-
* <FilteredCollection.Filters>
|
|
190
|
-
* {({ applyFilters, clearFilters, currentFilters, availableOptions, isFiltered }) => (
|
|
191
|
-
* <div className="filters">
|
|
192
|
-
* <h3>Filters</h3>
|
|
193
|
-
* <div className="price-filter">
|
|
194
|
-
* <label>Price Range</label>
|
|
195
|
-
* <input
|
|
196
|
-
* type="range"
|
|
197
|
-
* min={availableOptions.priceRange.min}
|
|
198
|
-
* max={availableOptions.priceRange.max}
|
|
199
|
-
* value={currentFilters.priceRange.min}
|
|
200
|
-
* onChange={(e) => applyFilters({
|
|
201
|
-
* ...currentFilters,
|
|
202
|
-
* priceRange: { ...currentFilters.priceRange, min: Number(e.target.value) }
|
|
203
|
-
* })}
|
|
204
|
-
* />
|
|
205
|
-
* </div>
|
|
206
|
-
* {isFiltered && (
|
|
207
|
-
* <button onClick={clearFilters}>Clear All Filters</button>
|
|
208
|
-
* )}
|
|
209
|
-
* </div>
|
|
210
|
-
* )}
|
|
211
|
-
* </FilteredCollection.Filters>
|
|
212
|
-
* );
|
|
213
|
-
* }
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
export declare const Filters: React.FC<FilteredFiltersProps>;
|