@wix/headless-stores 0.0.30 → 0.0.32
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 +30 -0
- package/cjs/dist/react/Category.js +30 -0
- package/cjs/dist/react/Collection.d.ts +145 -0
- package/cjs/dist/react/Collection.js +145 -0
- package/cjs/dist/react/FilteredCollection.d.ts +134 -0
- package/cjs/dist/react/FilteredCollection.js +134 -0
- package/cjs/dist/react/Product.d.ts +43 -18
- package/cjs/dist/react/Product.js +43 -18
- package/cjs/dist/react/ProductActions.d.ts +30 -0
- package/cjs/dist/react/ProductActions.js +30 -0
- package/cjs/dist/react/ProductModifiers.d.ts +172 -0
- package/cjs/dist/react/ProductModifiers.js +172 -0
- package/cjs/dist/react/ProductVariantSelector.d.ts +118 -0
- package/cjs/dist/react/ProductVariantSelector.js +118 -0
- package/cjs/dist/react/ProductsList.d.ts +101 -0
- package/cjs/dist/react/ProductsList.js +101 -0
- package/cjs/dist/react/RelatedProducts.d.ts +55 -0
- package/cjs/dist/react/RelatedProducts.js +55 -0
- package/cjs/dist/react/SelectedVariant.d.ts +59 -0
- package/cjs/dist/react/SelectedVariant.js +59 -0
- package/cjs/dist/react/SocialSharing.d.ts +82 -0
- package/cjs/dist/react/SocialSharing.js +82 -0
- package/cjs/dist/react/Sort.d.ts +22 -0
- package/cjs/dist/react/Sort.js +22 -0
- package/cjs/dist/services/category-service.d.ts +87 -0
- package/cjs/dist/services/category-service.js +87 -0
- package/cjs/dist/services/collection-service.d.ts +89 -0
- package/cjs/dist/services/collection-service.js +89 -0
- package/cjs/dist/services/product-service.d.ts +81 -4
- package/cjs/dist/services/product-service.js +76 -0
- package/cjs/dist/services/products-list-service.d.ts +93 -0
- package/cjs/dist/services/products-list-service.js +93 -0
- package/cjs/dist/services/related-products-service.d.ts +75 -0
- package/cjs/dist/services/related-products-service.js +75 -0
- package/cjs/dist/services/selected-variant-service.js +6 -7
- package/dist/react/Category.d.ts +30 -0
- package/dist/react/Category.js +30 -0
- package/dist/react/Collection.d.ts +145 -0
- package/dist/react/Collection.js +145 -0
- package/dist/react/FilteredCollection.d.ts +134 -0
- package/dist/react/FilteredCollection.js +134 -0
- package/dist/react/Product.d.ts +43 -18
- package/dist/react/Product.js +43 -18
- package/dist/react/ProductActions.d.ts +30 -0
- package/dist/react/ProductActions.js +30 -0
- package/dist/react/ProductModifiers.d.ts +172 -0
- package/dist/react/ProductModifiers.js +172 -0
- package/dist/react/ProductVariantSelector.d.ts +118 -0
- package/dist/react/ProductVariantSelector.js +118 -0
- package/dist/react/ProductsList.d.ts +101 -0
- package/dist/react/ProductsList.js +101 -0
- package/dist/react/RelatedProducts.d.ts +55 -0
- package/dist/react/RelatedProducts.js +55 -0
- package/dist/react/SelectedVariant.d.ts +59 -0
- package/dist/react/SelectedVariant.js +59 -0
- package/dist/react/SocialSharing.d.ts +82 -0
- package/dist/react/SocialSharing.js +82 -0
- package/dist/react/Sort.d.ts +22 -0
- package/dist/react/Sort.js +22 -0
- package/dist/services/category-service.d.ts +87 -0
- package/dist/services/category-service.js +87 -0
- package/dist/services/collection-service.d.ts +89 -0
- package/dist/services/collection-service.js +89 -0
- package/dist/services/product-service.d.ts +81 -4
- package/dist/services/product-service.js +76 -0
- package/dist/services/products-list-service.d.ts +93 -0
- package/dist/services/products-list-service.js +93 -0
- package/dist/services/related-products-service.d.ts +75 -0
- package/dist/services/related-products-service.js +75 -0
- package/dist/services/selected-variant-service.js +6 -7
- package/package.json +1 -1
|
@@ -11,5 +11,35 @@ export interface CategoryListProps {
|
|
|
11
11
|
* Headless component for displaying a list of categories
|
|
12
12
|
*
|
|
13
13
|
* @component
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { Category } from '@wix/stores/components';
|
|
17
|
+
*
|
|
18
|
+
* function CategoryNavigation() {
|
|
19
|
+
* return (
|
|
20
|
+
* <Category.List>
|
|
21
|
+
* {({ categories, selectedCategory, setSelectedCategory }) => (
|
|
22
|
+
* <nav>
|
|
23
|
+
* <button
|
|
24
|
+
* onClick={() => setSelectedCategory(null)}
|
|
25
|
+
* className={selectedCategory === null ? 'active' : ''}
|
|
26
|
+
* >
|
|
27
|
+
* All Categories
|
|
28
|
+
* </button>
|
|
29
|
+
* {categories.map(category => (
|
|
30
|
+
* <button
|
|
31
|
+
* key={category.id}
|
|
32
|
+
* onClick={() => setSelectedCategory(category.id)}
|
|
33
|
+
* className={selectedCategory === category.id ? 'active' : ''}
|
|
34
|
+
* >
|
|
35
|
+
* {category.name}
|
|
36
|
+
* </button>
|
|
37
|
+
* ))}
|
|
38
|
+
* </nav>
|
|
39
|
+
* )}
|
|
40
|
+
* </Category.List>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
14
44
|
*/
|
|
15
45
|
export declare const List: React.FC<CategoryListProps>;
|
|
@@ -5,6 +5,36 @@ import { CategoryServiceDefinition } from "../services/category-service.js";
|
|
|
5
5
|
* Headless component for displaying a list of categories
|
|
6
6
|
*
|
|
7
7
|
* @component
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* import { Category } from '@wix/stores/components';
|
|
11
|
+
*
|
|
12
|
+
* function CategoryNavigation() {
|
|
13
|
+
* return (
|
|
14
|
+
* <Category.List>
|
|
15
|
+
* {({ categories, selectedCategory, setSelectedCategory }) => (
|
|
16
|
+
* <nav>
|
|
17
|
+
* <button
|
|
18
|
+
* onClick={() => setSelectedCategory(null)}
|
|
19
|
+
* className={selectedCategory === null ? 'active' : ''}
|
|
20
|
+
* >
|
|
21
|
+
* All Categories
|
|
22
|
+
* </button>
|
|
23
|
+
* {categories.map(category => (
|
|
24
|
+
* <button
|
|
25
|
+
* key={category.id}
|
|
26
|
+
* onClick={() => setSelectedCategory(category.id)}
|
|
27
|
+
* className={selectedCategory === category.id ? 'active' : ''}
|
|
28
|
+
* >
|
|
29
|
+
* {category.name}
|
|
30
|
+
* </button>
|
|
31
|
+
* ))}
|
|
32
|
+
* </nav>
|
|
33
|
+
* )}
|
|
34
|
+
* </Category.List>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
8
38
|
*/
|
|
9
39
|
export const List = ({ children }) => {
|
|
10
40
|
const service = useService(CategoryServiceDefinition);
|
|
@@ -27,6 +27,37 @@ export interface GridRenderProps {
|
|
|
27
27
|
* Headless component for product grid
|
|
28
28
|
*
|
|
29
29
|
* @component
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { Collection } from '@wix/stores/components';
|
|
33
|
+
*
|
|
34
|
+
* function ProductGrid() {
|
|
35
|
+
* return (
|
|
36
|
+
* <Collection.Grid>
|
|
37
|
+
* {({ products, isLoading, error, isEmpty, totalProducts, hasProducts }) => (
|
|
38
|
+
* <div>
|
|
39
|
+
* {isLoading && <div>Loading products...</div>}
|
|
40
|
+
* {error && <div>Error: {error}</div>}
|
|
41
|
+
* {isEmpty && <div>No products found</div>}
|
|
42
|
+
* {hasProducts && (
|
|
43
|
+
* <div>
|
|
44
|
+
* <p>Showing {products.length} of {totalProducts} products</p>
|
|
45
|
+
* <div className="product-grid">
|
|
46
|
+
* {products.map(product => (
|
|
47
|
+
* <div key={product.id} className="product-card">
|
|
48
|
+
* <h3>{product.name}</h3>
|
|
49
|
+
* <p>{product.price?.price} {product.price?.currency}</p>
|
|
50
|
+
* </div>
|
|
51
|
+
* ))}
|
|
52
|
+
* </div>
|
|
53
|
+
* </div>
|
|
54
|
+
* )}
|
|
55
|
+
* </div>
|
|
56
|
+
* )}
|
|
57
|
+
* </Collection.Grid>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
30
61
|
*/
|
|
31
62
|
export declare const Grid: (props: GridProps) => import("react").ReactNode;
|
|
32
63
|
/**
|
|
@@ -63,6 +94,32 @@ export interface ItemRenderProps {
|
|
|
63
94
|
* Headless component for individual product item
|
|
64
95
|
*
|
|
65
96
|
* @component
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* import { Collection } from '@wix/stores/components';
|
|
100
|
+
*
|
|
101
|
+
* function ProductCard({ product }) {
|
|
102
|
+
* return (
|
|
103
|
+
* <Collection.Item product={product}>
|
|
104
|
+
* {({ id, title, slug, image, price, compareAtPrice, description, available }) => (
|
|
105
|
+
* <div className={`product-card ${!available ? 'unavailable' : ''}`}>
|
|
106
|
+
* {image && <img src={image} alt={title} />}
|
|
107
|
+
* <h3>{title}</h3>
|
|
108
|
+
* <p>{description}</p>
|
|
109
|
+
* <div className="pricing">
|
|
110
|
+
* <span className="price">{price}</span>
|
|
111
|
+
* {compareAtPrice && (
|
|
112
|
+
* <span className="compare-price"><s>{compareAtPrice}</s></span>
|
|
113
|
+
* )}
|
|
114
|
+
* </div>
|
|
115
|
+
* {!available && <div className="badge">Out of Stock</div>}
|
|
116
|
+
* <a href={`/products/${slug}`}>View Product</a>
|
|
117
|
+
* </div>
|
|
118
|
+
* )}
|
|
119
|
+
* </Collection.Item>
|
|
120
|
+
* );
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
66
123
|
*/
|
|
67
124
|
export declare const Item: (props: ItemProps) => import("react").ReactNode;
|
|
68
125
|
/**
|
|
@@ -94,6 +151,37 @@ export interface LoadMoreRenderProps {
|
|
|
94
151
|
* Note: V3 API uses simplified loading without traditional pagination
|
|
95
152
|
*
|
|
96
153
|
* @component
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* import { Collection } from '@wix/stores/components';
|
|
157
|
+
*
|
|
158
|
+
* function LoadMoreButton() {
|
|
159
|
+
* return (
|
|
160
|
+
* <Collection.LoadMore>
|
|
161
|
+
* {({ loadMore, refresh, isLoading, hasProducts, totalProducts, hasMoreProducts }) => (
|
|
162
|
+
* <div className="load-more-section">
|
|
163
|
+
* {hasProducts && (
|
|
164
|
+
* <div>
|
|
165
|
+
* <p>Loaded {totalProducts} products</p>
|
|
166
|
+
* <div className="actions">
|
|
167
|
+
* {hasMoreProducts && (
|
|
168
|
+
* <button
|
|
169
|
+
* onClick={loadMore}
|
|
170
|
+
* disabled={isLoading}
|
|
171
|
+
* >
|
|
172
|
+
* {isLoading ? 'Loading...' : 'Load More Products'}
|
|
173
|
+
* </button>
|
|
174
|
+
* )}
|
|
175
|
+
* <button onClick={refresh}>Refresh Collection</button>
|
|
176
|
+
* </div>
|
|
177
|
+
* </div>
|
|
178
|
+
* )}
|
|
179
|
+
* </div>
|
|
180
|
+
* )}
|
|
181
|
+
* </Collection.LoadMore>
|
|
182
|
+
* );
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
97
185
|
*/
|
|
98
186
|
export declare const LoadMore: (props: LoadMoreProps) => import("react").ReactNode;
|
|
99
187
|
/**
|
|
@@ -118,6 +206,28 @@ export interface HeaderRenderProps {
|
|
|
118
206
|
* Headless component for collection header with product count
|
|
119
207
|
*
|
|
120
208
|
* @component
|
|
209
|
+
* @example
|
|
210
|
+
* ```tsx
|
|
211
|
+
* import { Collection } from '@wix/stores/components';
|
|
212
|
+
*
|
|
213
|
+
* function CollectionHeader() {
|
|
214
|
+
* return (
|
|
215
|
+
* <Collection.Header>
|
|
216
|
+
* {({ totalProducts, isLoading, hasProducts }) => (
|
|
217
|
+
* <div className="collection-header">
|
|
218
|
+
* {isLoading && <div>Loading collection...</div>}
|
|
219
|
+
* {hasProducts && !isLoading && (
|
|
220
|
+
* <h2>Products ({totalProducts} items)</h2>
|
|
221
|
+
* )}
|
|
222
|
+
* {!hasProducts && !isLoading && (
|
|
223
|
+
* <h2>No products found</h2>
|
|
224
|
+
* )}
|
|
225
|
+
* </div>
|
|
226
|
+
* )}
|
|
227
|
+
* </Collection.Header>
|
|
228
|
+
* );
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
121
231
|
*/
|
|
122
232
|
export declare const Header: (props: HeaderProps) => import("react").ReactNode;
|
|
123
233
|
/**
|
|
@@ -145,5 +255,40 @@ export interface ActionsRenderProps {
|
|
|
145
255
|
* Replaces traditional pagination for V3 API
|
|
146
256
|
*
|
|
147
257
|
* @component
|
|
258
|
+
* @example
|
|
259
|
+
* ```tsx
|
|
260
|
+
* import { Collection } from '@wix/stores/components';
|
|
261
|
+
*
|
|
262
|
+
* function CollectionActions() {
|
|
263
|
+
* return (
|
|
264
|
+
* <Collection.Actions>
|
|
265
|
+
* {({ refresh, loadMore, isLoading, error }) => (
|
|
266
|
+
* <div className="collection-actions">
|
|
267
|
+
* {error && (
|
|
268
|
+
* <div className="error">
|
|
269
|
+
* Error: {error}
|
|
270
|
+
* <button onClick={refresh}>Retry</button>
|
|
271
|
+
* </div>
|
|
272
|
+
* )}
|
|
273
|
+
* <div className="action-buttons">
|
|
274
|
+
* <button
|
|
275
|
+
* onClick={refresh}
|
|
276
|
+
* disabled={isLoading}
|
|
277
|
+
* >
|
|
278
|
+
* {isLoading ? 'Refreshing...' : 'Refresh'}
|
|
279
|
+
* </button>
|
|
280
|
+
* <button
|
|
281
|
+
* onClick={loadMore}
|
|
282
|
+
* disabled={isLoading}
|
|
283
|
+
* >
|
|
284
|
+
* Load More
|
|
285
|
+
* </button>
|
|
286
|
+
* </div>
|
|
287
|
+
* </div>
|
|
288
|
+
* )}
|
|
289
|
+
* </Collection.Actions>
|
|
290
|
+
* );
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
148
293
|
*/
|
|
149
294
|
export declare const Actions: (props: ActionsProps) => import("react").ReactNode;
|
|
@@ -5,6 +5,37 @@ import { InventoryAvailabilityStatus, } from "@wix/auto_sdk_stores_products-v-3"
|
|
|
5
5
|
* Headless component for product grid
|
|
6
6
|
*
|
|
7
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
|
+
* ```
|
|
8
39
|
*/
|
|
9
40
|
export const Grid = (props) => {
|
|
10
41
|
const service = useService(CollectionServiceDefinition);
|
|
@@ -52,6 +83,32 @@ export const Grid = (props) => {
|
|
|
52
83
|
* Headless component for individual product item
|
|
53
84
|
*
|
|
54
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
|
+
* ```
|
|
55
112
|
*/
|
|
56
113
|
export const Item = (props) => {
|
|
57
114
|
const { product } = props;
|
|
@@ -84,6 +141,37 @@ export const Item = (props) => {
|
|
|
84
141
|
* Note: V3 API uses simplified loading without traditional pagination
|
|
85
142
|
*
|
|
86
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
|
+
* ```
|
|
87
175
|
*/
|
|
88
176
|
export const LoadMore = (props) => {
|
|
89
177
|
const service = useService(CollectionServiceDefinition);
|
|
@@ -129,6 +217,28 @@ export const LoadMore = (props) => {
|
|
|
129
217
|
* Headless component for collection header with product count
|
|
130
218
|
*
|
|
131
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
|
+
* ```
|
|
132
242
|
*/
|
|
133
243
|
export const Header = (props) => {
|
|
134
244
|
const service = useService(CollectionServiceDefinition);
|
|
@@ -165,6 +275,41 @@ export const Header = (props) => {
|
|
|
165
275
|
* Replaces traditional pagination for V3 API
|
|
166
276
|
*
|
|
167
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
|
+
* ```
|
|
168
313
|
*/
|
|
169
314
|
export const Actions = (props) => {
|
|
170
315
|
const service = useService(CollectionServiceDefinition);
|
|
@@ -11,6 +11,26 @@ export interface FiltersLoadingProps {
|
|
|
11
11
|
* Headless component for displaying a loading state for filters
|
|
12
12
|
*
|
|
13
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
|
+
* ```
|
|
14
34
|
*/
|
|
15
35
|
export declare const FiltersLoading: React.FC<FiltersLoadingProps>;
|
|
16
36
|
export interface FilteredGridProps {
|
|
@@ -27,6 +47,35 @@ export interface FilteredGridProps {
|
|
|
27
47
|
* Headless component for displaying a grid of filtered products
|
|
28
48
|
*
|
|
29
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
|
+
* ```
|
|
30
79
|
*/
|
|
31
80
|
export declare const Grid: React.FC<FilteredGridProps>;
|
|
32
81
|
export interface FilteredItemProps {
|
|
@@ -46,6 +95,30 @@ export interface FilteredItemProps {
|
|
|
46
95
|
* Headless component for displaying a filtered product item
|
|
47
96
|
*
|
|
48
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
|
+
* ```
|
|
49
122
|
*/
|
|
50
123
|
export declare const Item: React.FC<FilteredItemProps>;
|
|
51
124
|
export interface FilteredLoadMoreProps {
|
|
@@ -62,6 +135,35 @@ export interface FilteredLoadMoreProps {
|
|
|
62
135
|
* Headless component for load more filtered products functionality
|
|
63
136
|
*
|
|
64
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
|
+
* ```
|
|
65
167
|
*/
|
|
66
168
|
export declare const LoadMore: React.FC<FilteredLoadMoreProps>;
|
|
67
169
|
export interface FilteredFiltersProps {
|
|
@@ -78,5 +180,37 @@ export interface FilteredFiltersProps {
|
|
|
78
180
|
* Headless component for product filters with available options
|
|
79
181
|
*
|
|
80
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
|
+
* ```
|
|
81
215
|
*/
|
|
82
216
|
export declare const Filters: React.FC<FilteredFiltersProps>;
|