@wix/headless-gift-voucher 0.0.1

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 (69) hide show
  1. package/cjs/dist/__mocks__/gift-card.d.ts +14 -0
  2. package/cjs/dist/__mocks__/gift-card.d.ts.map +1 -0
  3. package/cjs/dist/__mocks__/gift-card.js +49 -0
  4. package/cjs/dist/enums/index.d.ts +52 -0
  5. package/cjs/dist/enums/index.d.ts.map +1 -0
  6. package/cjs/dist/enums/index.js +52 -0
  7. package/cjs/dist/react/GiftCard.d.ts +1318 -0
  8. package/cjs/dist/react/GiftCard.d.ts.map +1 -0
  9. package/cjs/dist/react/GiftCard.js +1126 -0
  10. package/cjs/dist/react/core/GiftCard.d.ts +863 -0
  11. package/cjs/dist/react/core/GiftCard.d.ts.map +1 -0
  12. package/cjs/dist/react/core/GiftCard.js +737 -0
  13. package/cjs/dist/react/index.d.ts +2 -0
  14. package/cjs/dist/react/index.d.ts.map +1 -0
  15. package/cjs/dist/react/index.js +1 -0
  16. package/cjs/dist/services/gift-card-checkout-service.d.ts +133 -0
  17. package/cjs/dist/services/gift-card-checkout-service.d.ts.map +1 -0
  18. package/cjs/dist/services/gift-card-checkout-service.js +159 -0
  19. package/cjs/dist/services/gift-card-service.d.ts +102 -0
  20. package/cjs/dist/services/gift-card-service.d.ts.map +1 -0
  21. package/cjs/dist/services/gift-card-service.js +165 -0
  22. package/cjs/dist/services/index.d.ts +3 -0
  23. package/cjs/dist/services/index.d.ts.map +1 -0
  24. package/cjs/dist/services/index.js +2 -0
  25. package/cjs/dist/utils/formatting-utils.d.ts +13 -0
  26. package/cjs/dist/utils/formatting-utils.d.ts.map +1 -0
  27. package/cjs/dist/utils/formatting-utils.js +38 -0
  28. package/cjs/dist/utils/gift-card-utils.d.ts +18 -0
  29. package/cjs/dist/utils/gift-card-utils.d.ts.map +1 -0
  30. package/cjs/dist/utils/gift-card-utils.js +118 -0
  31. package/cjs/dist/utils/validation-utils.d.ts +10 -0
  32. package/cjs/dist/utils/validation-utils.d.ts.map +1 -0
  33. package/cjs/dist/utils/validation-utils.js +24 -0
  34. package/dist/__mocks__/gift-card.d.ts +14 -0
  35. package/dist/__mocks__/gift-card.d.ts.map +1 -0
  36. package/dist/__mocks__/gift-card.js +49 -0
  37. package/dist/enums/index.d.ts +52 -0
  38. package/dist/enums/index.d.ts.map +1 -0
  39. package/dist/enums/index.js +52 -0
  40. package/dist/react/GiftCard.d.ts +1318 -0
  41. package/dist/react/GiftCard.d.ts.map +1 -0
  42. package/dist/react/GiftCard.js +1126 -0
  43. package/dist/react/core/GiftCard.d.ts +863 -0
  44. package/dist/react/core/GiftCard.d.ts.map +1 -0
  45. package/dist/react/core/GiftCard.js +737 -0
  46. package/dist/react/index.d.ts +2 -0
  47. package/dist/react/index.d.ts.map +1 -0
  48. package/dist/react/index.js +1 -0
  49. package/dist/services/gift-card-checkout-service.d.ts +133 -0
  50. package/dist/services/gift-card-checkout-service.d.ts.map +1 -0
  51. package/dist/services/gift-card-checkout-service.js +159 -0
  52. package/dist/services/gift-card-service.d.ts +102 -0
  53. package/dist/services/gift-card-service.d.ts.map +1 -0
  54. package/dist/services/gift-card-service.js +165 -0
  55. package/dist/services/index.d.ts +3 -0
  56. package/dist/services/index.d.ts.map +1 -0
  57. package/dist/services/index.js +2 -0
  58. package/dist/utils/formatting-utils.d.ts +13 -0
  59. package/dist/utils/formatting-utils.d.ts.map +1 -0
  60. package/dist/utils/formatting-utils.js +38 -0
  61. package/dist/utils/gift-card-utils.d.ts +18 -0
  62. package/dist/utils/gift-card-utils.d.ts.map +1 -0
  63. package/dist/utils/gift-card-utils.js +118 -0
  64. package/dist/utils/validation-utils.d.ts +10 -0
  65. package/dist/utils/validation-utils.d.ts.map +1 -0
  66. package/dist/utils/validation-utils.js +24 -0
  67. package/package.json +72 -0
  68. package/react/package.json +4 -0
  69. package/services/package.json +4 -0
@@ -0,0 +1,863 @@
1
+ import { GiftCardServiceConfig, GiftCardProduct } from '../../services/gift-card-service.js';
2
+ import { type LineItem } from '../../services/gift-card-checkout-service.js';
3
+ export interface RootProps {
4
+ children: React.ReactNode;
5
+ giftCardServiceConfig: GiftCardServiceConfig;
6
+ }
7
+ /**
8
+ * Root component that provides the GiftCard service context to its children.
9
+ * Supports both SSR (with product in config) and client-side auto-fetch (empty config).
10
+ *
11
+ * @component
12
+ * @example
13
+ * ```tsx
14
+ * // With SSR config
15
+ * <GiftCard.Root giftCardServiceConfig={{ product: myProduct }}>
16
+ * <GiftCard.Name />
17
+ * </GiftCard.Root>
18
+ *
19
+ * // Without config (auto-fetch)
20
+ * <GiftCard.Root giftCardServiceConfig={{}}>
21
+ * <GiftCard.Name />
22
+ * </GiftCard.Root>
23
+ * ```
24
+ */
25
+ export declare function Root(props: RootProps): React.ReactNode;
26
+ /**
27
+ * Props for GiftCardName headless component
28
+ */
29
+ export interface GiftCardNameProps {
30
+ /** Render prop function that receives the gift card name */
31
+ children: (props: GiftCardNameRenderProps) => React.ReactNode;
32
+ }
33
+ /**
34
+ * Render props for GiftCardName component
35
+ */
36
+ export interface GiftCardNameRenderProps {
37
+ /** Gift card product name */
38
+ name: string;
39
+ }
40
+ /**
41
+ * Headless component for displaying the gift card product name
42
+ *
43
+ * @component
44
+ * @example
45
+ * ```tsx
46
+ * <GiftCard.Name>
47
+ * {({ name }) => (
48
+ * <h1>{name}</h1>
49
+ * )}
50
+ * </GiftCard.Name>
51
+ * ```
52
+ */
53
+ export declare function Name(props: GiftCardNameProps): import("react").ReactNode;
54
+ /**
55
+ * Props for GiftCardLoading headless component
56
+ */
57
+ export interface GiftCardLoadingProps {
58
+ /** Render prop function that receives loading state */
59
+ children: (props: GiftCardLoadingRenderProps) => React.ReactNode;
60
+ }
61
+ /**
62
+ * Render props for GiftCardLoading component
63
+ */
64
+ export interface GiftCardLoadingRenderProps {
65
+ /** Whether the gift card is currently loading */
66
+ isLoading: boolean;
67
+ }
68
+ /**
69
+ * Headless component for handling loading state
70
+ *
71
+ * @component
72
+ * @example
73
+ * ```tsx
74
+ * <GiftCard.Loading>
75
+ * {({ isLoading }) => isLoading ? <Spinner /> : null}
76
+ * </GiftCard.Loading>
77
+ * ```
78
+ */
79
+ export declare function Loading(props: GiftCardLoadingProps): import("react").ReactNode;
80
+ /**
81
+ * Props for GiftCardError headless component
82
+ */
83
+ export interface GiftCardErrorProps {
84
+ /** Render prop function that receives error state */
85
+ children: (props: GiftCardErrorRenderProps) => React.ReactNode;
86
+ }
87
+ /**
88
+ * Render props for GiftCardError component
89
+ */
90
+ export interface GiftCardErrorRenderProps {
91
+ /** Error message, or null if no error */
92
+ error: string | null;
93
+ }
94
+ /**
95
+ * Headless component for handling error state
96
+ *
97
+ * @component
98
+ * @example
99
+ * ```tsx
100
+ * <GiftCard.Error>
101
+ * {({ error }) => error ? <div className="error">{error}</div> : null}
102
+ * </GiftCard.Error>
103
+ * ```
104
+ */
105
+ export declare function Error(props: GiftCardErrorProps): import("react").ReactNode;
106
+ /**
107
+ * Data exposed by the Raw component via render props
108
+ */
109
+ export interface GiftCardRawData {
110
+ /** The gift card product data, or null if not loaded */
111
+ giftCard: GiftCardProduct | null;
112
+ /** Whether the gift card is currently loading */
113
+ isLoading: boolean;
114
+ /** Error message if loading failed, or null */
115
+ error: string | null;
116
+ }
117
+ /**
118
+ * Props for GiftCardRaw headless component
119
+ */
120
+ export interface GiftCardRawProps {
121
+ /** Render prop function that receives the gift card state */
122
+ children: (props: GiftCardRawData) => React.ReactNode;
123
+ }
124
+ /**
125
+ * Headless component that exposes the gift card data via render props.
126
+ * Provides access to the gift card product, loading state, and error state.
127
+ *
128
+ * @component
129
+ * @example
130
+ * ```tsx
131
+ * <GiftCard.Raw>
132
+ * {({ giftCard, isLoading, error }) => {
133
+ * if (isLoading) return <div>Loading...</div>;
134
+ * if (error) return <div>Error: {error}</div>;
135
+ * return <div>{giftCard.name}</div>;
136
+ * }}
137
+ * </GiftCard.Raw>
138
+ * ```
139
+ */
140
+ export declare function Raw(props: GiftCardRawProps): import("react").ReactNode;
141
+ /**
142
+ * Render props for GiftCardImage component
143
+ */
144
+ export interface GiftCardImageRenderProps {
145
+ /** Gift card image URL (Wix media ID string) - changes based on selected variant */
146
+ image: string;
147
+ }
148
+ /**
149
+ * Props for GiftCardImage headless component
150
+ */
151
+ export interface GiftCardImageProps {
152
+ /** Render prop function that receives the gift card image */
153
+ children: (props: GiftCardImageRenderProps) => React.ReactNode;
154
+ }
155
+ /**
156
+ * Headless component for displaying the gift card image.
157
+ * The image automatically updates when selecting a variant that has its own image defined.
158
+ * Returns null if no image is available.
159
+ *
160
+ * Behavior:
161
+ * - Shows the selected preset variant's image if one is defined
162
+ * - Falls back to the default product image otherwise (including when custom amount is selected)
163
+ *
164
+ * @component
165
+ * @example
166
+ * ```tsx
167
+ * <GiftCard.Image>
168
+ * {({ image }) => (
169
+ * <img src={image} alt="Gift Card" />
170
+ * )}
171
+ * </GiftCard.Image>
172
+ * ```
173
+ */
174
+ export declare function Image(props: GiftCardImageProps): import("react").ReactNode;
175
+ /**
176
+ * Render props for GiftCardDescription component
177
+ */
178
+ export interface GiftCardDescriptionRenderProps {
179
+ /** Gift card product description */
180
+ description: string;
181
+ }
182
+ /**
183
+ * Props for GiftCardDescription headless component
184
+ */
185
+ export interface GiftCardDescriptionProps {
186
+ /** Render prop function that receives the gift card description */
187
+ children: (props: GiftCardDescriptionRenderProps) => React.ReactNode;
188
+ }
189
+ /**
190
+ * Headless component for displaying the gift card product description.
191
+ *
192
+ * @component
193
+ * @example
194
+ * ```tsx
195
+ * <GiftCard.Description>
196
+ * {({ description }) => (
197
+ * <p>{description}</p>
198
+ * )}
199
+ * </GiftCard.Description>
200
+ * ```
201
+ */
202
+ export declare function Description(props: GiftCardDescriptionProps): import("react").ReactNode;
203
+ /**
204
+ * Individual preset variant item data for the repeater context.
205
+ * Contains all data needed to render and interact with a single preset variant.
206
+ */
207
+ export interface PresetVariantItemData {
208
+ /** Preset variant ID */
209
+ id: string;
210
+ /** Price amount as number (what the customer pays) */
211
+ price: number;
212
+ /** Original value as number (what the gift card is worth) */
213
+ value: number;
214
+ /** Whether this variant has a discount (price < value) */
215
+ hasDiscount: boolean;
216
+ /** Whether this variant has a custom image */
217
+ hasImage: boolean;
218
+ /** Whether this variant is currently selected */
219
+ isSelected: boolean;
220
+ /** Function to select this variant */
221
+ select: () => void;
222
+ /** Currency code from service config (e.g., "ILS", "USD") */
223
+ currencyCode: string;
224
+ /** Locale code from service config (e.g., "en-US", "he-IL") */
225
+ locale: string;
226
+ }
227
+ /**
228
+ * Render props for PresetVariants component
229
+ */
230
+ export interface PresetVariantsRenderProps {
231
+ /** Array of preset variants with computed data */
232
+ presetVariants: PresetVariantItemData[];
233
+ }
234
+ /**
235
+ * Props for PresetVariants headless component
236
+ */
237
+ export interface PresetVariantsProps {
238
+ /** Render prop function that receives preset variants data */
239
+ children: (props: PresetVariantsRenderProps) => React.ReactNode;
240
+ }
241
+ /**
242
+ * Headless component that provides the list of preset variants.
243
+ * Use this as a container to check for empty state before rendering the repeater.
244
+ *
245
+ * @component
246
+ * @example
247
+ * ```tsx
248
+ * <GiftCard.PresetVariants>
249
+ * {({ presetVariants }) => (
250
+ * presetVariants.length > 0 ? (
251
+ * <div className="flex gap-2">
252
+ * {presetVariants.map(variant => (
253
+ * <button key={variant.id} onClick={variant.select}>
254
+ * <Money money={{ amount: variant.value, currency: variant.currencyCode }} />
255
+ * </button>
256
+ * ))}
257
+ * </div>
258
+ * ) : (
259
+ * <div>No variants available</div>
260
+ * )
261
+ * )}
262
+ * </GiftCard.PresetVariants>
263
+ * ```
264
+ */
265
+ export declare function PresetVariants(props: PresetVariantsProps): import("react").ReactNode;
266
+ /**
267
+ * Render props for PresetVariantRepeater component
268
+ */
269
+ export interface PresetVariantRepeaterRenderProps {
270
+ /** Array of preset variants to iterate over */
271
+ presetVariants: PresetVariantItemData[];
272
+ }
273
+ /**
274
+ * Props for PresetVariantRepeater headless component
275
+ */
276
+ export interface PresetVariantRepeaterProps {
277
+ /** Render prop function that receives preset variants array for iteration */
278
+ children: (props: PresetVariantRepeaterRenderProps) => React.ReactNode;
279
+ }
280
+ /**
281
+ * Headless component that provides preset variants for iteration.
282
+ * Used by the UI layer to create PresetVariant.Root contexts for each variant.
283
+ *
284
+ * @component
285
+ * @example
286
+ * ```tsx
287
+ * <GiftCard.PresetVariantRepeater>
288
+ * {({ presetVariants }) =>
289
+ * presetVariants.map(variant => (
290
+ * <PresetVariant.Root key={variant.id} variant={variant}>
291
+ * <PresetVariant.Amount />
292
+ * </PresetVariant.Root>
293
+ * ))
294
+ * }
295
+ * </GiftCard.PresetVariantRepeater>
296
+ * ```
297
+ */
298
+ export declare function PresetVariantRepeater(props: PresetVariantRepeaterProps): import("react").ReactNode;
299
+ /**
300
+ * Render props for GiftCardCurrentPrice component.
301
+ * Contains raw numeric amounts - use Money component for formatting.
302
+ */
303
+ export interface GiftCardCurrentPriceRenderProps {
304
+ /** Price amount as number (what the customer pays) */
305
+ price: number;
306
+ /** Original value as number (what the gift card is worth) */
307
+ value: number;
308
+ /** Whether current selection has a discount (price < value) */
309
+ hasDiscount: boolean;
310
+ /** Currency code from service config (e.g., "ILS", "USD") */
311
+ currencyCode: string;
312
+ /** Locale code from service config (e.g., "en-US", "he-IL") */
313
+ locale: string;
314
+ }
315
+ /**
316
+ * Props for GiftCardCurrentPrice headless component
317
+ */
318
+ export interface GiftCardCurrentPriceProps {
319
+ /** Render prop function that receives the current price data */
320
+ children: (props: GiftCardCurrentPriceRenderProps) => React.ReactNode;
321
+ }
322
+ /**
323
+ * Headless component for displaying the current gift card price based on selected variant.
324
+ * The price automatically updates when the variant selection changes.
325
+ * Use the Money component for formatting the price and value amounts.
326
+ *
327
+ * Price vs Value:
328
+ * - `price` - What the customer pays (raw number)
329
+ * - `value` - What the gift card is worth (raw number)
330
+ * - `hasDiscount` - `true` when `price < value`, indicating a discounted variant
331
+ *
332
+ * @component
333
+ * @example
334
+ * ```tsx
335
+ * <GiftCard.CurrentPrice>
336
+ * {({ price, value, hasDiscount, currencyCode }) => (
337
+ * <div className="flex items-baseline gap-3">
338
+ * {hasDiscount && (
339
+ * <Money money={{ amount: value, currency: currencyCode }} className="line-through text-muted" />
340
+ * )}
341
+ * <Money money={{ amount: price, currency: currencyCode }} className="text-4xl font-bold" />
342
+ * </div>
343
+ * )}
344
+ * </GiftCard.CurrentPrice>
345
+ * ```
346
+ */
347
+ export declare function CurrentPrice(props: GiftCardCurrentPriceProps): import("react").ReactNode;
348
+ /**
349
+ * Render props for GiftCardCustomVariantTrigger component
350
+ */
351
+ export interface GiftCardCustomVariantTriggerRenderProps {
352
+ /** Whether the custom variant is currently selected */
353
+ isSelected: boolean;
354
+ /** Function to select the custom variant */
355
+ onClick: () => void;
356
+ }
357
+ /**
358
+ * Props for GiftCardCustomVariantTrigger headless component
359
+ */
360
+ export interface GiftCardCustomVariantTriggerProps {
361
+ /** Render prop function that receives the custom variant trigger data */
362
+ children: (props: GiftCardCustomVariantTriggerRenderProps) => React.ReactNode;
363
+ }
364
+ /**
365
+ * Headless component for triggering custom amount selection.
366
+ * Only renders when custom variant is enabled for the gift card product.
367
+ *
368
+ * @component
369
+ * @example
370
+ * ```tsx
371
+ * <GiftCard.CustomVariantTrigger>
372
+ * {({ isSelected, onClick }) => (
373
+ * <button
374
+ * onClick={onClick}
375
+ * data-selected={isSelected}
376
+ * className="px-4 py-2 border-2 border-dashed rounded-xl"
377
+ * >
378
+ * Other amount
379
+ * </button>
380
+ * )}
381
+ * </GiftCard.CustomVariantTrigger>
382
+ * ```
383
+ */
384
+ export declare function CustomVariantTrigger(props: GiftCardCustomVariantTriggerProps): import("react").ReactNode;
385
+ /**
386
+ * Render props for GiftCardCustomAmountInput component
387
+ */
388
+ export interface GiftCardCustomAmountInputRenderProps {
389
+ /** Current custom amount value (defaults to 0) */
390
+ value: number;
391
+ /** Function to update the custom amount */
392
+ setValue: (amount: number) => void;
393
+ /** Minimum allowed amount (null if no minimum) */
394
+ min: number | null;
395
+ /** Maximum allowed amount (null if no maximum) */
396
+ max: number | null;
397
+ /** Whether the current value is valid (within min/max range) */
398
+ isValid: boolean;
399
+ /** Whether validation errors should be displayed */
400
+ showError: boolean;
401
+ /** Whether the input should be visible (custom variant is selected) */
402
+ isVisible: boolean;
403
+ /** Currency code from service config (e.g., "ILS", "USD") */
404
+ currencyCode: string;
405
+ /** Currency symbol derived from currency code (e.g., "$", "€", "₪") */
406
+ currencySymbol: string;
407
+ }
408
+ /**
409
+ * Props for GiftCardCustomAmountInput headless component
410
+ */
411
+ export interface GiftCardCustomAmountInputProps {
412
+ /** Render prop function that receives the custom amount input data */
413
+ children: (props: GiftCardCustomAmountInputRenderProps) => React.ReactNode;
414
+ }
415
+ /**
416
+ * Headless component for custom gift card amount input.
417
+ * Only renders when custom variant is selected.
418
+ * The custom amount affects the currentPrice value displayed by GiftCard.CurrentPrice.
419
+ *
420
+ * Validation:
421
+ * - Amount must be within min/max range defined by the product's custom variant
422
+ * - isValid will be false if amount is outside the allowed range
423
+ * - showError flag indicates whether validation errors should be displayed (set to true after form submission)
424
+ *
425
+ * @component
426
+ * @example
427
+ * ```tsx
428
+ * <GiftCard.CustomAmountInput>
429
+ * {({ value, setValue, min, max, isValid, showError, isVisible, currencyCode }) =>
430
+ * isVisible && (
431
+ * <div className="space-y-2">
432
+ * <label>Enter amount ({currencyCode})</label>
433
+ * <input
434
+ * type="number"
435
+ * value={value || ''}
436
+ * onChange={(e) => setValue(parseFloat(e.target.value) || 0)}
437
+ * min={min ?? undefined}
438
+ * max={max ?? undefined}
439
+ * data-invalid={showError && !isValid}
440
+ * />
441
+ * {showError && !isValid && min && max && (
442
+ * <p className="text-red-500">
443
+ * Enter an amount between {min} and {max}
444
+ * </p>
445
+ * )}
446
+ * </div>
447
+ * )
448
+ * }
449
+ * </GiftCard.CustomAmountInput>
450
+ * ```
451
+ */
452
+ export declare function CustomAmountInput(props: GiftCardCustomAmountInputProps): import("react").ReactNode;
453
+ /**
454
+ * Render props for GiftCardQuantity component
455
+ */
456
+ export interface GiftCardQuantityRenderProps {
457
+ /** Current quantity value */
458
+ quantity: number;
459
+ /** Function to set quantity value */
460
+ setQuantity: (quantity: number) => void;
461
+ }
462
+ /**
463
+ * Props for GiftCardQuantity headless component
464
+ */
465
+ export interface GiftCardQuantityProps {
466
+ /** Render prop function that receives quantity data */
467
+ children: (props: GiftCardQuantityRenderProps) => React.ReactNode;
468
+ }
469
+ /**
470
+ * Headless component for gift card quantity selection.
471
+ * Exposes quantity state and setter to allow building custom quantity UIs.
472
+ *
473
+ * @component
474
+ * @example
475
+ * ```tsx
476
+ * <GiftCard.Quantity>
477
+ * {({ quantity, setQuantity }) => (
478
+ * <div className="flex items-center gap-2">
479
+ * <button onClick={() => setQuantity(quantity - 1)} disabled={quantity <= 1}>-</button>
480
+ * <span>{quantity}</span>
481
+ * <button onClick={() => setQuantity(quantity + 1)}>+</button>
482
+ * </div>
483
+ * )}
484
+ * </GiftCard.Quantity>
485
+ * ```
486
+ */
487
+ export declare function Quantity(props: GiftCardQuantityProps): import("react").ReactNode;
488
+ /**
489
+ * Render props for GiftCardGiftToggle component
490
+ */
491
+ export interface GiftCardGiftToggleRenderProps {
492
+ /** Whether this is a gift purchase (for someone else) */
493
+ isGift: boolean;
494
+ /** Function to set whether this is a gift purchase */
495
+ setIsGift: (value: boolean) => void;
496
+ }
497
+ /**
498
+ * Props for GiftCardGiftToggle headless component
499
+ */
500
+ export interface GiftCardGiftToggleProps {
501
+ /** Render prop function that receives gift toggle data */
502
+ children: (props: GiftCardGiftToggleRenderProps) => React.ReactNode;
503
+ }
504
+ /**
505
+ * Headless component for toggling between gift and self-purchase modes.
506
+ * When isGift is true, the purchase is "for someone else" (shows recipient form).
507
+ * When isGift is false, the purchase is "for myself" (hides recipient form).
508
+ *
509
+ * @component
510
+ * @example
511
+ * ```tsx
512
+ * <GiftCard.GiftToggle>
513
+ * {({ isGift, setIsGift }) => (
514
+ * <div className="flex gap-2">
515
+ * <button
516
+ * onClick={() => setIsGift(true)}
517
+ * data-selected={isGift}
518
+ * >
519
+ * For someone else
520
+ * </button>
521
+ * <button
522
+ * onClick={() => setIsGift(false)}
523
+ * data-selected={!isGift}
524
+ * >
525
+ * For myself
526
+ * </button>
527
+ * </div>
528
+ * )}
529
+ * </GiftCard.GiftToggle>
530
+ * ```
531
+ */
532
+ export declare function GiftToggle(props: GiftCardGiftToggleProps): import("react").ReactNode;
533
+ /**
534
+ * Render props for GiftCardRecipientEmail component
535
+ */
536
+ export interface GiftCardRecipientEmailRenderProps {
537
+ /** Current email value */
538
+ value: string;
539
+ /** Function to update the email value */
540
+ setValue: (value: string) => void;
541
+ /** Whether the email is valid */
542
+ isValid: boolean;
543
+ /** Whether to show validation errors (e.g., after form submission attempt) */
544
+ showError: boolean;
545
+ /** Whether the input should be visible (isGift is true) */
546
+ isVisible: boolean;
547
+ }
548
+ /**
549
+ * Props for GiftCardRecipientEmail headless component
550
+ */
551
+ export interface GiftCardRecipientEmailProps {
552
+ /** Render prop function that receives recipient email data */
553
+ children: (props: GiftCardRecipientEmailRenderProps) => React.ReactNode;
554
+ }
555
+ /**
556
+ * Headless component for recipient email input.
557
+ * Exposes email state, setter, validation state, and error display flag.
558
+ *
559
+ * The `showError` flag is controlled by the checkout service and indicates
560
+ * whether validation errors should be displayed (typically set to true after
561
+ * a form submission attempt).
562
+ *
563
+ * @component
564
+ * @example
565
+ * ```tsx
566
+ * <GiftCard.RecipientEmail>
567
+ * {({ value, setValue, isValid, showError }) => (
568
+ * <div className="space-y-2">
569
+ * <label>Recipient email</label>
570
+ * <input
571
+ * type="email"
572
+ * value={value}
573
+ * onChange={(e) => setValue(e.target.value)}
574
+ * data-invalid={showError && !isValid}
575
+ * />
576
+ * {showError && !isValid && (
577
+ * <p className="text-red-500">Please enter a valid email</p>
578
+ * )}
579
+ * </div>
580
+ * )}
581
+ * </GiftCard.RecipientEmail>
582
+ * ```
583
+ */
584
+ export declare function RecipientEmail(props: GiftCardRecipientEmailProps): import("react").ReactNode;
585
+ /**
586
+ * Render props for GiftCardRecipientName component
587
+ */
588
+ export interface GiftCardRecipientNameRenderProps {
589
+ /** Current name value */
590
+ value: string;
591
+ /** Function to update the name value */
592
+ setValue: (value: string) => void;
593
+ /** Whether the input should be visible (isGift is true) */
594
+ isVisible: boolean;
595
+ }
596
+ /**
597
+ * Props for GiftCardRecipientName headless component
598
+ */
599
+ export interface GiftCardRecipientNameProps {
600
+ /** Render prop function that receives recipient name data */
601
+ children: (props: GiftCardRecipientNameRenderProps) => React.ReactNode;
602
+ }
603
+ /**
604
+ * Headless component for recipient name input.
605
+ * Exposes name state and setter.
606
+ * Only visible when isGift is true (purchasing for someone else).
607
+ *
608
+ * @component
609
+ * @example
610
+ * ```tsx
611
+ * <GiftCard.RecipientName>
612
+ * {({ value, setValue, isVisible }) =>
613
+ * isVisible && (
614
+ * <div className="space-y-2">
615
+ * <label>Recipient name (optional)</label>
616
+ * <input
617
+ * type="text"
618
+ * value={value}
619
+ * onChange={(e) => setValue(e.target.value)}
620
+ * />
621
+ * </div>
622
+ * )
623
+ * }
624
+ * </GiftCard.RecipientName>
625
+ * ```
626
+ */
627
+ export declare function RecipientName(props: GiftCardRecipientNameProps): import("react").ReactNode;
628
+ /**
629
+ * Render props for GiftCardRecipientDate component
630
+ */
631
+ export interface GiftCardRecipientDateRenderProps {
632
+ /** Current delivery date value */
633
+ value: Date;
634
+ /** Formatted date string according to locale (e.g., "Dec 25, 2025") */
635
+ formattedValue: string;
636
+ /** Date value formatted for HTML date input (YYYY-MM-DD) */
637
+ inputValue: string;
638
+ /** Function to update the delivery date */
639
+ setValue: (date: Date) => void;
640
+ /** Whether the input should be visible (isGift is true) */
641
+ isVisible: boolean;
642
+ }
643
+ /**
644
+ * Props for GiftCardRecipientDate headless component
645
+ */
646
+ export interface GiftCardRecipientDateProps {
647
+ /** Render prop function that receives recipient date data */
648
+ children: (props: GiftCardRecipientDateRenderProps) => React.ReactNode;
649
+ }
650
+ /**
651
+ * Headless component for recipient delivery date input.
652
+ * Exposes date state, setter, and formatted values.
653
+ * Only visible when isGift is true (purchasing for someone else).
654
+ *
655
+ * @component
656
+ * @example
657
+ * ```tsx
658
+ * <GiftCard.RecipientDate>
659
+ * {({ value, formattedValue, inputValue, setValue, isVisible }) =>
660
+ * isVisible && (
661
+ * <div className="space-y-2">
662
+ * <label>Delivery date</label>
663
+ * <input
664
+ * type="date"
665
+ * value={inputValue}
666
+ * onChange={(e) => setValue(new Date(e.target.value))}
667
+ * />
668
+ * <p>Selected: {formattedValue}</p>
669
+ * </div>
670
+ * )
671
+ * }
672
+ * </GiftCard.RecipientDate>
673
+ * ```
674
+ */
675
+ export declare function RecipientDate(props: GiftCardRecipientDateProps): import("react").ReactNode;
676
+ /**
677
+ * Render props for GiftCardRecipientMessage component
678
+ */
679
+ export interface GiftCardRecipientMessageRenderProps {
680
+ /** Current message value */
681
+ value: string;
682
+ /** Function to update the message value */
683
+ setValue: (value: string) => void;
684
+ /** Whether the input should be visible (isGift is true) */
685
+ isVisible: boolean;
686
+ }
687
+ /**
688
+ * Props for GiftCardRecipientMessage headless component
689
+ */
690
+ export interface GiftCardRecipientMessageProps {
691
+ /** Render prop function that receives recipient message data */
692
+ children: (props: GiftCardRecipientMessageRenderProps) => React.ReactNode;
693
+ }
694
+ /**
695
+ * Headless component for recipient message textarea.
696
+ * Exposes message state and setter.
697
+ * Only visible when isGift is true (purchasing for someone else).
698
+ *
699
+ * @component
700
+ * @example
701
+ * ```tsx
702
+ * <GiftCard.RecipientMessage>
703
+ * {({ value, setValue, isVisible }) =>
704
+ * isVisible && (
705
+ * <div className="space-y-2">
706
+ * <label>Personal message (optional)</label>
707
+ * <textarea
708
+ * value={value}
709
+ * onChange={(e) => setValue(e.target.value)}
710
+ * rows={4}
711
+ * />
712
+ * </div>
713
+ * )
714
+ * }
715
+ * </GiftCard.RecipientMessage>
716
+ * ```
717
+ */
718
+ export declare function RecipientMessage(props: GiftCardRecipientMessageProps): import("react").ReactNode;
719
+ /**
720
+ * Render props for GiftCardRecipientForm component
721
+ */
722
+ export interface GiftCardRecipientFormRenderProps {
723
+ /** Whether the form should be visible (isGift is true) */
724
+ isVisible: boolean;
725
+ /** Whether to show validation errors (e.g., after form submission attempt) */
726
+ showErrors: boolean;
727
+ /** Email field data */
728
+ email: {
729
+ /** Current email value */
730
+ value: string;
731
+ /** Function to update the email value */
732
+ setValue: (value: string) => void;
733
+ /** Whether the email is valid */
734
+ isValid: boolean;
735
+ };
736
+ /** Name field data */
737
+ name: {
738
+ /** Current name value */
739
+ value: string;
740
+ /** Function to update the name value */
741
+ setValue: (value: string) => void;
742
+ };
743
+ /** Delivery date field data */
744
+ deliverAt: {
745
+ /** Current delivery date value */
746
+ value: Date;
747
+ /** Formatted date string according to locale (e.g., "Dec 25, 2025") */
748
+ formattedValue: string;
749
+ /** Date value formatted for HTML date input (YYYY-MM-DD) */
750
+ inputValue: string;
751
+ /** Function to update the delivery date */
752
+ setValue: (date: Date) => void;
753
+ };
754
+ /** Message field data */
755
+ message: {
756
+ /** Current message value */
757
+ value: string;
758
+ /** Function to update the message value */
759
+ setValue: (value: string) => void;
760
+ };
761
+ }
762
+ /**
763
+ * Props for GiftCardRecipientForm headless component
764
+ */
765
+ export interface GiftCardRecipientFormProps {
766
+ /** Render prop function that receives recipient form data */
767
+ children: (props: GiftCardRecipientFormRenderProps) => React.ReactNode;
768
+ }
769
+ /**
770
+ * Headless component for recipient form that combines all recipient fields.
771
+ * Provides consolidated access to email, name, date, and message fields.
772
+ * Only visible when isGift is true (purchasing for someone else).
773
+ *
774
+ * This is a convenience component that aggregates all recipient field data.
775
+ * For granular control, use the individual RecipientEmail, RecipientName,
776
+ * RecipientDate, and RecipientMessage components.
777
+ *
778
+ * @component
779
+ * @example
780
+ * ```tsx
781
+ * <GiftCard.RecipientForm>
782
+ * {({ isVisible, showErrors, email, name, deliverAt, message }) =>
783
+ * isVisible && (
784
+ * <div className="space-y-4">
785
+ * <div>
786
+ * <label>Recipient email</label>
787
+ * <input
788
+ * type="email"
789
+ * value={email.value}
790
+ * onChange={(e) => email.setValue(e.target.value)}
791
+ * data-invalid={showErrors && !email.isValid}
792
+ * />
793
+ * {showErrors && !email.isValid && <p>Please enter a valid email</p>}
794
+ * </div>
795
+ * <div>
796
+ * <label>Recipient name</label>
797
+ * <input
798
+ * type="text"
799
+ * value={name.value}
800
+ * onChange={(e) => name.setValue(e.target.value)}
801
+ * />
802
+ * </div>
803
+ * <div>
804
+ * <label>Delivery date</label>
805
+ * <input
806
+ * type="date"
807
+ * value={deliverAt.inputValue}
808
+ * onChange={(e) => deliverAt.setValue(new Date(e.target.value))}
809
+ * />
810
+ * </div>
811
+ * <div>
812
+ * <label>Message</label>
813
+ * <textarea
814
+ * value={message.value}
815
+ * onChange={(e) => message.setValue(e.target.value)}
816
+ * />
817
+ * </div>
818
+ * </div>
819
+ * )
820
+ * }
821
+ * </GiftCard.RecipientForm>
822
+ * ```
823
+ */
824
+ export declare function RecipientForm(props: GiftCardRecipientFormProps): import("react").ReactNode;
825
+ /**
826
+ * Render props for the Actions component
827
+ */
828
+ export interface ActionsRenderProps {
829
+ /** Computed line items for cart API */
830
+ lineItems: LineItem[];
831
+ /** Validates form and triggers showErrors - call before adding to cart */
832
+ validateAndShowErrors: () => boolean;
833
+ }
834
+ /**
835
+ * Props for the Actions component
836
+ */
837
+ export interface ActionsProps {
838
+ /** Render prop function that receives action data */
839
+ children: (props: ActionsRenderProps) => React.ReactNode;
840
+ }
841
+ /**
842
+ * Headless component that exposes cart action data via render props.
843
+ * Provides lineItems, validation state, and validateAndShowErrors function.
844
+ *
845
+ * The loading state is handled by Commerce.Actions.AddToCart / CurrentCartService.
846
+ *
847
+ * @component
848
+ * @example
849
+ * ```tsx
850
+ * <CoreGiftCard.Actions>
851
+ * {({ lineItems, validateAndShowErrors }) => (
852
+ * <Commerce.Actions.AddToCart
853
+ * lineItems={lineItems}
854
+ * onClick={() => {
855
+ * if (!validateAndShowErrors()) return; // Validation failed, errors shown
856
+ * }}
857
+ * />
858
+ * )}
859
+ * </CoreGiftCard.Actions>
860
+ * ```
861
+ */
862
+ export declare function Actions(props: ActionsProps): import("react").ReactNode;
863
+ //# sourceMappingURL=GiftCard.d.ts.map