@thorprovider/blocks 3.0.2 → 4.0.0

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 (192) hide show
  1. package/README.md +61 -21
  2. package/dist/blocks/designs/marketplace-product-card/block.d.ts +12 -0
  3. package/dist/blocks/designs/marketplace-product-card/block.d.ts.map +1 -0
  4. package/dist/blocks/designs/marketplace-product-card/block.js +243 -0
  5. package/dist/blocks/designs/marketplace-product-card/block.js.map +1 -0
  6. package/dist/blocks/designs/marketplace-product-card/block.mjs +233 -0
  7. package/dist/blocks/designs/marketplace-product-card/block.mjs.map +1 -0
  8. package/dist/blocks/designs/marketplace-product-card/index.d.ts +3 -0
  9. package/dist/blocks/designs/marketplace-product-card/index.d.ts.map +1 -0
  10. package/dist/blocks/designs/marketplace-product-card/index.js +36 -0
  11. package/dist/blocks/designs/marketplace-product-card/index.js.map +1 -0
  12. package/dist/blocks/designs/marketplace-product-card/index.mjs +6 -0
  13. package/dist/blocks/designs/marketplace-product-card/index.mjs.map +1 -0
  14. package/dist/blocks/designs/marketplace-product-card/normalize.d.ts +13 -0
  15. package/dist/blocks/designs/marketplace-product-card/normalize.d.ts.map +1 -0
  16. package/dist/blocks/designs/marketplace-product-card/normalize.js +36 -0
  17. package/dist/blocks/designs/marketplace-product-card/normalize.js.map +1 -0
  18. package/dist/blocks/designs/marketplace-product-card/normalize.mjs +12 -0
  19. package/dist/blocks/designs/marketplace-product-card/normalize.mjs.map +1 -0
  20. package/dist/blocks/designs/marketplace-product-card/variants.d.ts +72 -0
  21. package/dist/blocks/designs/marketplace-product-card/variants.d.ts.map +1 -0
  22. package/dist/blocks/designs/marketplace-product-card/variants.js +123 -0
  23. package/dist/blocks/designs/marketplace-product-card/variants.js.map +1 -0
  24. package/dist/blocks/designs/marketplace-product-card/variants.mjs +89 -0
  25. package/dist/blocks/designs/marketplace-product-card/variants.mjs.map +1 -0
  26. package/dist/blocks/e-commerce/checkout-forms/checkbox-check.js +1 -1
  27. package/dist/blocks/e-commerce/checkout-forms/checkbox-check.js.map +1 -1
  28. package/dist/blocks/e-commerce/checkout-forms/checkbox-check.mjs +1 -1
  29. package/dist/blocks/e-commerce/checkout-forms/checkbox-check.mjs.map +1 -1
  30. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.d.ts +11 -0
  31. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.d.ts.map +1 -0
  32. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.js +46 -0
  33. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.js.map +1 -0
  34. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.mjs +22 -0
  35. package/dist/blocks/e-commerce/checkout-forms/checkout-address-equality.mjs.map +1 -0
  36. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.d.ts +28 -0
  37. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.d.ts.map +1 -0
  38. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.js +278 -0
  39. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.js.map +1 -0
  40. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.mjs +260 -0
  41. package/dist/blocks/e-commerce/checkout-forms/checkout-address-fields.mjs.map +1 -0
  42. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.d.ts +12 -9
  43. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.d.ts.map +1 -1
  44. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.js +49 -71
  45. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.js.map +1 -1
  46. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.mjs +50 -72
  47. package/dist/blocks/e-commerce/checkout-forms/checkout-contact-step.mjs.map +1 -1
  48. package/dist/blocks/e-commerce/checkout-forms/checkout-country-field.d.ts.map +1 -1
  49. package/dist/blocks/e-commerce/checkout-forms/checkout-country-field.js +6 -3
  50. package/dist/blocks/e-commerce/checkout-forms/checkout-country-field.js.map +1 -1
  51. package/dist/blocks/e-commerce/checkout-forms/checkout-country-field.mjs +6 -3
  52. package/dist/blocks/e-commerce/checkout-forms/checkout-country-field.mjs.map +1 -1
  53. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.d.ts +7 -0
  54. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.d.ts.map +1 -0
  55. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.js +41 -0
  56. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.js.map +1 -0
  57. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.mjs +16 -0
  58. package/dist/blocks/e-commerce/checkout-forms/checkout-id-context.mjs.map +1 -0
  59. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.d.ts +24 -0
  60. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.d.ts.map +1 -0
  61. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.js +75 -0
  62. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.js.map +1 -0
  63. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.mjs +58 -0
  64. package/dist/blocks/e-commerce/checkout-forms/checkout-location-select.mjs.map +1 -0
  65. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.d.ts +3 -2
  66. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.d.ts.map +1 -1
  67. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.js +9 -2
  68. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.js.map +1 -1
  69. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.mjs +9 -2
  70. package/dist/blocks/e-commerce/checkout-forms/checkout-order-summary.mjs.map +1 -1
  71. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.d.ts +23 -8
  72. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.d.ts.map +1 -1
  73. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.js +136 -31
  74. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.js.map +1 -1
  75. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.mjs +143 -32
  76. package/dist/blocks/e-commerce/checkout-forms/checkout-payment-step.mjs.map +1 -1
  77. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.d.ts +13 -7
  78. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.d.ts.map +1 -1
  79. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.js +179 -28
  80. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.js.map +1 -1
  81. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.mjs +180 -29
  82. package/dist/blocks/e-commerce/checkout-forms/checkout-review-step.mjs.map +1 -1
  83. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.d.ts +20 -0
  84. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.d.ts.map +1 -0
  85. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.js +199 -0
  86. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.js.map +1 -0
  87. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.mjs +175 -0
  88. package/dist/blocks/e-commerce/checkout-forms/checkout-saved-addresses.mjs.map +1 -0
  89. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.d.ts +14 -0
  90. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.d.ts.map +1 -0
  91. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.js +136 -0
  92. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.js.map +1 -0
  93. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.mjs +109 -0
  94. package/dist/blocks/e-commerce/checkout-forms/checkout-section-nav.mjs.map +1 -0
  95. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.d.ts +32 -10
  96. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.d.ts.map +1 -1
  97. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.js +265 -147
  98. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.js.map +1 -1
  99. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.mjs +272 -148
  100. package/dist/blocks/e-commerce/checkout-forms/checkout-shipping-step.mjs.map +1 -1
  101. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.d.ts +13 -0
  102. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.d.ts.map +1 -0
  103. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.js +74 -0
  104. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.js.map +1 -0
  105. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.mjs +50 -0
  106. package/dist/blocks/e-commerce/checkout-forms/checkout-step-header.mjs.map +1 -0
  107. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.d.ts +7 -0
  108. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.d.ts.map +1 -0
  109. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.js +91 -0
  110. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.js.map +1 -0
  111. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.mjs +65 -0
  112. package/dist/blocks/e-commerce/checkout-forms/checkout-step-summary.mjs.map +1 -0
  113. package/dist/blocks/e-commerce/checkout-forms/checkout.d.ts +174 -44
  114. package/dist/blocks/e-commerce/checkout-forms/checkout.d.ts.map +1 -1
  115. package/dist/blocks/e-commerce/checkout-forms/checkout.js +532 -108
  116. package/dist/blocks/e-commerce/checkout-forms/checkout.js.map +1 -1
  117. package/dist/blocks/e-commerce/checkout-forms/checkout.mjs +542 -109
  118. package/dist/blocks/e-commerce/checkout-forms/checkout.mjs.map +1 -1
  119. package/dist/blocks/e-commerce/navigation/storefront-navbar-cart-sheet.d.ts.map +1 -1
  120. package/dist/blocks/e-commerce/navigation/storefront-navbar-cart-sheet.js +44 -20
  121. package/dist/blocks/e-commerce/navigation/storefront-navbar-cart-sheet.js.map +1 -1
  122. package/dist/blocks/e-commerce/navigation/storefront-navbar-cart-sheet.mjs +44 -20
  123. package/dist/blocks/e-commerce/navigation/storefront-navbar-cart-sheet.mjs.map +1 -1
  124. package/dist/blocks/e-commerce/navigation/storefront-navbar.d.ts.map +1 -1
  125. package/dist/blocks/e-commerce/navigation/storefront-navbar.js +21 -10
  126. package/dist/blocks/e-commerce/navigation/storefront-navbar.js.map +1 -1
  127. package/dist/blocks/e-commerce/navigation/storefront-navbar.mjs +21 -10
  128. package/dist/blocks/e-commerce/navigation/storefront-navbar.mjs.map +1 -1
  129. package/dist/blocks/e-commerce/product-list/product-card.d.ts.map +1 -1
  130. package/dist/blocks/e-commerce/product-list/product-card.js +36 -9
  131. package/dist/blocks/e-commerce/product-list/product-card.js.map +1 -1
  132. package/dist/blocks/e-commerce/product-list/product-card.mjs +36 -9
  133. package/dist/blocks/e-commerce/product-list/product-card.mjs.map +1 -1
  134. package/dist/blocks/e-commerce/product-list/product-showcase-1.d.ts.map +1 -1
  135. package/dist/blocks/e-commerce/product-list/product-showcase-1.js +7 -2
  136. package/dist/blocks/e-commerce/product-list/product-showcase-1.js.map +1 -1
  137. package/dist/blocks/e-commerce/product-list/product-showcase-1.mjs +7 -2
  138. package/dist/blocks/e-commerce/product-list/product-showcase-1.mjs.map +1 -1
  139. package/dist/blocks/e-commerce/product-overview/product-quick-view-dialog.d.ts.map +1 -1
  140. package/dist/blocks/e-commerce/product-overview/product-quick-view-dialog.js +5 -1
  141. package/dist/blocks/e-commerce/product-overview/product-quick-view-dialog.js.map +1 -1
  142. package/dist/blocks/e-commerce/product-overview/product-quick-view-dialog.mjs +5 -1
  143. package/dist/blocks/e-commerce/product-overview/product-quick-view-dialog.mjs.map +1 -1
  144. package/dist/blocks/e-commerce/storefront-hero/storefront-hero.d.ts.map +1 -1
  145. package/dist/blocks/e-commerce/storefront-hero/storefront-hero.js +71 -51
  146. package/dist/blocks/e-commerce/storefront-hero/storefront-hero.js.map +1 -1
  147. package/dist/blocks/e-commerce/storefront-hero/storefront-hero.mjs +71 -51
  148. package/dist/blocks/e-commerce/storefront-hero/storefront-hero.mjs.map +1 -1
  149. package/dist/blocks/marketing/banners/banner-1.d.ts.map +1 -1
  150. package/dist/blocks/marketing/banners/banner-1.js +15 -27
  151. package/dist/blocks/marketing/banners/banner-1.js.map +1 -1
  152. package/dist/blocks/marketing/banners/banner-1.mjs +16 -28
  153. package/dist/blocks/marketing/banners/banner-1.mjs.map +1 -1
  154. package/dist/index.d.ts +6 -3
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +5 -0
  157. package/dist/index.js.map +1 -1
  158. package/dist/index.mjs +4 -0
  159. package/dist/index.mjs.map +1 -1
  160. package/dist/lib/contracts/marketplace-product-card.d.ts +324 -0
  161. package/dist/lib/contracts/marketplace-product-card.d.ts.map +1 -0
  162. package/dist/lib/contracts/marketplace-product-card.js +85 -0
  163. package/dist/lib/contracts/marketplace-product-card.js.map +1 -0
  164. package/dist/lib/contracts/marketplace-product-card.mjs +61 -0
  165. package/dist/lib/contracts/marketplace-product-card.mjs.map +1 -0
  166. package/dist/lib/contracts.d.ts +1861 -88
  167. package/dist/lib/contracts.d.ts.map +1 -1
  168. package/dist/lib/contracts.js +252 -25
  169. package/dist/lib/contracts.js.map +1 -1
  170. package/dist/lib/contracts.mjs +208 -5
  171. package/dist/lib/contracts.mjs.map +1 -1
  172. package/dist/lib/money-schema.d.ts +19 -0
  173. package/dist/lib/money-schema.d.ts.map +1 -0
  174. package/dist/lib/money-schema.js +33 -0
  175. package/dist/lib/money-schema.js.map +1 -0
  176. package/dist/lib/money-schema.mjs +9 -0
  177. package/dist/lib/money-schema.mjs.map +1 -0
  178. package/dist/lib/motion.d.ts +29 -0
  179. package/dist/lib/motion.d.ts.map +1 -0
  180. package/dist/lib/motion.js +65 -0
  181. package/dist/lib/motion.js.map +1 -0
  182. package/dist/lib/motion.mjs +41 -0
  183. package/dist/lib/motion.mjs.map +1 -0
  184. package/dist/ui/accordion.d.ts +3 -1
  185. package/dist/ui/accordion.d.ts.map +1 -1
  186. package/dist/ui/accordion.js +21 -5
  187. package/dist/ui/accordion.js.map +1 -1
  188. package/dist/ui/accordion.mjs +21 -5
  189. package/dist/ui/accordion.mjs.map +1 -1
  190. package/dist/ui/input-group.d.ts +1 -1
  191. package/package.json +18 -3
  192. package/dist/.tsbuildinfo +0 -1
@@ -28,6 +28,7 @@ var import_react = require("react");
28
28
  var import_lucide_react = require("lucide-react");
29
29
  var import_button = require("../../../ui/button.js");
30
30
  var import_card = require("../../../ui/card.js");
31
+ var import_accordion = require("../../../ui/accordion.js");
31
32
  var import_utils = require("../../../lib/utils.js");
32
33
  var import_checkout_contact_step = require("./checkout-contact-step.js");
33
34
  var import_checkout_shipping_step = require("./checkout-shipping-step.js");
@@ -35,6 +36,10 @@ var import_checkout_payment_step = require("./checkout-payment-step.js");
35
36
  var import_checkout_review_step = require("./checkout-review-step.js");
36
37
  var import_checkout_order_summary = require("./checkout-order-summary.js");
37
38
  var import_checkout_progress = require("./checkout-progress.js");
39
+ var import_checkout_section_nav = require("./checkout-section-nav.js");
40
+ var import_checkout_step_header = require("./checkout-step-header.js");
41
+ var import_checkout_step_summary = require("./checkout-step-summary.js");
42
+ var import_checkout_id_context = require("./checkout-id-context.js");
38
43
  const DEFAULT_LABELS = {
39
44
  title: "Checkout",
40
45
  description: "",
@@ -48,6 +53,8 @@ const DEFAULT_LABELS = {
48
53
  contactDescription: "We use these details to keep you informed about your order.",
49
54
  shippingHeading: "Shipping address",
50
55
  shippingDescription: "Tell us where the order should be delivered.",
56
+ billingHeading: "Billing address",
57
+ billingDescription: "Where should the invoice be addressed?",
51
58
  paymentHeading: "Payment",
52
59
  paymentDescription: "Choose how you want to pay for this order.",
53
60
  reviewHeading: "Review your order",
@@ -55,18 +62,70 @@ const DEFAULT_LABELS = {
55
62
  emailLabel: "Email",
56
63
  firstNameLabel: "First name",
57
64
  lastNameLabel: "Last name",
58
- phoneLabel: "Phone (optional)",
59
- addressLabel: "Street address",
65
+ phoneLabel: "Phone",
66
+ companyLabel: "Company (optional)",
67
+ addressLabel: "Address line 1",
68
+ address2Label: "Address line 2 (optional)",
60
69
  cityLabel: "City",
61
70
  stateLabel: "State / Province",
62
71
  zipCodeLabel: "ZIP / Postal code",
63
72
  countryLabel: "Country",
64
73
  countryPlaceholder: "Select a country",
74
+ provincePlaceholder: "Select a province or state",
75
+ cityPlaceholder: "Select a city",
76
+ signedInAsLabel: "Signed in as",
77
+ signOutLabel: "Sign out",
78
+ signInLabel: "Sign in",
79
+ accountRequiredHeading: "Sign in to continue",
80
+ accountRequiredDescription: "You need an account to complete this purchase.",
81
+ signUpLabel: "Create account",
82
+ identityPendingLabel: "Checking your account\u2026",
83
+ optionalIndicatorLabel: "optional",
84
+ savedAddressesLabel: "Saved addresses",
85
+ defaultAddressLabel: "Default",
86
+ recipientHeading: "Recipient",
87
+ recipientDescription: "Who should receive this order? It can be someone else.",
88
+ addressHeading: "Address",
89
+ addAddressLabel: "Add address",
90
+ useAddressLabel: "Use",
91
+ deleteAddressLabel: "Delete",
92
+ deleteAddressConfirmLabel: "Delete this saved address?",
93
+ deleteAddressHintLabel: "The order will still ship to the current address.",
94
+ cancelAddressLabel: "Cancel",
95
+ updateSavedAddressLabel: "Update saved address",
96
+ saveAsNewAddressLabel: "Save as new address",
97
+ saveAddressLabel: "Save to my addresses",
98
+ newAddressLabel: "New address",
99
+ savingAddressLabel: "Saving address\u2026",
100
+ deletingAddressLabel: "Deleting\u2026",
101
+ addressSaveErrorLabel: "We could not save this address.",
102
+ addressDeleteErrorLabel: "We could not delete this address.",
103
+ addressSavedLabel: "Address saved.",
104
+ addressDeletedLabel: "Address deleted.",
105
+ billingSameAsShippingLabel: "Billing address same as shipping",
106
+ locationLoadingLabel: "Loading options\u2026",
107
+ locationErrorLabel: "We could not load these options.",
108
+ locationUnavailableLabel: "No options are available.",
109
+ locationOptionalLabel: "Optional for this address.",
65
110
  shippingMethodLegend: "Shipping method",
111
+ noShippingOptionsLabel: "No delivery options are available for this address.",
112
+ groupUnavailableLabel: "Unavailable for this address.",
113
+ deliveryLoadingLabel: "Loading delivery options\u2026",
114
+ deliveryErrorLabel: "We could not load delivery options.",
115
+ deliveryUnavailableLabel: "Delivery is unavailable for this address.",
66
116
  paymentMethodLegend: "Payment method",
67
117
  noPaymentMethodsLabel: "No payment methods are available for this region.",
118
+ paymentLoadingLabel: "Loading payment methods\u2026",
119
+ paymentErrorLabel: "We could not load payment methods.",
120
+ paymentUnavailableLabel: "Payment is unavailable for this region.",
68
121
  unavailableMethodLabel: "Unavailable",
69
122
  requiresSetupLabel: "Requires additional setup",
123
+ giftCardLabel: "Gift card",
124
+ giftCardPlaceholder: "Enter a gift card code",
125
+ applyLabel: "Apply",
126
+ removeLabel: "Remove",
127
+ storeCreditLabel: "Store credit",
128
+ availableCreditLabel: "Available credit",
70
129
  saveInfoLabel: "Save this information for next time",
71
130
  newsletterLabel: "Email me about news and offers",
72
131
  promoCodeLabel: "Promotional code",
@@ -85,16 +144,30 @@ const DEFAULT_LABELS = {
85
144
  retryLabel: "Retry",
86
145
  reviewContactLabel: "Contact",
87
146
  reviewShipToLabel: "Ship to",
147
+ reviewBillingLabel: "Billing",
88
148
  reviewPaymentLabel: "Payment",
89
- reviewShippingLabel: "Shipping method",
149
+ reviewShippingLabel: "Delivery",
150
+ reviewDeliveryGroupsLabel: "Delivery groups",
151
+ reviewGroupLabel: "Group {n} of {total}",
152
+ reviewGroupItemsLabel: "Items",
153
+ reviewAdjustmentsLabel: "Adjustments",
154
+ reviewSameAsShippingLabel: "Same as shipping",
155
+ reviewLinesLabel: "Lines",
90
156
  reviewEmptyLabel: "No details provided yet.",
91
157
  backLabel: "Back",
92
158
  continueLabel: "Continue",
159
+ validationAttentionLabel: "Please review the {step} section.",
93
160
  completeOrderLabel: "Place order",
94
161
  processingLabel: "Placing order\u2026",
95
- submitErrorActionLabel: "Try again"
162
+ submitErrorActionLabel: "Try again",
163
+ interruptionAcknowledgeLabel: "Acknowledge and continue",
164
+ interruptionRefreshLabel: "Refresh",
165
+ interruptionReturnToCartLabel: "Return to cart",
166
+ interruptionRetryLabel: "Try again",
167
+ availabilityEmptyLabel: "Your cart is empty.",
168
+ availabilityUnavailableLabel: "Checkout is unavailable.",
169
+ availabilityErrorLabel: "We could not load checkout."
96
170
  };
97
- const BASE_STEPS = ["contact", "shipping", "payment"];
98
171
  const STEP_COPY = {
99
172
  contact: {
100
173
  name: "contactStepName",
@@ -117,19 +190,61 @@ const STEP_COPY = {
117
190
  description: "reviewDescription"
118
191
  }
119
192
  };
193
+ function availabilityLabel(status, labels) {
194
+ if (status === "empty") return labels.availabilityEmptyLabel;
195
+ if (status === "error") return labels.availabilityErrorLabel;
196
+ return labels.availabilityUnavailableLabel;
197
+ }
120
198
  function Checkout({
121
199
  presentation,
122
200
  showReviewStep = false,
123
- values,
124
- onChange,
201
+ requireAccount = false,
202
+ contactStep = "when-guest",
203
+ onSignUp,
204
+ requireContactPhone = false,
205
+ requireShippingPhone = false,
206
+ contact,
207
+ onContactChange,
208
+ customer,
209
+ onSignIn,
210
+ onSignOut,
211
+ savedAddresses,
212
+ onSelectSavedAddress,
213
+ onCreateSavedAddress,
214
+ onUpdateSavedAddress,
215
+ onDeleteSavedAddress,
216
+ onStartNewAddress,
217
+ onCancelNewAddress,
218
+ savedAddressState,
219
+ shippingAddress,
220
+ billingAddress,
221
+ sameAsShipping,
222
+ onShippingAddressChange,
223
+ onBillingAddressChange,
224
+ onSameAsShippingChange,
225
+ shippingLocations,
226
+ billingLocations,
227
+ onRetryLocations,
228
+ shippingGroups,
229
+ shippingState = "idle",
230
+ onSelectShippingOption,
231
+ onRetryShipping,
232
+ paymentMethods = [],
233
+ paymentState = "idle",
234
+ paymentMethod,
235
+ onSelectPaymentMethod,
236
+ onRetryPayment,
237
+ adjustmentPayments,
238
+ onApplyGiftCard,
239
+ giftCardState,
240
+ giftCardMessage,
241
+ onRemoveAdjustment,
242
+ storeCredit,
125
243
  orderSummary,
126
244
  totalsState = "idle",
127
245
  onRetryTotals,
128
- countries,
129
- shippingOptions,
130
- selectedShippingOptionId,
131
- onSelectShippingOption,
132
- paymentMethods = [],
246
+ promoCode,
247
+ onPromoCodeChange,
133
248
  onApplyPromo,
134
249
  promoPending = false,
135
250
  trustNotes,
@@ -139,43 +254,113 @@ function Checkout({
139
254
  fieldDescriptions,
140
255
  validateStep,
141
256
  onStepChange,
142
- onSubmit,
257
+ availability,
258
+ interruption,
259
+ onInterruptionAction,
143
260
  submitting = false,
144
261
  submitError,
145
- onRetrySubmit
262
+ onRetrySubmit,
263
+ onSubmit
146
264
  }) {
147
265
  const resolved = { ...DEFAULT_LABELS, ...labels };
148
- const steps = showReviewStep ? [...BASE_STEPS, "review"] : BASE_STEPS;
149
- const [stepIndex, setStepIndex] = (0, import_react.useState)(0);
150
- const activeStep = steps[Math.min(stepIndex, steps.length - 1)];
266
+ const identityPending = requireAccount && customer === void 0;
267
+ const accountGate = requireAccount && customer === null;
268
+ const contactVisible = contactStep === "always" || !customer;
269
+ const steps = [
270
+ ...contactVisible ? ["contact"] : [],
271
+ "shipping",
272
+ "payment",
273
+ ...showReviewStep ? ["review"] : []
274
+ ];
275
+ const checkoutInstanceId = `checkout-${(0, import_react.useId)().replace(/[^a-zA-Z0-9_-]/g, "")}`;
276
+ const [activeStepState, setActiveStepState] = (0, import_react.useState)(steps[0]);
277
+ const activeStep = steps.includes(activeStepState) ? activeStepState : steps[0];
278
+ const stepIndex = steps.indexOf(activeStep);
279
+ const [validationAlert, setValidationAlert] = (0, import_react.useState)();
280
+ const validationAlertNonce = (0, import_react.useRef)(0);
151
281
  const headingRef = (0, import_react.useRef)(null);
152
282
  const hasMounted = (0, import_react.useRef)(false);
153
283
  (0, import_react.useEffect)(() => {
154
- if (presentation !== "stepper") return;
284
+ if (activeStepState === activeStep) return;
285
+ setActiveStepState(activeStep);
286
+ onStepChange?.(activeStep);
287
+ }, [activeStep, activeStepState, onStepChange]);
288
+ (0, import_react.useEffect)(() => {
289
+ if (presentation !== "stepper" && presentation !== "accordion") return;
155
290
  if (!hasMounted.current) {
156
291
  hasMounted.current = true;
157
292
  return;
158
293
  }
159
- headingRef.current?.focus();
160
- }, [presentation, activeStep]);
294
+ if (presentation === "stepper") {
295
+ headingRef.current?.focus();
296
+ } else {
297
+ document.getElementById((0, import_checkout_section_nav.checkoutSectionHeadingId)(checkoutInstanceId, activeStep))?.focus();
298
+ }
299
+ }, [presentation, activeStep, checkoutInstanceId]);
300
+ (0, import_react.useEffect)(() => {
301
+ if (!validationAlert) return;
302
+ if ((presentation === "stepper" || presentation === "accordion") && activeStep !== validationAlert.step) {
303
+ return;
304
+ }
305
+ const heading = document.getElementById(
306
+ (0, import_checkout_section_nav.checkoutSectionHeadingId)(checkoutInstanceId, validationAlert.step)
307
+ );
308
+ const stepContainer = heading?.closest("[data-checkout-step]");
309
+ const firstInvalid = stepContainer?.querySelector('[aria-invalid="true"]');
310
+ const target = firstInvalid ?? heading;
311
+ if (!target) return;
312
+ const prefersReducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
313
+ target.scrollIntoView?.({ behavior: prefersReducedMotion ? "auto" : "smooth", block: "start" });
314
+ target.focus({ preventScroll: true });
315
+ }, [activeStep, checkoutInstanceId, presentation, validationAlert]);
161
316
  const moveTo = (nextIndex) => {
162
317
  const next = steps[nextIndex];
163
318
  if (!next) return;
164
- setStepIndex(nextIndex);
319
+ setActiveStepState(next);
165
320
  onStepChange?.(next);
166
321
  };
322
+ const revealStep = (step) => {
323
+ validationAlertNonce.current += 1;
324
+ setValidationAlert({ step, nonce: validationAlertNonce.current });
325
+ if (presentation === "stepper" || presentation === "accordion") {
326
+ const nextIndex = steps.indexOf(step);
327
+ if (nextIndex >= 0 && step !== activeStep) moveTo(nextIndex);
328
+ }
329
+ };
167
330
  const handleContinue = () => {
168
- if (validateStep && !validateStep(activeStep)) return;
331
+ if (validateStep && !validateStep(activeStep)) {
332
+ revealStep(activeStep);
333
+ return;
334
+ }
169
335
  moveTo(stepIndex + 1);
170
336
  };
171
337
  const handleBack = () => {
172
338
  if (stepIndex === 0) return;
173
339
  moveTo(stepIndex - 1);
174
340
  };
341
+ const blockedByInterruption = interruption?.severity === "blocking";
175
342
  const handleSubmit = () => {
176
- if (submitting) return;
177
- if (validateStep && !steps.every((step) => validateStep(step))) return;
178
- onSubmit?.(values);
343
+ if (submitting || blockedByInterruption) return;
344
+ if (validateStep) {
345
+ const firstInvalidStep = steps.find((step) => !validateStep(step));
346
+ if (firstInvalidStep) {
347
+ revealStep(firstInvalidStep);
348
+ return;
349
+ }
350
+ }
351
+ const snapshot = {
352
+ contact,
353
+ shippingAddress,
354
+ billingAddress: sameAsShipping ? void 0 : billingAddress,
355
+ sameAsShipping,
356
+ shippingSelections: (shippingGroups ?? []).flatMap(
357
+ (group) => group.selectedOptionId ? [{ groupId: group.id, optionId: group.selectedOptionId }] : []
358
+ ),
359
+ paymentMethod,
360
+ adjustmentPayments: adjustmentPayments ?? [],
361
+ promoCode: promoCode ?? ""
362
+ };
363
+ onSubmit?.(snapshot);
179
364
  };
180
365
  const renderStep = (step) => {
181
366
  switch (step) {
@@ -183,61 +368,103 @@ function Checkout({
183
368
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
184
369
  import_checkout_contact_step.CheckoutContactStep,
185
370
  {
186
- values,
187
- onChange,
371
+ contact,
372
+ onChange: onContactChange,
373
+ customer,
374
+ onSignIn,
375
+ onSignOut,
376
+ requirePhone: requireContactPhone,
188
377
  labels: resolved,
189
- showSaveInfo: labels?.saveInfoLabel !== void 0,
190
- showNewsletter: labels?.newsletterLabel !== void 0,
191
- fieldErrors,
192
- fieldDescriptions
378
+ fieldErrors: fieldErrors?.contact,
379
+ fieldDescriptions: fieldDescriptions?.contact
193
380
  }
194
381
  );
195
382
  case "shipping":
196
383
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
384
  import_checkout_shipping_step.CheckoutShippingStep,
198
385
  {
199
- values,
200
- onChange,
201
- labels: resolved,
202
- countries,
203
- shippingOptions,
204
- selectedShippingOptionId,
386
+ shippingAddress,
387
+ billingAddress,
388
+ sameAsShipping,
389
+ onShippingAddressChange,
390
+ onBillingAddressChange,
391
+ onSameAsShippingChange,
392
+ shippingLocations,
393
+ billingLocations,
394
+ onRetryLocations,
395
+ savedAddresses,
396
+ onSelectSavedAddress,
397
+ onCreateSavedAddress,
398
+ onUpdateSavedAddress,
399
+ onDeleteSavedAddress,
400
+ onStartNewAddress,
401
+ onCancelNewAddress,
402
+ savedAddressState,
403
+ shippingGroups,
404
+ shippingState,
205
405
  onSelectShippingOption,
406
+ onRetryShipping,
407
+ labels: resolved,
206
408
  formatMoney,
207
409
  fieldErrors,
208
- fieldDescriptions
410
+ fieldDescriptions,
411
+ requireShippingPhone
209
412
  }
210
413
  );
211
414
  case "payment":
212
415
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
416
  import_checkout_payment_step.CheckoutPaymentStep,
214
417
  {
215
- values,
216
- onChange,
217
- labels: resolved,
218
418
  paymentMethods,
219
- fieldErrors,
220
- fieldDescriptions
419
+ paymentState,
420
+ paymentMethod,
421
+ onSelectPaymentMethod,
422
+ onRetryPayment,
423
+ adjustmentPayments,
424
+ onApplyGiftCard,
425
+ giftCardState,
426
+ giftCardMessage,
427
+ onRemoveAdjustment,
428
+ storeCredit,
429
+ labels: resolved,
430
+ formatMoney,
431
+ fieldErrors: fieldErrors?.paymentMethod,
432
+ description: fieldDescriptions?.paymentMethod
221
433
  }
222
434
  );
223
435
  case "review":
224
436
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
225
437
  import_checkout_review_step.CheckoutReviewStep,
226
438
  {
227
- values,
439
+ contact,
440
+ shippingAddress,
441
+ billingAddress,
442
+ sameAsShipping,
443
+ shippingGroups,
444
+ paymentMethod,
445
+ paymentMethods,
446
+ adjustmentPayments,
447
+ orderSummary,
228
448
  labels: resolved,
229
- selectedShippingOptionId,
230
- shippingOptions,
231
- paymentMethods
449
+ formatMoney
232
450
  }
233
451
  );
234
452
  }
235
453
  };
236
454
  const isLastStep = stepIndex === steps.length - 1;
237
- const submitAction = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { type: "button", onClick: handleSubmit, disabled: submitting, children: [
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Lock, { className: "size-4" }),
239
- submitting ? resolved.processingLabel : resolved.completeOrderLabel
240
- ] });
455
+ const submitAction = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
456
+ import_button.Button,
457
+ {
458
+ type: "button",
459
+ onClick: handleSubmit,
460
+ disabled: submitting || blockedByInterruption,
461
+ "data-checkout-action": "submit",
462
+ children: [
463
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Lock, { className: "size-4" }),
464
+ submitting ? resolved.processingLabel : resolved.completeOrderLabel
465
+ ]
466
+ }
467
+ );
241
468
  const submitErrorNode = submitError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
242
469
  "div",
243
470
  {
@@ -259,6 +486,10 @@ function Checkout({
259
486
  ]
260
487
  }
261
488
  ) : null;
489
+ const validationAlertNode = validationAlert ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "sr-only", role: "alert", children: resolved.validationAttentionLabel.replace(
490
+ "{step}",
491
+ resolved[STEP_COPY[validationAlert.step].name]
492
+ ) }, validationAlert.nonce) : null;
262
493
  const summaryNode = orderSummary ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
263
494
  "div",
264
495
  {
@@ -273,75 +504,268 @@ function Checkout({
273
504
  labels: resolved,
274
505
  totalsState,
275
506
  onRetryTotals,
276
- promoCode: values.promoCode,
277
- onPromoCodeChange: (value) => onChange("promoCode", value),
507
+ promoCode: promoCode ?? "",
508
+ onPromoCodeChange: onPromoCodeChange ?? (() => {
509
+ }),
278
510
  onApplyPromo,
279
511
  promoPending,
512
+ adjustmentPayments,
280
513
  trustNotes,
281
514
  formatMoney
282
515
  }
283
516
  )
284
517
  }
285
518
  ) : null;
286
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto max-w-6xl px-4 py-12 sm:px-6 lg:px-8", children: [
287
- (resolved.title || resolved.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "mb-8 text-center", children: [
288
- resolved.title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-3xl font-bold tracking-tight sm:text-4xl", children: resolved.title }) : null,
289
- resolved.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2 text-muted-foreground", children: resolved.description }) : null
290
- ] }),
291
- presentation === "stepper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
292
- import_checkout_progress.CheckoutProgress,
293
- {
294
- steps: steps.map((step) => ({
295
- id: step,
296
- label: resolved[STEP_COPY[step].name]
297
- })),
298
- currentStep: activeStep,
299
- ariaLabel: resolved.stepProgressLabel
300
- }
301
- ) : null,
302
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("mt-8 grid grid-cols-1 gap-6", orderSummary && "lg:grid-cols-3"), children: [
303
- presentation === "single-page" ? summaryNode : null,
304
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("min-w-0", orderSummary ? "lg:col-span-2" : "lg:col-span-3"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardContent, { className: "p-6", children: [
305
- presentation === "stepper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
306
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-6", children: [
307
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { ref: headingRef, tabIndex: -1, className: "text-lg font-semibold outline-none", children: resolved[STEP_COPY[activeStep].heading] }),
308
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: resolved[STEP_COPY[activeStep].description] })
309
- ] }),
310
- renderStep(activeStep)
311
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-8", children: steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "flex flex-col gap-4", children: [
519
+ if (availability && availability.status !== "available") {
520
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto max-w-3xl px-4 py-12 sm:px-6 lg:px-8", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardContent, { className: "flex flex-col items-center gap-4 p-8 text-center", children: [
521
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-2xl font-semibold", children: resolved.title }),
522
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground", children: availability.reason ?? availabilityLabel(availability.status, resolved) }),
523
+ availability.actionLabel && availability.onAction ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", variant: "outline", onClick: availability.onAction, children: availability.actionLabel }) : null
524
+ ] }) }) });
525
+ }
526
+ if (identityPending || accountGate) {
527
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto max-w-6xl px-4 py-12 sm:px-6 lg:px-8", children: [
528
+ (resolved.title || resolved.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "mb-8 text-center", children: [
529
+ resolved.title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-3xl font-bold tracking-tight sm:text-4xl", children: resolved.title }) : null,
530
+ resolved.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2 text-muted-foreground", children: resolved.description }) : null
531
+ ] }),
532
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("grid grid-cols-1 gap-6", orderSummary && "lg:grid-cols-3"), children: [
533
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.Card, { className: (0, import_utils.cn)("min-w-0", orderSummary ? "lg:col-span-2" : "lg:col-span-3"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.CardContent, { className: "flex flex-col gap-4 p-6", children: identityPending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", "aria-live": "polite", className: "text-muted-foreground", children: resolved.identityPendingLabel }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
312
534
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
313
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold", children: resolved[STEP_COPY[step].heading] }),
314
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: resolved[STEP_COPY[step].description] })
535
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold", children: resolved.accountRequiredHeading }),
536
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: resolved.accountRequiredDescription })
315
537
  ] }),
316
- renderStep(step)
317
- ] }, step)) }),
318
- submitErrorNode,
319
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
320
- "div",
538
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap gap-3", children: [
539
+ onSignIn ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", onClick: onSignIn, "data-checkout-action": "sign-in", children: resolved.signInLabel }) : null,
540
+ onSignUp ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
541
+ import_button.Button,
542
+ {
543
+ type: "button",
544
+ variant: "outline",
545
+ onClick: onSignUp,
546
+ "data-checkout-action": "sign-up",
547
+ children: resolved.signUpLabel
548
+ }
549
+ ) : null
550
+ ] })
551
+ ] }) }) }),
552
+ summaryNode
553
+ ] })
554
+ ] });
555
+ }
556
+ const interruptionNode = interruption ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
557
+ "div",
558
+ {
559
+ role: interruption.severity === "blocking" ? "alert" : "status",
560
+ className: (0, import_utils.cn)(
561
+ "mt-6 flex flex-col gap-3 rounded-md border px-4 py-3 text-sm",
562
+ interruption.severity === "blocking" ? "border-destructive/50 bg-destructive/10 text-destructive" : "border-amber-500/50 bg-amber-500/10"
563
+ ),
564
+ children: [
565
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "font-medium", children: interruption.title }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: interruption.message }),
568
+ interruption.changes?.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "mt-2 list-disc pl-5", children: interruption.changes.map((change, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
569
+ change.label,
570
+ change.previous && change.next ? `: ${change.previous} \u2192 ${change.next}` : null
571
+ ] }, `${change.lineId ?? index}:${change.label}`)) }) : null
572
+ ] }),
573
+ interruption.actions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-wrap gap-2", children: interruption.actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
574
+ import_button.Button,
321
575
  {
322
- className: (0, import_utils.cn)(
323
- "mt-6 flex flex-wrap items-center gap-4",
324
- presentation === "stepper" ? "justify-between" : "justify-end"
325
- ),
326
- children: presentation === "stepper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
327
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
- import_button.Button,
329
- {
330
- type: "button",
331
- variant: "outline",
332
- onClick: handleBack,
333
- disabled: stepIndex === 0 || submitting,
334
- children: resolved.backLabel
335
- }
336
- ),
337
- isLastStep ? submitAction : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", onClick: handleContinue, disabled: submitting, children: resolved.continueLabel })
338
- ] }) : submitAction
576
+ type: "button",
577
+ variant: "outline",
578
+ size: "sm",
579
+ onClick: () => onInterruptionAction?.(action),
580
+ children: actionLabel(action, resolved)
581
+ },
582
+ action
583
+ )) }) : null
584
+ ]
585
+ }
586
+ ) : null;
587
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_checkout_id_context.CheckoutIdProvider, { prefix: checkoutInstanceId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
588
+ "div",
589
+ {
590
+ className: "mx-auto max-w-6xl px-4 py-12 sm:px-6 lg:px-8",
591
+ "data-checkout-presentation": presentation,
592
+ "data-checkout-step": presentation === "stepper" ? activeStep : void 0,
593
+ children: [
594
+ (resolved.title || resolved.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "mb-8 text-center", children: [
595
+ resolved.title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-3xl font-bold tracking-tight sm:text-4xl", children: resolved.title }) : null,
596
+ resolved.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2 text-muted-foreground", children: resolved.description }) : null
597
+ ] }),
598
+ presentation === "stepper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
599
+ import_checkout_progress.CheckoutProgress,
600
+ {
601
+ steps: steps.map((step) => ({
602
+ id: step,
603
+ label: resolved[STEP_COPY[step].name]
604
+ })),
605
+ currentStep: activeStep,
606
+ ariaLabel: resolved.stepProgressLabel
339
607
  }
340
- )
341
- ] }) }) }),
342
- presentation === "stepper" ? summaryNode : null
343
- ] })
344
- ] });
608
+ ) : null,
609
+ presentation === "single-page" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-8", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
610
+ import_checkout_section_nav.CheckoutSectionNav,
611
+ {
612
+ instanceId: checkoutInstanceId,
613
+ steps: steps.map((step) => ({
614
+ id: step,
615
+ label: resolved[STEP_COPY[step].name]
616
+ })),
617
+ ariaLabel: resolved.stepProgressLabel
618
+ }
619
+ ) }) : null,
620
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("mt-8 grid grid-cols-1 gap-6", orderSummary && "lg:grid-cols-3"), children: [
621
+ presentation === "single-page" ? summaryNode : null,
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("min-w-0", orderSummary ? "lg:col-span-2" : "lg:col-span-3"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardContent, { className: "p-6", children: [
623
+ presentation === "stepper" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
624
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-6", children: [
625
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
626
+ "h2",
627
+ {
628
+ id: (0, import_checkout_section_nav.checkoutSectionHeadingId)(checkoutInstanceId, activeStep),
629
+ ref: headingRef,
630
+ tabIndex: -1,
631
+ className: "scroll-mt-24 text-lg font-semibold outline-none",
632
+ children: resolved[STEP_COPY[activeStep].heading]
633
+ }
634
+ ),
635
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: resolved[STEP_COPY[activeStep].description] })
636
+ ] }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-checkout-step": activeStep, children: renderStep(activeStep) })
638
+ ] }) : presentation === "accordion" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
639
+ import_accordion.Accordion,
640
+ {
641
+ type: "single",
642
+ value: activeStep,
643
+ collapsible: false,
644
+ className: "flex flex-col",
645
+ onValueChange: (value) => {
646
+ const nextIndex = steps.indexOf(value);
647
+ if (nextIndex >= 0) moveTo(nextIndex);
648
+ },
649
+ children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
650
+ import_accordion.AccordionItem,
651
+ {
652
+ value: step,
653
+ id: (0, import_checkout_section_nav.checkoutSectionId)(checkoutInstanceId, step),
654
+ "data-checkout-step": step,
655
+ children: [
656
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
657
+ import_accordion.AccordionTrigger,
658
+ {
659
+ id: (0, import_checkout_section_nav.checkoutSectionHeadingId)(checkoutInstanceId, step),
660
+ headingLevel: 2,
661
+ className: "gap-4 py-5 hover:no-underline",
662
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
663
+ import_checkout_step_header.CheckoutStepHeader,
664
+ {
665
+ index,
666
+ heading: resolved[STEP_COPY[step].heading],
667
+ description: resolved[STEP_COPY[step].description],
668
+ headingAs: "span",
669
+ summary: step === activeStep ? void 0 : (0, import_checkout_step_summary.stepSummary)(step, {
670
+ contact,
671
+ shippingAddress,
672
+ shippingGroups,
673
+ paymentMethods,
674
+ paymentMethod
675
+ }),
676
+ errorMessage: (0, import_checkout_step_summary.stepHasErrors)(step, fieldErrors) ? (0, import_checkout_step_summary.stepErrorMessage)(step, fieldErrors) ?? resolved.validationAttentionLabel.replace(
677
+ "{step}",
678
+ resolved[STEP_COPY[step].name]
679
+ ) : void 0
680
+ }
681
+ )
682
+ }
683
+ ),
684
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_accordion.AccordionContent, { className: "pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: renderStep(step) }) })
685
+ ]
686
+ },
687
+ step
688
+ ))
689
+ }
690
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-8", children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
691
+ "section",
692
+ {
693
+ id: (0, import_checkout_section_nav.checkoutSectionId)(checkoutInstanceId, step),
694
+ className: "flex flex-col gap-4 border-t pt-8 first:border-t-0 first:pt-0",
695
+ "data-checkout-step": step,
696
+ children: [
697
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
698
+ import_checkout_step_header.CheckoutStepHeader,
699
+ {
700
+ index,
701
+ heading: resolved[STEP_COPY[step].heading],
702
+ description: resolved[STEP_COPY[step].description],
703
+ headingId: (0, import_checkout_section_nav.checkoutSectionHeadingId)(checkoutInstanceId, step),
704
+ headingTabIndex: -1,
705
+ errorMessage: (0, import_checkout_step_summary.stepHasErrors)(step, fieldErrors) ? (0, import_checkout_step_summary.stepErrorMessage)(step, fieldErrors) ?? resolved.validationAttentionLabel.replace(
706
+ "{step}",
707
+ resolved[STEP_COPY[step].name]
708
+ ) : void 0
709
+ }
710
+ ),
711
+ renderStep(step)
712
+ ]
713
+ },
714
+ step
715
+ )) }),
716
+ interruptionNode,
717
+ submitErrorNode,
718
+ validationAlertNode,
719
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
720
+ "div",
721
+ {
722
+ className: (0, import_utils.cn)(
723
+ "mt-6 flex flex-wrap items-center gap-4",
724
+ presentation === "stepper" || presentation === "accordion" ? "justify-between" : "justify-end"
725
+ ),
726
+ children: presentation === "stepper" || presentation === "accordion" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
727
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
728
+ import_button.Button,
729
+ {
730
+ type: "button",
731
+ variant: "outline",
732
+ onClick: handleBack,
733
+ disabled: stepIndex === 0 || submitting,
734
+ "data-checkout-action": "back",
735
+ children: resolved.backLabel
736
+ }
737
+ ),
738
+ isLastStep ? submitAction : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
739
+ import_button.Button,
740
+ {
741
+ type: "button",
742
+ onClick: handleContinue,
743
+ disabled: submitting || blockedByInterruption,
744
+ "data-checkout-action": "continue",
745
+ children: resolved.continueLabel
746
+ }
747
+ )
748
+ ] }) : submitAction
749
+ }
750
+ )
751
+ ] }) }) }),
752
+ presentation === "stepper" ? summaryNode : null
753
+ ] })
754
+ ]
755
+ }
756
+ ) });
757
+ }
758
+ function actionLabel(action, labels) {
759
+ switch (action) {
760
+ case "acknowledge":
761
+ return labels.interruptionAcknowledgeLabel;
762
+ case "refresh":
763
+ return labels.interruptionRefreshLabel;
764
+ case "return-to-cart":
765
+ return labels.interruptionReturnToCartLabel;
766
+ case "retry":
767
+ return labels.interruptionRetryLabel;
768
+ }
345
769
  }
346
770
  var checkout_default = Checkout;
347
771
  // Annotate the CommonJS export names for ESM import in node: