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