@wix/headless-stores 0.0.109 → 0.0.111
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/astro/actions/custom-checkout.d.ts +1 -3
- package/cjs/dist/astro/actions/custom-checkout.js +8 -4
- package/cjs/dist/astro/actions/index.js +17 -1
- package/cjs/dist/data-component-tags.js +5 -2
- package/cjs/dist/enums/index.js +18 -2
- package/cjs/dist/enums/social-platform-enums.js +7 -4
- package/cjs/dist/enums/sort-enums.js +6 -3
- package/cjs/dist/react/Category.js +64 -25
- package/cjs/dist/react/CategoryList.js +55 -14
- package/cjs/dist/react/Choice.js +32 -25
- package/cjs/dist/react/Option.js +68 -29
- package/cjs/dist/react/Product.js +194 -155
- package/cjs/dist/react/ProductList.js +84 -45
- package/cjs/dist/react/core/CategoryList.js +26 -16
- package/cjs/dist/react/core/Product.js +30 -20
- package/cjs/dist/react/core/ProductList.js +29 -21
- package/cjs/dist/react/core/ProductListFilters.js +30 -22
- package/cjs/dist/react/core/ProductListPagination.js +7 -4
- package/cjs/dist/react/core/ProductListSort.js +11 -6
- package/cjs/dist/react/core/ProductModifiers.js +25 -17
- package/cjs/dist/react/core/ProductVariantSelector.js +27 -19
- package/cjs/dist/react/core/SelectedVariant.js +28 -21
- package/cjs/dist/react/index.js +42 -6
- package/cjs/dist/react/types.js +5 -2
- package/cjs/dist/server-actions/custom-checkout-action.js +11 -8
- package/cjs/dist/server-actions/index.js +17 -1
- package/cjs/dist/services/buy-now-service.js +20 -15
- package/cjs/dist/services/categories-list-service.js +12 -8
- package/cjs/dist/services/index.js +25 -5
- package/cjs/dist/services/pay-now-service.js +16 -11
- package/cjs/dist/services/product-modifiers-service.js +16 -12
- package/cjs/dist/services/product-service.js +16 -12
- package/cjs/dist/services/products-list-search-service.d.ts +0 -1
- package/cjs/dist/services/products-list-search-service.js +1 -1
- package/cjs/dist/services/products-list-service.js +66 -59
- package/cjs/dist/services/selected-variant-service.js +21 -18
- package/cjs/dist/utils/index.js +9 -6
- package/cjs/dist/utils/url-params.js +5 -1
- package/dist/astro/actions/custom-checkout.d.ts +1 -3
- package/package.json +6 -6
|
@@ -1,36 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Quantity = exports.ProductVariant = exports.ProductVariantWeight = exports.ProductVariantSKU = exports.ProductVariantStock = exports.Link = exports.Action = exports.ProductActionPreOrder = exports.ProductActionBuyNow = exports.ProductActionAddToCart = exports.ProductVariantSelectorReset = exports.ProductQuantityRaw = exports.ProductQuantityIncrement = exports.ProductQuantityInput = exports.ProductQuantityDecrement = exports.ProductQuantity = exports.MediaGallery = exports.ProductMediaGallery = exports.ModifierOptionRepeater = exports.ModifierOptions = exports.Modifiers = exports.VariantOptionRepeater = exports.VariantOptions = exports.Variants = exports.Stock = exports.Ribbon = exports.Raw = exports.Slug = exports.CompareAtPrice = exports.Price = exports.Description = exports.Name = exports.Root = void 0;
|
|
40
|
+
exports.useVariantsContext = useVariantsContext;
|
|
41
|
+
exports.useModifiersContext = useModifiersContext;
|
|
42
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
43
|
+
const stores_1 = require("@wix/stores");
|
|
44
|
+
const react_1 = require("@wix/headless-components/react");
|
|
45
|
+
const react_2 = require("@wix/headless-ecom/react");
|
|
46
|
+
const react_3 = require("@wix/headless-media/react");
|
|
47
|
+
const react_4 = require("@wix/headless-utils/react");
|
|
48
|
+
const services_manager_react_1 = require("@wix/services-manager-react");
|
|
49
|
+
const react_5 = __importDefault(require("react"));
|
|
50
|
+
const data_component_tags_js_1 = require("../data-component-tags.js");
|
|
51
|
+
const index_js_1 = require("../services/index.js");
|
|
52
|
+
const CoreProduct = __importStar(require("./core/Product.js"));
|
|
53
|
+
const CoreProductModifiers = __importStar(require("./core/ProductModifiers.js"));
|
|
54
|
+
const CoreProductVariantSelector = __importStar(require("./core/ProductVariantSelector.js"));
|
|
55
|
+
const CoreSelectedVariant = __importStar(require("./core/SelectedVariant.js"));
|
|
56
|
+
const Option = __importStar(require("./Option.js"));
|
|
57
|
+
const types_js_1 = require("./types.js");
|
|
58
|
+
const VariantsContext = react_5.default.createContext(null);
|
|
18
59
|
/**
|
|
19
60
|
* Hook to access variants context
|
|
20
61
|
*/
|
|
21
|
-
|
|
22
|
-
const context =
|
|
62
|
+
function useVariantsContext() {
|
|
63
|
+
const context = react_5.default.useContext(VariantsContext);
|
|
23
64
|
if (!context) {
|
|
24
65
|
throw new Error('useVariantsContext must be used within a Product.Variants component');
|
|
25
66
|
}
|
|
26
67
|
return context;
|
|
27
68
|
}
|
|
28
|
-
const ModifiersContext =
|
|
69
|
+
const ModifiersContext = react_5.default.createContext(null);
|
|
29
70
|
/**
|
|
30
71
|
* Hook to access modifiers context
|
|
31
72
|
*/
|
|
32
|
-
|
|
33
|
-
const context =
|
|
73
|
+
function useModifiersContext() {
|
|
74
|
+
const context = react_5.default.useContext(ModifiersContext);
|
|
34
75
|
if (!context) {
|
|
35
76
|
throw new Error('useModifiersContext must be used within a Product.Modifiers component');
|
|
36
77
|
}
|
|
@@ -90,13 +131,14 @@ var TestIds;
|
|
|
90
131
|
* }
|
|
91
132
|
* ```
|
|
92
133
|
*/
|
|
93
|
-
|
|
134
|
+
const Root = (props) => {
|
|
94
135
|
const { children, product, ...attrs } = props;
|
|
95
|
-
return (
|
|
136
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Root, { productServiceConfig: { product: props.product }, children: (0, jsx_runtime_1.jsx)(react_3.MediaGallery.Root, { mediaGalleryServiceConfig: {
|
|
96
137
|
media: props.product.media?.itemsInfo?.items ?? [],
|
|
97
|
-
}, children:
|
|
138
|
+
}, children: (0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Root, { children: (0, jsx_runtime_1.jsx)(CoreProductModifiers.Root, { children: (0, jsx_runtime_1.jsx)(CoreSelectedVariant.Root, { children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { "data-testid": TestIds.productRoot, "data-component-tag": data_component_tags_js_1.DataComponentTags.productRoot, ...attrs, children: children }) }) }) }) }) }));
|
|
98
139
|
};
|
|
99
|
-
Root
|
|
140
|
+
exports.Root = Root;
|
|
141
|
+
exports.Root.displayName = 'Product.Root';
|
|
100
142
|
/**
|
|
101
143
|
* Displays the product name with customizable rendering following the documented API.
|
|
102
144
|
*
|
|
@@ -121,10 +163,10 @@ Root.displayName = 'Product.Root';
|
|
|
121
163
|
* </Product.Name>
|
|
122
164
|
* ```
|
|
123
165
|
*/
|
|
124
|
-
|
|
166
|
+
exports.Name = react_5.default.forwardRef((props, ref) => {
|
|
125
167
|
const { asChild, children, className, ...otherProps } = props;
|
|
126
|
-
return (
|
|
127
|
-
return (
|
|
168
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Name, { children: ({ name }) => {
|
|
169
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productName, customElement: children, customElementProps: { name }, content: name, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: name }) }));
|
|
128
170
|
} }));
|
|
129
171
|
});
|
|
130
172
|
/**
|
|
@@ -150,19 +192,19 @@ export const Name = React.forwardRef((props, ref) => {
|
|
|
150
192
|
* </Product.Description>
|
|
151
193
|
* ```
|
|
152
194
|
*/
|
|
153
|
-
|
|
154
|
-
const { asChild, children, className, as = AsContent.Plain, ...otherProps } = props;
|
|
155
|
-
return (
|
|
195
|
+
exports.Description = react_5.default.forwardRef((props, ref) => {
|
|
196
|
+
const { asChild, children, className, as = types_js_1.AsContent.Plain, ...otherProps } = props;
|
|
197
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Description, { children: ({ description: richDescription, plainDescription }) => {
|
|
156
198
|
// Determine which description to use based on the 'as' prop
|
|
157
199
|
let description;
|
|
158
200
|
switch (as) {
|
|
159
|
-
case AsContent.Html:
|
|
201
|
+
case types_js_1.AsContent.Html:
|
|
160
202
|
description = plainDescription || '';
|
|
161
203
|
break;
|
|
162
|
-
case AsContent.Ricos:
|
|
204
|
+
case types_js_1.AsContent.Ricos:
|
|
163
205
|
description = JSON.stringify(richDescription) || '';
|
|
164
206
|
break;
|
|
165
|
-
case AsContent.Plain:
|
|
207
|
+
case types_js_1.AsContent.Plain:
|
|
166
208
|
default:
|
|
167
209
|
// For plain text, we'll strip HTML tags from plainDescription
|
|
168
210
|
description = plainDescription
|
|
@@ -172,11 +214,11 @@ export const Description = React.forwardRef((props, ref) => {
|
|
|
172
214
|
}
|
|
173
215
|
// Handle default rendering based on format
|
|
174
216
|
if (!asChild || !children) {
|
|
175
|
-
if (as === AsContent.Html) {
|
|
176
|
-
return (
|
|
217
|
+
if (as === types_js_1.AsContent.Html) {
|
|
218
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, "data-testid": TestIds.productDescription, dangerouslySetInnerHTML: { __html: description } }));
|
|
177
219
|
}
|
|
178
220
|
}
|
|
179
|
-
return (
|
|
221
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productDescription, customElement: children, customElementProps: { description }, content: description, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: description }) }));
|
|
180
222
|
} }));
|
|
181
223
|
});
|
|
182
224
|
/**
|
|
@@ -203,13 +245,13 @@ export const Description = React.forwardRef((props, ref) => {
|
|
|
203
245
|
* </Product.Price>
|
|
204
246
|
* ```
|
|
205
247
|
*/
|
|
206
|
-
|
|
248
|
+
exports.Price = react_5.default.forwardRef((props, ref) => {
|
|
207
249
|
const { asChild, children, className, ...otherProps } = props;
|
|
208
|
-
return (
|
|
209
|
-
return (
|
|
250
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Price, { children: ({ price, compareAtPrice }) => {
|
|
251
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productPrice, "data-discounted": compareAtPrice !== null, customElement: children, customElementProps: {
|
|
210
252
|
price,
|
|
211
253
|
formattedPrice: price,
|
|
212
|
-
}, content: price, ...otherProps, children:
|
|
254
|
+
}, content: price, ...otherProps, children: (0, jsx_runtime_1.jsx)("span", { children: price }) }));
|
|
213
255
|
} }));
|
|
214
256
|
});
|
|
215
257
|
/**
|
|
@@ -240,18 +282,18 @@ export const Price = React.forwardRef((props, ref) => {
|
|
|
240
282
|
* </Product.CompareAtPrice>
|
|
241
283
|
* ```
|
|
242
284
|
*/
|
|
243
|
-
|
|
285
|
+
exports.CompareAtPrice = react_5.default.forwardRef((props, ref) => {
|
|
244
286
|
const { asChild, children, className, ...otherProps } = props;
|
|
245
287
|
const testId = TestIds.productCompareAtPrice;
|
|
246
|
-
return (
|
|
288
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Price, { children: ({ compareAtPrice }) => {
|
|
247
289
|
// Don't render anything if there's no compare-at price
|
|
248
290
|
if (!compareAtPrice) {
|
|
249
291
|
return null;
|
|
250
292
|
}
|
|
251
|
-
return (
|
|
293
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": testId, "data-discounted": compareAtPrice !== null, customElement: children, customElementProps: {
|
|
252
294
|
price: compareAtPrice,
|
|
253
295
|
formattedPrice: compareAtPrice,
|
|
254
|
-
}, content: compareAtPrice, ...otherProps, children:
|
|
296
|
+
}, content: compareAtPrice, ...otherProps, children: (0, jsx_runtime_1.jsx)("span", { children: compareAtPrice }) }));
|
|
255
297
|
} }));
|
|
256
298
|
});
|
|
257
299
|
/**
|
|
@@ -276,11 +318,11 @@ export const CompareAtPrice = React.forwardRef((props, ref) => {
|
|
|
276
318
|
* }
|
|
277
319
|
* ```
|
|
278
320
|
*/
|
|
279
|
-
|
|
321
|
+
exports.Slug = react_5.default.forwardRef((props, ref) => {
|
|
280
322
|
const { asChild, children, className, ...otherProps } = props;
|
|
281
323
|
const testId = TestIds.productSlug;
|
|
282
|
-
return (
|
|
283
|
-
return (
|
|
324
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Slug, { children: ({ slug }) => {
|
|
325
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": testId, customElement: children, customElementProps: { slug }, content: slug, ...otherProps, children: (0, jsx_runtime_1.jsx)("span", { children: slug }) }));
|
|
284
326
|
} }));
|
|
285
327
|
});
|
|
286
328
|
/**
|
|
@@ -302,14 +344,14 @@ export const Slug = React.forwardRef((props, ref) => {
|
|
|
302
344
|
* </Product.Raw>
|
|
303
345
|
* ```
|
|
304
346
|
*/
|
|
305
|
-
|
|
347
|
+
exports.Raw = react_5.default.forwardRef((props, ref) => {
|
|
306
348
|
const { asChild, children, className, ...otherProps } = props;
|
|
307
|
-
return (
|
|
349
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Content, { children: ({ product }) => {
|
|
308
350
|
// Raw component should not render anything by default when not using asChild
|
|
309
351
|
if (!asChild || !children) {
|
|
310
352
|
return null;
|
|
311
353
|
}
|
|
312
|
-
return (
|
|
354
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productRaw, customElement: children, customElementProps: { product }, ...otherProps }));
|
|
313
355
|
} }));
|
|
314
356
|
});
|
|
315
357
|
/**
|
|
@@ -336,14 +378,14 @@ export const Raw = React.forwardRef((props, ref) => {
|
|
|
336
378
|
* </Product.Ribbon>
|
|
337
379
|
* ```
|
|
338
380
|
*/
|
|
339
|
-
|
|
381
|
+
exports.Ribbon = react_5.default.forwardRef((props, ref) => {
|
|
340
382
|
const { asChild, children, className } = props;
|
|
341
|
-
return (
|
|
383
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Ribbon, { children: ({ ribbon, hasRibbon }) => {
|
|
342
384
|
// Don't render anything if there's no ribbon
|
|
343
385
|
if (!hasRibbon) {
|
|
344
386
|
return null;
|
|
345
387
|
}
|
|
346
|
-
return (
|
|
388
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productRibbon, customElement: children, customElementProps: { ribbon }, content: ribbon, children: (0, jsx_runtime_1.jsx)("span", { children: ribbon }) }));
|
|
347
389
|
} }));
|
|
348
390
|
});
|
|
349
391
|
/**
|
|
@@ -391,9 +433,9 @@ export const Ribbon = React.forwardRef((props, ref) => {
|
|
|
391
433
|
* </Product.Stock>
|
|
392
434
|
* ```
|
|
393
435
|
*/
|
|
394
|
-
|
|
436
|
+
exports.Stock = react_5.default.forwardRef((props, ref) => {
|
|
395
437
|
const { asChild, children, className, labels } = props;
|
|
396
|
-
return (
|
|
438
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Content, { children: ({ product }) => {
|
|
397
439
|
const availabilityStatus = product.inventory?.availabilityStatus;
|
|
398
440
|
// Default labels
|
|
399
441
|
const defaultLabels = {
|
|
@@ -406,24 +448,24 @@ export const Stock = React.forwardRef((props, ref) => {
|
|
|
406
448
|
let status;
|
|
407
449
|
let label;
|
|
408
450
|
switch (availabilityStatus) {
|
|
409
|
-
case productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
451
|
+
case stores_1.productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
410
452
|
status = 'in-stock';
|
|
411
453
|
label = finalLabels.inStock;
|
|
412
454
|
break;
|
|
413
|
-
case productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
455
|
+
case stores_1.productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
414
456
|
status = 'limited-stock';
|
|
415
457
|
label = finalLabels.limitedStock;
|
|
416
458
|
break;
|
|
417
|
-
case productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK:
|
|
459
|
+
case stores_1.productsV3.InventoryAvailabilityStatus.OUT_OF_STOCK:
|
|
418
460
|
default:
|
|
419
461
|
status = 'out-of-stock';
|
|
420
462
|
label = finalLabels.outOfStock;
|
|
421
463
|
break;
|
|
422
464
|
}
|
|
423
|
-
return (
|
|
465
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productStock, "data-state": status, customElement: children, customElementProps: {
|
|
424
466
|
status,
|
|
425
467
|
label,
|
|
426
|
-
}, content: label, children:
|
|
468
|
+
}, content: label, children: (0, jsx_runtime_1.jsx)("span", { children: label }) }));
|
|
427
469
|
} }));
|
|
428
470
|
});
|
|
429
471
|
/**
|
|
@@ -468,16 +510,16 @@ export const Stock = React.forwardRef((props, ref) => {
|
|
|
468
510
|
* </Product.Variants>
|
|
469
511
|
* ```
|
|
470
512
|
*/
|
|
471
|
-
|
|
513
|
+
exports.Variants = react_5.default.forwardRef((props, ref) => {
|
|
472
514
|
const { asChild, children, className, ...attributes } = props;
|
|
473
|
-
return (
|
|
515
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Options, { children: ({ hasOptions, options }) => {
|
|
474
516
|
if (!hasOptions)
|
|
475
517
|
return null;
|
|
476
518
|
const contextValue = {
|
|
477
519
|
hasOptions,
|
|
478
520
|
options,
|
|
479
521
|
};
|
|
480
|
-
return (
|
|
522
|
+
return ((0, jsx_runtime_1.jsx)(VariantsContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ...attributes, ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariants, customElement: children, children: (0, jsx_runtime_1.jsx)("div", { children: react_5.default.isValidElement(children) ? children : null }) }) }));
|
|
481
523
|
} }));
|
|
482
524
|
});
|
|
483
525
|
/**
|
|
@@ -508,7 +550,7 @@ export const Variants = React.forwardRef((props, ref) => {
|
|
|
508
550
|
* </Product.VariantOptions>
|
|
509
551
|
* ```
|
|
510
552
|
*/
|
|
511
|
-
|
|
553
|
+
exports.VariantOptions = react_5.default.forwardRef((props, ref) => {
|
|
512
554
|
const { children, emptyState } = props;
|
|
513
555
|
const { hasOptions } = useVariantsContext();
|
|
514
556
|
if (!hasOptions) {
|
|
@@ -517,20 +559,20 @@ export const VariantOptions = React.forwardRef((props, ref) => {
|
|
|
517
559
|
const attributes = {
|
|
518
560
|
'data-testid': TestIds.productVariantOptions,
|
|
519
561
|
};
|
|
520
|
-
return (
|
|
562
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...attributes, ref: ref, children: children }));
|
|
521
563
|
});
|
|
522
564
|
/**
|
|
523
565
|
* Repeater component that renders children for each variant option.
|
|
524
566
|
*
|
|
525
567
|
* @component
|
|
526
568
|
*/
|
|
527
|
-
|
|
569
|
+
exports.VariantOptionRepeater = react_5.default.forwardRef((props, _ref) => {
|
|
528
570
|
const { children } = props;
|
|
529
571
|
const { hasOptions, options } = useVariantsContext();
|
|
530
572
|
if (!hasOptions)
|
|
531
573
|
return null;
|
|
532
|
-
return (
|
|
533
|
-
return (
|
|
574
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: options.map((option) => {
|
|
575
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Option, { option: option, children: (optionData) => ((0, jsx_runtime_1.jsx)(Option.Root, { option: {
|
|
534
576
|
...optionData,
|
|
535
577
|
mandatory: false,
|
|
536
578
|
}, children: children })) }, option._id));
|
|
@@ -579,16 +621,16 @@ export const VariantOptionRepeater = React.forwardRef((props, _ref) => {
|
|
|
579
621
|
* </Product.Modifiers>
|
|
580
622
|
* ```
|
|
581
623
|
*/
|
|
582
|
-
|
|
624
|
+
exports.Modifiers = react_5.default.forwardRef((props, ref) => {
|
|
583
625
|
const { asChild, children, className, ...attributes } = props;
|
|
584
|
-
return (
|
|
626
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductModifiers.Modifiers, { children: ({ hasModifiers, modifiers }) => {
|
|
585
627
|
if (!hasModifiers)
|
|
586
628
|
return null;
|
|
587
629
|
const contextValue = {
|
|
588
630
|
hasModifiers,
|
|
589
631
|
modifiers,
|
|
590
632
|
};
|
|
591
|
-
return (
|
|
633
|
+
return ((0, jsx_runtime_1.jsx)(ModifiersContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ...attributes, ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productModifiers, customElement: children, children: (0, jsx_runtime_1.jsx)("div", { children: react_5.default.isValidElement(children) ? children : null }) }) }));
|
|
592
634
|
} }));
|
|
593
635
|
});
|
|
594
636
|
/**
|
|
@@ -621,7 +663,7 @@ export const Modifiers = React.forwardRef((props, ref) => {
|
|
|
621
663
|
* </Product.ModifierOptions>
|
|
622
664
|
* ```
|
|
623
665
|
*/
|
|
624
|
-
|
|
666
|
+
exports.ModifierOptions = react_5.default.forwardRef((props, ref) => {
|
|
625
667
|
const { children, emptyState } = props;
|
|
626
668
|
const { hasModifiers } = useModifiersContext();
|
|
627
669
|
if (!hasModifiers) {
|
|
@@ -630,20 +672,20 @@ export const ModifierOptions = React.forwardRef((props, ref) => {
|
|
|
630
672
|
const attributes = {
|
|
631
673
|
'data-testid': TestIds.productModifierOptions,
|
|
632
674
|
};
|
|
633
|
-
return (
|
|
675
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...attributes, ref: ref, children: children }));
|
|
634
676
|
});
|
|
635
677
|
/**
|
|
636
678
|
* Repeater component that renders children for each modifier option.
|
|
637
679
|
*
|
|
638
680
|
* @component
|
|
639
681
|
*/
|
|
640
|
-
|
|
682
|
+
exports.ModifierOptionRepeater = react_5.default.forwardRef((props, _ref) => {
|
|
641
683
|
const { children, allowedTypes = ['color', 'text', 'free-text'] } = props;
|
|
642
684
|
const { hasModifiers, modifiers } = useModifiersContext();
|
|
643
685
|
if (!hasModifiers)
|
|
644
686
|
return null;
|
|
645
|
-
return (
|
|
646
|
-
return (
|
|
687
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: modifiers.map((modifier) => {
|
|
688
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductModifiers.Modifier, { modifier: modifier, children: (modifierData) => ((0, jsx_runtime_1.jsx)(Option.Root, { option: {
|
|
647
689
|
...modifierData,
|
|
648
690
|
}, allowedTypes: allowedTypes, children: children })) }, modifier._id));
|
|
649
691
|
}) }));
|
|
@@ -676,9 +718,9 @@ export const ModifierOptionRepeater = React.forwardRef((props, _ref) => {
|
|
|
676
718
|
* </Product.MediaGallery>
|
|
677
719
|
* ```
|
|
678
720
|
*/
|
|
679
|
-
|
|
721
|
+
exports.ProductMediaGallery = react_5.default.forwardRef((props, ref) => {
|
|
680
722
|
const { children, infinite, autoPlay, ...otherProps } = props;
|
|
681
|
-
return (
|
|
723
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Media, { children: ({ mediaItems, mainMedia }) => {
|
|
682
724
|
const media = mediaItems.length > 0 ? mediaItems : mainMedia ? [mainMedia] : [];
|
|
683
725
|
const mediaGalleryServiceConfig = {
|
|
684
726
|
media,
|
|
@@ -688,13 +730,10 @@ export const ProductMediaGallery = React.forwardRef((props, ref) => {
|
|
|
688
730
|
const attributes = {
|
|
689
731
|
'data-testid': TestIds.productMediaGallery,
|
|
690
732
|
};
|
|
691
|
-
return (
|
|
733
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...attributes, ref: ref, ...otherProps, children: (0, jsx_runtime_1.jsx)(react_3.MediaGallery.Root, { mediaGalleryServiceConfig: mediaGalleryServiceConfig, children: children }) }));
|
|
692
734
|
} }));
|
|
693
735
|
});
|
|
694
|
-
|
|
695
|
-
* Alias for ProductMediaGallery to match the documented API
|
|
696
|
-
*/
|
|
697
|
-
export { ProductMediaGallery as MediaGallery };
|
|
736
|
+
exports.MediaGallery = exports.ProductMediaGallery;
|
|
698
737
|
/**
|
|
699
738
|
* Product quantity selector component that integrates with the selected variant.
|
|
700
739
|
* Provides quantity controls with stock validation and can-pre-order support.
|
|
@@ -756,9 +795,9 @@ export { ProductMediaGallery as MediaGallery };
|
|
|
756
795
|
* </Product.Quantity>
|
|
757
796
|
* ```
|
|
758
797
|
*/
|
|
759
|
-
|
|
798
|
+
exports.ProductQuantity = react_5.default.forwardRef((props, ref) => {
|
|
760
799
|
const { asChild, children, className } = props;
|
|
761
|
-
return (
|
|
800
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: ({ inStock, isPreOrderEnabled, availableQuantity, selectedQuantity, setSelectedQuantity, }) => {
|
|
762
801
|
const renderProps = {
|
|
763
802
|
selectedQuantity,
|
|
764
803
|
availableQuantity,
|
|
@@ -767,9 +806,9 @@ export const ProductQuantity = React.forwardRef((props, ref) => {
|
|
|
767
806
|
setSelectedQuantity,
|
|
768
807
|
};
|
|
769
808
|
if (asChild && children) {
|
|
770
|
-
return (
|
|
809
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantity, customElement: children, customElementProps: renderProps }));
|
|
771
810
|
}
|
|
772
|
-
return (
|
|
811
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Quantity.Root, { initialValue: selectedQuantity, onValueChange: setSelectedQuantity, className: className, ref: ref, "data-testid": TestIds.productQuantity, children: react_5.default.isValidElement(children) ? children : null }));
|
|
773
812
|
} }));
|
|
774
813
|
});
|
|
775
814
|
/**
|
|
@@ -783,14 +822,14 @@ export const ProductQuantity = React.forwardRef((props, ref) => {
|
|
|
783
822
|
* <Product.Quantity.Decrement className="px-3 py-1 hover:bg-surface-primary transition-colors" />
|
|
784
823
|
* ```
|
|
785
824
|
*/
|
|
786
|
-
|
|
825
|
+
exports.ProductQuantityDecrement = react_5.default.forwardRef((props, ref) => {
|
|
787
826
|
const { asChild, children, className } = props;
|
|
788
|
-
return (
|
|
827
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: ({ selectedQuantity, inStock, isPreOrderEnabled }) => {
|
|
789
828
|
const disabled = selectedQuantity <= 1 || (!inStock && !isPreOrderEnabled);
|
|
790
829
|
if (asChild && children) {
|
|
791
|
-
return (
|
|
830
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityDecrement, customElement: children, customElementProps: { disabled } }));
|
|
792
831
|
}
|
|
793
|
-
return (
|
|
832
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Quantity.Decrement, { className: className, ref: ref, "data-testid": TestIds.productQuantityDecrement, disabled }));
|
|
794
833
|
} }));
|
|
795
834
|
});
|
|
796
835
|
/**
|
|
@@ -803,13 +842,13 @@ export const ProductQuantityDecrement = React.forwardRef((props, ref) => {
|
|
|
803
842
|
* <Product.Quantity.Input className="w-16 text-center py-1 border-x border-brand-light focus:outline-none focus:ring-2 focus:ring-brand-primary" />
|
|
804
843
|
* ```
|
|
805
844
|
*/
|
|
806
|
-
|
|
845
|
+
exports.ProductQuantityInput = react_5.default.forwardRef((props, ref) => {
|
|
807
846
|
const { asChild, children, className, disabled = true } = props;
|
|
808
|
-
return (
|
|
847
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: () => {
|
|
809
848
|
if (asChild && children) {
|
|
810
|
-
return (
|
|
849
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, disabled: disabled, "data-testid": TestIds.productQuantityInput, customElement: children, customElementProps: {} }));
|
|
811
850
|
}
|
|
812
|
-
return (
|
|
851
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Quantity.Input, { className: className, disabled: disabled, ref: ref, "data-testid": TestIds.productQuantityInput }));
|
|
813
852
|
} }));
|
|
814
853
|
});
|
|
815
854
|
/**
|
|
@@ -823,15 +862,15 @@ export const ProductQuantityInput = React.forwardRef((props, ref) => {
|
|
|
823
862
|
* <Product.Quantity.Increment className="px-3 py-1 hover:bg-surface-primary transition-colors" />
|
|
824
863
|
* ```
|
|
825
864
|
*/
|
|
826
|
-
|
|
865
|
+
exports.ProductQuantityIncrement = react_5.default.forwardRef((props, ref) => {
|
|
827
866
|
const { asChild, children, className } = props;
|
|
828
|
-
return (
|
|
867
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: ({ selectedQuantity, availableQuantity, inStock, isPreOrderEnabled, }) => {
|
|
829
868
|
const disabled = (!!availableQuantity && selectedQuantity >= availableQuantity) ||
|
|
830
869
|
(!inStock && !isPreOrderEnabled);
|
|
831
870
|
if (asChild && children) {
|
|
832
|
-
return (
|
|
871
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productQuantityIncrement, customElement: children, customElementProps: { disabled } }));
|
|
833
872
|
}
|
|
834
|
-
return (
|
|
873
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Quantity.Increment, { className: className, ref: ref, "data-testid": TestIds.productQuantityIncrement, disabled }));
|
|
835
874
|
} }));
|
|
836
875
|
});
|
|
837
876
|
/**
|
|
@@ -860,31 +899,31 @@ export const ProductQuantityIncrement = React.forwardRef((props, ref) => {
|
|
|
860
899
|
* </Product.Quantity.Raw>
|
|
861
900
|
* ```
|
|
862
901
|
*/
|
|
863
|
-
|
|
902
|
+
exports.ProductQuantityRaw = react_5.default.forwardRef((props, ref) => {
|
|
864
903
|
const { asChild, children, className } = props;
|
|
865
|
-
return (
|
|
866
|
-
return (
|
|
904
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: (renderProps) => {
|
|
905
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productQuantityRaw, customElementProps: renderProps }));
|
|
867
906
|
} }));
|
|
868
907
|
});
|
|
869
|
-
|
|
908
|
+
exports.ProductVariantSelectorReset = react_5.default.forwardRef((props, ref) => {
|
|
870
909
|
const { asChild, children, className } = props;
|
|
871
|
-
return (
|
|
910
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Reset, { children: (renderProps) => {
|
|
872
911
|
if (!renderProps.hasSelections) {
|
|
873
912
|
return null;
|
|
874
913
|
}
|
|
875
914
|
const label = props.label || 'Reset Selections';
|
|
876
|
-
return (
|
|
915
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, customElement: children, asChild: asChild, className: className, "data-testid": TestIds.productVariantSelectorReset, customElementProps: renderProps, children: (0, jsx_runtime_1.jsx)("button", { onClick: renderProps.reset, children: label }) }));
|
|
877
916
|
} }));
|
|
878
917
|
});
|
|
879
918
|
/**
|
|
880
919
|
* Add to cart action button component following the documented API.
|
|
881
920
|
* Automatically integrates with the selected variant and handles loading states.
|
|
882
921
|
*/
|
|
883
|
-
|
|
922
|
+
exports.ProductActionAddToCart = react_5.default.forwardRef((props, ref) => {
|
|
884
923
|
const { asChild, children, className, label, loadingState } = props;
|
|
885
924
|
// Get services for tracking
|
|
886
|
-
const productService = useService(ProductServiceDefinition);
|
|
887
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
925
|
+
const productService = (0, services_manager_react_1.useService)(index_js_1.ProductServiceDefinition);
|
|
926
|
+
const variantService = (0, services_manager_react_1.useService)(index_js_1.SelectedVariantServiceDefinition);
|
|
888
927
|
// Track after successful add to cart
|
|
889
928
|
const handleSuccess = async () => {
|
|
890
929
|
const choices = variantService.selectedChoices.get();
|
|
@@ -895,53 +934,53 @@ export const ProductActionAddToCart = React.forwardRef((props, ref) => {
|
|
|
895
934
|
variant: variantString,
|
|
896
935
|
});
|
|
897
936
|
};
|
|
898
|
-
return (
|
|
937
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Actions, { children: ({ lineItems, canAddToCart, isLoading, addToCart, isPreOrderEnabled, }) => {
|
|
899
938
|
if (isPreOrderEnabled) {
|
|
900
939
|
return null;
|
|
901
940
|
}
|
|
902
941
|
const onClick = addToCart;
|
|
903
942
|
const disabled = !canAddToCart || isLoading;
|
|
904
943
|
if (asChild && children) {
|
|
905
|
-
return (
|
|
944
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, onSuccess: handleSuccess, children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
906
945
|
disabled,
|
|
907
946
|
isLoading,
|
|
908
947
|
onClick,
|
|
909
948
|
} }) }));
|
|
910
949
|
}
|
|
911
|
-
return (
|
|
950
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, onSuccess: handleSuccess, "data-testid": TestIds.productActionAddToCart, "data-in-progress": isLoading }));
|
|
912
951
|
} }));
|
|
913
952
|
});
|
|
914
953
|
/**
|
|
915
954
|
* Buy Now action button component following the documented API.
|
|
916
955
|
* Bypasses the cart and redirects directly to checkout.
|
|
917
956
|
*/
|
|
918
|
-
|
|
957
|
+
exports.ProductActionBuyNow = react_5.default.forwardRef((props, ref) => {
|
|
919
958
|
const { asChild, children, className, label, loadingState } = props;
|
|
920
|
-
return (
|
|
959
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Actions, { children: ({ lineItems, canAddToCart, isLoading, buyNow, inStock, isPreOrderEnabled, }) => {
|
|
921
960
|
if (!inStock || isPreOrderEnabled) {
|
|
922
961
|
return null;
|
|
923
962
|
}
|
|
924
963
|
const onClick = buyNow;
|
|
925
964
|
const disabled = !canAddToCart || isLoading;
|
|
926
965
|
if (asChild && children) {
|
|
927
|
-
return (
|
|
966
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.BuyNow, { lineItems: lineItems, asChild: asChild, children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionBuyNow, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
928
967
|
disabled,
|
|
929
968
|
isLoading,
|
|
930
969
|
onClick,
|
|
931
970
|
} }) }));
|
|
932
971
|
}
|
|
933
|
-
return (
|
|
972
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.BuyNow, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, "data-testid": TestIds.productActionBuyNow, "data-in-progress": isLoading }));
|
|
934
973
|
} }));
|
|
935
974
|
});
|
|
936
975
|
/**
|
|
937
976
|
* Pre-Order action button component following the documented API.
|
|
938
977
|
* Handles can-pre-order functionality when products are not in stock.
|
|
939
978
|
*/
|
|
940
|
-
|
|
979
|
+
exports.ProductActionPreOrder = react_5.default.forwardRef((props, ref) => {
|
|
941
980
|
const { asChild, children, className, label, loadingState } = props;
|
|
942
981
|
// Get services for tracking
|
|
943
|
-
const productService = useService(ProductServiceDefinition);
|
|
944
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
982
|
+
const productService = (0, services_manager_react_1.useService)(index_js_1.ProductServiceDefinition);
|
|
983
|
+
const variantService = (0, services_manager_react_1.useService)(index_js_1.SelectedVariantServiceDefinition);
|
|
945
984
|
// Track after successful pre-order
|
|
946
985
|
const handleSuccess = async () => {
|
|
947
986
|
const choices = variantService.selectedChoices.get();
|
|
@@ -952,7 +991,7 @@ export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
|
952
991
|
variant: variantString,
|
|
953
992
|
});
|
|
954
993
|
};
|
|
955
|
-
return (
|
|
994
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Actions, { children: ({ lineItems, isLoading, addToCart, isPreOrderEnabled }) => {
|
|
956
995
|
if (!isPreOrderEnabled) {
|
|
957
996
|
return null;
|
|
958
997
|
}
|
|
@@ -960,26 +999,26 @@ export const ProductActionPreOrder = React.forwardRef((props, ref) => {
|
|
|
960
999
|
const onClick = addToCart;
|
|
961
1000
|
const disabled = !canPreOrder;
|
|
962
1001
|
if (asChild && children) {
|
|
963
|
-
return (
|
|
1002
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.AddToCart, { lineItems: lineItems, asChild: asChild, onSuccess: handleSuccess, children: (0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading, customElement: children, customElementProps: {
|
|
964
1003
|
disabled,
|
|
965
1004
|
isLoading,
|
|
966
1005
|
onClick,
|
|
967
1006
|
} }) }));
|
|
968
1007
|
}
|
|
969
|
-
return (
|
|
1008
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Commerce.Actions.AddToCart, { ref: ref, label: label, lineItems: lineItems, className: className, disabled: disabled, loadingState: loadingState, onSuccess: handleSuccess, "data-testid": TestIds.productActionPreOrder, "data-in-progress": isLoading }));
|
|
970
1009
|
} }));
|
|
971
1010
|
});
|
|
972
1011
|
/**
|
|
973
1012
|
* Actions namespace containing all product action components
|
|
974
1013
|
* following the documented API: Product.Action.AddToCart, Product.Action.BuyNow, Product.Action.PreOrder
|
|
975
1014
|
*/
|
|
976
|
-
|
|
1015
|
+
exports.Action = {
|
|
977
1016
|
/** Add to cart action button */
|
|
978
|
-
AddToCart: ProductActionAddToCart,
|
|
1017
|
+
AddToCart: exports.ProductActionAddToCart,
|
|
979
1018
|
/** Buy now action button */
|
|
980
|
-
BuyNow: ProductActionBuyNow,
|
|
1019
|
+
BuyNow: exports.ProductActionBuyNow,
|
|
981
1020
|
/** Pre-order action button */
|
|
982
|
-
PreOrder: ProductActionPreOrder,
|
|
1021
|
+
PreOrder: exports.ProductActionPreOrder,
|
|
983
1022
|
};
|
|
984
1023
|
/**
|
|
985
1024
|
* Product link component that automatically tracks ClickProduct events.
|
|
@@ -1010,12 +1049,12 @@ export const Action = {
|
|
|
1010
1049
|
* </Product.Link>
|
|
1011
1050
|
* ```
|
|
1012
1051
|
*/
|
|
1013
|
-
|
|
1052
|
+
exports.Link = react_5.default.forwardRef((props, ref) => {
|
|
1014
1053
|
const { asChild, children, className, list, position, origin } = props;
|
|
1015
1054
|
// Get services for tracking
|
|
1016
|
-
const productService = useService(ProductServiceDefinition);
|
|
1017
|
-
const variantService = useService(SelectedVariantServiceDefinition);
|
|
1018
|
-
return (
|
|
1055
|
+
const productService = (0, services_manager_react_1.useService)(index_js_1.ProductServiceDefinition);
|
|
1056
|
+
const variantService = (0, services_manager_react_1.useService)(index_js_1.SelectedVariantServiceDefinition);
|
|
1057
|
+
return ((0, jsx_runtime_1.jsx)(CoreProduct.Slug, { children: ({ slug }) => {
|
|
1019
1058
|
const handleClick = () => {
|
|
1020
1059
|
const choices = variantService.selectedChoices.get();
|
|
1021
1060
|
const variantString = Object.values(choices).join(' ') || undefined;
|
|
@@ -1027,9 +1066,9 @@ export const Link = React.forwardRef((props, ref) => {
|
|
|
1027
1066
|
});
|
|
1028
1067
|
};
|
|
1029
1068
|
if (asChild && children) {
|
|
1030
|
-
return (
|
|
1069
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productLink, customElement: children, customElementProps: { onClick: handleClick } }));
|
|
1031
1070
|
}
|
|
1032
|
-
return (
|
|
1071
|
+
return ((0, jsx_runtime_1.jsx)("a", { ref: ref, href: `/${slug}`, onClick: handleClick, className: className, "data-testid": TestIds.productLink, children: children }));
|
|
1033
1072
|
} }));
|
|
1034
1073
|
});
|
|
1035
1074
|
/**
|
|
@@ -1046,12 +1085,12 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
1046
1085
|
// Handle stock status based on availability
|
|
1047
1086
|
if (inStock) {
|
|
1048
1087
|
switch (availabilityStatus) {
|
|
1049
|
-
case productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
1088
|
+
case stores_1.productsV3.InventoryAvailabilityStatus.IN_STOCK:
|
|
1050
1089
|
return {
|
|
1051
1090
|
status: 'in-stock',
|
|
1052
1091
|
label: labels.inStock,
|
|
1053
1092
|
};
|
|
1054
|
-
case productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
1093
|
+
case stores_1.productsV3.InventoryAvailabilityStatus.PARTIALLY_OUT_OF_STOCK:
|
|
1055
1094
|
return {
|
|
1056
1095
|
status: 'limited-stock',
|
|
1057
1096
|
label: labels.limitedStock,
|
|
@@ -1116,9 +1155,9 @@ function getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, l
|
|
|
1116
1155
|
* </Product.ProductVariant.Stock>
|
|
1117
1156
|
* ```
|
|
1118
1157
|
*/
|
|
1119
|
-
|
|
1158
|
+
exports.ProductVariantStock = react_5.default.forwardRef((props, ref) => {
|
|
1120
1159
|
const { asChild, children, className, labels } = props;
|
|
1121
|
-
return (
|
|
1160
|
+
return ((0, jsx_runtime_1.jsx)(CoreProductVariantSelector.Stock, { children: ({ inStock, isPreOrderEnabled, availabilityStatus, currentVariantId, }) => {
|
|
1122
1161
|
// Only render if we have a current variant selected
|
|
1123
1162
|
if (!currentVariantId && !availabilityStatus) {
|
|
1124
1163
|
return null;
|
|
@@ -1133,10 +1172,10 @@ export const ProductVariantStock = React.forwardRef((props, ref) => {
|
|
|
1133
1172
|
const finalLabels = { ...defaultLabels, ...labels };
|
|
1134
1173
|
// Get status and label using the helper function
|
|
1135
1174
|
const { status, label } = getStockStatusMessage(inStock, isPreOrderEnabled, availabilityStatus, finalLabels);
|
|
1136
|
-
return (
|
|
1175
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantStock, "data-state": status, customElement: children, customElementProps: {
|
|
1137
1176
|
status,
|
|
1138
1177
|
label,
|
|
1139
|
-
}, content: label, children:
|
|
1178
|
+
}, content: label, children: (0, jsx_runtime_1.jsx)("span", { children: label }) }));
|
|
1140
1179
|
} }));
|
|
1141
1180
|
});
|
|
1142
1181
|
/**
|
|
@@ -1163,14 +1202,14 @@ export const ProductVariantStock = React.forwardRef((props, ref) => {
|
|
|
1163
1202
|
* </Product.ProductVariant.SKU>
|
|
1164
1203
|
* ```
|
|
1165
1204
|
*/
|
|
1166
|
-
|
|
1205
|
+
exports.ProductVariantSKU = react_5.default.forwardRef((props, ref) => {
|
|
1167
1206
|
const { asChild, children, className } = props;
|
|
1168
|
-
return (
|
|
1207
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Details, { children: ({ sku }) => {
|
|
1169
1208
|
// Don't render anything if there's no SKU
|
|
1170
1209
|
if (!sku) {
|
|
1171
1210
|
return null;
|
|
1172
1211
|
}
|
|
1173
|
-
return (
|
|
1212
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantSku, customElement: children, customElementProps: { sku }, content: sku, children: (0, jsx_runtime_1.jsx)("span", { children: sku }) }));
|
|
1174
1213
|
} }));
|
|
1175
1214
|
});
|
|
1176
1215
|
/**
|
|
@@ -1197,41 +1236,41 @@ export const ProductVariantSKU = React.forwardRef((props, ref) => {
|
|
|
1197
1236
|
* </Product.ProductVariant.Weight>
|
|
1198
1237
|
* ```
|
|
1199
1238
|
*/
|
|
1200
|
-
|
|
1239
|
+
exports.ProductVariantWeight = react_5.default.forwardRef((props, ref) => {
|
|
1201
1240
|
const { asChild, children, className } = props;
|
|
1202
|
-
return (
|
|
1241
|
+
return ((0, jsx_runtime_1.jsx)(CoreSelectedVariant.Details, { children: ({ weight }) => {
|
|
1203
1242
|
// Don't render anything if there's no weight
|
|
1204
1243
|
if (!weight) {
|
|
1205
1244
|
return null;
|
|
1206
1245
|
}
|
|
1207
|
-
return (
|
|
1246
|
+
return ((0, jsx_runtime_1.jsx)(react_4.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.productVariantWeight, customElement: children, customElementProps: { weight }, content: weight, children: (0, jsx_runtime_1.jsx)("span", { children: weight }) }));
|
|
1208
1247
|
} }));
|
|
1209
1248
|
});
|
|
1210
1249
|
/**
|
|
1211
1250
|
* ProductVariant namespace containing product variant components
|
|
1212
1251
|
* following the compound component pattern: Product.ProductVariant.Stock, Product.ProductVariant.SKU, Product.ProductVariant.Weight
|
|
1213
1252
|
*/
|
|
1214
|
-
|
|
1253
|
+
exports.ProductVariant = {
|
|
1215
1254
|
/** Product variant stock component */
|
|
1216
|
-
Stock: ProductVariantStock,
|
|
1255
|
+
Stock: exports.ProductVariantStock,
|
|
1217
1256
|
/** Product variant SKU component */
|
|
1218
|
-
SKU: ProductVariantSKU,
|
|
1257
|
+
SKU: exports.ProductVariantSKU,
|
|
1219
1258
|
/** Product variant weight component */
|
|
1220
|
-
Weight: ProductVariantWeight,
|
|
1259
|
+
Weight: exports.ProductVariantWeight,
|
|
1221
1260
|
};
|
|
1222
1261
|
/**
|
|
1223
1262
|
* Quantity namespace containing all product quantity components
|
|
1224
1263
|
* following the compound component pattern: Product.Quantity.Root, Product.Quantity.Decrement, etc.
|
|
1225
1264
|
*/
|
|
1226
|
-
|
|
1265
|
+
exports.Quantity = {
|
|
1227
1266
|
/** Product quantity selector component */
|
|
1228
|
-
Root: ProductQuantity,
|
|
1267
|
+
Root: exports.ProductQuantity,
|
|
1229
1268
|
/** Product quantity decrement component */
|
|
1230
|
-
Decrement: ProductQuantityDecrement,
|
|
1269
|
+
Decrement: exports.ProductQuantityDecrement,
|
|
1231
1270
|
/** Product quantity input component */
|
|
1232
|
-
Input: ProductQuantityInput,
|
|
1271
|
+
Input: exports.ProductQuantityInput,
|
|
1233
1272
|
/** Product quantity increment component */
|
|
1234
|
-
Increment: ProductQuantityIncrement,
|
|
1273
|
+
Increment: exports.ProductQuantityIncrement,
|
|
1235
1274
|
/** Product quantity raw component */
|
|
1236
|
-
Raw: ProductQuantityRaw,
|
|
1275
|
+
Raw: exports.ProductQuantityRaw,
|
|
1237
1276
|
};
|