@wix/headless-gift-voucher 0.0.4 → 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.
Files changed (57) hide show
  1. package/cjs/dist/__mocks__/gift-card.d.ts +0 -1
  2. package/cjs/dist/__mocks__/gift-card.js +29 -25
  3. package/cjs/dist/enums/index.d.ts +0 -1
  4. package/cjs/dist/enums/index.js +11 -8
  5. package/cjs/dist/react/GiftCard.d.ts +0 -1
  6. package/cjs/dist/react/GiftCard.js +147 -106
  7. package/cjs/dist/react/core/GiftCard.d.ts +0 -1
  8. package/cjs/dist/react/core/GiftCard.js +86 -64
  9. package/cjs/dist/react/index.d.ts +0 -1
  10. package/cjs/dist/react/index.js +37 -1
  11. package/cjs/dist/services/gift-card-checkout-service.d.ts +0 -1
  12. package/cjs/dist/services/gift-card-checkout-service.js +19 -16
  13. package/cjs/dist/services/gift-card-service.d.ts +0 -1
  14. package/cjs/dist/services/gift-card-service.js +19 -15
  15. package/cjs/dist/services/index.d.ts +0 -1
  16. package/cjs/dist/services/index.js +10 -2
  17. package/cjs/dist/utils/formatting-utils.d.ts +0 -1
  18. package/cjs/dist/utils/formatting-utils.js +8 -3
  19. package/cjs/dist/utils/gift-card-utils.d.ts +0 -1
  20. package/cjs/dist/utils/gift-card-utils.js +18 -11
  21. package/cjs/dist/utils/validation-utils.d.ts +0 -1
  22. package/cjs/dist/utils/validation-utils.js +6 -2
  23. package/cjs/package.json +3 -0
  24. package/dist/__mocks__/gift-card.d.ts +0 -1
  25. package/dist/enums/index.d.ts +0 -1
  26. package/dist/react/GiftCard.d.ts +0 -1
  27. package/dist/react/core/GiftCard.d.ts +0 -1
  28. package/dist/react/index.d.ts +0 -1
  29. package/dist/services/gift-card-checkout-service.d.ts +0 -1
  30. package/dist/services/gift-card-service.d.ts +0 -1
  31. package/dist/services/index.d.ts +0 -1
  32. package/dist/utils/formatting-utils.d.ts +0 -1
  33. package/dist/utils/gift-card-utils.d.ts +0 -1
  34. package/dist/utils/validation-utils.d.ts +0 -1
  35. package/package.json +4 -4
  36. package/cjs/dist/__mocks__/gift-card.d.ts.map +0 -1
  37. package/cjs/dist/enums/index.d.ts.map +0 -1
  38. package/cjs/dist/react/GiftCard.d.ts.map +0 -1
  39. package/cjs/dist/react/core/GiftCard.d.ts.map +0 -1
  40. package/cjs/dist/react/index.d.ts.map +0 -1
  41. package/cjs/dist/services/gift-card-checkout-service.d.ts.map +0 -1
  42. package/cjs/dist/services/gift-card-service.d.ts.map +0 -1
  43. package/cjs/dist/services/index.d.ts.map +0 -1
  44. package/cjs/dist/utils/formatting-utils.d.ts.map +0 -1
  45. package/cjs/dist/utils/gift-card-utils.d.ts.map +0 -1
  46. package/cjs/dist/utils/validation-utils.d.ts.map +0 -1
  47. package/dist/__mocks__/gift-card.d.ts.map +0 -1
  48. package/dist/enums/index.d.ts.map +0 -1
  49. package/dist/react/GiftCard.d.ts.map +0 -1
  50. package/dist/react/core/GiftCard.d.ts.map +0 -1
  51. package/dist/react/index.d.ts.map +0 -1
  52. package/dist/services/gift-card-checkout-service.d.ts.map +0 -1
  53. package/dist/services/gift-card-service.d.ts.map +0 -1
  54. package/dist/services/index.d.ts.map +0 -1
  55. package/dist/utils/formatting-utils.d.ts.map +0 -1
  56. package/dist/utils/gift-card-utils.d.ts.map +0 -1
  57. package/dist/utils/validation-utils.d.ts.map +0 -1
@@ -860,4 +860,3 @@ export interface ActionsProps {
860
860
  * ```
861
861
  */
862
862
  export declare function Actions(props: ActionsProps): import("react").ReactNode;
863
- //# sourceMappingURL=GiftCard.d.ts.map
@@ -1,10 +1,32 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useService, WixServices } from '@wix/services-manager-react';
3
- import { createServicesMap } from '@wix/services-manager';
4
- import { GiftCardServiceDefinition, GiftCardService, } from '../../services/gift-card-service.js';
5
- import { GiftCardCheckoutServiceDefinition, GiftCardCheckoutService, } from '../../services/gift-card-checkout-service.js';
6
- import { CUSTOM_VARIANT_ID } from '../../enums/index.js';
7
- import { getCurrencySymbol, formatDate, formatDateForInput, } from '../../utils/formatting-utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Root = Root;
4
+ exports.Name = Name;
5
+ exports.Loading = Loading;
6
+ exports.Error = Error;
7
+ exports.Raw = Raw;
8
+ exports.Image = Image;
9
+ exports.Description = Description;
10
+ exports.PresetVariants = PresetVariants;
11
+ exports.PresetVariantRepeater = PresetVariantRepeater;
12
+ exports.CurrentPrice = CurrentPrice;
13
+ exports.CustomVariantTrigger = CustomVariantTrigger;
14
+ exports.CustomAmountInput = CustomAmountInput;
15
+ exports.Quantity = Quantity;
16
+ exports.GiftToggle = GiftToggle;
17
+ exports.RecipientEmail = RecipientEmail;
18
+ exports.RecipientName = RecipientName;
19
+ exports.RecipientDate = RecipientDate;
20
+ exports.RecipientMessage = RecipientMessage;
21
+ exports.RecipientForm = RecipientForm;
22
+ exports.Actions = Actions;
23
+ const jsx_runtime_1 = require("react/jsx-runtime");
24
+ const services_manager_react_1 = require("@wix/services-manager-react");
25
+ const services_manager_1 = require("@wix/services-manager");
26
+ const gift_card_service_js_1 = require("../../services/gift-card-service.js");
27
+ const gift_card_checkout_service_js_1 = require("../../services/gift-card-checkout-service.js");
28
+ const index_js_1 = require("../../enums/index.js");
29
+ const formatting_utils_js_1 = require("../../utils/formatting-utils.js");
8
30
  /**
9
31
  * Root component that provides the GiftCard service context to its children.
10
32
  * Supports both SSR (with product in config) and client-side auto-fetch (empty config).
@@ -23,10 +45,10 @@ import { getCurrencySymbol, formatDate, formatDateForInput, } from '../../utils/
23
45
  * </GiftCard.Root>
24
46
  * ```
25
47
  */
26
- export function Root(props) {
27
- return (_jsx(WixServices, { servicesMap: createServicesMap()
28
- .addService(GiftCardServiceDefinition, GiftCardService, props.giftCardServiceConfig)
29
- .addService(GiftCardCheckoutServiceDefinition, GiftCardCheckoutService, {}), children: props.children }));
48
+ function Root(props) {
49
+ return ((0, jsx_runtime_1.jsx)(services_manager_react_1.WixServices, { servicesMap: (0, services_manager_1.createServicesMap)()
50
+ .addService(gift_card_service_js_1.GiftCardServiceDefinition, gift_card_service_js_1.GiftCardService, props.giftCardServiceConfig)
51
+ .addService(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition, gift_card_checkout_service_js_1.GiftCardCheckoutService, {}), children: props.children }));
30
52
  }
31
53
  /**
32
54
  * Headless component for displaying the gift card product name
@@ -41,8 +63,8 @@ export function Root(props) {
41
63
  * </GiftCard.Name>
42
64
  * ```
43
65
  */
44
- export function Name(props) {
45
- const service = useService(GiftCardServiceDefinition);
66
+ function Name(props) {
67
+ const service = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
46
68
  const product = service.product.get();
47
69
  const name = product?.name ?? '';
48
70
  return props.children({
@@ -60,8 +82,8 @@ export function Name(props) {
60
82
  * </GiftCard.Loading>
61
83
  * ```
62
84
  */
63
- export function Loading(props) {
64
- const service = useService(GiftCardServiceDefinition);
85
+ function Loading(props) {
86
+ const service = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
65
87
  const isLoading = service.isLoading.get();
66
88
  return props.children({
67
89
  isLoading,
@@ -78,8 +100,8 @@ export function Loading(props) {
78
100
  * </GiftCard.Error>
79
101
  * ```
80
102
  */
81
- export function Error(props) {
82
- const service = useService(GiftCardServiceDefinition);
103
+ function Error(props) {
104
+ const service = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
83
105
  const error = service.error.get();
84
106
  return props.children({
85
107
  error,
@@ -101,8 +123,8 @@ export function Error(props) {
101
123
  * </GiftCard.Raw>
102
124
  * ```
103
125
  */
104
- export function Raw(props) {
105
- const service = useService(GiftCardServiceDefinition);
126
+ function Raw(props) {
127
+ const service = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
106
128
  const isLoading = service.isLoading.get();
107
129
  const error = service.error.get();
108
130
  const giftCard = service.product.get();
@@ -131,8 +153,8 @@ export function Raw(props) {
131
153
  * </GiftCard.Image>
132
154
  * ```
133
155
  */
134
- export function Image(props) {
135
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
156
+ function Image(props) {
157
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
136
158
  const currentImage = checkoutService.currentImage.get();
137
159
  // Return null if no image available
138
160
  if (!currentImage) {
@@ -155,8 +177,8 @@ export function Image(props) {
155
177
  * </GiftCard.Description>
156
178
  * ```
157
179
  */
158
- export function Description(props) {
159
- const service = useService(GiftCardServiceDefinition);
180
+ function Description(props) {
181
+ const service = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
160
182
  const product = service.product.get();
161
183
  const description = product?.description ?? '';
162
184
  return props.children({
@@ -187,9 +209,9 @@ export function Description(props) {
187
209
  * </GiftCard.PresetVariants>
188
210
  * ```
189
211
  */
190
- export function PresetVariants(props) {
191
- const giftCardService = useService(GiftCardServiceDefinition);
192
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
212
+ function PresetVariants(props) {
213
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
214
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
193
215
  const product = giftCardService.product.get();
194
216
  const selectedId = checkoutService.selectedVariantId.get();
195
217
  const currencyCode = giftCardService.currencyCode.get();
@@ -232,9 +254,9 @@ export function PresetVariants(props) {
232
254
  * </GiftCard.PresetVariantRepeater>
233
255
  * ```
234
256
  */
235
- export function PresetVariantRepeater(props) {
236
- const giftCardService = useService(GiftCardServiceDefinition);
237
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
257
+ function PresetVariantRepeater(props) {
258
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
259
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
238
260
  const product = giftCardService.product.get();
239
261
  const selectedId = checkoutService.selectedVariantId.get();
240
262
  const currencyCode = giftCardService.currencyCode.get();
@@ -284,9 +306,9 @@ export function PresetVariantRepeater(props) {
284
306
  * </GiftCard.CurrentPrice>
285
307
  * ```
286
308
  */
287
- export function CurrentPrice(props) {
288
- const giftCardService = useService(GiftCardServiceDefinition);
289
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
309
+ function CurrentPrice(props) {
310
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
311
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
290
312
  const currentPriceData = checkoutService.currentPriceData.get();
291
313
  const currencyCode = giftCardService.currencyCode.get();
292
314
  const locale = giftCardService.locale.get();
@@ -322,9 +344,9 @@ export function CurrentPrice(props) {
322
344
  * </GiftCard.CustomVariantTrigger>
323
345
  * ```
324
346
  */
325
- export function CustomVariantTrigger(props) {
326
- const giftCardService = useService(GiftCardServiceDefinition);
327
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
347
+ function CustomVariantTrigger(props) {
348
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
349
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
328
350
  const product = giftCardService.product.get();
329
351
  const selectedVariantId = checkoutService.selectedVariantId.get();
330
352
  // Don't render if product doesn't have custom variant enabled
@@ -332,9 +354,9 @@ export function CustomVariantTrigger(props) {
332
354
  if (!hasCustomVariant) {
333
355
  return null;
334
356
  }
335
- const isSelected = selectedVariantId === CUSTOM_VARIANT_ID;
357
+ const isSelected = selectedVariantId === index_js_1.CUSTOM_VARIANT_ID;
336
358
  const onClick = () => {
337
- checkoutService.setVariant(CUSTOM_VARIANT_ID);
359
+ checkoutService.setVariant(index_js_1.CUSTOM_VARIANT_ID);
338
360
  };
339
361
  return props.children({
340
362
  isSelected,
@@ -378,17 +400,17 @@ export function CustomVariantTrigger(props) {
378
400
  * </GiftCard.CustomAmountInput>
379
401
  * ```
380
402
  */
381
- export function CustomAmountInput(props) {
382
- const giftCardService = useService(GiftCardServiceDefinition);
383
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
403
+ function CustomAmountInput(props) {
404
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
405
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
384
406
  const selectedVariantId = checkoutService.selectedVariantId.get();
385
407
  const customAmount = checkoutService.customAmount.get();
386
408
  const isCustomAmountValid = checkoutService.isCustomAmountValid.get();
387
409
  const customAmountData = checkoutService.customAmountData.get();
388
410
  const showErrors = checkoutService.showErrors.get();
389
411
  const currencyCode = giftCardService.currencyCode.get();
390
- const currencySymbol = getCurrencySymbol(currencyCode);
391
- const isVisible = selectedVariantId === CUSTOM_VARIANT_ID;
412
+ const currencySymbol = (0, formatting_utils_js_1.getCurrencySymbol)(currencyCode);
413
+ const isVisible = selectedVariantId === index_js_1.CUSTOM_VARIANT_ID;
392
414
  return props.children({
393
415
  value: customAmount,
394
416
  setValue: checkoutService.setCustomAmount,
@@ -419,8 +441,8 @@ export function CustomAmountInput(props) {
419
441
  * </GiftCard.Quantity>
420
442
  * ```
421
443
  */
422
- export function Quantity(props) {
423
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
444
+ function Quantity(props) {
445
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
424
446
  const quantity = checkoutService.quantity.get();
425
447
  return props.children({
426
448
  quantity,
@@ -455,8 +477,8 @@ export function Quantity(props) {
455
477
  * </GiftCard.GiftToggle>
456
478
  * ```
457
479
  */
458
- export function GiftToggle(props) {
459
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
480
+ function GiftToggle(props) {
481
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
460
482
  const isGift = checkoutService.isGift.get();
461
483
  return props.children({
462
484
  isGift,
@@ -492,8 +514,8 @@ export function GiftToggle(props) {
492
514
  * </GiftCard.RecipientEmail>
493
515
  * ```
494
516
  */
495
- export function RecipientEmail(props) {
496
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
517
+ function RecipientEmail(props) {
518
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
497
519
  const value = checkoutService.recipientEmail.get();
498
520
  const isValid = checkoutService.isRecipientEmailValid.get();
499
521
  const showError = checkoutService.showErrors.get();
@@ -530,8 +552,8 @@ export function RecipientEmail(props) {
530
552
  * </GiftCard.RecipientName>
531
553
  * ```
532
554
  */
533
- export function RecipientName(props) {
534
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
555
+ function RecipientName(props) {
556
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
535
557
  const value = checkoutService.recipientName.get();
536
558
  const isGift = checkoutService.isGift.get();
537
559
  return props.children({
@@ -565,16 +587,16 @@ export function RecipientName(props) {
565
587
  * </GiftCard.RecipientDate>
566
588
  * ```
567
589
  */
568
- export function RecipientDate(props) {
569
- const giftCardService = useService(GiftCardServiceDefinition);
570
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
590
+ function RecipientDate(props) {
591
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
592
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
571
593
  const value = checkoutService.deliverAt.get();
572
594
  const isGift = checkoutService.isGift.get();
573
595
  const locale = giftCardService.locale.get();
574
596
  return props.children({
575
597
  value,
576
- formattedValue: formatDate(value, locale),
577
- inputValue: formatDateForInput(value),
598
+ formattedValue: (0, formatting_utils_js_1.formatDate)(value, locale),
599
+ inputValue: (0, formatting_utils_js_1.formatDateForInput)(value),
578
600
  setValue: checkoutService.setDeliverAt,
579
601
  isVisible: isGift,
580
602
  });
@@ -603,8 +625,8 @@ export function RecipientDate(props) {
603
625
  * </GiftCard.RecipientMessage>
604
626
  * ```
605
627
  */
606
- export function RecipientMessage(props) {
607
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
628
+ function RecipientMessage(props) {
629
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
608
630
  const value = checkoutService.recipientMessage.get();
609
631
  const isGift = checkoutService.isGift.get();
610
632
  return props.children({
@@ -668,9 +690,9 @@ export function RecipientMessage(props) {
668
690
  * </GiftCard.RecipientForm>
669
691
  * ```
670
692
  */
671
- export function RecipientForm(props) {
672
- const giftCardService = useService(GiftCardServiceDefinition);
673
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
693
+ function RecipientForm(props) {
694
+ const giftCardService = (0, services_manager_react_1.useService)(gift_card_service_js_1.GiftCardServiceDefinition);
695
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
674
696
  const isGift = checkoutService.isGift.get();
675
697
  const showErrors = checkoutService.showErrors.get();
676
698
  const locale = giftCardService.locale.get();
@@ -697,8 +719,8 @@ export function RecipientForm(props) {
697
719
  },
698
720
  deliverAt: {
699
721
  value: dateValue,
700
- formattedValue: formatDate(dateValue, locale),
701
- inputValue: formatDateForInput(dateValue),
722
+ formattedValue: (0, formatting_utils_js_1.formatDate)(dateValue, locale),
723
+ inputValue: (0, formatting_utils_js_1.formatDateForInput)(dateValue),
702
724
  setValue: checkoutService.setDeliverAt,
703
725
  },
704
726
  message: {
@@ -728,8 +750,8 @@ export function RecipientForm(props) {
728
750
  * </CoreGiftCard.Actions>
729
751
  * ```
730
752
  */
731
- export function Actions(props) {
732
- const checkoutService = useService(GiftCardCheckoutServiceDefinition);
753
+ function Actions(props) {
754
+ const checkoutService = (0, services_manager_react_1.useService)(gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition);
733
755
  return props.children({
734
756
  lineItems: checkoutService.lineItems.get(),
735
757
  validateAndShowErrors: checkoutService.validateAndShowErrors,
@@ -1,2 +1 @@
1
1
  export * as GiftCard from './GiftCard.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +1,37 @@
1
- export * as GiftCard from './GiftCard.js';
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GiftCard = void 0;
37
+ exports.GiftCard = __importStar(require("./GiftCard.js"));
@@ -130,4 +130,3 @@ export declare const GiftCardCheckoutService: import("@wix/services-definitions"
130
130
  __config: {};
131
131
  isServiceDefinition?: boolean;
132
132
  } & GiftCardCheckoutServiceAPI, GiftCardCheckoutServiceConfig>;
133
- //# sourceMappingURL=gift-card-checkout-service.d.ts.map
@@ -1,12 +1,15 @@
1
- import { defineService, implementService } from '@wix/services-definitions';
2
- import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
3
- import { GiftCardServiceDefinition } from './gift-card-service.js';
4
- import { getCurrentImage, getCurrentPriceData, getCustomAmountData, canAddToCartCheck, productToLineItems, } from '../utils/gift-card-utils.js';
5
- import { validateCustomAmount, validateEmail, } from '../utils/validation-utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GiftCardCheckoutService = exports.GiftCardCheckoutServiceDefinition = void 0;
4
+ const services_definitions_1 = require("@wix/services-definitions");
5
+ const signals_1 = require("@wix/services-definitions/core-services/signals");
6
+ const gift_card_service_js_1 = require("./gift-card-service.js");
7
+ const gift_card_utils_js_1 = require("../utils/gift-card-utils.js");
8
+ const validation_utils_js_1 = require("../utils/validation-utils.js");
6
9
  /**
7
10
  * Service definition for the GiftCardCheckout service.
8
11
  */
9
- export const GiftCardCheckoutServiceDefinition = defineService('gift-card-checkout');
12
+ exports.GiftCardCheckoutServiceDefinition = (0, services_definitions_1.defineService)('gift-card-checkout');
10
13
  /**
11
14
  * Implementation of the GiftCardCheckout service.
12
15
  * Manages variant selection and provides computed values based on selection.
@@ -14,9 +17,9 @@ export const GiftCardCheckoutServiceDefinition = defineService('gift-card-checko
14
17
  * Dependencies:
15
18
  * - GiftCardServiceDefinition: to get product data
16
19
  */
17
- export const GiftCardCheckoutService = implementService.withConfig()(GiftCardCheckoutServiceDefinition, ({ getService }) => {
18
- const signalsService = getService(SignalsServiceDefinition);
19
- const giftCardService = getService(GiftCardServiceDefinition);
20
+ exports.GiftCardCheckoutService = services_definitions_1.implementService.withConfig()(exports.GiftCardCheckoutServiceDefinition, ({ getService }) => {
21
+ const signalsService = getService(signals_1.SignalsServiceDefinition);
22
+ const giftCardService = getService(gift_card_service_js_1.GiftCardServiceDefinition);
20
23
  const getInitialVariantId = () => {
21
24
  const product = giftCardService.product.get();
22
25
  const firstVariant = product?.presetVariants?.[0];
@@ -34,26 +37,26 @@ export const GiftCardCheckoutService = implementService.withConfig()(GiftCardChe
34
37
  const currentImage = signalsService.computed(() => {
35
38
  const product = giftCardService.product.get();
36
39
  const variantId = selectedVariantId.get();
37
- return getCurrentImage(product, variantId);
40
+ return (0, gift_card_utils_js_1.getCurrentImage)(product, variantId);
38
41
  });
39
42
  const currentPriceData = signalsService.computed(() => {
40
43
  const product = giftCardService.product.get();
41
44
  const variantId = selectedVariantId.get();
42
45
  const customAmountValue = customAmount.get();
43
- return getCurrentPriceData(product, variantId, customAmountValue);
46
+ return (0, gift_card_utils_js_1.getCurrentPriceData)(product, variantId, customAmountValue);
44
47
  });
45
48
  const customAmountData = signalsService.computed(() => {
46
49
  const product = giftCardService.product.get();
47
- return getCustomAmountData(product);
50
+ return (0, gift_card_utils_js_1.getCustomAmountData)(product);
48
51
  });
49
52
  const isCustomAmountValid = signalsService.computed(() => {
50
53
  const amount = customAmount.get();
51
54
  const data = customAmountData.get();
52
- return validateCustomAmount(amount, data);
55
+ return (0, validation_utils_js_1.validateCustomAmount)(amount, data);
53
56
  });
54
57
  const isRecipientEmailValid = signalsService.computed(() => {
55
58
  const email = recipientEmail.get();
56
- return validateEmail(email);
59
+ return (0, validation_utils_js_1.validateEmail)(email);
57
60
  });
58
61
  const canAddToCart = signalsService.computed(() => {
59
62
  const product = giftCardService.product.get();
@@ -61,7 +64,7 @@ export const GiftCardCheckoutService = implementService.withConfig()(GiftCardChe
61
64
  const isGiftPurchase = isGift.get();
62
65
  const isCustomAmountValidCheck = isCustomAmountValid.get();
63
66
  const isRecipientEmailValidCheck = isRecipientEmailValid.get();
64
- return canAddToCartCheck(product, variantId, isGiftPurchase, isCustomAmountValidCheck, isRecipientEmailValidCheck);
67
+ return (0, gift_card_utils_js_1.canAddToCartCheck)(product, variantId, isGiftPurchase, isCustomAmountValidCheck, isRecipientEmailValidCheck);
65
68
  });
66
69
  const lineItems = signalsService.computed(() => {
67
70
  const product = giftCardService.product.get();
@@ -74,7 +77,7 @@ export const GiftCardCheckoutService = implementService.withConfig()(GiftCardChe
74
77
  const recipientNameValue = recipientName.get();
75
78
  const deliverAtValue = deliverAt.get();
76
79
  const recipientMessageValue = recipientMessage.get();
77
- return productToLineItems(product, currency, variantId, customAmountValue, qty, isGiftPurchase, recipientEmailValue, recipientNameValue, deliverAtValue, recipientMessageValue);
80
+ return (0, gift_card_utils_js_1.productToLineItems)(product, currency, variantId, customAmountValue, qty, isGiftPurchase, recipientEmailValue, recipientNameValue, deliverAtValue, recipientMessageValue);
78
81
  });
79
82
  const validateAndShowErrors = () => {
80
83
  setShowErrors(true);
@@ -99,4 +99,3 @@ export interface LoadGiftCardServiceConfigOptions {
99
99
  * ```
100
100
  */
101
101
  export declare function loadGiftCardServiceConfig(options?: LoadGiftCardServiceConfigOptions): Promise<SuccessGiftCardServiceConfigResult | NotFoundGiftCardServiceConfigResult>;
102
- //# sourceMappingURL=gift-card-service.d.ts.map
@@ -1,18 +1,22 @@
1
- import { i18n } from '@wix/essentials';
2
- import { giftVoucherProducts } from '@wix/gift-vouchers';
3
- import { defineService, implementService } from '@wix/services-definitions';
4
- import { ecommerceSettings } from '@wix/ecom';
5
- import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
6
- import { DEFAULT_CURRENCY_CODE, DEFAULT_LOCALE } from '../enums/index.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GiftCardService = exports.GiftCardServiceDefinition = void 0;
4
+ exports.loadGiftCardServiceConfig = loadGiftCardServiceConfig;
5
+ const essentials_1 = require("@wix/essentials");
6
+ const gift_vouchers_1 = require("@wix/gift-vouchers");
7
+ const services_definitions_1 = require("@wix/services-definitions");
8
+ const ecom_1 = require("@wix/ecom");
9
+ const signals_1 = require("@wix/services-definitions/core-services/signals");
10
+ const index_js_1 = require("../enums/index.js");
7
11
  /**
8
12
  * Service definition for the GiftCard service.
9
13
  */
10
- export const GiftCardServiceDefinition = defineService('gift-card');
14
+ exports.GiftCardServiceDefinition = (0, services_definitions_1.defineService)('gift-card');
11
15
  /**
12
16
  * Internal helper function to load the gift card product from the Wix API.
13
17
  */
14
18
  const loadGiftCardProduct = async () => {
15
- const result = await giftVoucherProducts.queryGiftCardProducts().find();
19
+ const result = await gift_vouchers_1.giftVoucherProducts.queryGiftCardProducts().find();
16
20
  return result?.items?.[0];
17
21
  };
18
22
  /**
@@ -37,7 +41,7 @@ const loadGiftCardProduct = async () => {
37
41
  * @returns Promise that resolves to the site currency code (e.g., "USD", "EUR")
38
42
  */
39
43
  const loadSiteCurrency = async () => {
40
- const settings = await ecommerceSettings.getEcommerceSettings([
44
+ const settings = await ecom_1.ecommerceSettings.getEcommerceSettings([
41
45
  'BUSINESS_INFO',
42
46
  ]);
43
47
  return settings.ecommerceSettings?.businessInfo?.currency;
@@ -48,15 +52,15 @@ const loadSiteCurrency = async () => {
48
52
  */
49
53
  const loadLocale = () => {
50
54
  try {
51
- return i18n.getLocale() ?? DEFAULT_LOCALE;
55
+ return essentials_1.i18n.getLocale() ?? index_js_1.DEFAULT_LOCALE;
52
56
  }
53
57
  catch (e) {
54
58
  console.warn('Failed to get locale, using default:', e);
55
- return DEFAULT_LOCALE;
59
+ return index_js_1.DEFAULT_LOCALE;
56
60
  }
57
61
  };
58
- export const GiftCardService = implementService.withConfig()(GiftCardServiceDefinition, ({ getService, config }) => {
59
- const signalsService = getService(SignalsServiceDefinition);
62
+ exports.GiftCardService = services_definitions_1.implementService.withConfig()(exports.GiftCardServiceDefinition, ({ getService, config }) => {
63
+ const signalsService = getService(signals_1.SignalsServiceDefinition);
60
64
  const product = signalsService.signal(config.product);
61
65
  const currencyCode = signalsService.signal(config.currencyCode ?? '');
62
66
  const locale = signalsService.signal(loadLocale());
@@ -71,7 +75,7 @@ export const GiftCardService = implementService.withConfig()(GiftCardServiceDefi
71
75
  }
72
76
  catch (e) {
73
77
  console.warn('Failed to load currency, using default:', e);
74
- currencyCode.set(DEFAULT_CURRENCY_CODE);
78
+ currencyCode.set(index_js_1.DEFAULT_CURRENCY_CODE);
75
79
  }
76
80
  isLoading.set(false);
77
81
  };
@@ -139,7 +143,7 @@ export const GiftCardService = implementService.withConfig()(GiftCardServiceDefi
139
143
  * </GiftCard.Root>
140
144
  * ```
141
145
  */
142
- export async function loadGiftCardServiceConfig(options) {
146
+ async function loadGiftCardServiceConfig(options) {
143
147
  try {
144
148
  // Load product and optionally currency in parallel
145
149
  // Currency is fetched from site settings only if not provided in options
@@ -1,3 +1,2 @@
1
1
  export { GiftCardService, GiftCardServiceDefinition, type GiftCardServiceConfig, type GiftCardServiceAPI, type GiftCardProduct, loadGiftCardServiceConfig, type LoadGiftCardServiceConfigOptions, } from './gift-card-service.js';
2
2
  export { GiftCardCheckoutService, GiftCardCheckoutServiceDefinition, type GiftCardCheckoutServiceConfig, type GiftCardCheckoutServiceAPI, type CurrentPriceData, type MultiCurrencyPrice, type CustomAmountData, type LineItem, type GiftCardCatalogOptions, } from './gift-card-checkout-service.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,10 @@
1
- export { GiftCardService, GiftCardServiceDefinition, loadGiftCardServiceConfig, } from './gift-card-service.js';
2
- export { GiftCardCheckoutService, GiftCardCheckoutServiceDefinition, } from './gift-card-checkout-service.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GiftCardCheckoutServiceDefinition = exports.GiftCardCheckoutService = exports.loadGiftCardServiceConfig = exports.GiftCardServiceDefinition = exports.GiftCardService = void 0;
4
+ var gift_card_service_js_1 = require("./gift-card-service.js");
5
+ Object.defineProperty(exports, "GiftCardService", { enumerable: true, get: function () { return gift_card_service_js_1.GiftCardService; } });
6
+ Object.defineProperty(exports, "GiftCardServiceDefinition", { enumerable: true, get: function () { return gift_card_service_js_1.GiftCardServiceDefinition; } });
7
+ Object.defineProperty(exports, "loadGiftCardServiceConfig", { enumerable: true, get: function () { return gift_card_service_js_1.loadGiftCardServiceConfig; } });
8
+ var gift_card_checkout_service_js_1 = require("./gift-card-checkout-service.js");
9
+ Object.defineProperty(exports, "GiftCardCheckoutService", { enumerable: true, get: function () { return gift_card_checkout_service_js_1.GiftCardCheckoutService; } });
10
+ Object.defineProperty(exports, "GiftCardCheckoutServiceDefinition", { enumerable: true, get: function () { return gift_card_checkout_service_js_1.GiftCardCheckoutServiceDefinition; } });
@@ -10,4 +10,3 @@ export declare function formatDate(date: Date, locale: string): string;
10
10
  * Formats a date for HTML date input (YYYY-MM-DD).
11
11
  */
12
12
  export declare function formatDateForInput(date: Date): string;
13
- //# sourceMappingURL=formatting-utils.d.ts.map
@@ -1,7 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrencySymbol = getCurrencySymbol;
4
+ exports.formatDate = formatDate;
5
+ exports.formatDateForInput = formatDateForInput;
1
6
  /**
2
7
  * Get currency symbol from currency code using Intl.NumberFormat
3
8
  */
4
- export function getCurrencySymbol(currencyCode) {
9
+ function getCurrencySymbol(currencyCode) {
5
10
  try {
6
11
  // the locale does not matter for the narrowSymbol
7
12
  const formatter = new Intl.NumberFormat('en', {
@@ -20,7 +25,7 @@ export function getCurrencySymbol(currencyCode) {
20
25
  /**
21
26
  * Formats a date according to the given locale.
22
27
  */
23
- export function formatDate(date, locale) {
28
+ function formatDate(date, locale) {
24
29
  return date.toLocaleDateString(locale, {
25
30
  year: 'numeric',
26
31
  month: 'short',
@@ -30,7 +35,7 @@ export function formatDate(date, locale) {
30
35
  /**
31
36
  * Formats a date for HTML date input (YYYY-MM-DD).
32
37
  */
33
- export function formatDateForInput(date) {
38
+ function formatDateForInput(date) {
34
39
  const year = date.getFullYear();
35
40
  const month = String(date.getMonth() + 1).padStart(2, '0');
36
41
  const day = String(date.getDate()).padStart(2, '0');
@@ -15,4 +15,3 @@ export declare function canAddToCartCheck(product: GiftCardProduct | undefined,
15
15
  * Converts the product data to line items for the cart API.
16
16
  */
17
17
  export declare function productToLineItems(product: GiftCardProduct | undefined, currency: string, variantId: string | null, customAmount: number, qty: number, isGiftPurchase: boolean, recipientEmail: string, recipientName: string, deliverAt: Date, recipientMessage: string): LineItem[];
18
- //# sourceMappingURL=gift-card-utils.d.ts.map