@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
@@ -1,80 +1,94 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { Field, FieldContent, FieldGroup, FieldLabel } from "../../../ui/field.mjs";
3
+ import { Button } from "../../../ui/button.mjs";
4
+ import { Field, FieldGroup, FieldLabel } from "../../../ui/field.mjs";
4
5
  import { Input } from "../../../ui/input.mjs";
5
- import { CheckboxCheck } from "./checkbox-check.mjs";
6
6
  import { CheckoutFieldFeedback, checkoutFieldAria } from "./checkout-field-feedback.mjs";
7
+ import { useCheckoutIds } from "./checkout-id-context.mjs";
7
8
  function CheckoutContactStep({
8
- values,
9
+ contact,
9
10
  onChange,
11
+ customer,
12
+ onSignIn,
13
+ onSignOut,
14
+ requirePhone = false,
10
15
  labels,
11
- showSaveInfo,
12
- showNewsletter,
13
16
  fieldErrors,
14
17
  fieldDescriptions
15
18
  }) {
19
+ const checkoutId = useCheckoutIds();
20
+ const displayName = [customer?.firstName, customer?.lastName].filter(Boolean).join(" ");
16
21
  return /* @__PURE__ */ jsxs(FieldGroup, { className: "grid grid-cols-1 gap-4", children: [
17
- /* @__PURE__ */ jsxs(Field, { "data-invalid": !!fieldErrors?.email?.length, children: [
18
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-email", children: labels.emailLabel }),
22
+ customer ? /* @__PURE__ */ jsxs("div", { className: "bg-muted/50 flex flex-wrap items-center justify-between gap-3 rounded-lg p-4", children: [
23
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", children: /* @__PURE__ */ jsxs("p", { className: "text-sm font-medium", children: [
24
+ labels.signedInAsLabel,
25
+ " ",
26
+ displayName ? `${displayName} <${customer.email}>` : customer.email
27
+ ] }) }),
28
+ onSignOut ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onSignOut, children: labels.signOutLabel }) : null
29
+ ] }) : /* @__PURE__ */ jsxs(Field, { "data-invalid": !!fieldErrors?.email?.length, children: [
30
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: checkoutId("checkout-email"), children: labels.emailLabel }),
19
31
  /* @__PURE__ */ jsx(
20
32
  Input,
21
33
  {
22
- id: "checkout-email",
34
+ id: checkoutId("checkout-email"),
35
+ "data-checkout-field": "email",
23
36
  type: "email",
24
37
  inputMode: "email",
25
38
  autoComplete: "email",
26
- value: values.email,
39
+ value: contact.email,
27
40
  onChange: (e) => onChange("email", e.target.value),
28
- ...checkoutFieldAria("checkout-email", fieldErrors?.email)
41
+ ...checkoutFieldAria(checkoutId("checkout-email"), fieldErrors?.email)
29
42
  }
30
43
  ),
31
44
  /* @__PURE__ */ jsx(
32
45
  CheckoutFieldFeedback,
33
46
  {
34
- id: "checkout-email",
47
+ id: checkoutId("checkout-email"),
35
48
  errors: fieldErrors?.email,
36
49
  description: fieldDescriptions?.email
37
50
  }
38
- )
51
+ ),
52
+ onSignIn ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", className: "w-fit px-0", onClick: onSignIn, children: labels.signInLabel }) : null
39
53
  ] }),
40
54
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
41
55
  /* @__PURE__ */ jsxs(Field, { "data-invalid": !!fieldErrors?.firstName?.length, children: [
42
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-first-name", children: labels.firstNameLabel }),
56
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: checkoutId("checkout-first-name"), children: labels.firstNameLabel }),
43
57
  /* @__PURE__ */ jsx(
44
58
  Input,
45
59
  {
46
- id: "checkout-first-name",
60
+ id: checkoutId("checkout-first-name"),
47
61
  autoComplete: "given-name",
48
- value: values.firstName,
62
+ value: contact.firstName,
49
63
  onChange: (e) => onChange("firstName", e.target.value),
50
- ...checkoutFieldAria("checkout-first-name", fieldErrors?.firstName)
64
+ ...checkoutFieldAria(checkoutId("checkout-first-name"), fieldErrors?.firstName)
51
65
  }
52
66
  ),
53
67
  /* @__PURE__ */ jsx(
54
68
  CheckoutFieldFeedback,
55
69
  {
56
- id: "checkout-first-name",
70
+ id: checkoutId("checkout-first-name"),
57
71
  errors: fieldErrors?.firstName,
58
72
  description: fieldDescriptions?.firstName
59
73
  }
60
74
  )
61
75
  ] }),
62
76
  /* @__PURE__ */ jsxs(Field, { "data-invalid": !!fieldErrors?.lastName?.length, children: [
63
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-last-name", children: labels.lastNameLabel }),
77
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: checkoutId("checkout-last-name"), children: labels.lastNameLabel }),
64
78
  /* @__PURE__ */ jsx(
65
79
  Input,
66
80
  {
67
- id: "checkout-last-name",
81
+ id: checkoutId("checkout-last-name"),
68
82
  autoComplete: "family-name",
69
- value: values.lastName,
83
+ value: contact.lastName,
70
84
  onChange: (e) => onChange("lastName", e.target.value),
71
- ...checkoutFieldAria("checkout-last-name", fieldErrors?.lastName)
85
+ ...checkoutFieldAria(checkoutId("checkout-last-name"), fieldErrors?.lastName)
72
86
  }
73
87
  ),
74
88
  /* @__PURE__ */ jsx(
75
89
  CheckoutFieldFeedback,
76
90
  {
77
- id: "checkout-last-name",
91
+ id: checkoutId("checkout-last-name"),
78
92
  errors: fieldErrors?.lastName,
79
93
  description: fieldDescriptions?.lastName
80
94
  }
@@ -82,72 +96,36 @@ function CheckoutContactStep({
82
96
  ] })
83
97
  ] }),
84
98
  /* @__PURE__ */ jsxs(Field, { "data-invalid": !!fieldErrors?.phone?.length, children: [
85
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-phone", children: labels.phoneLabel }),
99
+ /* @__PURE__ */ jsxs(FieldLabel, { htmlFor: checkoutId("checkout-phone"), children: [
100
+ labels.phoneLabel,
101
+ !requirePhone ? /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
102
+ " (",
103
+ labels.optionalIndicatorLabel,
104
+ ")"
105
+ ] }) : null
106
+ ] }),
86
107
  /* @__PURE__ */ jsx(
87
108
  Input,
88
109
  {
89
- id: "checkout-phone",
110
+ id: checkoutId("checkout-phone"),
90
111
  type: "tel",
91
112
  inputMode: "tel",
92
113
  autoComplete: "tel",
93
- value: values.phone,
114
+ "aria-required": requirePhone || void 0,
115
+ value: contact.phone,
94
116
  onChange: (e) => onChange("phone", e.target.value),
95
- ...checkoutFieldAria("checkout-phone", fieldErrors?.phone)
117
+ ...checkoutFieldAria(checkoutId("checkout-phone"), fieldErrors?.phone)
96
118
  }
97
119
  ),
98
120
  /* @__PURE__ */ jsx(
99
121
  CheckoutFieldFeedback,
100
122
  {
101
- id: "checkout-phone",
123
+ id: checkoutId("checkout-phone"),
102
124
  errors: fieldErrors?.phone,
103
125
  description: fieldDescriptions?.phone
104
126
  }
105
127
  )
106
- ] }),
107
- showSaveInfo ? /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", className: "gap-2", "data-invalid": !!fieldErrors?.saveInfo?.length, children: [
108
- /* @__PURE__ */ jsx(
109
- CheckboxCheck,
110
- {
111
- id: "checkout-save-info",
112
- checked: values.saveInfo,
113
- onCheckedChange: (checked) => onChange("saveInfo", checked === true),
114
- ...checkoutFieldAria("checkout-save-info", fieldErrors?.saveInfo)
115
- }
116
- ),
117
- /* @__PURE__ */ jsxs(FieldContent, { children: [
118
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-save-info", className: "text-sm font-normal", children: labels.saveInfoLabel }),
119
- /* @__PURE__ */ jsx(
120
- CheckoutFieldFeedback,
121
- {
122
- id: "checkout-save-info",
123
- errors: fieldErrors?.saveInfo,
124
- description: fieldDescriptions?.saveInfo
125
- }
126
- )
127
- ] })
128
- ] }) : null,
129
- showNewsletter ? /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", className: "gap-2", "data-invalid": !!fieldErrors?.newsletter?.length, children: [
130
- /* @__PURE__ */ jsx(
131
- CheckboxCheck,
132
- {
133
- id: "checkout-newsletter",
134
- checked: values.newsletter,
135
- onCheckedChange: (checked) => onChange("newsletter", checked === true),
136
- ...checkoutFieldAria("checkout-newsletter", fieldErrors?.newsletter)
137
- }
138
- ),
139
- /* @__PURE__ */ jsxs(FieldContent, { children: [
140
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-newsletter", className: "text-sm font-normal", children: labels.newsletterLabel }),
141
- /* @__PURE__ */ jsx(
142
- CheckoutFieldFeedback,
143
- {
144
- id: "checkout-newsletter",
145
- errors: fieldErrors?.newsletter,
146
- description: fieldDescriptions?.newsletter
147
- }
148
- )
149
- ] })
150
- ] }) : null
128
+ ] })
151
129
  ] });
152
130
  }
153
131
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-contact-step.tsx"],"sourcesContent":["'use client'\n\nimport { Field, FieldContent, FieldGroup, FieldLabel } from '../../../ui/field'\nimport { Input } from '../../../ui/input'\nimport { CheckboxCheck } from './checkbox-check'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport type {\n CheckoutChangeHandler,\n CheckoutFieldDescriptions,\n CheckoutValuesFieldErrors,\n CheckoutLabels,\n CheckoutValues,\n} from './checkout'\n\nexport interface CheckoutContactStepProps {\n values: CheckoutValues\n onChange: CheckoutChangeHandler\n labels: CheckoutLabels\n /** Rendered only when the host supplies the corresponding label. */\n showSaveInfo: boolean\n showNewsletter: boolean\n fieldErrors?: CheckoutValuesFieldErrors\n fieldDescriptions?: CheckoutFieldDescriptions\n}\n\nexport function CheckoutContactStep({\n values,\n onChange,\n labels,\n showSaveInfo,\n showNewsletter,\n fieldErrors,\n fieldDescriptions,\n}: CheckoutContactStepProps) {\n return (\n <FieldGroup className=\"grid grid-cols-1 gap-4\">\n <Field data-invalid={!!fieldErrors?.email?.length}>\n <FieldLabel htmlFor=\"checkout-email\">{labels.emailLabel}</FieldLabel>\n <Input\n id=\"checkout-email\"\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"email\"\n value={values.email}\n onChange={(e) => onChange('email', e.target.value)}\n {...checkoutFieldAria('checkout-email', fieldErrors?.email)}\n />\n <CheckoutFieldFeedback\n id=\"checkout-email\"\n errors={fieldErrors?.email}\n description={fieldDescriptions?.email}\n />\n </Field>\n\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n <Field data-invalid={!!fieldErrors?.firstName?.length}>\n <FieldLabel htmlFor=\"checkout-first-name\">{labels.firstNameLabel}</FieldLabel>\n <Input\n id=\"checkout-first-name\"\n autoComplete=\"given-name\"\n value={values.firstName}\n onChange={(e) => onChange('firstName', e.target.value)}\n {...checkoutFieldAria('checkout-first-name', fieldErrors?.firstName)}\n />\n <CheckoutFieldFeedback\n id=\"checkout-first-name\"\n errors={fieldErrors?.firstName}\n description={fieldDescriptions?.firstName}\n />\n </Field>\n <Field data-invalid={!!fieldErrors?.lastName?.length}>\n <FieldLabel htmlFor=\"checkout-last-name\">{labels.lastNameLabel}</FieldLabel>\n <Input\n id=\"checkout-last-name\"\n autoComplete=\"family-name\"\n value={values.lastName}\n onChange={(e) => onChange('lastName', e.target.value)}\n {...checkoutFieldAria('checkout-last-name', fieldErrors?.lastName)}\n />\n <CheckoutFieldFeedback\n id=\"checkout-last-name\"\n errors={fieldErrors?.lastName}\n description={fieldDescriptions?.lastName}\n />\n </Field>\n </div>\n\n <Field data-invalid={!!fieldErrors?.phone?.length}>\n <FieldLabel htmlFor=\"checkout-phone\">{labels.phoneLabel}</FieldLabel>\n <Input\n id=\"checkout-phone\"\n type=\"tel\"\n inputMode=\"tel\"\n autoComplete=\"tel\"\n value={values.phone}\n onChange={(e) => onChange('phone', e.target.value)}\n {...checkoutFieldAria('checkout-phone', fieldErrors?.phone)}\n />\n <CheckoutFieldFeedback\n id=\"checkout-phone\"\n errors={fieldErrors?.phone}\n description={fieldDescriptions?.phone}\n />\n </Field>\n\n {showSaveInfo ? (\n <Field orientation=\"horizontal\" className=\"gap-2\" data-invalid={!!fieldErrors?.saveInfo?.length}>\n <CheckboxCheck\n id=\"checkout-save-info\"\n checked={values.saveInfo}\n onCheckedChange={(checked) => onChange('saveInfo', checked === true)}\n {...checkoutFieldAria('checkout-save-info', fieldErrors?.saveInfo)}\n />\n <FieldContent>\n <FieldLabel htmlFor=\"checkout-save-info\" className=\"text-sm font-normal\">\n {labels.saveInfoLabel}\n </FieldLabel>\n <CheckoutFieldFeedback\n id=\"checkout-save-info\"\n errors={fieldErrors?.saveInfo}\n description={fieldDescriptions?.saveInfo}\n />\n </FieldContent>\n </Field>\n ) : null}\n\n {showNewsletter ? (\n <Field orientation=\"horizontal\" className=\"gap-2\" data-invalid={!!fieldErrors?.newsletter?.length}>\n <CheckboxCheck\n id=\"checkout-newsletter\"\n checked={values.newsletter}\n onCheckedChange={(checked) => onChange('newsletter', checked === true)}\n {...checkoutFieldAria('checkout-newsletter', fieldErrors?.newsletter)}\n />\n <FieldContent>\n <FieldLabel htmlFor=\"checkout-newsletter\" className=\"text-sm font-normal\">\n {labels.newsletterLabel}\n </FieldLabel>\n <CheckoutFieldFeedback\n id=\"checkout-newsletter\"\n errors={fieldErrors?.newsletter}\n description={fieldDescriptions?.newsletter}\n />\n </FieldContent>\n </Field>\n ) : null}\n </FieldGroup>\n )\n}\n"],"mappings":";AAoCM,SACE,KADF;AAlCN,SAAS,OAAO,cAAc,YAAY,kBAAkB;AAC5D,SAAS,aAAa;AACtB,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,yBAAyB;AAoBlD,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,SACE,qBAAC,cAA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,SAAQ,gBAAc,CAAC,CAAC,aAAa,YAAY,QACzF;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,IAAG;AAAA,UACH,SAAS,OAAO;AAAA,UAChB,iBAAiB,CAAC,YAAY,SAAS,cAAc,YAAY,IAAI;AAAA,UACpE,GAAG,kBAAkB,uBAAuB,aAAa,UAAU;AAAA;AAAA,MACtE;AAAA,MACA,qBAAC,gBACC;AAAA,4BAAC,cAAW,SAAQ,uBAAsB,WAAU,uBACjD,iBAAO,iBACV;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,QAAQ,aAAa;AAAA,YACrB,aAAa,mBAAmB;AAAA;AAAA,QAClC;AAAA,SACF;AAAA,OACF,IACE;AAAA,KACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-contact-step.tsx"],"sourcesContent":["'use client'\n\nimport { Button } from '../../../ui/button'\nimport { Field, FieldGroup, FieldLabel } from '../../../ui/field'\nimport { Input } from '../../../ui/input'\nimport type { CheckoutContactValues, CheckoutCustomerIdentity } from '@thorprovider/types'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport { useCheckoutIds } from './checkout-id-context'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type {\n CheckoutContactChangeHandler,\n CheckoutLabels,\n} from './checkout'\n\nexport interface CheckoutContactStepProps {\n contact: CheckoutContactValues\n onChange: CheckoutContactChangeHandler\n customer?: CheckoutCustomerIdentity | null\n onSignIn?: () => void\n onSignOut?: () => void\n requirePhone?: boolean\n labels: CheckoutLabels\n fieldErrors?: Partial<Record<keyof CheckoutContactValues, CheckoutFieldError[]>>\n fieldDescriptions?: Partial<Record<keyof CheckoutContactValues, string>>\n}\n\nexport function CheckoutContactStep({\n contact,\n onChange,\n customer,\n onSignIn,\n onSignOut,\n requirePhone = false,\n labels,\n fieldErrors,\n fieldDescriptions,\n}: CheckoutContactStepProps) {\n const checkoutId = useCheckoutIds()\n const displayName = [customer?.firstName, customer?.lastName].filter(Boolean).join(' ')\n\n return (\n <FieldGroup className=\"grid grid-cols-1 gap-4\">\n {customer ? (\n <div className=\"bg-muted/50 flex flex-wrap items-center justify-between gap-3 rounded-lg p-4\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium\">\n {labels.signedInAsLabel}{' '}\n {displayName ? `${displayName} <${customer.email}>` : customer.email}\n </p>\n </div>\n {onSignOut ? (\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={onSignOut}>\n {labels.signOutLabel}\n </Button>\n ) : null}\n </div>\n ) : (\n <Field data-invalid={!!fieldErrors?.email?.length}>\n <FieldLabel htmlFor={checkoutId('checkout-email')}>{labels.emailLabel}</FieldLabel>\n <Input\n id={checkoutId('checkout-email')}\n data-checkout-field=\"email\"\n type=\"email\"\n inputMode=\"email\"\n autoComplete=\"email\"\n value={contact.email}\n onChange={(e) => onChange('email', e.target.value)}\n {...checkoutFieldAria(checkoutId('checkout-email'), fieldErrors?.email)}\n />\n <CheckoutFieldFeedback\n id={checkoutId('checkout-email')}\n errors={fieldErrors?.email}\n description={fieldDescriptions?.email}\n />\n {onSignIn ? (\n <Button type=\"button\" variant=\"link\" size=\"sm\" className=\"w-fit px-0\" onClick={onSignIn}>\n {labels.signInLabel}\n </Button>\n ) : null}\n </Field>\n )}\n\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n <Field data-invalid={!!fieldErrors?.firstName?.length}>\n <FieldLabel htmlFor={checkoutId('checkout-first-name')}>{labels.firstNameLabel}</FieldLabel>\n <Input\n id={checkoutId('checkout-first-name')}\n autoComplete=\"given-name\"\n value={contact.firstName}\n onChange={(e) => onChange('firstName', e.target.value)}\n {...checkoutFieldAria(checkoutId('checkout-first-name'), fieldErrors?.firstName)}\n />\n <CheckoutFieldFeedback\n id={checkoutId('checkout-first-name')}\n errors={fieldErrors?.firstName}\n description={fieldDescriptions?.firstName}\n />\n </Field>\n <Field data-invalid={!!fieldErrors?.lastName?.length}>\n <FieldLabel htmlFor={checkoutId('checkout-last-name')}>{labels.lastNameLabel}</FieldLabel>\n <Input\n id={checkoutId('checkout-last-name')}\n autoComplete=\"family-name\"\n value={contact.lastName}\n onChange={(e) => onChange('lastName', e.target.value)}\n {...checkoutFieldAria(checkoutId('checkout-last-name'), fieldErrors?.lastName)}\n />\n <CheckoutFieldFeedback\n id={checkoutId('checkout-last-name')}\n errors={fieldErrors?.lastName}\n description={fieldDescriptions?.lastName}\n />\n </Field>\n </div>\n\n <Field data-invalid={!!fieldErrors?.phone?.length}>\n <FieldLabel htmlFor={checkoutId('checkout-phone')}>\n {labels.phoneLabel}\n {!requirePhone ? (\n <span className=\"text-muted-foreground\"> ({labels.optionalIndicatorLabel})</span>\n ) : null}\n </FieldLabel>\n <Input\n id={checkoutId('checkout-phone')}\n type=\"tel\"\n inputMode=\"tel\"\n autoComplete=\"tel\"\n aria-required={requirePhone || undefined}\n value={contact.phone}\n onChange={(e) => onChange('phone', e.target.value)}\n {...checkoutFieldAria(checkoutId('checkout-phone'), fieldErrors?.phone)}\n />\n <CheckoutFieldFeedback\n id={checkoutId('checkout-phone')}\n errors={fieldErrors?.phone}\n description={fieldDescriptions?.phone}\n />\n </Field>\n </FieldGroup>\n )\n}\n"],"mappings":";AA4CU,cACE,YADF;AA1CV,SAAS,cAAc;AACvB,SAAS,OAAO,YAAY,kBAAkB;AAC9C,SAAS,aAAa;AAEtB,SAAS,uBAAuB,yBAAyB;AACzD,SAAS,sBAAsB;AAmBxB,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,aAAa,eAAe;AAClC,QAAM,cAAc,CAAC,UAAU,WAAW,UAAU,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAEtF,SACE,qBAAC,cAAW,WAAU,0BACnB;AAA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,KAAK;AAAA,UAChD,GAAG,kBAAkB,WAAW,gBAAgB,GAAG,aAAa,KAAK;AAAA;AAAA,MACxE;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI,WAAW,gBAAgB;AAAA,UAC/B,QAAQ,aAAa;AAAA,UACrB,aAAa,mBAAmB;AAAA;AAAA,MAClC;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-country-field.d.ts","sourceRoot":"","sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEvE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,cAAc,CAAA;IACtB,SAAS,EAAE,qBAAqB,EAAE,CAAA;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EACb,MAAM,EACN,WAAW,GACZ,EAAE,yBAAyB,+BAqB3B"}
1
+ {"version":3,"file":"checkout-country-field.d.ts","sourceRoot":"","sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEvE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,cAAc,CAAA;IACtB,SAAS,EAAE,qBAAqB,EAAE,CAAA;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EACb,MAAM,EACN,WAAW,GACZ,EAAE,yBAAyB,+BAuB3B"}
@@ -26,6 +26,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
26
26
  var import_field = require("../../../ui/field.js");
27
27
  var import_select = require("../../../ui/select.js");
28
28
  var import_checkout_field_feedback = require("./checkout-field-feedback.js");
29
+ var import_checkout_id_context = require("./checkout-id-context.js");
29
30
  function CheckoutCountryField({
30
31
  labels,
31
32
  countries,
@@ -34,13 +35,15 @@ function CheckoutCountryField({
34
35
  errors,
35
36
  description
36
37
  }) {
38
+ const checkoutId = (0, import_checkout_id_context.useCheckoutIds)();
39
+ const countryId = checkoutId("checkout-country");
37
40
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_field.Field, { "data-invalid": !!errors?.length, children: [
38
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_field.FieldLabel, { htmlFor: "checkout-country", children: labels.countryLabel }),
41
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_field.FieldLabel, { htmlFor: countryId, children: labels.countryLabel }),
39
42
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_select.Select, { value, onValueChange, children: [
40
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectTrigger, { id: "checkout-country", ...(0, import_checkout_field_feedback.checkoutFieldAria)("checkout-country", errors), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectValue, { placeholder: labels.countryPlaceholder }) }),
43
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectTrigger, { id: countryId, ...(0, import_checkout_field_feedback.checkoutFieldAria)(countryId, errors), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectValue, { placeholder: labels.countryPlaceholder }) }),
41
44
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectGroup, { children: countries.map((country) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { value: country.value, children: country.label }, country.value)) }) })
42
45
  ] }),
43
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_checkout_field_feedback.CheckoutFieldFeedback, { id: "checkout-country", errors, description })
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_checkout_field_feedback.CheckoutFieldFeedback, { id: countryId, errors, description })
44
47
  ] });
45
48
  }
46
49
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"sourcesContent":["'use client'\n\nimport { Field, FieldLabel } from '../../../ui/field'\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../../../ui/select'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type { CheckoutCountryOption, CheckoutLabels } from './checkout'\n\nexport interface CheckoutCountryFieldProps {\n labels: CheckoutLabels\n countries: CheckoutCountryOption[]\n value: string\n onValueChange: (value: string) => void\n errors?: CheckoutFieldError[]\n description?: string\n}\n\nexport function CheckoutCountryField({\n labels,\n countries,\n value,\n onValueChange,\n errors,\n description,\n}: CheckoutCountryFieldProps) {\n return (\n <Field data-invalid={!!errors?.length}>\n <FieldLabel htmlFor=\"checkout-country\">{labels.countryLabel}</FieldLabel>\n <Select value={value} onValueChange={onValueChange}>\n <SelectTrigger id=\"checkout-country\" {...checkoutFieldAria('checkout-country', errors)}>\n <SelectValue placeholder={labels.countryPlaceholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {countries.map((country) => (\n <SelectItem key={country.value} value={country.value}>\n {country.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n <CheckoutFieldFeedback id=\"checkout-country\" errors={errors} description={description} />\n </Field>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCM;AAhCN,mBAAkC;AAClC,oBAOO;AACP,qCAAyD;AAalD,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,SACE,6CAAC,sBAAM,gBAAc,CAAC,CAAC,QAAQ,QAC7B;AAAA,gDAAC,2BAAW,SAAQ,oBAAoB,iBAAO,cAAa;AAAA,IAC5D,6CAAC,wBAAO,OAAc,eACpB;AAAA,kDAAC,+BAAc,IAAG,oBAAoB,OAAG,kDAAkB,oBAAoB,MAAM,GACnF,sDAAC,6BAAY,aAAa,OAAO,oBAAoB,GACvD;AAAA,MACA,4CAAC,+BACC,sDAAC,6BACE,oBAAU,IAAI,CAAC,YACd,4CAAC,4BAA+B,OAAO,QAAQ,OAC5C,kBAAQ,SADM,QAAQ,KAEzB,CACD,GACH,GACF;AAAA,OACF;AAAA,IACA,4CAAC,wDAAsB,IAAG,oBAAmB,QAAgB,aAA0B;AAAA,KACzF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"sourcesContent":["'use client'\n\nimport { Field, FieldLabel } from '../../../ui/field'\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../../../ui/select'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport { useCheckoutIds } from './checkout-id-context'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type { CheckoutCountryOption, CheckoutLabels } from './checkout'\n\nexport interface CheckoutCountryFieldProps {\n labels: CheckoutLabels\n countries: CheckoutCountryOption[]\n value: string\n onValueChange: (value: string) => void\n errors?: CheckoutFieldError[]\n description?: string\n}\n\nexport function CheckoutCountryField({\n labels,\n countries,\n value,\n onValueChange,\n errors,\n description,\n}: CheckoutCountryFieldProps) {\n const checkoutId = useCheckoutIds()\n const countryId = checkoutId('checkout-country')\n return (\n <Field data-invalid={!!errors?.length}>\n <FieldLabel htmlFor={countryId}>{labels.countryLabel}</FieldLabel>\n <Select value={value} onValueChange={onValueChange}>\n <SelectTrigger id={countryId} {...checkoutFieldAria(countryId, errors)}>\n <SelectValue placeholder={labels.countryPlaceholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {countries.map((country) => (\n <SelectItem key={country.value} value={country.value}>\n {country.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n <CheckoutFieldFeedback id={countryId} errors={errors} description={description} />\n </Field>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCM;AAnCN,mBAAkC;AAClC,oBAOO;AACP,qCAAyD;AACzD,iCAA+B;AAaxB,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,iBAAa,2CAAe;AAClC,QAAM,YAAY,WAAW,kBAAkB;AAC/C,SACE,6CAAC,sBAAM,gBAAc,CAAC,CAAC,QAAQ,QAC7B;AAAA,gDAAC,2BAAW,SAAS,WAAY,iBAAO,cAAa;AAAA,IACrD,6CAAC,wBAAO,OAAc,eACpB;AAAA,kDAAC,+BAAc,IAAI,WAAY,OAAG,kDAAkB,WAAW,MAAM,GACnE,sDAAC,6BAAY,aAAa,OAAO,oBAAoB,GACvD;AAAA,MACA,4CAAC,+BACC,sDAAC,6BACE,oBAAU,IAAI,CAAC,YACd,4CAAC,4BAA+B,OAAO,QAAQ,OAC5C,kBAAQ,SADM,QAAQ,KAEzB,CACD,GACH,GACF;AAAA,OACF;AAAA,IACA,4CAAC,wDAAsB,IAAI,WAAW,QAAgB,aAA0B;AAAA,KAClF;AAEJ;","names":[]}
@@ -10,6 +10,7 @@ import {
10
10
  SelectValue
11
11
  } from "../../../ui/select.mjs";
12
12
  import { CheckoutFieldFeedback, checkoutFieldAria } from "./checkout-field-feedback.mjs";
13
+ import { useCheckoutIds } from "./checkout-id-context.mjs";
13
14
  function CheckoutCountryField({
14
15
  labels,
15
16
  countries,
@@ -18,13 +19,15 @@ function CheckoutCountryField({
18
19
  errors,
19
20
  description
20
21
  }) {
22
+ const checkoutId = useCheckoutIds();
23
+ const countryId = checkoutId("checkout-country");
21
24
  return /* @__PURE__ */ jsxs(Field, { "data-invalid": !!errors?.length, children: [
22
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "checkout-country", children: labels.countryLabel }),
25
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: countryId, children: labels.countryLabel }),
23
26
  /* @__PURE__ */ jsxs(Select, { value, onValueChange, children: [
24
- /* @__PURE__ */ jsx(SelectTrigger, { id: "checkout-country", ...checkoutFieldAria("checkout-country", errors), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: labels.countryPlaceholder }) }),
27
+ /* @__PURE__ */ jsx(SelectTrigger, { id: countryId, ...checkoutFieldAria(countryId, errors), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: labels.countryPlaceholder }) }),
25
28
  /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: countries.map((country) => /* @__PURE__ */ jsx(SelectItem, { value: country.value, children: country.label }, country.value)) }) })
26
29
  ] }),
27
- /* @__PURE__ */ jsx(CheckoutFieldFeedback, { id: "checkout-country", errors, description })
30
+ /* @__PURE__ */ jsx(CheckoutFieldFeedback, { id: countryId, errors, description })
28
31
  ] });
29
32
  }
30
33
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"sourcesContent":["'use client'\n\nimport { Field, FieldLabel } from '../../../ui/field'\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../../../ui/select'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type { CheckoutCountryOption, CheckoutLabels } from './checkout'\n\nexport interface CheckoutCountryFieldProps {\n labels: CheckoutLabels\n countries: CheckoutCountryOption[]\n value: string\n onValueChange: (value: string) => void\n errors?: CheckoutFieldError[]\n description?: string\n}\n\nexport function CheckoutCountryField({\n labels,\n countries,\n value,\n onValueChange,\n errors,\n description,\n}: CheckoutCountryFieldProps) {\n return (\n <Field data-invalid={!!errors?.length}>\n <FieldLabel htmlFor=\"checkout-country\">{labels.countryLabel}</FieldLabel>\n <Select value={value} onValueChange={onValueChange}>\n <SelectTrigger id=\"checkout-country\" {...checkoutFieldAria('checkout-country', errors)}>\n <SelectValue placeholder={labels.countryPlaceholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {countries.map((country) => (\n <SelectItem key={country.value} value={country.value}>\n {country.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n <CheckoutFieldFeedback id=\"checkout-country\" errors={errors} description={description} />\n </Field>\n )\n}\n"],"mappings":";AAkCM,cACA,YADA;AAhCN,SAAS,OAAO,kBAAkB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,yBAAyB;AAalD,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,SACE,qBAAC,SAAM,gBAAc,CAAC,CAAC,QAAQ,QAC7B;AAAA,wBAAC,cAAW,SAAQ,oBAAoB,iBAAO,cAAa;AAAA,IAC5D,qBAAC,UAAO,OAAc,eACpB;AAAA,0BAAC,iBAAc,IAAG,oBAAoB,GAAG,kBAAkB,oBAAoB,MAAM,GACnF,8BAAC,eAAY,aAAa,OAAO,oBAAoB,GACvD;AAAA,MACA,oBAAC,iBACC,8BAAC,eACE,oBAAU,IAAI,CAAC,YACd,oBAAC,cAA+B,OAAO,QAAQ,OAC5C,kBAAQ,SADM,QAAQ,KAEzB,CACD,GACH,GACF;AAAA,OACF;AAAA,IACA,oBAAC,yBAAsB,IAAG,oBAAmB,QAAgB,aAA0B;AAAA,KACzF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-country-field.tsx"],"sourcesContent":["'use client'\n\nimport { Field, FieldLabel } from '../../../ui/field'\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../../../ui/select'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport { useCheckoutIds } from './checkout-id-context'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type { CheckoutCountryOption, CheckoutLabels } from './checkout'\n\nexport interface CheckoutCountryFieldProps {\n labels: CheckoutLabels\n countries: CheckoutCountryOption[]\n value: string\n onValueChange: (value: string) => void\n errors?: CheckoutFieldError[]\n description?: string\n}\n\nexport function CheckoutCountryField({\n labels,\n countries,\n value,\n onValueChange,\n errors,\n description,\n}: CheckoutCountryFieldProps) {\n const checkoutId = useCheckoutIds()\n const countryId = checkoutId('checkout-country')\n return (\n <Field data-invalid={!!errors?.length}>\n <FieldLabel htmlFor={countryId}>{labels.countryLabel}</FieldLabel>\n <Select value={value} onValueChange={onValueChange}>\n <SelectTrigger id={countryId} {...checkoutFieldAria(countryId, errors)}>\n <SelectValue placeholder={labels.countryPlaceholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {countries.map((country) => (\n <SelectItem key={country.value} value={country.value}>\n {country.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n <CheckoutFieldFeedback id={countryId} errors={errors} description={description} />\n </Field>\n )\n}\n"],"mappings":";AAqCM,cACA,YADA;AAnCN,SAAS,OAAO,kBAAkB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,yBAAyB;AACzD,SAAS,sBAAsB;AAaxB,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;AAC5B,QAAM,aAAa,eAAe;AAClC,QAAM,YAAY,WAAW,kBAAkB;AAC/C,SACE,qBAAC,SAAM,gBAAc,CAAC,CAAC,QAAQ,QAC7B;AAAA,wBAAC,cAAW,SAAS,WAAY,iBAAO,cAAa;AAAA,IACrD,qBAAC,UAAO,OAAc,eACpB;AAAA,0BAAC,iBAAc,IAAI,WAAY,GAAG,kBAAkB,WAAW,MAAM,GACnE,8BAAC,eAAY,aAAa,OAAO,oBAAoB,GACvD;AAAA,MACA,oBAAC,iBACC,8BAAC,eACE,oBAAU,IAAI,CAAC,YACd,oBAAC,cAA+B,OAAO,QAAQ,OAC5C,kBAAQ,SADM,QAAQ,KAEzB,CACD,GACH,GACF;AAAA,OACF;AAAA,IACA,oBAAC,yBAAsB,IAAI,WAAW,QAAgB,aAA0B;AAAA,KAClF;AAEJ;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare function CheckoutIdProvider({ prefix, children }: {
3
+ prefix: string;
4
+ children: ReactNode;
5
+ }): import("react").JSX.Element;
6
+ export declare function useCheckoutIds(): (id: string) => string;
7
+ //# sourceMappingURL=checkout-id-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-id-context.d.ts","sourceRoot":"","sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-id-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAI9E,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAE/F;AAED,wBAAgB,cAAc,SAEJ,MAAM,YAC/B"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var checkout_id_context_exports = {};
21
+ __export(checkout_id_context_exports, {
22
+ CheckoutIdProvider: () => CheckoutIdProvider,
23
+ useCheckoutIds: () => useCheckoutIds
24
+ });
25
+ module.exports = __toCommonJS(checkout_id_context_exports);
26
+ var import_jsx_runtime = require("react/jsx-runtime");
27
+ var import_react = require("react");
28
+ const CheckoutIdContext = (0, import_react.createContext)(void 0);
29
+ function CheckoutIdProvider({ prefix, children }) {
30
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckoutIdContext.Provider, { value: prefix, children });
31
+ }
32
+ function useCheckoutIds() {
33
+ const prefix = (0, import_react.useContext)(CheckoutIdContext);
34
+ return (0, import_react.useCallback)((id) => prefix ? `${prefix}-${id}` : id, [prefix]);
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ CheckoutIdProvider,
39
+ useCheckoutIds
40
+ });
41
+ //# sourceMappingURL=checkout-id-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-id-context.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useCallback, useContext, type ReactNode } from 'react'\n\nconst CheckoutIdContext = createContext<string | undefined>(undefined)\n\nexport function CheckoutIdProvider({ prefix, children }: { prefix: string; children: ReactNode }) {\n return <CheckoutIdContext.Provider value={prefix}>{children}</CheckoutIdContext.Provider>\n}\n\nexport function useCheckoutIds() {\n const prefix = useContext(CheckoutIdContext)\n return useCallback((id: string) => (prefix ? `${prefix}-${id}` : id), [prefix])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOS;AALT,mBAAuE;AAEvE,MAAM,wBAAoB,4BAAkC,MAAS;AAE9D,SAAS,mBAAmB,EAAE,QAAQ,SAAS,GAA4C;AAChG,SAAO,4CAAC,kBAAkB,UAAlB,EAA2B,OAAO,QAAS,UAAS;AAC9D;AAEO,SAAS,iBAAiB;AAC/B,QAAM,aAAS,yBAAW,iBAAiB;AAC3C,aAAO,0BAAY,CAAC,OAAgB,SAAS,GAAG,MAAM,IAAI,EAAE,KAAK,IAAK,CAAC,MAAM,CAAC;AAChF;","names":[]}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext } from "react";
4
+ const CheckoutIdContext = createContext(void 0);
5
+ function CheckoutIdProvider({ prefix, children }) {
6
+ return /* @__PURE__ */ jsx(CheckoutIdContext.Provider, { value: prefix, children });
7
+ }
8
+ function useCheckoutIds() {
9
+ const prefix = useContext(CheckoutIdContext);
10
+ return useCallback((id) => prefix ? `${prefix}-${id}` : id, [prefix]);
11
+ }
12
+ export {
13
+ CheckoutIdProvider,
14
+ useCheckoutIds
15
+ };
16
+ //# sourceMappingURL=checkout-id-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-id-context.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useCallback, useContext, type ReactNode } from 'react'\n\nconst CheckoutIdContext = createContext<string | undefined>(undefined)\n\nexport function CheckoutIdProvider({ prefix, children }: { prefix: string; children: ReactNode }) {\n return <CheckoutIdContext.Provider value={prefix}>{children}</CheckoutIdContext.Provider>\n}\n\nexport function useCheckoutIds() {\n const prefix = useContext(CheckoutIdContext)\n return useCallback((id: string) => (prefix ? `${prefix}-${id}` : id), [prefix])\n}\n"],"mappings":";AAOS;AALT,SAAS,eAAe,aAAa,kBAAkC;AAEvE,MAAM,oBAAoB,cAAkC,MAAS;AAE9D,SAAS,mBAAmB,EAAE,QAAQ,SAAS,GAA4C;AAChG,SAAO,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,QAAS,UAAS;AAC9D;AAEO,SAAS,iBAAiB;AAC/B,QAAM,SAAS,WAAW,iBAAiB;AAC3C,SAAO,YAAY,CAAC,OAAgB,SAAS,GAAG,MAAM,IAAI,EAAE,KAAK,IAAK,CAAC,MAAM,CAAC;AAChF;","names":[]}
@@ -0,0 +1,24 @@
1
+ import type { CheckoutAddressOption, CheckoutReadState } from '@thorprovider/types';
2
+ import type { CheckoutFieldError } from './checkout-form-types';
3
+ import type { CheckoutLabels } from './checkout';
4
+ export interface CheckoutLocationSelectProps {
5
+ id: string;
6
+ label: string;
7
+ placeholder: string;
8
+ value: string;
9
+ options: CheckoutAddressOption[];
10
+ state?: CheckoutReadState;
11
+ error?: string;
12
+ disabled?: boolean;
13
+ onChange: (value: string) => void;
14
+ onRetry?: () => void;
15
+ labels: CheckoutLabels;
16
+ errors?: CheckoutFieldError[];
17
+ description?: string;
18
+ }
19
+ /**
20
+ * One country/province/city selector. The block renders the supplied options
21
+ * and states; it never fetches, filters, clears, or cascades them.
22
+ */
23
+ export declare function CheckoutLocationSelect({ id, label, placeholder, value, options, state, error, disabled, onChange, onRetry, labels, errors, description, }: CheckoutLocationSelectProps): import("react").JSX.Element;
24
+ //# sourceMappingURL=checkout-location-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-location-select.d.ts","sourceRoot":"","sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-location-select.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAChC,KAAK,CAAC,EAAE,iBAAiB,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,cAAc,CAAA;IACtB,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,EAAE,EACF,KAAK,EACL,WAAW,EACX,KAAK,EACL,OAAO,EACP,KAAc,EACd,KAAK,EACL,QAAgB,EAChB,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,WAAW,GACZ,EAAE,2BAA2B,+BAgD7B"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var checkout_location_select_exports = {};
21
+ __export(checkout_location_select_exports, {
22
+ CheckoutLocationSelect: () => CheckoutLocationSelect
23
+ });
24
+ module.exports = __toCommonJS(checkout_location_select_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_button = require("../../../ui/button.js");
27
+ var import_field = require("../../../ui/field.js");
28
+ var import_select = require("../../../ui/select.js");
29
+ var import_checkout_field_feedback = require("./checkout-field-feedback.js");
30
+ function CheckoutLocationSelect({
31
+ id,
32
+ label,
33
+ placeholder,
34
+ value,
35
+ options,
36
+ state = "idle",
37
+ error,
38
+ disabled = false,
39
+ onChange,
40
+ onRetry,
41
+ labels,
42
+ errors,
43
+ description
44
+ }) {
45
+ const pending = state === "pending";
46
+ const failed = state === "error";
47
+ const unavailable = state === "unavailable";
48
+ const noOptions = options.length === 0;
49
+ const isDisabled = disabled || pending || failed || unavailable || noOptions;
50
+ const locationErrors = error ? [{ message: error }] : [];
51
+ const allErrors = [...errors ?? [], ...locationErrors];
52
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_field.Field, { "data-invalid": !!allErrors.length, children: [
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_field.FieldLabel, { htmlFor: id, children: label }),
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_select.Select, { value, onValueChange: onChange, disabled: isDisabled, children: [
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectTrigger, { id, "data-checkout-location": id, ...(0, import_checkout_field_feedback.checkoutFieldAria)(id, allErrors), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectValue, { placeholder }) }),
56
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectGroup, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.SelectItem, { value: option.value, children: option.label }, option.value)) }) })
57
+ ] }),
58
+ pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground text-sm", role: "status", children: labels.locationLoadingLabel }) : null,
59
+ unavailable || !pending && !failed && noOptions ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground text-sm", role: "status", children: labels.locationUnavailableLabel }) : null,
60
+ failed && onRetry ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", variant: "outline", size: "sm", className: "w-fit", onClick: onRetry, children: labels.retryLabel }) : null,
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
+ import_checkout_field_feedback.CheckoutFieldFeedback,
63
+ {
64
+ id,
65
+ errors: allErrors,
66
+ description
67
+ }
68
+ )
69
+ ] });
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ CheckoutLocationSelect
74
+ });
75
+ //# sourceMappingURL=checkout-location-select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/blocks/e-commerce/checkout-forms/checkout-location-select.tsx"],"sourcesContent":["'use client'\n\nimport { Button } from '../../../ui/button'\nimport { Field, FieldLabel } from '../../../ui/field'\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '../../../ui/select'\nimport type { CheckoutAddressOption, CheckoutReadState } from '@thorprovider/types'\nimport { CheckoutFieldFeedback, checkoutFieldAria } from './checkout-field-feedback'\nimport type { CheckoutFieldError } from './checkout-form-types'\nimport type { CheckoutLabels } from './checkout'\n\nexport interface CheckoutLocationSelectProps {\n id: string\n label: string\n placeholder: string\n value: string\n options: CheckoutAddressOption[]\n state?: CheckoutReadState\n error?: string\n disabled?: boolean\n onChange: (value: string) => void\n onRetry?: () => void\n labels: CheckoutLabels\n errors?: CheckoutFieldError[]\n description?: string\n}\n\n/**\n * One country/province/city selector. The block renders the supplied options\n * and states; it never fetches, filters, clears, or cascades them.\n */\nexport function CheckoutLocationSelect({\n id,\n label,\n placeholder,\n value,\n options,\n state = 'idle',\n error,\n disabled = false,\n onChange,\n onRetry,\n labels,\n errors,\n description,\n}: CheckoutLocationSelectProps) {\n const pending = state === 'pending'\n const failed = state === 'error'\n const unavailable = state === 'unavailable'\n const noOptions = options.length === 0\n const isDisabled = disabled || pending || failed || unavailable || noOptions\n const locationErrors: CheckoutFieldError[] = error ? [{ message: error }] : []\n const allErrors = [...(errors ?? []), ...locationErrors]\n\n return (\n <Field data-invalid={!!allErrors.length}>\n <FieldLabel htmlFor={id}>{label}</FieldLabel>\n <Select value={value} onValueChange={onChange} disabled={isDisabled}>\n <SelectTrigger id={id} data-checkout-location={id} {...checkoutFieldAria(id, allErrors)}>\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n {pending ? (\n <p className=\"text-muted-foreground text-sm\" role=\"status\">\n {labels.locationLoadingLabel}\n </p>\n ) : null}\n {unavailable || (!pending && !failed && noOptions) ? (\n <p className=\"text-muted-foreground text-sm\" role=\"status\">\n {labels.locationUnavailableLabel}\n </p>\n ) : null}\n {failed && onRetry ? (\n <Button type=\"button\" variant=\"outline\" size=\"sm\" className=\"w-fit\" onClick={onRetry}>\n {labels.retryLabel}\n </Button>\n ) : null}\n <CheckoutFieldFeedback\n id={id}\n errors={allErrors}\n description={description}\n />\n </Field>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8DM;AA5DN,oBAAuB;AACvB,mBAAkC;AAClC,oBAOO;AAEP,qCAAyD;AAwBlD,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgC;AAC9B,QAAM,UAAU,UAAU;AAC1B,QAAM,SAAS,UAAU;AACzB,QAAM,cAAc,UAAU;AAC9B,QAAM,YAAY,QAAQ,WAAW;AACrC,QAAM,aAAa,YAAY,WAAW,UAAU,eAAe;AACnE,QAAM,iBAAuC,QAAQ,CAAC,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC;AAC7E,QAAM,YAAY,CAAC,GAAI,UAAU,CAAC,GAAI,GAAG,cAAc;AAEvD,SACE,6CAAC,sBAAM,gBAAc,CAAC,CAAC,UAAU,QAC/B;AAAA,gDAAC,2BAAW,SAAS,IAAK,iBAAM;AAAA,IAChC,6CAAC,wBAAO,OAAc,eAAe,UAAU,UAAU,YACvD;AAAA,kDAAC,+BAAc,IAAQ,0BAAwB,IAAK,OAAG,kDAAkB,IAAI,SAAS,GACpF,sDAAC,6BAAY,aAA0B,GACzC;AAAA,MACA,4CAAC,+BACC,sDAAC,6BACE,kBAAQ,IAAI,CAAC,WACZ,4CAAC,4BAA8B,OAAO,OAAO,OAC1C,iBAAO,SADO,OAAO,KAExB,CACD,GACH,GACF;AAAA,OACF;AAAA,IACC,UACC,4CAAC,OAAE,WAAU,iCAAgC,MAAK,UAC/C,iBAAO,sBACV,IACE;AAAA,IACH,eAAgB,CAAC,WAAW,CAAC,UAAU,YACtC,4CAAC,OAAE,WAAU,iCAAgC,MAAK,UAC/C,iBAAO,0BACV,IACE;AAAA,IACH,UAAU,UACT,4CAAC,wBAAO,MAAK,UAAS,SAAQ,WAAU,MAAK,MAAK,WAAU,SAAQ,SAAS,SAC1E,iBAAO,YACV,IACE;AAAA,IACJ;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,QAAQ;AAAA,QACR;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Button } from "../../../ui/button.mjs";
4
+ import { Field, FieldLabel } from "../../../ui/field.mjs";
5
+ import {
6
+ Select,
7
+ SelectContent,
8
+ SelectGroup,
9
+ SelectItem,
10
+ SelectTrigger,
11
+ SelectValue
12
+ } from "../../../ui/select.mjs";
13
+ import { CheckoutFieldFeedback, checkoutFieldAria } from "./checkout-field-feedback.mjs";
14
+ function CheckoutLocationSelect({
15
+ id,
16
+ label,
17
+ placeholder,
18
+ value,
19
+ options,
20
+ state = "idle",
21
+ error,
22
+ disabled = false,
23
+ onChange,
24
+ onRetry,
25
+ labels,
26
+ errors,
27
+ description
28
+ }) {
29
+ const pending = state === "pending";
30
+ const failed = state === "error";
31
+ const unavailable = state === "unavailable";
32
+ const noOptions = options.length === 0;
33
+ const isDisabled = disabled || pending || failed || unavailable || noOptions;
34
+ const locationErrors = error ? [{ message: error }] : [];
35
+ const allErrors = [...errors ?? [], ...locationErrors];
36
+ return /* @__PURE__ */ jsxs(Field, { "data-invalid": !!allErrors.length, children: [
37
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: id, children: label }),
38
+ /* @__PURE__ */ jsxs(Select, { value, onValueChange: onChange, disabled: isDisabled, children: [
39
+ /* @__PURE__ */ jsx(SelectTrigger, { id, "data-checkout-location": id, ...checkoutFieldAria(id, allErrors), children: /* @__PURE__ */ jsx(SelectValue, { placeholder }) }),
40
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) }) })
41
+ ] }),
42
+ pending ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", role: "status", children: labels.locationLoadingLabel }) : null,
43
+ unavailable || !pending && !failed && noOptions ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", role: "status", children: labels.locationUnavailableLabel }) : null,
44
+ failed && onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", className: "w-fit", onClick: onRetry, children: labels.retryLabel }) : null,
45
+ /* @__PURE__ */ jsx(
46
+ CheckoutFieldFeedback,
47
+ {
48
+ id,
49
+ errors: allErrors,
50
+ description
51
+ }
52
+ )
53
+ ] });
54
+ }
55
+ export {
56
+ CheckoutLocationSelect
57
+ };
58
+ //# sourceMappingURL=checkout-location-select.mjs.map