@wix/headless-stores 0.0.54 → 0.0.56
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/Product.d.ts +102 -1
- package/cjs/dist/react/Product.js +138 -1
- package/cjs/dist/react/ProductList.d.ts +163 -0
- package/cjs/dist/react/ProductList.js +235 -0
- package/cjs/dist/react/core/Product.d.ts +38 -1
- package/cjs/dist/react/core/Product.js +33 -2
- package/cjs/dist/react/index.d.ts +2 -1
- package/cjs/dist/react/index.js +2 -1
- package/cjs/dist/services/selected-variant-service.js +1 -1
- package/dist/react/Product.d.ts +102 -1
- package/dist/react/Product.js +138 -1
- package/dist/react/ProductList.d.ts +163 -0
- package/dist/react/ProductList.js +235 -0
- package/dist/react/core/Product.d.ts +38 -1
- package/dist/react/core/Product.js +33 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/services/selected-variant-service.js +1 -1
- package/package.json +2 -2
|
@@ -129,7 +129,8 @@ export interface ProductMediaProps {
|
|
|
129
129
|
children: (props: ProductMediaRenderProps) => React.ReactNode;
|
|
130
130
|
}
|
|
131
131
|
export interface ProductMediaRenderProps {
|
|
132
|
-
|
|
132
|
+
mediaItems: ProductMedia[];
|
|
133
|
+
mainMedia?: ProductMedia;
|
|
133
134
|
}
|
|
134
135
|
export declare function Media(props: ProductMediaProps): import("react").ReactNode;
|
|
135
136
|
export interface ProductProps {
|
|
@@ -146,3 +147,39 @@ export interface LoadingRenderProps {
|
|
|
146
147
|
isLoading: boolean;
|
|
147
148
|
}
|
|
148
149
|
export declare function Loading(props: LoadingProps): import("react").ReactNode;
|
|
150
|
+
/**
|
|
151
|
+
* Props for ProductSlug headless component
|
|
152
|
+
*/
|
|
153
|
+
export interface ProductSlugProps {
|
|
154
|
+
/** Render prop function that receives product slug data */
|
|
155
|
+
children: (props: ProductSlugRenderProps) => React.ReactNode;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Render props for ProductSlug component
|
|
159
|
+
*/
|
|
160
|
+
export interface ProductSlugRenderProps {
|
|
161
|
+
/** Product slug */
|
|
162
|
+
slug: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Headless component for product slug display
|
|
166
|
+
*
|
|
167
|
+
* @component
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* import { Product } from '@wix/stores/components';
|
|
171
|
+
*
|
|
172
|
+
* function ProductSlugDisplay() {
|
|
173
|
+
* return (
|
|
174
|
+
* <Product.Slug>
|
|
175
|
+
* {({ slug }) => (
|
|
176
|
+
* <a href={`/product/${slug}`}>
|
|
177
|
+
* View Product
|
|
178
|
+
* </a>
|
|
179
|
+
* )}
|
|
180
|
+
* </Product.Slug>
|
|
181
|
+
* );
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export declare function Slug(props: ProductSlugProps): import("react").ReactNode;
|
|
@@ -105,9 +105,11 @@ export function Description(props) {
|
|
|
105
105
|
export function Media(props) {
|
|
106
106
|
const service = useService(ProductServiceDefinition);
|
|
107
107
|
const product = service.product.get();
|
|
108
|
-
const
|
|
108
|
+
const mainMedia = product.media?.main;
|
|
109
|
+
const mediaItems = product.media?.itemsInfo?.items ?? [];
|
|
109
110
|
return props.children({
|
|
110
|
-
|
|
111
|
+
mediaItems,
|
|
112
|
+
mainMedia,
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
export function Content(props) {
|
|
@@ -124,3 +126,32 @@ export function Loading(props) {
|
|
|
124
126
|
isLoading,
|
|
125
127
|
});
|
|
126
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Headless component for product slug display
|
|
131
|
+
*
|
|
132
|
+
* @component
|
|
133
|
+
* @example
|
|
134
|
+
* ```tsx
|
|
135
|
+
* import { Product } from '@wix/stores/components';
|
|
136
|
+
*
|
|
137
|
+
* function ProductSlugDisplay() {
|
|
138
|
+
* return (
|
|
139
|
+
* <Product.Slug>
|
|
140
|
+
* {({ slug }) => (
|
|
141
|
+
* <a href={`/product/${slug}`}>
|
|
142
|
+
* View Product
|
|
143
|
+
* </a>
|
|
144
|
+
* )}
|
|
145
|
+
* </Product.Slug>
|
|
146
|
+
* );
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export function Slug(props) {
|
|
151
|
+
const service = useService(ProductServiceDefinition);
|
|
152
|
+
const product = service.product.get();
|
|
153
|
+
const slug = product.slug;
|
|
154
|
+
return props.children({
|
|
155
|
+
slug,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -2,13 +2,14 @@ export * as CategoryListCore from './core/CategoryList.js';
|
|
|
2
2
|
export * as CategoryCore from './core/Category.js';
|
|
3
3
|
export * as ProductCore from './core/Product.js';
|
|
4
4
|
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
5
|
-
export * as
|
|
5
|
+
export * as ProductListCore from './core/ProductList.js';
|
|
6
6
|
export * as ProductListFilters from './core/ProductListFilters.js';
|
|
7
7
|
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
8
8
|
export * as ProductListSort from './core/ProductListSort.js';
|
|
9
9
|
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
10
10
|
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
11
11
|
export * as Product from './Product.js';
|
|
12
|
+
export * as ProductList from './ProductList.js';
|
|
12
13
|
export * as Option from './Option.js';
|
|
13
14
|
export * as Choice from './Choice.js';
|
|
14
15
|
export * as CategoryList from './CategoryList.js';
|
package/cjs/dist/react/index.js
CHANGED
|
@@ -2,13 +2,14 @@ export * as CategoryListCore from './core/CategoryList.js';
|
|
|
2
2
|
export * as CategoryCore from './core/Category.js';
|
|
3
3
|
export * as ProductCore from './core/Product.js';
|
|
4
4
|
export * as ProductModifiers from './core/ProductModifiers.js';
|
|
5
|
-
export * as
|
|
5
|
+
export * as ProductListCore from './core/ProductList.js';
|
|
6
6
|
export * as ProductListFilters from './core/ProductListFilters.js';
|
|
7
7
|
export * as ProductListPagination from './core/ProductListPagination.js';
|
|
8
8
|
export * as ProductListSort from './core/ProductListSort.js';
|
|
9
9
|
export * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
10
10
|
export * as SelectedVariant from './core/SelectedVariant.js';
|
|
11
11
|
export * as Product from './Product.js';
|
|
12
|
+
export * as ProductList from './ProductList.js';
|
|
12
13
|
export * as Option from './Option.js';
|
|
13
14
|
export * as Choice from './Choice.js';
|
|
14
15
|
export * as CategoryList from './CategoryList.js';
|
|
@@ -249,7 +249,7 @@ export const SelectedVariantService = implementService.withConfig()(SelectedVari
|
|
|
249
249
|
else if (prod?.compareAtPriceRange?.minValue?.amount) {
|
|
250
250
|
rawAmount = prod.compareAtPriceRange.minValue.amount;
|
|
251
251
|
}
|
|
252
|
-
return rawAmount ? `$${rawAmount}` : null;
|
|
252
|
+
return rawAmount && rawAmount !== '0' ? `$${rawAmount}` : null;
|
|
253
253
|
});
|
|
254
254
|
const isInStock = signalsService.computed(() => {
|
|
255
255
|
const variant = currentVariant.get();
|
package/dist/react/Product.d.ts
CHANGED
|
@@ -188,6 +188,64 @@ export interface CompareAtPriceProps extends AsChildProps<{
|
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
export declare const CompareAtPrice: React.ForwardRefExoticComponent<CompareAtPriceProps & React.RefAttributes<HTMLElement>>;
|
|
191
|
+
/**
|
|
192
|
+
* Props for Slug component
|
|
193
|
+
* @interface SlugProps
|
|
194
|
+
*/
|
|
195
|
+
export interface SlugProps extends AsChildProps<{
|
|
196
|
+
slug: string;
|
|
197
|
+
}> {
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Product Slug component that displays the product's slug
|
|
201
|
+
*
|
|
202
|
+
* @component
|
|
203
|
+
* @order 6
|
|
204
|
+
* @example
|
|
205
|
+
* ```tsx
|
|
206
|
+
* import { Product } from '@wix/stores/components';
|
|
207
|
+
*
|
|
208
|
+
* function ProductSlugLink() {
|
|
209
|
+
* return (
|
|
210
|
+
* <Product.Slug>
|
|
211
|
+
* {({ slug }) => (
|
|
212
|
+
* <a href={`/product/${slug}`}>
|
|
213
|
+
* View Product Details
|
|
214
|
+
* </a>
|
|
215
|
+
* )}
|
|
216
|
+
* </Product.Slug>
|
|
217
|
+
* );
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare const Slug: React.ForwardRefExoticComponent<SlugProps & React.RefAttributes<HTMLElement>>;
|
|
222
|
+
/**
|
|
223
|
+
* Props for Product Raw component
|
|
224
|
+
*/
|
|
225
|
+
export interface RawProps extends AsChildProps<{
|
|
226
|
+
product: V3Product;
|
|
227
|
+
}> {
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Provides access to the raw product data for advanced use cases.
|
|
231
|
+
* Similar to Category.Raw, this should only be used when you need custom access to product data.
|
|
232
|
+
*
|
|
233
|
+
* @component
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx
|
|
236
|
+
* // Custom rendering with forwardRef
|
|
237
|
+
* <Product.Raw asChild>
|
|
238
|
+
* {React.forwardRef(({product, ...props}, ref) => (
|
|
239
|
+
* <div ref={ref} {...props} className="product-debug">
|
|
240
|
+
* <span>Product ID: {product._id}</span>
|
|
241
|
+
* <span>SKU: {product.sku}</span>
|
|
242
|
+
* <span>Inventory: {product.inventory?.quantity}</span>
|
|
243
|
+
* </div>
|
|
244
|
+
* ))}
|
|
245
|
+
* </Product.Raw>
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export declare const Raw: React.ForwardRefExoticComponent<RawProps & React.RefAttributes<HTMLElement>>;
|
|
191
249
|
/**
|
|
192
250
|
* Props for Product Variants container
|
|
193
251
|
*/
|
|
@@ -388,4 +446,47 @@ export interface ModifierOptionRepeaterProps {
|
|
|
388
446
|
* @component
|
|
389
447
|
*/
|
|
390
448
|
export declare const ModifierOptionRepeater: React.ForwardRefExoticComponent<ModifierOptionRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
391
|
-
|
|
449
|
+
/**
|
|
450
|
+
* Props for Product MediaGallery component
|
|
451
|
+
*/
|
|
452
|
+
export interface ProductMediaGalleryProps {
|
|
453
|
+
children: React.ReactNode;
|
|
454
|
+
infinite?: boolean;
|
|
455
|
+
autoPlay?: {
|
|
456
|
+
direction?: 'forward' | 'backward';
|
|
457
|
+
intervalMs?: number;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Container for product media gallery.
|
|
462
|
+
* Renders a MediaGallery.Root with the product media items.
|
|
463
|
+
*
|
|
464
|
+
* @component
|
|
465
|
+
* @example
|
|
466
|
+
* ```tsx
|
|
467
|
+
* // Default usage
|
|
468
|
+
* <Product.MediaGallery
|
|
469
|
+
* infinite={true}
|
|
470
|
+
* autoPlay={{ direction: "forward", intervalMs: 5000 }}
|
|
471
|
+
* >
|
|
472
|
+
* <MediaGallery.Viewport />
|
|
473
|
+
* <MediaGallery.Previous />
|
|
474
|
+
* <MediaGallery.Next />
|
|
475
|
+
* <MediaGallery.Thumbnails>
|
|
476
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
477
|
+
* <MediaGallery.ThumbnailItem />
|
|
478
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
479
|
+
* </MediaGallery.Thumbnails>
|
|
480
|
+
* </Product.MediaGallery>
|
|
481
|
+
*
|
|
482
|
+
* // Simple usage
|
|
483
|
+
* <Product.MediaGallery>
|
|
484
|
+
* <MediaGallery.Viewport className="rounded-lg" />
|
|
485
|
+
* </Product.MediaGallery>
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
export declare const ProductMediaGallery: React.ForwardRefExoticComponent<ProductMediaGalleryProps & React.RefAttributes<HTMLElement>>;
|
|
489
|
+
/**
|
|
490
|
+
* Alias for ProductMediaGallery to match the documented API
|
|
491
|
+
*/
|
|
492
|
+
export { ProductMediaGallery as MediaGallery };
|
package/dist/react/Product.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { renderAsChild } from '../utils/index.js';
|
|
4
|
+
import { MediaGallery } from '@wix/headless-media/react';
|
|
4
5
|
import * as CoreProduct from './core/Product.js';
|
|
5
6
|
import * as ProductVariantSelector from './core/ProductVariantSelector.js';
|
|
6
7
|
import * as ProductModifiers from './core/ProductModifiers.js';
|
|
@@ -36,12 +37,15 @@ var TestIds;
|
|
|
36
37
|
TestIds["productDescription"] = "product-description";
|
|
37
38
|
TestIds["productPrice"] = "product-price";
|
|
38
39
|
TestIds["productCompareAtPrice"] = "product-compare-at-price";
|
|
40
|
+
TestIds["productSlug"] = "product-slug";
|
|
41
|
+
TestIds["productRaw"] = "product-raw";
|
|
39
42
|
TestIds["productVariants"] = "product-variants";
|
|
40
43
|
TestIds["productVariantOptions"] = "product-variant-options";
|
|
41
44
|
TestIds["productVariantOption"] = "product-variant-option";
|
|
42
45
|
TestIds["productModifiers"] = "product-modifiers";
|
|
43
46
|
TestIds["productModifierOptions"] = "product-modifier-options";
|
|
44
47
|
TestIds["productModifierOption"] = "product-modifier-option";
|
|
48
|
+
TestIds["productMediaGallery"] = "product-media-gallery";
|
|
45
49
|
})(TestIds || (TestIds = {}));
|
|
46
50
|
/**
|
|
47
51
|
* Root component that provides all necessary service contexts for a complete product experience.
|
|
@@ -64,7 +68,9 @@ var TestIds;
|
|
|
64
68
|
* ```
|
|
65
69
|
*/
|
|
66
70
|
export function Root(props) {
|
|
67
|
-
return (_jsx(CoreProduct.Root, { productServiceConfig: { product: props.product }, "data-testid": TestIds.productRoot, children: _jsx(
|
|
71
|
+
return (_jsx(CoreProduct.Root, { productServiceConfig: { product: props.product }, "data-testid": TestIds.productRoot, children: _jsx(MediaGallery.Root, { mediaGalleryServiceConfig: {
|
|
72
|
+
media: props.product.media?.itemsInfo?.items ?? [],
|
|
73
|
+
}, children: _jsx(ProductVariantSelector.Root, { children: _jsx(ProductModifiers.Root, { children: _jsx(SelectedVariant.Root, { children: props.children }) }) }) }) }));
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
76
|
* Displays the product name with customizable rendering following the documented API.
|
|
@@ -281,6 +287,90 @@ export const CompareAtPrice = React.forwardRef((props, ref) => {
|
|
|
281
287
|
return (_jsx("span", { className: className, ...attributes, ref: ref, children: compareAtPrice }));
|
|
282
288
|
} }));
|
|
283
289
|
});
|
|
290
|
+
/**
|
|
291
|
+
* Product Slug component that displays the product's slug
|
|
292
|
+
*
|
|
293
|
+
* @component
|
|
294
|
+
* @order 6
|
|
295
|
+
* @example
|
|
296
|
+
* ```tsx
|
|
297
|
+
* import { Product } from '@wix/stores/components';
|
|
298
|
+
*
|
|
299
|
+
* function ProductSlugLink() {
|
|
300
|
+
* return (
|
|
301
|
+
* <Product.Slug>
|
|
302
|
+
* {({ slug }) => (
|
|
303
|
+
* <a href={`/product/${slug}`}>
|
|
304
|
+
* View Product Details
|
|
305
|
+
* </a>
|
|
306
|
+
* )}
|
|
307
|
+
* </Product.Slug>
|
|
308
|
+
* );
|
|
309
|
+
* }
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export const Slug = React.forwardRef((props, ref) => {
|
|
313
|
+
const { asChild, children } = props;
|
|
314
|
+
const testId = TestIds.productSlug;
|
|
315
|
+
return (_jsx(CoreProduct.Slug, { children: ({ slug }) => {
|
|
316
|
+
const attributes = {
|
|
317
|
+
'data-testid': testId,
|
|
318
|
+
};
|
|
319
|
+
const slugData = { slug };
|
|
320
|
+
if (asChild) {
|
|
321
|
+
const rendered = renderAsChild({
|
|
322
|
+
children,
|
|
323
|
+
props: slugData,
|
|
324
|
+
ref,
|
|
325
|
+
content: slug,
|
|
326
|
+
attributes,
|
|
327
|
+
});
|
|
328
|
+
if (rendered)
|
|
329
|
+
return rendered;
|
|
330
|
+
}
|
|
331
|
+
return (_jsx("span", { ...attributes, ref: ref, children: slug }));
|
|
332
|
+
} }));
|
|
333
|
+
});
|
|
334
|
+
/**
|
|
335
|
+
* Provides access to the raw product data for advanced use cases.
|
|
336
|
+
* Similar to Category.Raw, this should only be used when you need custom access to product data.
|
|
337
|
+
*
|
|
338
|
+
* @component
|
|
339
|
+
* @example
|
|
340
|
+
* ```tsx
|
|
341
|
+
* // Custom rendering with forwardRef
|
|
342
|
+
* <Product.Raw asChild>
|
|
343
|
+
* {React.forwardRef(({product, ...props}, ref) => (
|
|
344
|
+
* <div ref={ref} {...props} className="product-debug">
|
|
345
|
+
* <span>Product ID: {product._id}</span>
|
|
346
|
+
* <span>SKU: {product.sku}</span>
|
|
347
|
+
* <span>Inventory: {product.inventory?.quantity}</span>
|
|
348
|
+
* </div>
|
|
349
|
+
* ))}
|
|
350
|
+
* </Product.Raw>
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
export const Raw = React.forwardRef((props, ref) => {
|
|
354
|
+
const { asChild, children } = props;
|
|
355
|
+
return (_jsx(CoreProduct.Content, { children: ({ product }) => {
|
|
356
|
+
const attributes = {
|
|
357
|
+
'data-testid': TestIds.productRaw,
|
|
358
|
+
};
|
|
359
|
+
if (asChild) {
|
|
360
|
+
const rendered = renderAsChild({
|
|
361
|
+
children,
|
|
362
|
+
props: { product },
|
|
363
|
+
ref,
|
|
364
|
+
content: null,
|
|
365
|
+
attributes,
|
|
366
|
+
});
|
|
367
|
+
if (rendered)
|
|
368
|
+
return rendered;
|
|
369
|
+
}
|
|
370
|
+
// Raw component should not render anything by default when not using asChild
|
|
371
|
+
return null;
|
|
372
|
+
} }));
|
|
373
|
+
});
|
|
284
374
|
/**
|
|
285
375
|
* Container for product variant selection system.
|
|
286
376
|
* Does not render when there are no variants.
|
|
@@ -537,3 +627,50 @@ export const ModifierOptionRepeater = React.forwardRef((props, _ref) => {
|
|
|
537
627
|
}, allowedTypes: allowedTypes, children: children })) }, modifier._id));
|
|
538
628
|
}) }));
|
|
539
629
|
});
|
|
630
|
+
/**
|
|
631
|
+
* Container for product media gallery.
|
|
632
|
+
* Renders a MediaGallery.Root with the product media items.
|
|
633
|
+
*
|
|
634
|
+
* @component
|
|
635
|
+
* @example
|
|
636
|
+
* ```tsx
|
|
637
|
+
* // Default usage
|
|
638
|
+
* <Product.MediaGallery
|
|
639
|
+
* infinite={true}
|
|
640
|
+
* autoPlay={{ direction: "forward", intervalMs: 5000 }}
|
|
641
|
+
* >
|
|
642
|
+
* <MediaGallery.Viewport />
|
|
643
|
+
* <MediaGallery.Previous />
|
|
644
|
+
* <MediaGallery.Next />
|
|
645
|
+
* <MediaGallery.Thumbnails>
|
|
646
|
+
* <MediaGallery.ThumbnailRepeater>
|
|
647
|
+
* <MediaGallery.ThumbnailItem />
|
|
648
|
+
* </MediaGallery.ThumbnailRepeater>
|
|
649
|
+
* </MediaGallery.Thumbnails>
|
|
650
|
+
* </Product.MediaGallery>
|
|
651
|
+
*
|
|
652
|
+
* // Simple usage
|
|
653
|
+
* <Product.MediaGallery>
|
|
654
|
+
* <MediaGallery.Viewport className="rounded-lg" />
|
|
655
|
+
* </Product.MediaGallery>
|
|
656
|
+
* ```
|
|
657
|
+
*/
|
|
658
|
+
export const ProductMediaGallery = React.forwardRef((props, ref) => {
|
|
659
|
+
const { children, infinite, autoPlay, ...otherProps } = props;
|
|
660
|
+
return (_jsx(CoreProduct.Media, { children: ({ mediaItems, mainMedia }) => {
|
|
661
|
+
const media = mediaItems.length > 0 ? mediaItems : mainMedia ? [mainMedia] : [];
|
|
662
|
+
const mediaGalleryServiceConfig = {
|
|
663
|
+
media,
|
|
664
|
+
infinite,
|
|
665
|
+
autoPlay,
|
|
666
|
+
};
|
|
667
|
+
const attributes = {
|
|
668
|
+
'data-testid': TestIds.productMediaGallery,
|
|
669
|
+
};
|
|
670
|
+
return (_jsx("div", { ...attributes, ref: ref, ...otherProps, children: _jsx(MediaGallery.Root, { mediaGalleryServiceConfig: mediaGalleryServiceConfig, children: children }) }));
|
|
671
|
+
} }));
|
|
672
|
+
});
|
|
673
|
+
/**
|
|
674
|
+
* Alias for ProductMediaGallery to match the documented API
|
|
675
|
+
*/
|
|
676
|
+
export { ProductMediaGallery as MediaGallery };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { V3Product } from '@wix/auto_sdk_stores_products-v-3';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ProductsListSearchServiceConfig } from '../services/products-list-search-service.js';
|
|
4
|
+
import type { ProductsListServiceConfig } from '../services/products-list-service.js';
|
|
5
|
+
import { type AsChildProps } from '../utils/renderAsChild.js';
|
|
6
|
+
/**
|
|
7
|
+
* Props for the ProductList root component following the documented API
|
|
8
|
+
*/
|
|
9
|
+
export interface ProductListRootProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
products?: V3Product[];
|
|
12
|
+
productsListConfig?: ProductsListServiceConfig;
|
|
13
|
+
productsListSearchConfig?: ProductsListSearchServiceConfig;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Root component that provides the ProductList service context for rendering product lists.
|
|
18
|
+
*
|
|
19
|
+
* @order 1
|
|
20
|
+
* @component
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { ProductList } from '@wix/stores/components';
|
|
24
|
+
*
|
|
25
|
+
* function ProductListPage({ products }) {
|
|
26
|
+
* return (
|
|
27
|
+
* <ProductList.Root products={products}>
|
|
28
|
+
* <ProductList.Products>
|
|
29
|
+
* <ProductList.ProductRepeater>
|
|
30
|
+
* <Product.Name />
|
|
31
|
+
* <Product.Price />
|
|
32
|
+
* </ProductList.ProductRepeater>
|
|
33
|
+
* </ProductList.Products>
|
|
34
|
+
* </ProductList.Root>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const Root: React.ForwardRefExoticComponent<ProductListRootProps & React.RefAttributes<HTMLElement>>;
|
|
40
|
+
/**
|
|
41
|
+
* Props for ProductList Raw component
|
|
42
|
+
*/
|
|
43
|
+
export interface RawProps {
|
|
44
|
+
children: ((props: {
|
|
45
|
+
totalProducts: number;
|
|
46
|
+
displayedProducts: number;
|
|
47
|
+
isFiltered: boolean;
|
|
48
|
+
}) => React.ReactNode) | React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Raw component that provides direct access to product list data.
|
|
52
|
+
* Similar to Product.Raw, this should only be used when you need custom access to list data.
|
|
53
|
+
*
|
|
54
|
+
* @component
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <ProductList.Raw>
|
|
58
|
+
* {({ totalProducts, displayedProducts, isFiltered }) => (
|
|
59
|
+
* <div className="text-content-muted">
|
|
60
|
+
* Showing {displayedProducts} of {totalProducts} products
|
|
61
|
+
* {isFiltered && <span className="ml-2 text-brand-primary">(Filtered)</span>}
|
|
62
|
+
* </div>
|
|
63
|
+
* )}
|
|
64
|
+
* </ProductList.Raw>
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const Raw: React.ForwardRefExoticComponent<RawProps & React.RefAttributes<HTMLElement>>;
|
|
68
|
+
/**
|
|
69
|
+
* Props for ProductList Products component
|
|
70
|
+
*/
|
|
71
|
+
export interface ProductsProps {
|
|
72
|
+
children: React.ReactNode;
|
|
73
|
+
emptyState?: React.ReactNode;
|
|
74
|
+
infiniteScroll?: boolean;
|
|
75
|
+
pageSize?: number;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Container for the product list with empty state support.
|
|
80
|
+
* Follows List Container Level pattern.
|
|
81
|
+
*
|
|
82
|
+
* @component
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* <ProductList.Products emptyState={<div>No products found</div>}>
|
|
86
|
+
* <ProductList.ProductRepeater>
|
|
87
|
+
* <Product.Name />
|
|
88
|
+
* <Product.Price />
|
|
89
|
+
* </ProductList.ProductRepeater>
|
|
90
|
+
* </ProductList.Products>
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const Products: React.ForwardRefExoticComponent<ProductsProps & React.RefAttributes<HTMLElement>>;
|
|
94
|
+
/**
|
|
95
|
+
* Props for ProductList ProductRepeater component
|
|
96
|
+
*/
|
|
97
|
+
export interface ProductRepeaterProps {
|
|
98
|
+
children: React.ReactNode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Repeater component that renders Product.Root for each product.
|
|
102
|
+
* Follows Repeater Level pattern.
|
|
103
|
+
* Note: Repeater components do NOT support asChild as per architecture rules.
|
|
104
|
+
*
|
|
105
|
+
* @component
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <ProductList.ProductRepeater>
|
|
109
|
+
* <Product.Name />
|
|
110
|
+
* <Product.Price />
|
|
111
|
+
* <Product.MediaGallery>
|
|
112
|
+
* <MediaGallery.Viewport />
|
|
113
|
+
* </Product.MediaGallery>
|
|
114
|
+
* </ProductList.ProductRepeater>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare const ProductRepeater: React.ForwardRefExoticComponent<ProductRepeaterProps & React.RefAttributes<HTMLElement>>;
|
|
118
|
+
/**
|
|
119
|
+
* Props for ProductList LoadMoreTrigger component
|
|
120
|
+
*/
|
|
121
|
+
export interface LoadMoreTriggerProps {
|
|
122
|
+
children?: React.ReactNode;
|
|
123
|
+
asChild?: boolean;
|
|
124
|
+
className?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Displays a button to load more products. Not rendered if infiniteScroll is false or no products are left to load.
|
|
128
|
+
* Follows the architecture rules - does not support asChild as it's a simple trigger component.
|
|
129
|
+
*
|
|
130
|
+
* @component
|
|
131
|
+
* @example
|
|
132
|
+
* ```tsx
|
|
133
|
+
* <ProductList.LoadMoreTrigger asChild>
|
|
134
|
+
* <button>Load More</button>
|
|
135
|
+
* </ProductList.LoadMoreTrigger>
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const LoadMoreTrigger: React.ForwardRefExoticComponent<LoadMoreTriggerProps & React.RefAttributes<HTMLElement>>;
|
|
139
|
+
/**
|
|
140
|
+
* Props for ProductList Totals Displayed component
|
|
141
|
+
*/
|
|
142
|
+
export interface TotalsDisplayedProps extends AsChildProps<{
|
|
143
|
+
displayedProducts: number;
|
|
144
|
+
}> {
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Displays the number of products currently displayed.
|
|
148
|
+
*
|
|
149
|
+
* @component
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* <ProductList.TotalsDisplayed />
|
|
153
|
+
* // or with asChild
|
|
154
|
+
* <ProductList.TotalsDisplayed asChild>
|
|
155
|
+
* <strong />
|
|
156
|
+
* </ProductList.TotalsDisplayed>
|
|
157
|
+
* // or with render function
|
|
158
|
+
* <ProductList.TotalsDisplayed asChild>
|
|
159
|
+
* {({ displayedProducts }, ref) => <strong ref={ref}>{displayedProducts}</strong>}
|
|
160
|
+
* </ProductList.TotalsDisplayed>
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare const TotalsDisplayed: React.ForwardRefExoticComponent<TotalsDisplayedProps & React.RefAttributes<HTMLElement>>;
|