@wix/headless-gift-voucher 0.0.3 → 0.0.5
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/__mocks__/gift-card.d.ts +0 -1
- package/cjs/dist/__mocks__/gift-card.js +29 -25
- package/cjs/dist/enums/index.d.ts +0 -1
- package/cjs/dist/enums/index.js +11 -8
- package/cjs/dist/react/GiftCard.d.ts +0 -1
- package/cjs/dist/react/GiftCard.js +147 -106
- package/cjs/dist/react/core/GiftCard.d.ts +0 -1
- package/cjs/dist/react/core/GiftCard.js +86 -64
- package/cjs/dist/react/index.d.ts +0 -1
- package/cjs/dist/react/index.js +37 -1
- package/cjs/dist/services/gift-card-checkout-service.d.ts +0 -1
- package/cjs/dist/services/gift-card-checkout-service.js +19 -16
- package/cjs/dist/services/gift-card-service.d.ts +0 -1
- package/cjs/dist/services/gift-card-service.js +19 -15
- package/cjs/dist/services/index.d.ts +0 -1
- package/cjs/dist/services/index.js +10 -2
- package/cjs/dist/utils/formatting-utils.d.ts +0 -1
- package/cjs/dist/utils/formatting-utils.js +8 -3
- package/cjs/dist/utils/gift-card-utils.d.ts +0 -1
- package/cjs/dist/utils/gift-card-utils.js +18 -11
- package/cjs/dist/utils/validation-utils.d.ts +0 -1
- package/cjs/dist/utils/validation-utils.js +6 -2
- package/cjs/package.json +3 -0
- package/dist/__mocks__/gift-card.d.ts +0 -1
- package/dist/enums/index.d.ts +0 -1
- package/dist/react/GiftCard.d.ts +0 -1
- package/dist/react/core/GiftCard.d.ts +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/services/gift-card-checkout-service.d.ts +0 -1
- package/dist/services/gift-card-service.d.ts +0 -1
- package/dist/services/index.d.ts +0 -1
- package/dist/utils/formatting-utils.d.ts +0 -1
- package/dist/utils/gift-card-utils.d.ts +0 -1
- package/dist/utils/validation-utils.d.ts +0 -1
- package/package.json +5 -5
- package/cjs/dist/__mocks__/gift-card.d.ts.map +0 -1
- package/cjs/dist/enums/index.d.ts.map +0 -1
- package/cjs/dist/react/GiftCard.d.ts.map +0 -1
- package/cjs/dist/react/core/GiftCard.d.ts.map +0 -1
- package/cjs/dist/react/index.d.ts.map +0 -1
- package/cjs/dist/services/gift-card-checkout-service.d.ts.map +0 -1
- package/cjs/dist/services/gift-card-service.d.ts.map +0 -1
- package/cjs/dist/services/index.d.ts.map +0 -1
- package/cjs/dist/utils/formatting-utils.d.ts.map +0 -1
- package/cjs/dist/utils/gift-card-utils.d.ts.map +0 -1
- package/cjs/dist/utils/validation-utils.d.ts.map +0 -1
- package/dist/__mocks__/gift-card.d.ts.map +0 -1
- package/dist/enums/index.d.ts.map +0 -1
- package/dist/react/GiftCard.d.ts.map +0 -1
- package/dist/react/core/GiftCard.d.ts.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/services/gift-card-checkout-service.d.ts.map +0 -1
- package/dist/services/gift-card-service.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/utils/formatting-utils.d.ts.map +0 -1
- package/dist/utils/gift-card-utils.d.ts.map +0 -1
- package/dist/utils/validation-utils.d.ts.map +0 -1
|
@@ -1,11 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.Action = exports.ActionBuyNow = exports.ActionAddToCart = exports.RecipientForm = exports.RecipientMessage = exports.RecipientDate = exports.RecipientName = exports.RecipientEmail = exports.GiftToggle = exports.Quantity = exports.CustomAmountInput = exports.CustomVariantTrigger = exports.CurrentPrice = exports.PresetVariant = exports.PresetVariantRepeater = exports.PresetVariants = exports.Error = exports.Loading = exports.Description = exports.Name = exports.Image = exports.Raw = exports.Root = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const react_1 = __importDefault(require("react"));
|
|
42
|
+
const CoreGiftCard = __importStar(require("./core/GiftCard.js"));
|
|
43
|
+
const react_2 = require("@wix/headless-utils/react");
|
|
44
|
+
const react_3 = require("@wix/headless-media/react");
|
|
45
|
+
const react_4 = require("@wix/headless-components/react");
|
|
46
|
+
const react_5 = require("@wix/headless-ecom/react");
|
|
47
|
+
const index_js_1 = require("../enums/index.js");
|
|
9
48
|
/**
|
|
10
49
|
* Root component that provides the GiftCard service context.
|
|
11
50
|
* Supports both SSR (with product in config) and client-side auto-fetch (empty config).
|
|
@@ -24,11 +63,12 @@ import { DEFAULT_LOADING_TEXT, GIFT_CARD_ROOT_COMPONENT_TAG, TestIds, } from '..
|
|
|
24
63
|
* </GiftCard.Root>
|
|
25
64
|
* ```
|
|
26
65
|
*/
|
|
27
|
-
|
|
66
|
+
const Root = (props) => {
|
|
28
67
|
const { children, giftCardServiceConfig, ...attrs } = props;
|
|
29
|
-
return (
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Root, { giftCardServiceConfig: giftCardServiceConfig, children: (0, jsx_runtime_1.jsx)("div", { "data-testid": index_js_1.TestIds.giftCardRoot, "data-component-tag": index_js_1.GIFT_CARD_ROOT_COMPONENT_TAG, ...attrs, children: children }) }));
|
|
30
69
|
};
|
|
31
|
-
Root
|
|
70
|
+
exports.Root = Root;
|
|
71
|
+
exports.Root.displayName = 'GiftCard.Root';
|
|
32
72
|
/**
|
|
33
73
|
* Provides direct access to the gift card data via render props.
|
|
34
74
|
* Should be used only when you need full control over rendering all states.
|
|
@@ -52,16 +92,16 @@ Root.displayName = 'GiftCard.Root';
|
|
|
52
92
|
* </GiftCard.Raw>
|
|
53
93
|
* ```
|
|
54
94
|
*/
|
|
55
|
-
|
|
95
|
+
exports.Raw = react_1.default.forwardRef((props, ref) => {
|
|
56
96
|
const { asChild, children, className } = props;
|
|
57
|
-
return (
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Raw, { children: (rawData) => {
|
|
58
98
|
if (!asChild || !children) {
|
|
59
99
|
return null;
|
|
60
100
|
}
|
|
61
|
-
return (
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRaw, customElement: children, customElementProps: rawData }));
|
|
62
102
|
} }));
|
|
63
103
|
});
|
|
64
|
-
Raw.displayName = 'GiftCard.Raw';
|
|
104
|
+
exports.Raw.displayName = 'GiftCard.Raw';
|
|
65
105
|
/**
|
|
66
106
|
* Displays the gift card image using WixMediaImage
|
|
67
107
|
*
|
|
@@ -84,7 +124,7 @@ Raw.displayName = 'GiftCard.Raw';
|
|
|
84
124
|
* </GiftCard.Image>
|
|
85
125
|
* ```
|
|
86
126
|
*/
|
|
87
|
-
|
|
127
|
+
exports.Image = react_1.default.forwardRef((props, ref) => ((0, jsx_runtime_1.jsx)(CoreGiftCard.Image, { children: (renderProps) => ((0, jsx_runtime_1.jsx)(react_3.WixMediaImage, { ...props, ref: ref, media: { image: renderProps.image }, "data-testid": index_js_1.TestIds.giftCardImage })) })));
|
|
88
128
|
/**
|
|
89
129
|
* Displays the gift card product name with customizable rendering.
|
|
90
130
|
*
|
|
@@ -109,13 +149,13 @@ export const Image = React.forwardRef((props, ref) => (_jsx(CoreGiftCard.Image,
|
|
|
109
149
|
* </GiftCard.Name>
|
|
110
150
|
* ```
|
|
111
151
|
*/
|
|
112
|
-
|
|
152
|
+
exports.Name = react_1.default.forwardRef((props, ref) => {
|
|
113
153
|
const { asChild, children, className, ...otherProps } = props;
|
|
114
|
-
return (
|
|
115
|
-
return (
|
|
154
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Name, { children: ({ name }) => {
|
|
155
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardName, customElement: children, customElementProps: { name }, content: name, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: name }) }));
|
|
116
156
|
} }));
|
|
117
157
|
});
|
|
118
|
-
Name.displayName = 'GiftCard.Name';
|
|
158
|
+
exports.Name.displayName = 'GiftCard.Name';
|
|
119
159
|
/**
|
|
120
160
|
* Renders the gift card product description.
|
|
121
161
|
*
|
|
@@ -138,11 +178,11 @@ Name.displayName = 'GiftCard.Name';
|
|
|
138
178
|
* </GiftCard.Description>
|
|
139
179
|
* ```
|
|
140
180
|
*/
|
|
141
|
-
|
|
181
|
+
exports.Description = react_1.default.forwardRef((props, ref) => {
|
|
142
182
|
const { asChild, children, className, ...otherProps } = props;
|
|
143
|
-
return (
|
|
183
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Description, { children: ({ description }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardDescription, customElement: children, customElementProps: { description }, content: description, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: description }) })) }));
|
|
144
184
|
});
|
|
145
|
-
Description.displayName = 'GiftCard.Description';
|
|
185
|
+
exports.Description.displayName = 'GiftCard.Description';
|
|
146
186
|
/**
|
|
147
187
|
* Displays loading state indicator.
|
|
148
188
|
* Only renders content when isLoading is true.
|
|
@@ -155,15 +195,15 @@ Description.displayName = 'GiftCard.Description';
|
|
|
155
195
|
* </GiftCard.Loading>
|
|
156
196
|
* ```
|
|
157
197
|
*/
|
|
158
|
-
|
|
198
|
+
exports.Loading = react_1.default.forwardRef((props, ref) => {
|
|
159
199
|
const { className, children, ...otherProps } = props;
|
|
160
|
-
return (
|
|
200
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Loading, { children: ({ isLoading }) => {
|
|
161
201
|
if (!isLoading)
|
|
162
202
|
return null;
|
|
163
|
-
return (
|
|
203
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, "data-testid": index_js_1.TestIds.giftCardLoading, ...otherProps, children: children ?? index_js_1.DEFAULT_LOADING_TEXT }));
|
|
164
204
|
} }));
|
|
165
205
|
});
|
|
166
|
-
Loading.displayName = 'GiftCard.Loading';
|
|
206
|
+
exports.Loading.displayName = 'GiftCard.Loading';
|
|
167
207
|
/**
|
|
168
208
|
* Displays error state.
|
|
169
209
|
* Only renders when there's an error.
|
|
@@ -174,24 +214,24 @@ Loading.displayName = 'GiftCard.Loading';
|
|
|
174
214
|
* <GiftCard.Error className="text-red-500" />
|
|
175
215
|
* ```
|
|
176
216
|
*/
|
|
177
|
-
|
|
217
|
+
exports.Error = react_1.default.forwardRef((props, ref) => {
|
|
178
218
|
const { className, ...otherProps } = props;
|
|
179
|
-
return (
|
|
219
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Error, { children: ({ error }) => {
|
|
180
220
|
if (!error)
|
|
181
221
|
return null;
|
|
182
|
-
return (
|
|
222
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, "data-testid": index_js_1.TestIds.giftCardError, ...otherProps, children: error }));
|
|
183
223
|
} }));
|
|
184
224
|
});
|
|
185
|
-
Error.displayName = 'GiftCard.Error';
|
|
225
|
+
exports.Error.displayName = 'GiftCard.Error';
|
|
186
226
|
/**
|
|
187
227
|
* Context for individual preset variant data
|
|
188
228
|
*/
|
|
189
|
-
const PresetVariantContext =
|
|
229
|
+
const PresetVariantContext = react_1.default.createContext(null);
|
|
190
230
|
/**
|
|
191
231
|
* Hook to access PresetVariant context
|
|
192
232
|
*/
|
|
193
233
|
function usePresetVariantContext() {
|
|
194
|
-
const context =
|
|
234
|
+
const context = react_1.default.useContext(PresetVariantContext);
|
|
195
235
|
if (!context) {
|
|
196
236
|
// Use globalThis.Error to avoid conflict with exported Error component
|
|
197
237
|
throw new globalThis.Error('PresetVariant components must be used within PresetVariantRepeater');
|
|
@@ -214,16 +254,16 @@ function usePresetVariantContext() {
|
|
|
214
254
|
* </GiftCard.PresetVariants>
|
|
215
255
|
* ```
|
|
216
256
|
*/
|
|
217
|
-
|
|
257
|
+
exports.PresetVariants = react_1.default.forwardRef((props, ref) => {
|
|
218
258
|
const { asChild, children, className, label, emptyState, ...otherProps } = props;
|
|
219
|
-
return (
|
|
259
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.PresetVariants, { children: (variantsData) => {
|
|
220
260
|
if (variantsData.presetVariants.length === 0 && emptyState) {
|
|
221
|
-
return
|
|
261
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: emptyState });
|
|
222
262
|
}
|
|
223
|
-
return (
|
|
263
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardPresetVariants, customElement: children, customElementProps: variantsData, ...otherProps, children: (0, jsx_runtime_1.jsxs)("div", { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), children] }) }));
|
|
224
264
|
} }));
|
|
225
265
|
});
|
|
226
|
-
PresetVariants.displayName = 'GiftCard.PresetVariants';
|
|
266
|
+
exports.PresetVariants.displayName = 'GiftCard.PresetVariants';
|
|
227
267
|
/**
|
|
228
268
|
* Repeater component that renders children for each preset variant.
|
|
229
269
|
* Creates a PresetVariant context for each variant that child components can access.
|
|
@@ -236,11 +276,12 @@ PresetVariants.displayName = 'GiftCard.PresetVariants';
|
|
|
236
276
|
* </GiftCard.PresetVariantRepeater>
|
|
237
277
|
* ```
|
|
238
278
|
*/
|
|
239
|
-
|
|
279
|
+
const PresetVariantRepeater = (props) => {
|
|
240
280
|
const { children, className } = props;
|
|
241
|
-
return (
|
|
281
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.PresetVariantRepeater, { children: ({ presetVariants }) => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: presetVariants.map((variant) => ((0, jsx_runtime_1.jsx)(PresetVariantContext.Provider, { value: variant, children: (0, jsx_runtime_1.jsx)("div", { "data-testid": index_js_1.TestIds.giftCardPresetVariant, "data-variant-id": variant.id, "data-selected": variant.isSelected || undefined, "data-has-discount": variant.hasDiscount || undefined, className: className, children: children }) }, variant.id))) })) }));
|
|
242
282
|
};
|
|
243
|
-
PresetVariantRepeater
|
|
283
|
+
exports.PresetVariantRepeater = PresetVariantRepeater;
|
|
284
|
+
exports.PresetVariantRepeater.displayName = 'GiftCard.PresetVariantRepeater';
|
|
244
285
|
/**
|
|
245
286
|
* Clickable button for selecting a preset variant amount.
|
|
246
287
|
* Default renders a button with Money-formatted value.
|
|
@@ -268,7 +309,7 @@ PresetVariantRepeater.displayName = 'GiftCard.PresetVariantRepeater';
|
|
|
268
309
|
* </GiftCard.PresetVariant.Amount>
|
|
269
310
|
* ```
|
|
270
311
|
*/
|
|
271
|
-
const PresetVariantAmount =
|
|
312
|
+
const PresetVariantAmount = react_1.default.forwardRef((props, ref) => {
|
|
272
313
|
const { asChild, children, className, ...otherProps } = props;
|
|
273
314
|
const variant = usePresetVariantContext();
|
|
274
315
|
const amountData = {
|
|
@@ -281,7 +322,7 @@ const PresetVariantAmount = React.forwardRef((props, ref) => {
|
|
|
281
322
|
currencyCode: variant.currencyCode,
|
|
282
323
|
locale: variant.locale,
|
|
283
324
|
};
|
|
284
|
-
const moneyContent = (
|
|
325
|
+
const moneyContent = ((0, jsx_runtime_1.jsx)(react_4.Money, { money: {
|
|
285
326
|
amount: variant.value,
|
|
286
327
|
currency: variant.currencyCode,
|
|
287
328
|
locale: variant.locale,
|
|
@@ -290,13 +331,13 @@ const PresetVariantAmount = React.forwardRef((props, ref) => {
|
|
|
290
331
|
maximumFractionDigits: 2,
|
|
291
332
|
},
|
|
292
333
|
} }));
|
|
293
|
-
return (
|
|
334
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardPresetVariantAmount, "data-selected": variant.isSelected || undefined, "data-has-discount": variant.hasDiscount || undefined, onClick: variant.select, customElement: children, customElementProps: amountData, content: moneyContent, ...otherProps, children: (0, jsx_runtime_1.jsx)("button", { onClick: variant.select, children: moneyContent }) }));
|
|
294
335
|
});
|
|
295
336
|
PresetVariantAmount.displayName = 'GiftCard.PresetVariant.Amount';
|
|
296
337
|
/**
|
|
297
338
|
== * PresetVariant namespace containing preset variant sub-components
|
|
298
339
|
*/
|
|
299
|
-
|
|
340
|
+
exports.PresetVariant = {
|
|
300
341
|
Amount: PresetVariantAmount,
|
|
301
342
|
};
|
|
302
343
|
/**
|
|
@@ -332,10 +373,10 @@ export const PresetVariant = {
|
|
|
332
373
|
* </GiftCard.CurrentPrice>
|
|
333
374
|
* ```
|
|
334
375
|
*/
|
|
335
|
-
|
|
376
|
+
exports.CurrentPrice = react_1.default.forwardRef((props, ref) => {
|
|
336
377
|
const { asChild, children, className, ...otherProps } = props;
|
|
337
|
-
return (
|
|
338
|
-
const priceContent = (
|
|
378
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.CurrentPrice, { children: (priceData) => {
|
|
379
|
+
const priceContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [priceData.hasDiscount && ((0, jsx_runtime_1.jsx)("span", { style: { textDecoration: 'line-through', marginRight: '8px' }, children: (0, jsx_runtime_1.jsx)(react_4.Money, { money: {
|
|
339
380
|
amount: priceData.value,
|
|
340
381
|
currency: priceData.currencyCode,
|
|
341
382
|
locale: priceData.locale,
|
|
@@ -343,7 +384,7 @@ export const CurrentPrice = React.forwardRef((props, ref) => {
|
|
|
343
384
|
minimumFractionDigits: 0,
|
|
344
385
|
maximumFractionDigits: 2,
|
|
345
386
|
},
|
|
346
|
-
} }) })),
|
|
387
|
+
} }) })), (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(react_4.Money, { money: {
|
|
347
388
|
amount: priceData.price,
|
|
348
389
|
currency: priceData.currencyCode,
|
|
349
390
|
locale: priceData.locale,
|
|
@@ -352,10 +393,10 @@ export const CurrentPrice = React.forwardRef((props, ref) => {
|
|
|
352
393
|
maximumFractionDigits: 2,
|
|
353
394
|
},
|
|
354
395
|
} }) })] }));
|
|
355
|
-
return (
|
|
396
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardCurrentPrice, "data-has-discount": priceData.hasDiscount || undefined, customElement: children, customElementProps: priceData, content: priceContent, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: priceContent }) }));
|
|
356
397
|
} }));
|
|
357
398
|
});
|
|
358
|
-
CurrentPrice.displayName = 'GiftCard.CurrentPrice';
|
|
399
|
+
exports.CurrentPrice.displayName = 'GiftCard.CurrentPrice';
|
|
359
400
|
/**
|
|
360
401
|
* Trigger button for selecting custom amount option.
|
|
361
402
|
* Use alongside PresetVariantRepeater to allow custom amounts.
|
|
@@ -388,11 +429,11 @@ CurrentPrice.displayName = 'GiftCard.CurrentPrice';
|
|
|
388
429
|
* </GiftCard.CustomVariantTrigger>
|
|
389
430
|
* ```
|
|
390
431
|
*/
|
|
391
|
-
|
|
432
|
+
exports.CustomVariantTrigger = react_1.default.forwardRef((props, ref) => {
|
|
392
433
|
const { label = 'Other amount', asChild, children, className, ...otherProps } = props;
|
|
393
|
-
return (
|
|
434
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.CustomVariantTrigger, { children: ({ isSelected, onClick }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardCustomVariantTrigger, "data-selected": isSelected || undefined, customElement: children, customElementProps: { isSelected, onClick }, onClick: onClick, content: label, ...otherProps, children: (0, jsx_runtime_1.jsx)("button", { onClick: onClick, children: label }) })) }));
|
|
394
435
|
});
|
|
395
|
-
CustomVariantTrigger.displayName = 'GiftCard.CustomVariantTrigger';
|
|
436
|
+
exports.CustomVariantTrigger.displayName = 'GiftCard.CustomVariantTrigger';
|
|
396
437
|
/**
|
|
397
438
|
* Input for entering a custom gift card amount.
|
|
398
439
|
* Only renders when custom variant is selected.
|
|
@@ -450,17 +491,17 @@ CustomVariantTrigger.displayName = 'GiftCard.CustomVariantTrigger';
|
|
|
450
491
|
* </GiftCard.CustomAmountInput>
|
|
451
492
|
* ```
|
|
452
493
|
*/
|
|
453
|
-
|
|
494
|
+
exports.CustomAmountInput = react_1.default.forwardRef((props, ref) => {
|
|
454
495
|
const { label, asChild, children, className, ...otherProps } = props;
|
|
455
|
-
return (
|
|
496
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.CustomAmountInput, { children: (inputData) => {
|
|
456
497
|
// Don't render if not visible (not custom variant) unless using asChild
|
|
457
498
|
if (!inputData.isVisible && !asChild) {
|
|
458
499
|
return null;
|
|
459
500
|
}
|
|
460
|
-
return (
|
|
501
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardCustomAmountInput, "data-invalid": !inputData.isValid || undefined, "data-visible": inputData.isVisible || undefined, customElement: children, customElementProps: inputData, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: inputData.isVisible && ((0, jsx_runtime_1.jsxs)("div", { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { children: inputData.currencySymbol }), (0, jsx_runtime_1.jsx)("input", { prefix: inputData.currencySymbol, type: "number", value: inputData.value, onChange: (e) => inputData.setValue(parseFloat(e.target.value) || 0), min: inputData.min ?? undefined, max: inputData.max ?? undefined, className: className })] })] })) }) }));
|
|
461
502
|
} }));
|
|
462
503
|
});
|
|
463
|
-
CustomAmountInput.displayName = 'GiftCard.CustomAmountInput';
|
|
504
|
+
exports.CustomAmountInput.displayName = 'GiftCard.CustomAmountInput';
|
|
464
505
|
/**
|
|
465
506
|
* Container for quantity selection controls.
|
|
466
507
|
* Renders a Quantity.Root from @wix/headless-components connected to the gift card service state.
|
|
@@ -523,11 +564,11 @@ CustomAmountInput.displayName = 'GiftCard.CustomAmountInput';
|
|
|
523
564
|
* </GiftCard.Quantity>
|
|
524
565
|
* ```
|
|
525
566
|
*/
|
|
526
|
-
|
|
567
|
+
exports.Quantity = react_1.default.forwardRef((props, ref) => {
|
|
527
568
|
const { asChild, children, className, steps = 1, label, ...otherProps } = props;
|
|
528
|
-
return (
|
|
569
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Quantity, { children: ({ quantity, setQuantity }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardQuantity, customElement: children, customElementProps: { quantity, setQuantity }, ...otherProps, children: (0, jsx_runtime_1.jsxs)("div", { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsxs)(react_4.Quantity.Root, { initialValue: quantity, onValueChange: setQuantity, steps: steps, min: 1, className: className, children: [(0, jsx_runtime_1.jsx)(react_4.Quantity.Decrement, {}), (0, jsx_runtime_1.jsx)(react_4.Quantity.Input, {}), (0, jsx_runtime_1.jsx)(react_4.Quantity.Increment, {})] })] }) })) }));
|
|
529
570
|
});
|
|
530
|
-
Quantity.displayName = 'GiftCard.Quantity';
|
|
571
|
+
exports.Quantity.displayName = 'GiftCard.Quantity';
|
|
531
572
|
/**
|
|
532
573
|
* Toggle between "For someone else" (gift) and "For myself" purchase modes.
|
|
533
574
|
* When isGift is true, the recipient form should be shown.
|
|
@@ -580,11 +621,11 @@ Quantity.displayName = 'GiftCard.Quantity';
|
|
|
580
621
|
* </GiftCard.GiftToggle>
|
|
581
622
|
* ```
|
|
582
623
|
*/
|
|
583
|
-
|
|
624
|
+
exports.GiftToggle = react_1.default.forwardRef((props, ref) => {
|
|
584
625
|
const { label, forSomeoneLabel = 'For someone else', forMyselfLabel = 'For myself', asChild, children, className, ...otherProps } = props;
|
|
585
|
-
return (
|
|
626
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.GiftToggle, { children: ({ isGift, setIsGift }) => ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardGiftToggle, customElement: children, customElementProps: { isGift, setIsGift }, ...otherProps, children: (0, jsx_runtime_1.jsxs)("div", { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsxs)("div", { className: className, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setIsGift(true), "data-selected": isGift || undefined, "data-testid": index_js_1.TestIds.giftCardGiftToggleSomeone, children: forSomeoneLabel }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setIsGift(false), "data-selected": !isGift || undefined, "data-testid": index_js_1.TestIds.giftCardGiftToggleMyself, children: forMyselfLabel })] })] }) })) }));
|
|
586
627
|
});
|
|
587
|
-
GiftToggle.displayName = 'GiftCard.GiftToggle';
|
|
628
|
+
exports.GiftToggle.displayName = 'GiftCard.GiftToggle';
|
|
588
629
|
/**
|
|
589
630
|
* Input for entering recipient email address.
|
|
590
631
|
* Provides email state, validation, and error display control.
|
|
@@ -628,24 +669,24 @@ GiftToggle.displayName = 'GiftCard.GiftToggle';
|
|
|
628
669
|
* </GiftCard.RecipientEmail>
|
|
629
670
|
* ```
|
|
630
671
|
*/
|
|
631
|
-
|
|
672
|
+
exports.RecipientEmail = react_1.default.forwardRef((props, ref) => {
|
|
632
673
|
const { label, asChild, children, className, ...otherProps } = props;
|
|
633
|
-
return (
|
|
674
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.RecipientEmail, { children: ({ value, setValue, isValid, showError, isVisible }) => {
|
|
634
675
|
// Don't render if not visible (isGift is false) unless using asChild
|
|
635
676
|
if (!isVisible && !asChild) {
|
|
636
677
|
return null;
|
|
637
678
|
}
|
|
638
679
|
const showInvalidState = showError && !isValid;
|
|
639
|
-
return (
|
|
680
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRecipientEmail, "data-invalid": showInvalidState || undefined, "data-visible": isVisible || undefined, customElement: children, customElementProps: {
|
|
640
681
|
value,
|
|
641
682
|
setValue,
|
|
642
683
|
isValid,
|
|
643
684
|
showError,
|
|
644
685
|
isVisible,
|
|
645
|
-
}, ...otherProps, children:
|
|
686
|
+
}, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: isVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsx)("input", { type: "email", value: value, onChange: (e) => setValue(e.target.value), className: className, "data-invalid": showInvalidState || undefined })] })) }) }));
|
|
646
687
|
} }));
|
|
647
688
|
});
|
|
648
|
-
RecipientEmail.displayName = 'GiftCard.RecipientEmail';
|
|
689
|
+
exports.RecipientEmail.displayName = 'GiftCard.RecipientEmail';
|
|
649
690
|
/**
|
|
650
691
|
* Input for entering recipient name.
|
|
651
692
|
* Only renders when isGift is true (purchasing for someone else).
|
|
@@ -682,21 +723,21 @@ RecipientEmail.displayName = 'GiftCard.RecipientEmail';
|
|
|
682
723
|
* </GiftCard.RecipientName>
|
|
683
724
|
* ```
|
|
684
725
|
*/
|
|
685
|
-
|
|
726
|
+
exports.RecipientName = react_1.default.forwardRef((props, ref) => {
|
|
686
727
|
const { label, asChild, children, className, ...otherProps } = props;
|
|
687
|
-
return (
|
|
728
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.RecipientName, { children: ({ value, setValue, isVisible }) => {
|
|
688
729
|
// Don't render if not visible (isGift is false) unless using asChild
|
|
689
730
|
if (!isVisible && !asChild) {
|
|
690
731
|
return null;
|
|
691
732
|
}
|
|
692
|
-
return (
|
|
733
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRecipientName, "data-visible": isVisible || undefined, customElement: children, customElementProps: {
|
|
693
734
|
value,
|
|
694
735
|
setValue,
|
|
695
736
|
isVisible,
|
|
696
|
-
}, ...otherProps, children:
|
|
737
|
+
}, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: isVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsx)("input", { type: "text", value: value, onChange: (e) => setValue(e.target.value), className: className })] })) }) }));
|
|
697
738
|
} }));
|
|
698
739
|
});
|
|
699
|
-
RecipientName.displayName = 'GiftCard.RecipientName';
|
|
740
|
+
exports.RecipientName.displayName = 'GiftCard.RecipientName';
|
|
700
741
|
/**
|
|
701
742
|
* Input for selecting gift card delivery date.
|
|
702
743
|
* Only renders when isGift is true (purchasing for someone else).
|
|
@@ -734,27 +775,27 @@ RecipientName.displayName = 'GiftCard.RecipientName';
|
|
|
734
775
|
* </GiftCard.RecipientDate>
|
|
735
776
|
* ```
|
|
736
777
|
*/
|
|
737
|
-
|
|
778
|
+
exports.RecipientDate = react_1.default.forwardRef((props, ref) => {
|
|
738
779
|
const { label, asChild, children, className, ...otherProps } = props;
|
|
739
|
-
return (
|
|
780
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.RecipientDate, { children: ({ value, formattedValue, inputValue, setValue, isVisible }) => {
|
|
740
781
|
// Don't render if not visible (isGift is false) unless using asChild
|
|
741
782
|
if (!isVisible && !asChild) {
|
|
742
783
|
return null;
|
|
743
784
|
}
|
|
744
|
-
return (
|
|
785
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRecipientDate, "data-visible": isVisible || undefined, customElement: children, customElementProps: {
|
|
745
786
|
value,
|
|
746
787
|
formattedValue,
|
|
747
788
|
inputValue,
|
|
748
789
|
setValue,
|
|
749
790
|
isVisible,
|
|
750
|
-
}, ...otherProps, children:
|
|
791
|
+
}, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: isVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: inputValue, onChange: (e) => {
|
|
751
792
|
if (e.target.value) {
|
|
752
793
|
setValue(new Date(e.target.value));
|
|
753
794
|
}
|
|
754
795
|
}, className: className })] })) }) }));
|
|
755
796
|
} }));
|
|
756
797
|
});
|
|
757
|
-
RecipientDate.displayName = 'GiftCard.RecipientDate';
|
|
798
|
+
exports.RecipientDate.displayName = 'GiftCard.RecipientDate';
|
|
758
799
|
/**
|
|
759
800
|
* Textarea for entering a personal message to include with the gift card.
|
|
760
801
|
* Only renders when isGift is true (purchasing for someone else).
|
|
@@ -791,21 +832,21 @@ RecipientDate.displayName = 'GiftCard.RecipientDate';
|
|
|
791
832
|
* </GiftCard.RecipientMessage>
|
|
792
833
|
* ```
|
|
793
834
|
*/
|
|
794
|
-
|
|
835
|
+
exports.RecipientMessage = react_1.default.forwardRef((props, ref) => {
|
|
795
836
|
const { label, asChild, children, className, ...otherProps } = props;
|
|
796
|
-
return (
|
|
837
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.RecipientMessage, { children: ({ value, setValue, isVisible }) => {
|
|
797
838
|
// Don't render if not visible (isGift is false) unless using asChild
|
|
798
839
|
if (!isVisible && !asChild) {
|
|
799
840
|
return null;
|
|
800
841
|
}
|
|
801
|
-
return (
|
|
842
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRecipientMessage, "data-visible": isVisible || undefined, customElement: children, customElementProps: {
|
|
802
843
|
value,
|
|
803
844
|
setValue,
|
|
804
845
|
isVisible,
|
|
805
|
-
}, ...otherProps, children:
|
|
846
|
+
}, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { children: isVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [label && (0, jsx_runtime_1.jsx)("label", { children: label }), (0, jsx_runtime_1.jsx)("textarea", { value: value, onChange: (e) => setValue(e.target.value), className: className, rows: 4 })] })) }) }));
|
|
806
847
|
} }));
|
|
807
848
|
});
|
|
808
|
-
RecipientMessage.displayName = 'GiftCard.RecipientMessage';
|
|
849
|
+
exports.RecipientMessage.displayName = 'GiftCard.RecipientMessage';
|
|
809
850
|
/**
|
|
810
851
|
* Form for entering recipient details when purchasing a gift card for someone else.
|
|
811
852
|
* Only renders when isGift is true (purchasing for someone else).
|
|
@@ -906,22 +947,22 @@ RecipientMessage.displayName = 'GiftCard.RecipientMessage';
|
|
|
906
947
|
* </GiftCard.RecipientForm>
|
|
907
948
|
* ```
|
|
908
949
|
*/
|
|
909
|
-
|
|
950
|
+
exports.RecipientForm = react_1.default.forwardRef((props, ref) => {
|
|
910
951
|
const { emailLabel, nameLabel, dateLabel, messageLabel, asChild, children, className, ...otherProps } = props;
|
|
911
|
-
return (
|
|
952
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.RecipientForm, { children: (formData) => {
|
|
912
953
|
// Don't render if not visible (isGift is false) unless using asChild
|
|
913
954
|
if (!formData.isVisible && !asChild) {
|
|
914
955
|
return null;
|
|
915
956
|
}
|
|
916
957
|
const showEmailError = formData.showErrors && !formData.email.isValid;
|
|
917
|
-
return (
|
|
958
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardRecipientForm, "data-visible": formData.isVisible || undefined, customElement: children, customElementProps: formData, ...otherProps, children: (0, jsx_runtime_1.jsx)("div", { className: className, children: formData.isVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { "data-testid": index_js_1.TestIds.giftCardRecipientEmail, children: [emailLabel && (0, jsx_runtime_1.jsx)("label", { children: emailLabel }), (0, jsx_runtime_1.jsx)("input", { type: "email", value: formData.email.value, onChange: (e) => formData.email.setValue(e.target.value), "data-invalid": showEmailError || undefined })] }), (0, jsx_runtime_1.jsxs)("div", { "data-testid": index_js_1.TestIds.giftCardRecipientName, children: [nameLabel && (0, jsx_runtime_1.jsx)("label", { children: nameLabel }), (0, jsx_runtime_1.jsx)("input", { type: "text", value: formData.name.value, onChange: (e) => formData.name.setValue(e.target.value) })] }), (0, jsx_runtime_1.jsxs)("div", { "data-testid": index_js_1.TestIds.giftCardRecipientDate, children: [dateLabel && (0, jsx_runtime_1.jsx)("label", { children: dateLabel }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: formData.deliverAt.inputValue, onChange: (e) => {
|
|
918
959
|
if (e.target.value) {
|
|
919
960
|
formData.deliverAt.setValue(new Date(e.target.value));
|
|
920
961
|
}
|
|
921
|
-
} })] }),
|
|
962
|
+
} })] }), (0, jsx_runtime_1.jsxs)("div", { "data-testid": index_js_1.TestIds.giftCardRecipientMessage, children: [messageLabel && (0, jsx_runtime_1.jsx)("label", { children: messageLabel }), (0, jsx_runtime_1.jsx)("textarea", { value: formData.message.value, onChange: (e) => formData.message.setValue(e.target.value), rows: 4 })] })] })) }) }));
|
|
922
963
|
} }));
|
|
923
964
|
});
|
|
924
|
-
RecipientForm.displayName = 'GiftCard.RecipientForm';
|
|
965
|
+
exports.RecipientForm.displayName = 'GiftCard.RecipientForm';
|
|
925
966
|
/**
|
|
926
967
|
* Add to cart button for gift cards.
|
|
927
968
|
* Validates the form (triggers showErrors), then adds the gift card to cart.
|
|
@@ -978,19 +1019,19 @@ RecipientForm.displayName = 'GiftCard.RecipientForm';
|
|
|
978
1019
|
* />
|
|
979
1020
|
* ```
|
|
980
1021
|
*/
|
|
981
|
-
|
|
1022
|
+
exports.ActionAddToCart = react_1.default.forwardRef((props, ref) => {
|
|
982
1023
|
const { label = 'Add to Cart', loadingLabel, asChild, children, className, onSuccess, ...otherProps } = props;
|
|
983
|
-
return (
|
|
1024
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Actions, { children: ({ lineItems, validateAndShowErrors }) => {
|
|
984
1025
|
// asChild
|
|
985
1026
|
if (asChild && children) {
|
|
986
|
-
return (
|
|
1027
|
+
return ((0, jsx_runtime_1.jsx)(react_5.Commerce.Actions.AddToCart, { ref: ref, lineItems: lineItems, asChild: true, onSuccess: onSuccess, children: (commerceProps, commerceRef) => {
|
|
987
1028
|
const onClick = async () => {
|
|
988
1029
|
if (!validateAndShowErrors()) {
|
|
989
1030
|
return;
|
|
990
1031
|
}
|
|
991
1032
|
await commerceProps.onClick();
|
|
992
1033
|
};
|
|
993
|
-
return (
|
|
1034
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: commerceRef, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardAddToCart, customElement: children, customElementProps: {
|
|
994
1035
|
onClick,
|
|
995
1036
|
isLoading: commerceProps.isLoading,
|
|
996
1037
|
}, content: commerceProps.isLoading && loadingLabel
|
|
@@ -999,20 +1040,20 @@ export const ActionAddToCart = React.forwardRef((props, ref) => {
|
|
|
999
1040
|
} }));
|
|
1000
1041
|
}
|
|
1001
1042
|
// default rendering
|
|
1002
|
-
return (
|
|
1043
|
+
return ((0, jsx_runtime_1.jsx)(react_5.Commerce.Actions.AddToCart, { ref: ref, lineItems: lineItems, asChild: true, onSuccess: onSuccess, children: (commerceProps, commerceRef) => {
|
|
1003
1044
|
const onClick = async () => {
|
|
1004
1045
|
if (!validateAndShowErrors()) {
|
|
1005
1046
|
return;
|
|
1006
1047
|
}
|
|
1007
1048
|
await commerceProps.onClick();
|
|
1008
1049
|
};
|
|
1009
|
-
return (
|
|
1050
|
+
return ((0, jsx_runtime_1.jsx)("button", { ref: commerceRef, className: className, disabled: commerceProps.isLoading, onClick: onClick, "data-testid": index_js_1.TestIds.giftCardAddToCart, "data-loading": commerceProps.isLoading || undefined, ...otherProps, children: commerceProps.isLoading && loadingLabel
|
|
1010
1051
|
? loadingLabel
|
|
1011
1052
|
: label }));
|
|
1012
1053
|
} }));
|
|
1013
1054
|
} }));
|
|
1014
1055
|
});
|
|
1015
|
-
ActionAddToCart.displayName = 'GiftCard.Action.AddToCart';
|
|
1056
|
+
exports.ActionAddToCart.displayName = 'GiftCard.Action.AddToCart';
|
|
1016
1057
|
/**
|
|
1017
1058
|
* Buy now button for gift cards.
|
|
1018
1059
|
* Validates the form (triggers showErrors), then redirects to checkout.
|
|
@@ -1061,19 +1102,19 @@ ActionAddToCart.displayName = 'GiftCard.Action.AddToCart';
|
|
|
1061
1102
|
* </GiftCard.Action.BuyNow>
|
|
1062
1103
|
* ```
|
|
1063
1104
|
*/
|
|
1064
|
-
|
|
1105
|
+
exports.ActionBuyNow = react_1.default.forwardRef((props, ref) => {
|
|
1065
1106
|
const { label = 'Buy Now', loadingLabel, asChild, children, className, ...otherProps } = props;
|
|
1066
|
-
return (
|
|
1107
|
+
return ((0, jsx_runtime_1.jsx)(CoreGiftCard.Actions, { children: ({ lineItems, validateAndShowErrors }) => {
|
|
1067
1108
|
// asChild
|
|
1068
1109
|
if (asChild && children) {
|
|
1069
|
-
return (
|
|
1110
|
+
return ((0, jsx_runtime_1.jsx)(react_5.Commerce.Actions.BuyNow, { ref: ref, lineItems: lineItems, asChild: true, children: (commerceProps, commerceRef) => {
|
|
1070
1111
|
const onClick = async () => {
|
|
1071
1112
|
if (!validateAndShowErrors()) {
|
|
1072
1113
|
return;
|
|
1073
1114
|
}
|
|
1074
1115
|
await commerceProps.onClick();
|
|
1075
1116
|
};
|
|
1076
|
-
return (
|
|
1117
|
+
return ((0, jsx_runtime_1.jsx)(react_2.AsChildSlot, { ref: commerceRef, asChild: asChild, className: className, "data-testid": index_js_1.TestIds.giftCardBuyNow, customElement: children, customElementProps: {
|
|
1077
1118
|
onClick,
|
|
1078
1119
|
isLoading: commerceProps.isLoading,
|
|
1079
1120
|
}, content: commerceProps.isLoading && loadingLabel
|
|
@@ -1082,20 +1123,20 @@ export const ActionBuyNow = React.forwardRef((props, ref) => {
|
|
|
1082
1123
|
} }));
|
|
1083
1124
|
}
|
|
1084
1125
|
// default rendering
|
|
1085
|
-
return (
|
|
1126
|
+
return ((0, jsx_runtime_1.jsx)(react_5.Commerce.Actions.BuyNow, { ref: ref, lineItems: lineItems, asChild: true, children: (commerceProps, commerceRef) => {
|
|
1086
1127
|
const onClick = async () => {
|
|
1087
1128
|
if (!validateAndShowErrors()) {
|
|
1088
1129
|
return;
|
|
1089
1130
|
}
|
|
1090
1131
|
await commerceProps.onClick();
|
|
1091
1132
|
};
|
|
1092
|
-
return (
|
|
1133
|
+
return ((0, jsx_runtime_1.jsx)("button", { ref: commerceRef, className: className, disabled: commerceProps.isLoading, onClick: onClick, "data-testid": index_js_1.TestIds.giftCardBuyNow, "data-loading": commerceProps.isLoading || undefined, ...otherProps, children: commerceProps.isLoading && loadingLabel
|
|
1093
1134
|
? loadingLabel
|
|
1094
1135
|
: label }));
|
|
1095
1136
|
} }));
|
|
1096
1137
|
} }));
|
|
1097
1138
|
});
|
|
1098
|
-
ActionBuyNow.displayName = 'GiftCard.Action.BuyNow';
|
|
1139
|
+
exports.ActionBuyNow.displayName = 'GiftCard.Action.BuyNow';
|
|
1099
1140
|
/**
|
|
1100
1141
|
* Namespace containing all gift card action components.
|
|
1101
1142
|
* These components provide consistent interfaces for gift card purchase actions.
|
|
@@ -1118,9 +1159,9 @@ ActionBuyNow.displayName = 'GiftCard.Action.BuyNow';
|
|
|
1118
1159
|
* />
|
|
1119
1160
|
* ```
|
|
1120
1161
|
*/
|
|
1121
|
-
|
|
1162
|
+
exports.Action = {
|
|
1122
1163
|
/** Add to Cart button for adding gift card to the current cart */
|
|
1123
|
-
AddToCart: ActionAddToCart,
|
|
1164
|
+
AddToCart: exports.ActionAddToCart,
|
|
1124
1165
|
/** Buy Now button for immediate checkout with the gift card */
|
|
1125
|
-
BuyNow: ActionBuyNow,
|
|
1166
|
+
BuyNow: exports.ActionBuyNow,
|
|
1126
1167
|
};
|