@vtex/faststore 0.0.10 → 0.0.11

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 (506) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +0 -1
  3. package/dist/actions.json +6 -1
  4. package/dist/catalog.json +789 -1701
  5. package/dist/cli/index.d.ts +66 -28
  6. package/dist/cli/index.js +7371 -512
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/cli/server-runtime.js +41 -60
  9. package/dist/cli/server-runtime.js.map +1 -1
  10. package/dist/client.d.ts +3 -3
  11. package/dist/client.js +2 -2
  12. package/dist/components.d.ts +63 -57
  13. package/dist/components.js +60 -54
  14. package/dist/content-types.json +5785 -754
  15. package/dist/core/dist/define-component.d.ts +1 -1
  16. package/dist/core/dist/define-content-type.d.ts +50 -2
  17. package/dist/core/dist/define-content-type.js +107 -3
  18. package/dist/core/dist/define-content-type.js.map +1 -1
  19. package/dist/core/dist/index.d.ts +2 -2
  20. package/dist/docs/access-code-field.md +1 -1
  21. package/dist/docs/access-code-sign-in.md +126 -77
  22. package/dist/docs/account-address-book.md +210 -95
  23. package/dist/docs/account-menu.md +14 -15
  24. package/dist/docs/account-saved-cards.md +44 -39
  25. package/dist/docs/alert-dialog.md +3 -1
  26. package/dist/docs/avatar.md +4 -2
  27. package/dist/docs/billing-address.md +99 -30
  28. package/dist/docs/binding-switcher.md +5 -2
  29. package/dist/docs/buy-button.md +7 -8
  30. package/dist/docs/card-entry.md +39 -26
  31. package/dist/docs/card-summary.md +18 -8
  32. package/dist/docs/cardholder-document.md +5 -3
  33. package/dist/docs/carousel.md +5 -4
  34. package/dist/docs/cart-destination.md +39 -26
  35. package/dist/docs/cart-item.md +29 -14
  36. package/dist/docs/cart-totalizer.md +7 -5
  37. package/dist/docs/cart.md +135 -41
  38. package/dist/docs/challenge-return.md +135 -0
  39. package/dist/docs/client-preferences-fieldset.md +10 -5
  40. package/dist/docs/client-preferences.md +31 -8
  41. package/dist/docs/client-profile-fieldset.md +20 -6
  42. package/dist/docs/client-profile.md +12 -3
  43. package/dist/docs/copy-text.md +9 -7
  44. package/dist/docs/document-field.md +1 -1
  45. package/dist/docs/email-field.md +2 -1
  46. package/dist/docs/email-identification.md +12 -2
  47. package/dist/docs/footer-copyright.md +4 -2
  48. package/dist/docs/form.md +54 -18
  49. package/dist/docs/free-shipping-progress.md +6 -5
  50. package/dist/docs/identity-edit.md +8 -2
  51. package/dist/docs/identity-summary.md +18 -5
  52. package/dist/docs/installments.md +46 -32
  53. package/dist/docs/my-account-profile.md +16 -11
  54. package/dist/docs/navigation-link.md +5 -3
  55. package/dist/docs/order-cancel.md +3 -1
  56. package/dist/docs/order-delivery-address.md +7 -5
  57. package/dist/docs/order-delivery-group.md +1 -3
  58. package/dist/docs/order-details-back.md +1 -1
  59. package/dist/docs/order-details-header.md +1 -4
  60. package/dist/docs/order-invoice-download.md +60 -0
  61. package/dist/docs/order-list-row.md +1 -1
  62. package/dist/docs/order-list-search.md +13 -20
  63. package/dist/docs/order-list-views.md +11 -17
  64. package/dist/docs/order-list.md +12 -5
  65. package/dist/docs/order-payment.md +9 -7
  66. package/dist/docs/order-placed-date.md +1 -1
  67. package/dist/docs/order-placed-payment-summary.md +28 -15
  68. package/dist/docs/order-placed.md +49 -14
  69. package/dist/docs/order-progress.md +1 -1
  70. package/dist/docs/order-status-badge.md +20 -9
  71. package/dist/docs/order-summary.md +2 -2
  72. package/dist/docs/order-tracking-link.md +58 -0
  73. package/dist/docs/payment-method-badges.md +30 -4
  74. package/dist/docs/payment-methods.md +1 -1
  75. package/dist/docs/payment.md +36 -17
  76. package/dist/docs/phone-field.md +4 -4
  77. package/dist/docs/place-order.md +84 -36
  78. package/dist/docs/postal-code-field.md +3 -1
  79. package/dist/docs/pricing.md +21 -23
  80. package/dist/docs/product-gallery.md +19 -20
  81. package/dist/docs/product-information.md +13 -9
  82. package/dist/docs/product-list.md +7 -6
  83. package/dist/docs/product-shelf.md +0 -1
  84. package/dist/docs/promotion.md +4 -2
  85. package/dist/docs/region.md +23 -15
  86. package/dist/docs/save-card.md +7 -6
  87. package/dist/docs/saved-cards.md +65 -36
  88. package/dist/docs/shipping-address.md +57 -21
  89. package/dist/docs/shipping-simulator.md +53 -15
  90. package/dist/docs/sign-in-disclosure.md +176 -0
  91. package/dist/docs/sign-in-form.md +78 -47
  92. package/dist/docs/sign-in-redirect.md +4 -2
  93. package/dist/docs/sign-in.md +173 -0
  94. package/dist/docs/toast.md +15 -4
  95. package/dist/docs/variant-selector.md +15 -11
  96. package/dist/graphql/types.d.ts +4 -14
  97. package/dist/index.d.ts +2 -2
  98. package/dist/internal/client.d.ts +1 -3
  99. package/dist/internal/client.js +1 -1
  100. package/dist/internal/server.d.ts +7 -4
  101. package/dist/internal/server.js +7 -4
  102. package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +250 -66
  103. package/dist/matter/access-code-sign-in/access-code-sign-in.js +459 -188
  104. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
  105. package/dist/matter/account-address-book/account-address-book-delete.d.ts +78 -40
  106. package/dist/matter/account-address-book/account-address-book-delete.js +86 -50
  107. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -1
  108. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +21 -4
  109. package/dist/matter/account-address-book/account-address-book-deliverability.js +45 -17
  110. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -1
  111. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +74 -19
  112. package/dist/matter/account-address-book/account-address-book-form-parts.js +77 -26
  113. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -1
  114. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +27 -6
  115. package/dist/matter/account-address-book/account-address-book-profile-notice.js +55 -28
  116. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -1
  117. package/dist/matter/account-address-book/account-address-book.d.ts +67 -14
  118. package/dist/matter/account-address-book/account-address-book.js +74 -33
  119. package/dist/matter/account-address-book/account-address-book.js.map +1 -1
  120. package/dist/matter/account-address-book/account-address-country-switch.js +3 -3
  121. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -1
  122. package/dist/matter/account-address-book/account-address-country.d.ts +66 -20
  123. package/dist/matter/account-address-book/account-address-country.js +83 -49
  124. package/dist/matter/account-address-book/account-address-country.js.map +1 -1
  125. package/dist/matter/account-address-book/account-address-form-context.d.ts +8 -4
  126. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -1
  127. package/dist/matter/account-address-book/account-address-form.d.ts +468 -45
  128. package/dist/matter/account-address-book/account-address-form.js +518 -155
  129. package/dist/matter/account-address-book/account-address-form.js.map +1 -1
  130. package/dist/matter/account-address-book/account-address-record.d.ts +27 -6
  131. package/dist/matter/account-address-book/account-address-record.js +32 -17
  132. package/dist/matter/account-address-book/account-address-record.js.map +1 -1
  133. package/dist/matter/account-menu/account-menu.d.ts +34 -17
  134. package/dist/matter/account-menu/account-menu.js +46 -54
  135. package/dist/matter/account-menu/account-menu.js.map +1 -1
  136. package/dist/matter/account-menu-identity/account-menu-identity.js +1 -1
  137. package/dist/matter/account-saved-cards/account-saved-cards.d.ts +108 -28
  138. package/dist/matter/account-saved-cards/account-saved-cards.js +177 -122
  139. package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -1
  140. package/dist/matter/billing-address/billing-address.d.ts +156 -74
  141. package/dist/matter/billing-address/billing-address.js +227 -156
  142. package/dist/matter/billing-address/billing-address.js.map +1 -1
  143. package/dist/matter/breadcrumb/breadcrumb.d.ts +21 -3
  144. package/dist/matter/breadcrumb/breadcrumb.js +24 -9
  145. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  146. package/dist/matter/buy-button/buy-button.d.ts +8 -11
  147. package/dist/matter/buy-button/buy-button.js +10 -19
  148. package/dist/matter/buy-button/buy-button.js.map +1 -1
  149. package/dist/matter/card-entry/card-capture.js +12 -4
  150. package/dist/matter/card-entry/card-capture.js.map +1 -1
  151. package/dist/matter/card-entry/card-entry.d.ts +123 -32
  152. package/dist/matter/card-entry/card-entry.js +348 -221
  153. package/dist/matter/card-entry/card-entry.js.map +1 -1
  154. package/dist/matter/cart/cart-namespace.d.ts +7 -1
  155. package/dist/matter/cart/cart-namespace.js +7 -1
  156. package/dist/matter/cart/cart-namespace.js.map +1 -1
  157. package/dist/matter/cart/cart.d.ts +402 -61
  158. package/dist/matter/cart/cart.js +624 -153
  159. package/dist/matter/cart/cart.js.map +1 -1
  160. package/dist/matter/cart-destination/cart-destination.d.ts +30 -19
  161. package/dist/matter/cart-destination/cart-destination.js +160 -70
  162. package/dist/matter/cart-destination/cart-destination.js.map +1 -1
  163. package/dist/matter/cart-item/cart-item.d.ts +144 -17
  164. package/dist/matter/cart-item/cart-item.js +166 -49
  165. package/dist/matter/cart-item/cart-item.js.map +1 -1
  166. package/dist/matter/cart-item-compositions/cart-item-compositions.js +1 -1
  167. package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -1
  168. package/dist/matter/cart-item-customizations/cart-item-customizations.js +1 -1
  169. package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -1
  170. package/dist/matter/cart-item-discounts/cart-item-discounts.js +1 -1
  171. package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -1
  172. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +1 -1
  173. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -1
  174. package/dist/matter/cart-item-variations/cart-item-variations.js +1 -1
  175. package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -1
  176. package/dist/matter/cart-totalizer/cart-totalizer.d.ts +43 -9
  177. package/dist/matter/cart-totalizer/cart-totalizer.js +46 -17
  178. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
  179. package/dist/matter/challenge-return/challenge-return.d.ts +62 -0
  180. package/dist/matter/challenge-return/challenge-return.js +241 -0
  181. package/dist/matter/challenge-return/challenge-return.js.map +1 -0
  182. package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +86 -17
  183. package/dist/matter/client-preferences/client-preferences-fieldset.js +126 -54
  184. package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -1
  185. package/dist/matter/client-preferences/client-preferences.d.ts +50 -7
  186. package/dist/matter/client-preferences/client-preferences.js +84 -15
  187. package/dist/matter/client-preferences/client-preferences.js.map +1 -1
  188. package/dist/matter/client-profile/client-profile.d.ts +44 -9
  189. package/dist/matter/client-profile/client-profile.js +64 -24
  190. package/dist/matter/client-profile/client-profile.js.map +1 -1
  191. package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -22
  192. package/dist/matter/client-profile-form/client-profile-fieldset.js +161 -73
  193. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  194. package/dist/matter/delivery-options/delivery-options-accordion.d.ts +49 -4
  195. package/dist/matter/delivery-options/delivery-options-accordion.js +67 -14
  196. package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
  197. package/dist/matter/delivery-options/delivery-options-controller.d.ts +69 -9
  198. package/dist/matter/delivery-options/delivery-options-controller.js +80 -14
  199. package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
  200. package/dist/matter/delivery-options/delivery-options.d.ts +37 -2
  201. package/dist/matter/delivery-options/delivery-options.js +75 -12
  202. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  203. package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +1 -0
  204. package/dist/matter/delivery-options/use-delivery-option-selection.js +1 -1
  205. package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -1
  206. package/dist/matter/email-identification/email-identification.d.ts +25 -3
  207. package/dist/matter/email-identification/email-identification.js +49 -12
  208. package/dist/matter/email-identification/email-identification.js.map +1 -1
  209. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +79 -7
  210. package/dist/matter/free-shipping-progress/free-shipping-progress.js +77 -20
  211. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
  212. package/dist/matter/identity-edit/identity-edit.d.ts +52 -10
  213. package/dist/matter/identity-edit/identity-edit.js +47 -19
  214. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  215. package/dist/matter/identity-summary/identity-summary.d.ts +76 -22
  216. package/dist/matter/identity-summary/identity-summary.js +95 -45
  217. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  218. package/dist/matter/installments/installments-select.d.ts +98 -16
  219. package/dist/matter/installments/installments-select.js +156 -48
  220. package/dist/matter/installments/installments-select.js.map +1 -1
  221. package/dist/matter/installments/installments.d.ts +96 -16
  222. package/dist/matter/installments/installments.js +115 -40
  223. package/dist/matter/installments/installments.js.map +1 -1
  224. package/dist/matter/installments/use-installments-selection.d.ts +1 -0
  225. package/dist/matter/installments/use-installments-selection.js +8 -3
  226. package/dist/matter/installments/use-installments-selection.js.map +1 -1
  227. package/dist/matter/my-account-profile/my-account-profile.d.ts +358 -103
  228. package/dist/matter/my-account-profile/my-account-profile.js +370 -174
  229. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  230. package/dist/matter/order-cancel/order-cancel.d.ts +65 -19
  231. package/dist/matter/order-cancel/order-cancel.js +118 -51
  232. package/dist/matter/order-cancel/order-cancel.js.map +1 -1
  233. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +8 -18
  234. package/dist/matter/order-delivery-address/order-delivery-address.js +14 -23
  235. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -1
  236. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +40 -24
  237. package/dist/matter/order-delivery-group/order-delivery-group.js +64 -74
  238. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -1
  239. package/dist/matter/order-details-header/order-details-header.d.ts +32 -15
  240. package/dist/matter/order-details-header/order-details-header.js +66 -58
  241. package/dist/matter/order-details-header/order-details-header.js.map +1 -1
  242. package/dist/matter/order-invoice-download/order-invoice-download.d.ts +78 -0
  243. package/dist/matter/order-invoice-download/order-invoice-download.js +173 -0
  244. package/dist/matter/order-invoice-download/order-invoice-download.js.map +1 -0
  245. package/dist/matter/order-list/order-list.d.ts +164 -19
  246. package/dist/matter/order-list/order-list.js +229 -87
  247. package/dist/matter/order-list/order-list.js.map +1 -1
  248. package/dist/matter/order-list-row/order-list-row.d.ts +6 -1
  249. package/dist/matter/order-list-row/order-list-row.js +3 -2
  250. package/dist/matter/order-list-row/order-list-row.js.map +1 -1
  251. package/dist/matter/order-list-search/order-list-search.d.ts +18 -26
  252. package/dist/matter/order-list-search/order-list-search.js +30 -69
  253. package/dist/matter/order-list-search/order-list-search.js.map +1 -1
  254. package/dist/matter/order-list-views/order-list-views.d.ts +15 -22
  255. package/dist/matter/order-list-views/order-list-views.js +22 -68
  256. package/dist/matter/order-list-views/order-list-views.js.map +1 -1
  257. package/dist/matter/order-payment/order-payment.d.ts +33 -10
  258. package/dist/matter/order-payment/order-payment.js +44 -39
  259. package/dist/matter/order-payment/order-payment.js.map +1 -1
  260. package/dist/matter/order-placed/order-placed-deliveries.d.ts +144 -12
  261. package/dist/matter/order-placed/order-placed-deliveries.js +115 -40
  262. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -1
  263. package/dist/matter/order-placed/order-placed.d.ts +198 -31
  264. package/dist/matter/order-placed/order-placed.js +230 -139
  265. package/dist/matter/order-placed/order-placed.js.map +1 -1
  266. package/dist/matter/order-placed-date/order-placed-date.d.ts +5 -8
  267. package/dist/matter/order-placed-date/order-placed-date.js +7 -8
  268. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -1
  269. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +90 -17
  270. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +93 -117
  271. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  272. package/dist/matter/order-progress/order-progress.d.ts +19 -8
  273. package/dist/matter/order-progress/order-progress.js +37 -45
  274. package/dist/matter/order-progress/order-progress.js.map +1 -1
  275. package/dist/matter/order-summary/order-summary.d.ts +19 -9
  276. package/dist/matter/order-summary/order-summary.js +38 -44
  277. package/dist/matter/order-summary/order-summary.js.map +1 -1
  278. package/dist/matter/order-tracking-link/order-tracking-link.d.ts +43 -0
  279. package/dist/matter/order-tracking-link/order-tracking-link.js +107 -0
  280. package/dist/matter/order-tracking-link/order-tracking-link.js.map +1 -0
  281. package/dist/matter/payment/payment-card-capture.js +17 -10
  282. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  283. package/dist/matter/payment/payment-controller.d.ts +4 -2
  284. package/dist/matter/payment/payment-controller.js +30 -9
  285. package/dist/matter/payment/payment-controller.js.map +1 -1
  286. package/dist/matter/payment/payment-method-badges.js +1 -1
  287. package/dist/matter/payment/payment.d.ts +69 -19
  288. package/dist/matter/payment/payment.js +101 -35
  289. package/dist/matter/payment/payment.js.map +1 -1
  290. package/dist/matter/payment/use-payment-method-selection.d.ts +25 -4
  291. package/dist/matter/payment/use-payment-method-selection.js +94 -32
  292. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  293. package/dist/matter/payment/use-payment-submit-gate.d.ts +14 -3
  294. package/dist/matter/payment/use-payment-submit-gate.js +47 -8
  295. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  296. package/dist/matter/place-order/place-order.d.ts +171 -57
  297. package/dist/matter/place-order/place-order.js +376 -185
  298. package/dist/matter/place-order/place-order.js.map +1 -1
  299. package/dist/matter/pricing/pricing.d.ts +152 -13
  300. package/dist/matter/pricing/pricing.js +153 -52
  301. package/dist/matter/pricing/pricing.js.map +1 -1
  302. package/dist/matter/product-information/product-information.d.ts +27 -4
  303. package/dist/matter/product-information/product-information.js +32 -15
  304. package/dist/matter/product-information/product-information.js.map +1 -1
  305. package/dist/matter/product-list/product-list.d.ts +24 -6
  306. package/dist/matter/product-list/product-list.js +32 -26
  307. package/dist/matter/product-list/product-list.js.map +1 -1
  308. package/dist/matter/product-shelf/product-shelf.d.ts +1 -3
  309. package/dist/matter/product-shelf/product-shelf.js +2 -15
  310. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  311. package/dist/matter/region/region.d.ts +33 -16
  312. package/dist/matter/region/region.js +59 -52
  313. package/dist/matter/region/region.js.map +1 -1
  314. package/dist/matter/save-card/save-card.d.ts +43 -8
  315. package/dist/matter/save-card/save-card.js +61 -23
  316. package/dist/matter/save-card/save-card.js.map +1 -1
  317. package/dist/matter/saved-cards/saved-cards.d.ts +113 -21
  318. package/dist/matter/saved-cards/saved-cards.js +349 -77
  319. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  320. package/dist/matter/shipping-address/address-payload.js +25 -0
  321. package/dist/matter/shipping-address/address-payload.js.map +1 -0
  322. package/dist/matter/shipping-address/country-descriptors.js +71 -71
  323. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  324. package/dist/matter/shipping-address/library-country-descriptors.js +136 -0
  325. package/dist/matter/shipping-address/library-country-descriptors.js.map +1 -0
  326. package/dist/matter/shipping-address/shipping-address.d.ts +312 -45
  327. package/dist/matter/shipping-address/shipping-address.js +443 -188
  328. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  329. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +250 -24
  330. package/dist/matter/shipping-simulator/shipping-simulator.js +257 -51
  331. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  332. package/dist/matter/sign-in/sign-in.d.ts +108 -0
  333. package/dist/matter/sign-in/sign-in.js +285 -0
  334. package/dist/matter/sign-in/sign-in.js.map +1 -0
  335. package/dist/matter/sign-in-disclosure/sign-in-disclosure.d.ts +81 -0
  336. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js +232 -0
  337. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js.map +1 -0
  338. package/dist/matter/sign-in-form/sign-in-form.d.ts +93 -62
  339. package/dist/matter/sign-in-form/sign-in-form.js +134 -144
  340. package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
  341. package/dist/particles/binding-switcher/binding-switcher.d.ts +29 -8
  342. package/dist/particles/binding-switcher/binding-switcher.js +37 -26
  343. package/dist/particles/binding-switcher/binding-switcher.js.map +1 -1
  344. package/dist/particles/card-summary/card-summary.d.ts +38 -8
  345. package/dist/particles/card-summary/card-summary.js +55 -22
  346. package/dist/particles/card-summary/card-summary.js.map +1 -1
  347. package/dist/particles/carousel/carousel.d.ts +99 -11
  348. package/dist/particles/carousel/carousel.js +103 -35
  349. package/dist/particles/carousel/carousel.js.map +1 -1
  350. package/dist/particles/copy-text/copy-text.js +5 -15
  351. package/dist/particles/copy-text/copy-text.js.map +1 -1
  352. package/dist/particles/dialog/dialog.d.ts +14 -6
  353. package/dist/particles/dialog/dialog.js +6 -3
  354. package/dist/particles/dialog/dialog.js.map +1 -1
  355. package/dist/particles/drawer/drawer.js +1 -1
  356. package/dist/particles/drawer/drawer.js.map +1 -1
  357. package/dist/particles/email-field/email-field.d.ts +2 -1
  358. package/dist/particles/email-field/email-field.js +2 -1
  359. package/dist/particles/email-field/email-field.js.map +1 -1
  360. package/dist/particles/footer-link-group/footer-link-group.js +1 -0
  361. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  362. package/dist/particles/form/form.d.ts +85 -13
  363. package/dist/particles/form/form.js +91 -42
  364. package/dist/particles/form/form.js.map +1 -1
  365. package/dist/particles/gallery/gallery.d.ts +129 -12
  366. package/dist/particles/gallery/gallery.js +121 -34
  367. package/dist/particles/gallery/gallery.js.map +1 -1
  368. package/dist/particles/order-details-back/order-details-back.d.ts +5 -3
  369. package/dist/particles/order-details-back/order-details-back.js +8 -10
  370. package/dist/particles/order-details-back/order-details-back.js.map +1 -1
  371. package/dist/particles/order-status-badge/order-status-badge.d.ts +3 -3
  372. package/dist/particles/order-status-badge/order-status-badge.js +4 -20
  373. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -1
  374. package/dist/particles/password-field/password-field.d.ts +1 -1
  375. package/dist/particles/password-field/password-field.js +2 -4
  376. package/dist/particles/password-field/password-field.js.map +1 -1
  377. package/dist/particles/phone-field/phone-field.d.ts +4 -4
  378. package/dist/particles/phone-field/phone-field.js +8 -11
  379. package/dist/particles/phone-field/phone-field.js.map +1 -1
  380. package/dist/particles/spinner/spinner.d.ts +24 -4
  381. package/dist/particles/spinner/spinner.js +25 -9
  382. package/dist/particles/spinner/spinner.js.map +1 -1
  383. package/dist/particles/switch/switch.d.ts +4 -1
  384. package/dist/particles/switch/switch.js +3 -1
  385. package/dist/particles/switch/switch.js.map +1 -1
  386. package/dist/particles/toast/toast.d.ts +29 -3
  387. package/dist/particles/toast/toast.js +34 -10
  388. package/dist/particles/toast/toast.js.map +1 -1
  389. package/dist/schema.graphql +164 -56
  390. package/dist/sdk/address/address-fields.js +4 -4
  391. package/dist/sdk/address/address-fields.js.map +1 -1
  392. package/dist/sdk/address/constants.js +1 -6
  393. package/dist/sdk/address/constants.js.map +1 -1
  394. package/dist/sdk/address/messages.js +44 -44
  395. package/dist/sdk/address/messages.js.map +1 -1
  396. package/dist/sdk/address/postal-code.js +15 -2
  397. package/dist/sdk/address/postal-code.js.map +1 -1
  398. package/dist/sdk/address/types.d.ts +5 -3
  399. package/dist/sdk/address/validate-address.js +3 -3
  400. package/dist/sdk/address/validate-address.js.map +1 -1
  401. package/dist/sdk/analytics/use-analytics-actions.d.ts +1 -1
  402. package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
  403. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  404. package/dist/sdk/data/index.js +2 -2
  405. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  406. package/dist/sdk/generated/gql.js +1 -1
  407. package/dist/sdk/generated/gql.js.map +1 -1
  408. package/dist/sdk/generated/graphql.d.ts +20 -5
  409. package/dist/sdk/generated/graphql.js +6 -0
  410. package/dist/sdk/generated/graphql.js.map +1 -1
  411. package/dist/sdk/i18n/format-error-code.js +23 -0
  412. package/dist/sdk/i18n/format-error-code.js.map +1 -0
  413. package/dist/sdk/i18n/message-formatter.d.ts +22 -0
  414. package/dist/sdk/i18n/message-formatter.js +140 -0
  415. package/dist/sdk/i18n/message-formatter.js.map +1 -0
  416. package/dist/sdk/i18n/use-message-formatter.d.ts +8 -0
  417. package/dist/sdk/i18n/use-message-formatter.js +18 -0
  418. package/dist/sdk/i18n/use-message-formatter.js.map +1 -0
  419. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  420. package/dist/sdk/navigation/redirect.d.ts +2 -0
  421. package/dist/sdk/navigation/redirect.js +19 -1
  422. package/dist/sdk/navigation/redirect.js.map +1 -1
  423. package/dist/sdk/navigation/types.d.ts +13 -0
  424. package/dist/sdk/payment/bin-format.js +20 -0
  425. package/dist/sdk/payment/bin-format.js.map +1 -0
  426. package/dist/sdk/payment/challenge-return.js +37 -0
  427. package/dist/sdk/payment/challenge-return.js.map +1 -0
  428. package/dist/sdk/payment/confirmation-last-four.js +39 -0
  429. package/dist/sdk/payment/confirmation-last-four.js.map +1 -0
  430. package/dist/sdk/payment/gateway.d.ts +1 -1
  431. package/dist/sdk/payment/gateway.js +8 -2
  432. package/dist/sdk/payment/gateway.js.map +1 -1
  433. package/dist/sdk/payment/operations.d.ts +1 -0
  434. package/dist/sdk/payment/operations.js +28 -6
  435. package/dist/sdk/payment/operations.js.map +1 -1
  436. package/dist/sdk/payment/resumed-purchase.d.ts +1 -0
  437. package/dist/sdk/payment/resumed-purchase.js +119 -0
  438. package/dist/sdk/payment/resumed-purchase.js.map +1 -0
  439. package/dist/sdk/payment/security-code-mask.js +16 -23
  440. package/dist/sdk/payment/security-code-mask.js.map +1 -1
  441. package/dist/sdk/payment/submission-registry.js +6 -2
  442. package/dist/sdk/payment/submission-registry.js.map +1 -1
  443. package/dist/sdk/payment/use-payment-actions.d.ts +18 -3
  444. package/dist/sdk/payment/use-payment-actions.js +23 -3
  445. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  446. package/dist/sdk/payment/use-place-order.d.ts +10 -2
  447. package/dist/sdk/payment/use-place-order.js +138 -76
  448. package/dist/sdk/payment/use-place-order.js.map +1 -1
  449. package/dist/sdk/provider/storefront-provider.d.ts +1 -7
  450. package/dist/sdk/provider/storefront-provider.js +4 -11
  451. package/dist/sdk/provider/storefront-provider.js.map +1 -1
  452. package/dist/sdk/seo/entity-landing.d.ts +24 -0
  453. package/dist/sdk/seo/entity-landing.js +30 -0
  454. package/dist/sdk/seo/entity-landing.js.map +1 -0
  455. package/dist/sdk/seo/page-alternates.d.ts +3 -2
  456. package/dist/sdk/seo/page-alternates.js +4 -2
  457. package/dist/sdk/seo/page-alternates.js.map +1 -1
  458. package/dist/sdk/seo/search-landing.d.ts +42 -0
  459. package/dist/sdk/seo/search-landing.js +85 -0
  460. package/dist/sdk/seo/search-landing.js.map +1 -0
  461. package/dist/sdk/session/mock-session.d.ts +9 -0
  462. package/dist/sdk/session/mock-session.js +31 -0
  463. package/dist/sdk/session/mock-session.js.map +1 -0
  464. package/dist/sdk/session/read-server-session.d.ts +3 -0
  465. package/dist/sdk/session/read-server-session.js +5 -0
  466. package/dist/sdk/session/read-server-session.js.map +1 -1
  467. package/dist/sdk/session/return-path-segment.d.ts +10 -0
  468. package/dist/sdk/session/return-path-segment.js +15 -0
  469. package/dist/sdk/session/return-path-segment.js.map +1 -0
  470. package/dist/sdk/session/use-session-actions.js.map +1 -1
  471. package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -1
  472. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  473. package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -1
  474. package/dist/utils/safe-href.d.ts +2 -0
  475. package/package.json +4 -3
  476. package/skills/storefront-asset/SKILL.md +2 -2
  477. package/skills/storefront-asset/references/api-side.md +27 -14
  478. package/skills/storefront-asset/references/findings.md +5 -2
  479. package/src/styles/tailwind.css +8 -0
  480. package/dist/matter/shipping-address/country-descriptors.d.ts +0 -1
  481. package/dist/message-locales.json +0 -7
  482. package/dist/sdk/i18n/client.d.ts +0 -4
  483. package/dist/sdk/i18n/client.js +0 -4
  484. package/dist/sdk/i18n/locales.d.ts +0 -8
  485. package/dist/sdk/i18n/locales.js +0 -57
  486. package/dist/sdk/i18n/locales.js.map +0 -1
  487. package/dist/sdk/i18n/messages/en-US.js +0 -183
  488. package/dist/sdk/i18n/messages/en-US.js.map +0 -1
  489. package/dist/sdk/i18n/messages/en-US.json +0 -178
  490. package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -182
  491. package/dist/sdk/i18n/messages/es-ES.js +0 -183
  492. package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
  493. package/dist/sdk/i18n/messages/es-ES.json +0 -178
  494. package/dist/sdk/i18n/messages/pt-BR.js +0 -183
  495. package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
  496. package/dist/sdk/i18n/messages/pt-BR.json +0 -178
  497. package/dist/sdk/i18n/provider.d.ts +0 -1
  498. package/dist/sdk/i18n/provider.js +0 -30
  499. package/dist/sdk/i18n/provider.js.map +0 -1
  500. package/dist/sdk/i18n/server.d.ts +0 -28
  501. package/dist/sdk/i18n/server.js +0 -59
  502. package/dist/sdk/i18n/server.js.map +0 -1
  503. package/dist/utils/resolve-authored-copy.js +0 -18
  504. package/dist/utils/resolve-authored-copy.js.map +0 -1
  505. package/dist/utils/substitute-template.js +0 -33
  506. package/dist/utils/substitute-template.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"account-address-form.js","names":[],"sources":["../../../src/matter/account-address-book/account-address-form.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { Button } from '../../particles/button/button.js';\nimport {\n Field,\n FieldsetFieldContext,\n TEXT_FIELD_VALUE,\n useBoundField,\n useFieldsetField,\n useFieldsetFieldNames,\n} from '../../particles/field/field.js';\nimport { FormRoot, type FormUserError, useFormRegistry } from '../../particles/form/form.js';\nimport { Select } from '../../particles/select/select.js';\nimport { useToast } from '../../particles/toast/toast.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { addressFields } from '../../sdk/address/address-fields.js';\nimport { ACCOUNT_FIELD_LABELS, ACCOUNT_MAX_LENGTH } from '../../sdk/address/constants.js';\nimport { loadCountryRules } from '../../sdk/address/country-rules.js';\nimport type {\n AddressCreatePayload,\n AddressUpdatePayload,\n CustomerAddressUserError,\n} from '../../sdk/address/operations.js';\nimport { toAddressFieldName } from '../../sdk/address/server-fields.js';\nimport type {\n AddressFieldDescriptor,\n AddressFieldError,\n AddressFieldName,\n CountryRules,\n} from '../../sdk/address/types.js';\nimport { validateAddress } from '../../sdk/address/validate-address.js';\nimport { type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { PageRef } from '../../sdk/navigation/types.js';\nimport { useStorefrontNavigation } from '../../sdk/navigation/use-storefront-navigation.js';\nimport { loggableErrorName } from '../../utils/loggable-error-name.js';\nimport { resolveAuthoredCopy } from '../../utils/resolve-authored-copy.js';\nimport { resolveSiteRelativeHref } from '../../utils/safe-href.js';\nimport { useSession } from '../session/session.js';\nimport { type AccountAddressBookItemSlice, useOptionalAccountAddressBook } from './account-address-book.js';\nimport { AccountAddressCountryNotice, AddressCountryControl } from './account-address-country.js';\nimport {\n type AddressCountryMemory,\n applyCountrySwitch,\n initialAddressCountry,\n} from './account-address-country-switch.js';\nimport {\n type AccountAddressCountryChange,\n AccountAddressFormContext,\n type AccountAddressFormContextValue,\n type AccountAddressFormCountryChoice,\n type AccountAddressFormDraft,\n type AccountAddressFormErrorKind,\n type AccountAddressFormFieldErrors,\n type EditableField,\n useAccountAddressForm,\n} from './account-address-form-context.js';\nimport { dependentsOf, type FilledFields, usePostalCodeAutofill } from './account-address-postal-autofill.js';\nimport { useOptionalAccountAddressRecord } from './account-address-record.js';\n\n/**\n * The form that adds an address and corrects a saved one (specs/sfs-3441-address-book-form.md, RFC\n * REQ-02 and REQ-03). The Root renders `FormRoot` and registers one fieldset with it, under the\n * `accountAddress` namespace: react-hook-form holds the draft and knows what is dirty, and the\n * fieldset owns the field errors, the form-level error, the status message and the save. It holds no\n * country rule: the fields come from `addressFields`, the verdict from `validateAddress`, and the\n * writes go through `$actions.address`.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type AccountAddressFormRootProps = ComponentPropsWithRef<'form'> & {\n /**\n * ISO 3166-1 alpha-3 country a new address prefers: taken when the store ships there or its list\n * is unknown. A blank value falls back to `BRA`.\n */\n defaultCountry?: string;\n /** Toast after an address is added. A blank value falls back to the catalog copy. */\n addedMessage?: string;\n /** Toast after an address is saved. A blank value falls back to the catalog copy. */\n savedMessage?: string;\n /** Announced when a save is blocked. A blank value falls back to the catalog copy. */\n blockedMessage?: string;\n /** Where leaving the form goes when it stands on its own page. A page reference, or a site-relative string. A blank value falls back to the address page. */\n returnHref?: PageRef | string;\n /** Injected by the compiler from `actions: { address: [...] }`; the address write surface. */\n $actions?: ComponentActions;\n};\n\n/** `className` goes on every field's wrapper. */\nexport type AccountAddressFormFieldsProps = Readonly<{ className?: string }>;\n\nexport type AccountAddressFormLabelProps = Readonly<{\n /** The field's label. A blank value falls back to the catalog copy. */\n label?: string;\n className?: string;\n}>;\n\nexport type AccountAddressFormErrorProps = ComponentPropsWithRef<'div'> & {\n /** Each message below falls back to the catalog copy when blank. */\n unrenderedFieldMessage?: string;\n notFoundMessage?: string;\n unauthorizedMessage?: string;\n saveFailedMessage?: string;\n rulesFailedMessage?: string;\n countrySwitchFailedMessage?: string;\n unsupportedCountryMessage?: string;\n};\n\nexport type AccountAddressFormButtonProps = Omit<ComponentPropsWithRef<'button'>, 'type'> & {\n /** The button's text. A blank value falls back to the catalog copy. */\n label?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Constants and helpers\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_COUNTRY = 'BRA';\n\nconst DEFAULT_RETURN_PAGE: PageRef = { standard: 'address' };\n\n/** The react-hook-form namespace every field of the form registers under. */\nconst ADDRESS_NAMESPACE = 'accountAddress';\n\n/** What `dispatch` hands `FormRoot` when it writes nothing because a write or a switch is in flight. */\nconst BUSY: readonly FormUserError[] = [{ code: 'ADDRESS_FORM_BUSY', message: '' }];\n\nconst EDITABLE_FIELDS: readonly EditableField[] = [\n 'recipientName',\n 'street',\n 'number',\n 'complement',\n 'neighborhood',\n 'city',\n 'state',\n 'postalCode',\n 'reference',\n];\n\nconst SERVER_REQUIRED: AddressFieldError = { code: 'required', messageId: 'fs/address.error.required' };\nconst SERVER_INVALID: AddressFieldError = { code: 'invalid', messageId: 'fs/address.error.invalid' };\n\nconst ERROR_MESSAGE_IDS: Readonly<Record<AccountAddressFormErrorKind, MessageId>> = {\n unrenderedField: 'fs/address-form.error.unrendered-field',\n notFound: 'fs/address-form.error.not-found',\n unauthorized: 'fs/address-form.error.unauthorized',\n saveFailed: 'fs/address-form.error.save-failed',\n rulesFailed: 'fs/address-form.error.rules-failed',\n countrySwitchFailed: 'fs/address-form.error.country-switch-failed',\n unsupportedCountry: 'fs/address-form.error.unsupported-country',\n};\n\ntype Status =\n | Readonly<{ kind: 'fields'; count: number }>\n | Readonly<{ kind: 'failed' }>\n | Readonly<{ kind: 'filled'; count: number }>;\n\nfunction toDraft(address: AccountAddressBookItemSlice | null): AccountAddressFormDraft {\n if (!address) return {};\n return Object.fromEntries(EDITABLE_FIELDS.map((field) => [field, address[field] ?? '']));\n}\n\nfunction isBlankDraft(draft: AccountAddressFormDraft): boolean {\n return EDITABLE_FIELDS.every((field) => (draft[field] ?? '').trim() === '');\n}\n\nfunction toCountry(code: string | null | undefined): string {\n return resolveAuthoredCopy(code, DEFAULT_COUNTRY).trim().toUpperCase();\n}\n\n/** A refusal's code decides the message when it names no field on screen; a named field reads as unrendered. */\nfunction toFormError({ code, field }: CustomerAddressUserError): AccountAddressFormErrorKind {\n if (code === 'UNSUPPORTED_COUNTRY') return 'unsupportedCountry';\n if (code === 'NOT_FOUND') return 'notFound';\n if (code === 'UNAUTHORIZED') return 'unauthorized';\n return field === null ? 'saveFailed' : 'unrenderedField';\n}\n\nfunction fieldPath(name: AddressFieldName): string {\n return `${ADDRESS_NAMESPACE}.${name}`;\n}\n\n/** The editable fields react-hook-form holds a value for, out of the namespace's raw values. */\nfunction pickEditable(values: unknown): AccountAddressFormDraft {\n if (typeof values !== 'object' || values === null) return {};\n const raw = values as Record<string, unknown>;\n return Object.fromEntries(\n EDITABLE_FIELDS.flatMap((field) => (typeof raw[field] === 'string' ? [[field, raw[field]]] : [])),\n );\n}\n\nfunction pick(draft: AccountAddressFormDraft, fields: readonly EditableField[]): Record<string, string> {\n return Object.fromEntries(fields.map((field) => [field, draft[field] ?? '']));\n}\n\nfunction changedFields(draft: AccountAddressFormDraft, seedDraft: AccountAddressFormDraft): EditableField[] {\n return EDITABLE_FIELDS.filter((field) => (draft[field] ?? '') !== (seedDraft[field] ?? ''));\n}\n\nfunction typedFields(draft: AccountAddressFormDraft): EditableField[] {\n return EDITABLE_FIELDS.filter((field) => (draft[field] ?? '').trim() !== '');\n}\n\ntype AddressWrite = (payload: Record<string, unknown>) => Promise<readonly CustomerAddressUserError[]>;\n\n/** The write a save sends, or `undefined` when the provider chain never delivered its action. */\nfunction resolveWrite(actions: ComponentActions | undefined, edit: boolean): AddressWrite | undefined {\n if (edit) {\n const update = actions?.address?.update;\n return update ? (payload) => update(payload as AddressUpdatePayload) : undefined;\n }\n const create = actions?.address?.create;\n return create ? (payload) => create(payload as AddressCreatePayload) : undefined;\n}\n\n/** Splits the draft's errors into those a control on screen can show, and a form-level error for any with none. */\nfunction splitByScreen(\n found: AccountAddressFormFieldErrors,\n controls: ReadonlySet<AddressFieldName>,\n): Readonly<{ onScreen: AccountAddressFormFieldErrors; formLevel: AccountAddressFormErrorKind | null }> {\n const onScreen: Partial<Record<AddressFieldName, AddressFieldError>> = {};\n let offScreen = false;\n for (const [name, error] of Object.entries(found) as [AddressFieldName, AddressFieldError][]) {\n if (controls.has(name)) onScreen[name] = error;\n else offScreen = true;\n }\n return { onScreen, formLevel: offScreen ? 'unrenderedField' : null };\n}\n\ntype SuccessTitleInput = Readonly<{\n edited: boolean;\n addedMessage: string | undefined;\n savedMessage: string | undefined;\n intl: ReturnType<typeof useIntl>;\n}>;\n\nfunction successTitle({ edited, addedMessage, savedMessage, intl }: SuccessTitleInput): string {\n if (edited) return resolveAuthoredCopy(savedMessage, intl.formatMessage({ id: 'fs/address-form.saved' }));\n return resolveAuthoredCopy(addedMessage, intl.formatMessage({ id: 'fs/address-form.added' }));\n}\n\nfunction describeStatus(\n status: Status | null,\n blockedMessage: string | undefined,\n intl: ReturnType<typeof useIntl>,\n): string {\n if (status === null) return '';\n if (status.kind === 'filled')\n return intl.formatMessage({ id: 'fs/address-form.status.filled' }, { count: status.count });\n const fallback =\n status.kind === 'fields'\n ? intl.formatMessage({ id: 'fs/address-form.status.fields' }, { count: status.count })\n : intl.formatMessage({ id: 'fs/address-form.status.failed' });\n return resolveAuthoredCopy(blockedMessage, fallback);\n}\n\nfunction focusFirstInvalid(form: HTMLFormElement | null, errors: AccountAddressFormFieldErrors) {\n if (!form) return;\n for (const wrapper of form.querySelectorAll<HTMLElement>('[data-fs-account-address-form-field]')) {\n const name = wrapper.dataset.fsAccountAddressFormField as AddressFieldName | undefined;\n if (name && errors[name]) {\n wrapper.querySelector<HTMLElement>('[data-fs-account-address-form-control]')?.focus();\n return;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\n/** Where the form stands decides its seed: the book's open edit form, then the record the page names, then nothing. */\nfunction useFormPlacement() {\n const book = useOptionalAccountAddressBook();\n const record = useOptionalAccountAddressRecord();\n const openForm = book?.openForm ?? null;\n const seed = (openForm?.mode === 'edit' ? openForm.address : null) ?? record?.address ?? null;\n return { book, record, seed, mode: seed ? ('edit' as const) : ('add' as const) };\n}\n\nexport function AccountAddressFormRoot({\n defaultCountry,\n addedMessage,\n savedMessage,\n blockedMessage,\n returnHref,\n $actions,\n className,\n children,\n ...props\n}: AccountAddressFormRootProps) {\n // Enforces the SessionRoot and ToastProvider ancestors: both hooks throw outside one.\n const { state: sessionState } = useSession();\n useToast();\n const { book, record, mode } = useFormPlacement();\n // Held here because `aria-busy` goes on FormRoot's <form>, which only this component renders.\n const [writing, setWriting] = useState(false);\n const setBookFormPending = book?.setFormPending;\n useEffect(() => {\n setBookFormPending?.(writing);\n return () => setBookFormPending?.(false);\n }, [writing, setBookFormPending]);\n const [switchTarget, setSwitchTarget] = useState<string | null>(null);\n\n if (sessionState !== 'loggedIn') return null;\n // A record that has not delivered its address must not read as \"add\": nothing renders until it does.\n if (!book && record && !record.address) return null;\n\n return (\n <FormRoot\n {...props}\n className={className}\n aria-busy={writing || switchTarget !== null || undefined}\n data-fs-account-address-form=\"\"\n data-fs-account-address-form-mode={mode}\n >\n <AccountAddressFieldset\n defaultCountry={defaultCountry}\n addedMessage={addedMessage}\n savedMessage={savedMessage}\n blockedMessage={blockedMessage}\n returnHref={returnHref}\n $actions={$actions}\n writing={writing}\n setWriting={setWriting}\n switchTarget={switchTarget}\n setSwitchTarget={setSwitchTarget}\n >\n {children ?? (\n <>\n <AddressCountryControl />\n <AccountAddressCountryNotice />\n <AccountAddressFormRecipientName />\n <AccountAddressFormFields />\n <AccountAddressFormReference />\n <AccountAddressFormError />\n <AccountAddressFormSubmit />\n <AccountAddressFormCancel />\n </>\n )}\n </AccountAddressFieldset>\n </FormRoot>\n );\n}\n\ntype AccountAddressFieldsetProps = Readonly<{\n defaultCountry?: string;\n addedMessage?: string;\n savedMessage?: string;\n blockedMessage?: string;\n returnHref?: PageRef | string;\n $actions?: ComponentActions;\n writing: boolean;\n setWriting: (writing: boolean) => void;\n switchTarget: string | null;\n setSwitchTarget: (target: string | null) => void;\n children: ReactNode;\n}>;\n\n/**\n * The form's one fieldset under its FormRoot. It reads and writes the draft through react-hook-form,\n * and owns the rules, the errors, the country switch, the postal-code fill and the write.\n */\nfunction AccountAddressFieldset({\n defaultCountry,\n addedMessage,\n savedMessage,\n blockedMessage,\n returnHref,\n $actions: $actionsProp,\n writing,\n setWriting,\n switchTarget,\n setSwitchTarget,\n children,\n}: AccountAddressFieldsetProps) {\n const { registerFieldset } = useFormRegistry();\n const { getValues, setValue, subscribe } = useFormContext();\n const toast = useToast();\n const intl = useIntl();\n const $actions = useActionsOverride($actionsProp);\n const { push } = useStorefrontNavigation();\n const { book, seed, mode } = useFormPlacement();\n const preferredCountry = toCountry(seed?.country ?? defaultCountry);\n const seedDraft = useMemo(() => toDraft(seed), [seed]);\n const close = book?.close;\n\n const [offered, setOffered] = useState<readonly string[] | null | undefined>(undefined);\n const [chosenCountry, setChosenCountry] = useState<string | null>(null);\n const [lastChange, setLastChange] = useState<AccountAddressCountryChange | null>(null);\n const [rules, setRules] = useState<CountryRules | null>(null);\n const [fieldErrors, setFieldErrors] = useState<AccountAddressFormFieldErrors>({});\n const [formError, setFormError] = useState<AccountAddressFormErrorKind | null>(null);\n const [status, setStatus] = useState<Status | null>(null);\n const pendingRef = useRef(false);\n // A save outlives the form that sent it when the shopper opens another address meanwhile. Only a\n // form that is still mounted may close the book's open form once the save settles.\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n const dispatched = useRef(false);\n const statusRef = useRef<HTMLOutputElement>(null);\n const offers = useRef(0);\n const switchedRef = useRef(false);\n const switchToken = useRef(0);\n const asideRef = useRef<AddressCountryMemory>({});\n\n const { registry, getFieldNames } = useFieldsetFieldNames(ADDRESS_NAMESPACE);\n const watched = useWatch({ name: ADDRESS_NAMESPACE });\n // A field with no control never reaches react-hook-form, so the seed fills what it does not hold.\n const draft = useMemo<AccountAddressFormDraft>(\n () => ({ ...seedDraft, ...pickEditable(watched) }),\n [seedDraft, watched],\n );\n\n // A new address has no country until the control's list resolves it, so only its chunk loads.\n const country = mode === 'edit' ? preferredCountry : (chosenCountry ?? '');\n const latest = useRef({ mode, country, rules, seedDraft });\n useLayoutEffect(() => {\n latest.current = { mode, country, rules, seedDraft };\n });\n\n /** The draft as react-hook-form holds it now, not as the last render saw it. */\n const readDraft = useCallback(\n (): AccountAddressFormDraft => ({ ...latest.current.seedDraft, ...pickEditable(getValues(ADDRESS_NAMESPACE)) }),\n [getValues],\n );\n\n /** Writes each field whose value changes. The country switch and the postal-code fill both write through here. */\n const writeDraft = useCallback(\n (values: AccountAddressFormDraft) => {\n const current = readDraft();\n for (const [name, value] of Object.entries(values) as [EditableField, string][]) {\n if ((current[name] ?? '') !== value) setValue(fieldPath(name), value, { shouldDirty: true });\n }\n },\n [readDraft, setValue],\n );\n\n const mountedFields = useCallback(\n () => new Set(getFieldNames().map((name) => name.slice(ADDRESS_NAMESPACE.length + 1) as AddressFieldName)),\n [getFieldNames],\n );\n\n /**\n * Loads `next`'s rules and applies the switch to the draft as it is then; only the latest call applies.\n * A `silent` switch is one the shopper did not ask for, so its failure shows no error.\n */\n const startSwitch = useCallback(\n (next: string, silent = false) => {\n const to = toCountry(next);\n if (latest.current.mode !== 'add') return;\n const token = ++switchToken.current;\n if (to === latest.current.country) {\n setSwitchTarget(null);\n return;\n }\n setSwitchTarget(to);\n loadCountryRules(to).then(\n (toRules) => {\n if (token !== switchToken.current) return;\n const { rules: fromRules } = latest.current;\n if (fromRules) {\n const result = applyCountrySwitch({\n draft: readDraft(),\n aside: asideRef.current,\n from: fromRules,\n to: toRules,\n });\n asideRef.current = result.aside;\n // Every editable field, so react-hook-form keeps no value the new country did not take.\n writeDraft(Object.fromEntries(EDITABLE_FIELDS.map((field) => [field, result.draft[field] ?? ''])));\n setLastChange(result.change);\n }\n setRules(toRules);\n setChosenCountry(to);\n setSwitchTarget(null);\n setFieldErrors({});\n setFormError(null);\n setStatus(null);\n },\n () => {\n if (token !== switchToken.current) return;\n setSwitchTarget(null);\n if (!silent) setFormError('countrySwitchFailed');\n },\n );\n },\n [readDraft, writeDraft, setSwitchTarget],\n );\n\n useEffect(\n () => () => {\n switchToken.current += 1;\n },\n [],\n );\n\n const change = useCallback(\n (to: string) => {\n if (pendingRef.current) return;\n switchedRef.current = true;\n startSwitch(to);\n },\n [startSwitch],\n );\n\n const offer = useCallback((countries: readonly string[] | null) => {\n offers.current += 1;\n setOffered(countries);\n return () => {\n offers.current -= 1;\n if (offers.current === 0) setOffered(undefined);\n };\n }, []);\n\n // The control's effect runs before this one, so a list it reports is in by the next render. With no\n // control, the preferred country applies. A later list moves the country only while the shopper has\n // neither switched nor typed, and silently.\n useEffect(() => {\n if (mode !== 'add') return;\n if (offered === undefined) {\n if (offers.current === 0) setChosenCountry((current) => current ?? preferredCountry);\n return;\n }\n const initial = initialAddressCountry(offered, preferredCountry);\n if (chosenCountry === null) setChosenCountry(initial);\n else if (!switchedRef.current && initial !== chosenCountry && isBlankDraft(readDraft())) {\n startSwitch(initial, true);\n }\n }, [mode, offered, preferredCountry, chosenCountry, startSwitch, readDraft]);\n\n // The rules load once the country is known. A failed load is not remembered by `loadCountryRules`,\n // so opening the form again retries it. An edit shows the saved address's gaps as soon as it can.\n useEffect(() => {\n if (!country) return;\n let current = true;\n loadCountryRules(country).then(\n (loaded) => {\n if (!current) return;\n setRules(loaded);\n if (seed) setFieldErrors(validateAddress(seedDraft, loaded));\n },\n () => {\n if (current) setFormError('rulesFailed');\n },\n );\n return () => {\n current = false;\n };\n }, [country, seed, seedDraft]);\n\n const registerField = useCallback(\n (name: AddressFieldName) => registry.registerFieldName(fieldPath(name)),\n [registry],\n );\n\n const applyFill = useCallback(\n (filled: FilledFields) => {\n writeDraft(filled);\n setFieldErrors((previous) => {\n const next = Object.fromEntries(Object.entries(previous).filter(([name]) => !(name in filled)));\n return Object.keys(next).length === Object.keys(previous).length ? previous : next;\n });\n const count = Object.values(filled).filter((value) => value !== '').length;\n if (count > 0) setStatus({ kind: 'filled', count });\n },\n [writeDraft],\n );\n\n const autofill = usePostalCodeAutofill({ country, rules, draft, onFill: applyFill });\n const { fieldChanged, postalCodeChanged } = autofill;\n\n const setField = useCallback(\n (name: EditableField, value: string) => {\n fieldChanged(name);\n if (name === 'postalCode') postalCodeChanged(value);\n setValue(fieldPath(name), value, { shouldDirty: true });\n setFieldErrors((previous) => {\n if (!previous[name]) return previous;\n const { [name]: _cleared, ...rest } = previous;\n return rest;\n });\n setFormError((previous) => (previous === 'rulesFailed' ? previous : null));\n setStatus(null);\n },\n [fieldChanged, postalCodeChanged, setValue],\n );\n\n const destination = typeof returnHref === 'string' && returnHref.trim().length === 0 ? undefined : returnHref;\n\n // Under a book, leaving closes the form in place. On its own page there is nothing to close, so it\n // goes back to the list. A refused destination stays put: the save already happened.\n const closeForm = useCallback(() => {\n if (book) {\n close?.();\n return;\n }\n if (destination === undefined) {\n push(DEFAULT_RETURN_PAGE);\n } else if (typeof destination === 'string') {\n const target = resolveSiteRelativeHref(destination);\n if (target.safe) {\n push(target.href);\n } else {\n console.warn(`[AccountAddressFormRoot] returnHref refused (${target.reason}): ${destination}`);\n }\n } else {\n push(destination);\n }\n }, [book, close, destination, push]);\n\n function block(errors: AccountAddressFormFieldErrors, formLevel: AccountAddressFormErrorKind | null): Status {\n const count = Object.keys(errors).length;\n const blocked: Status = count > 0 ? { kind: 'fields', count } : { kind: 'failed' };\n setFieldErrors(errors);\n setFormError(formLevel);\n setStatus(blocked);\n focusFirstInvalid(statusRef.current?.closest('form') ?? null, errors);\n return blocked;\n }\n\n /** Blocks on the draft's errors and returns what `dispatch` hands `FormRoot`, or `null` when the draft passes. */\n function blockInvalid(current: AccountAddressFormDraft, currentRules: CountryRules): FormUserError[] | null {\n const { onScreen, formLevel } = splitByScreen(validateAddress(current, currentRules), mountedFields());\n if (formLevel === null && Object.keys(onScreen).length === 0) return null;\n const blocked = block(onScreen, formLevel);\n return [{ code: 'ADDRESS_FORM_BLOCKED', message: describeStatus(blocked, blockedMessage, intl) }];\n }\n\n /** Puts each refusal on the field it names, and the rest on the form: a save never fails silently. */\n function refuse(userErrors: readonly CustomerAddressUserError[]) {\n const errors: Partial<Record<AddressFieldName, AddressFieldError>> = {};\n const controls = mountedFields();\n let formLevel: AccountAddressFormErrorKind | null = null;\n\n for (const userError of userErrors) {\n const name = toAddressFieldName(userError.field);\n const onField = userError.code !== 'NOT_FOUND' && userError.code !== 'UNSUPPORTED_COUNTRY';\n if (name && controls.has(name) && onField) {\n errors[name] ??= userError.code === 'MISSING_REQUIRED_FIELD' ? SERVER_REQUIRED : SERVER_INVALID;\n } else {\n formLevel ??= toFormError(userError);\n }\n }\n block(errors, formLevel);\n }\n\n function toPayload(values: Record<string, unknown>): Record<string, unknown> {\n const current = { ...seedDraft, ...pickEditable(values) };\n if (seed) return { id: seed.id, ...pick(current, changedFields(current, seedDraft)) };\n return { country, ...pick(current, typedFields(current)) };\n }\n\n /** The form's only path to a write: FormRoot calls it when a mounted field is dirty, `settleUnsent` otherwise. */\n async function dispatch(payload: Record<string, unknown>): Promise<readonly FormUserError[]> {\n if (!rules || pendingRef.current || switchTarget !== null) return BUSY;\n\n const current = readDraft();\n const blocked = blockInvalid(current, rules);\n if (blocked) return blocked;\n if (seed && changedFields(current, seedDraft).length === 0) {\n setFieldErrors({});\n closeForm();\n return [];\n }\n\n setFieldErrors({});\n setFormError(null);\n setStatus(null);\n\n const write = resolveWrite($actions, seed !== null);\n if (!write) {\n // A composition gap (the provider chain never delivered the action) is otherwise a dead button.\n block({}, 'saveFailed');\n throw new Error('AccountAddressFormRoot requires $actions.address.');\n }\n\n pendingRef.current = true;\n setWriting(true);\n try {\n const userErrors = await write(payload);\n if (userErrors.length > 0) {\n refuse(userErrors);\n return userErrors;\n }\n toast.add({ title: successTitle({ edited: seed !== null, addedMessage, savedMessage, intl }), type: 'success' });\n if (mountedRef.current) closeForm();\n return [];\n } catch (error) {\n // Log only the error name: a message can echo a typed address.\n console.error('[AccountAddressFormRoot] address write failed', loggableErrorName(error));\n block({}, 'saveFailed');\n throw error;\n } finally {\n pendingRef.current = false;\n setWriting(false);\n }\n }\n\n /**\n * A submit FormRoot settled without calling `dispatch`, because no mounted field is dirty. The draft\n * can still differ from what was saved: a value written before its control mounted is that control's\n * dirty baseline. So the save takes the same path, which writes only what changed.\n */\n function settleUnsent() {\n // `dispatch` has already put a failed write on the form.\n dispatch(toPayload(getValues(ADDRESS_NAMESPACE) ?? {})).catch(() => undefined);\n }\n\n const handlers = useRef({ toPayload, dispatch, settleUnsent });\n useLayoutEffect(() => {\n handlers.current = { toPayload, dispatch, settleUnsent };\n });\n\n useEffect(\n () =>\n registerFieldset({\n namespace: ADDRESS_NAMESPACE,\n getFieldNames,\n toPayload: (values) => handlers.current.toPayload(values),\n dispatch: (payload) => {\n dispatched.current = true;\n return handlers.current.dispatch(payload);\n },\n label: 'account-address',\n }),\n [registerFieldset, getFieldNames],\n );\n\n // FormRoot skips a fieldset with nothing dirty and says nothing; the end of the submit is the only sign.\n useEffect(() => {\n let seen = 0;\n return subscribe({\n formState: { submitCount: true },\n callback: ({ submitCount = 0 }) => {\n if (submitCount === seen) return;\n seen = submitCount;\n if (dispatched.current) dispatched.current = false;\n else handlers.current.settleUnsent();\n },\n });\n }, [subscribe]);\n\n const selected = switchTarget ?? country;\n const countryChoice = useMemo<AccountAddressFormCountryChoice>(\n () => ({ offer, selected, change, lastChange }),\n [offer, selected, change, lastChange],\n );\n\n const value = useMemo<AccountAddressFormContextValue>(\n () => ({\n mode,\n country,\n rules,\n draft,\n fieldErrors,\n formError,\n pending: writing,\n setField,\n registerField,\n close: closeForm,\n countryChoice,\n }),\n [mode, country, rules, draft, fieldErrors, formError, writing, setField, registerField, closeForm, countryChoice],\n );\n\n return (\n <FieldsetFieldContext value={registry}>\n <AccountAddressFormContext value={value}>\n {children}\n <output\n ref={statusRef}\n aria-live=\"polite\"\n data-fs-account-address-form-status=\"\"\n data-fs-sr-only=\"\"\n className=\"sr-only\"\n >\n {describeStatus(status, blockedMessage, intl)}\n </output>\n </AccountAddressFormContext>\n </FieldsetFieldContext>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Fields\n// ---------------------------------------------------------------------------\n\nfunction fieldErrorText(error: AddressFieldError, intl: ReturnType<typeof useIntl>): string {\n return intl.formatMessage({ id: error.messageId }, error.values);\n}\n\n/** Registers the field with the form while it is on screen and returns its value. */\nfunction useAddressFieldValue(name: EditableField): string {\n const { draft } = useAccountAddressForm();\n const { getValues } = useFormContext();\n const path = useFieldsetField(ADDRESS_NAMESPACE, name);\n // Adopting a seed resets the field to it, so the seed is what the field holds when it mounts: a\n // control that first mounts after a country switch keeps the value the switch carried.\n const [seed] = useState(() => {\n const live: unknown = getValues(path);\n return typeof live === 'string' ? live : (draft[name] ?? '');\n });\n return useBoundField({ name: path, defaultValue: seed }, TEXT_FIELD_VALUE).value;\n}\n\n/** Sets a list's option and empties the fields that read their options from it. The form's only dependent reset. */\nfunction chooseOption(\n setField: AccountAddressFormContextValue['setField'],\n name: EditableField,\n value: string,\n descriptors: readonly AddressFieldDescriptor[],\n) {\n setField(name, value);\n for (const dependent of dependentsOf(name, descriptors)) setField(dependent, '');\n}\n\ntype TextFieldProps = Readonly<{\n name: EditableField;\n label: string;\n maxLength: number;\n inputMode?: AddressFieldDescriptor['inputMode'];\n placeholder?: string;\n className?: string;\n}>;\n\nfunction AddressTextField({ name, label, maxLength, inputMode, placeholder, className }: TextFieldProps) {\n const { fieldErrors, setField } = useAccountAddressForm();\n const value = useAddressFieldValue(name);\n const intl = useIntl();\n const error = fieldErrors[name];\n\n return (\n <Field.Root className={className} invalid={!!error} data-fs-account-address-form-field={name}>\n <Field.Label>{label}</Field.Label>\n <Field.Control\n value={value}\n onChange={(event) => setField(name, event.target.value)}\n maxLength={maxLength}\n inputMode={inputMode}\n placeholder={placeholder}\n data-fs-account-address-form-control=\"\"\n />\n {error ? <Field.Error match>{fieldErrorText(error, intl)}</Field.Error> : null}\n </Field.Root>\n );\n}\n\ntype SelectFieldProps = Readonly<{\n name: EditableField;\n label: string;\n options: readonly Readonly<{ value: string; label: string }>[];\n placeholder?: string;\n className?: string;\n /** Called after the value changes, with the new value, so fields that depend on it can reset. */\n onChange: (value: string) => void;\n}>;\n\nfunction AddressSelectField({ name, label, options, placeholder, className, onChange }: SelectFieldProps) {\n const { fieldErrors } = useAccountAddressForm();\n const value = useAddressFieldValue(name);\n const intl = useIntl();\n const errorId = useId();\n const error = fieldErrors[name];\n\n return (\n <div className={className} data-fs-account-address-form-field={name} {...(error ? { 'data-invalid': '' } : {})}>\n <Select.Root value={value} onValueChange={(next) => onChange(next ?? '')}>\n <Select.Label>{label}</Select.Label>\n <Select.Trigger\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? errorId : undefined}\n data-fs-account-address-form-control=\"\"\n >\n <Select.Value placeholder={placeholder}>\n {(value) => options.find((option) => option.value === value)?.label ?? placeholder}\n </Select.Value>\n <Select.Icon />\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n <Select.List>\n {options.map((option) => (\n <Select.Item key={option.value} value={option.value} label={option.label}>\n <Select.ItemText>{option.label}</Select.ItemText>\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n {error ? (\n <p id={errorId} data-fs-account-address-form-field-error=\"\">\n {fieldErrorText(error, intl)}\n </p>\n ) : null}\n </div>\n );\n}\n\nexport function AccountAddressFormRecipientName({ label, className }: AccountAddressFormLabelProps) {\n const { rules } = useAccountAddressForm();\n const intl = useIntl();\n\n if (!rules) return null;\n\n return (\n <AddressTextField\n name=\"recipientName\"\n label={resolveAuthoredCopy(label, intl.formatMessage({ id: ACCOUNT_FIELD_LABELS.recipientName }))}\n maxLength={ACCOUNT_MAX_LENGTH.recipientName}\n className={className}\n />\n );\n}\n\nexport function AccountAddressFormReference({ label, className }: AccountAddressFormLabelProps) {\n const { rules } = useAccountAddressForm();\n const intl = useIntl();\n\n if (!rules) return null;\n\n return (\n <AddressTextField\n name=\"reference\"\n label={resolveAuthoredCopy(label, intl.formatMessage({ id: ACCOUNT_FIELD_LABELS.reference }))}\n maxLength={ACCOUNT_MAX_LENGTH.reference}\n className={className}\n />\n );\n}\n\n/**\n * One field per descriptor the country's rules give for the draft, in the order the country's form lists them.\n * A complete postal code fills the empty state, city, neighborhood and street the shopper has not typed;\n * the fill is announced once.\n */\nexport function AccountAddressFormFields({ className }: AccountAddressFormFieldsProps) {\n const { rules, draft, setField } = useAccountAddressForm();\n const intl = useIntl();\n\n if (!rules) return null;\n\n const descriptors = addressFields(rules, draft);\n\n return descriptors.map((descriptor) => {\n const { name, control, labelId, maxLength, inputMode, options, placeholder } = descriptor;\n const label = intl.formatMessage({ id: labelId });\n const hint = placeholder ? intl.formatMessage({ id: placeholder.id }, placeholder.values) : undefined;\n\n if (control === 'select') {\n return (\n <AddressSelectField\n key={name}\n name={name}\n label={label}\n options={options ?? []}\n placeholder={hint}\n className={className}\n onChange={(value) => chooseOption(setField, name, value, descriptors)}\n />\n );\n }\n\n return (\n <AddressTextField\n key={name}\n name={name}\n label={label}\n maxLength={maxLength}\n inputMode={inputMode}\n placeholder={hint}\n className={className}\n />\n );\n });\n}\n\n// ---------------------------------------------------------------------------\n// Error, submit, cancel\n// ---------------------------------------------------------------------------\n\nexport function AccountAddressFormError({\n unrenderedFieldMessage,\n notFoundMessage,\n unauthorizedMessage,\n saveFailedMessage,\n rulesFailedMessage,\n countrySwitchFailedMessage,\n unsupportedCountryMessage,\n className,\n ...props\n}: AccountAddressFormErrorProps) {\n const { formError } = useAccountAddressForm();\n const intl = useIntl();\n\n if (!formError) return null;\n\n const authored: Readonly<Record<AccountAddressFormErrorKind, string | undefined>> = {\n unrenderedField: unrenderedFieldMessage,\n notFound: notFoundMessage,\n unauthorized: unauthorizedMessage,\n saveFailed: saveFailedMessage,\n rulesFailed: rulesFailedMessage,\n countrySwitchFailed: countrySwitchFailedMessage,\n unsupportedCountry: unsupportedCountryMessage,\n };\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-account-address-form-error={formError}>\n {resolveAuthoredCopy(authored[formError], intl.formatMessage({ id: ERROR_MESSAGE_IDS[formError] }))}\n </div>\n );\n}\n\nexport function AccountAddressFormSubmit({ label, className, children, ...props }: AccountAddressFormButtonProps) {\n const { country, rules, formError, pending, countryChoice } = useAccountAddressForm();\n const intl = useIntl();\n const switching = countryChoice.selected !== country;\n\n return (\n <Button\n {...props}\n type=\"submit\"\n className={className}\n disabled={rules === null || formError === 'rulesFailed' || pending || switching}\n aria-busy={pending || undefined}\n data-fs-account-address-form-submit=\"\"\n >\n {children ?? resolveAuthoredCopy(label, intl.formatMessage({ id: 'fs/address-form.submit' }))}\n </Button>\n );\n}\n\nexport function AccountAddressFormCancel({\n label,\n className,\n children,\n onClick,\n ...props\n}: AccountAddressFormButtonProps) {\n const { close, pending } = useAccountAddressForm();\n const intl = useIntl();\n\n return (\n <Button\n {...props}\n type=\"button\"\n disabled={pending || props.disabled}\n className={className}\n onClick={(event) => {\n onClick?.(event);\n close();\n }}\n data-fs-account-address-form-cancel=\"\"\n >\n {children ?? resolveAuthoredCopy(label, intl.formatMessage({ id: 'fs/address-form.cancel' }))}\n </Button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const AccountAddressFormRootDefinition = defineComponent<AccountAddressFormRootProps>({\n name: 'AccountAddressFormRoot',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormRoot,\n requiresContext: 'session',\n providesContext: 'account-address-form',\n actions: { address: ['create', 'update'] },\n editor: { label: 'Account Address Form', category: 'identity' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Preferred country (ISO-3)' },\n addedMessage: { type: 'string', label: 'Address added message' },\n savedMessage: { type: 'string', label: 'Address saved message' },\n blockedMessage: { type: 'string', label: 'Save blocked message' },\n returnHref: { type: 'link', default: { standard: 'address' }, label: 'Return page' },\n },\n guideline:\n \"The form that adds an address or corrects a saved one, with the fields, order and options of the address's country. Opens through AccountAddressBookAddTrigger and AccountAddressBookEditTrigger, placed by AccountAddressBookFormSlot or AccountAddressBookFormDialog. Requires a SessionRoot and a mounted ToastProvider ancestor: saving shows a toast and closes the form. On its own page (add: no ancestor; edit: inside AccountAddressRecord) leaving the form, by a save, a save with no changes or Cancel, goes to returnHref instead, so mount the ToastProvider in the layout for the toast to outlive the navigation. A new address takes defaultCountry when the store ships there or the list is unknown, else the first country the store ships to; the shopper picks another through AddressCountryControl. A saved address keeps its own country, shown as text. A save the form or the server blocks marks each field, moves focus to the first one and announces it, and keeps what was typed. With no children it renders AddressCountryControl, AccountAddressCountryNotice, RecipientName, Fields, Reference, Error, Submit and Cancel; that control gets no list there and shows defaultCountry as text, so compose AddressCountryControl explicitly to offer the choice. See account-address-book.md.\",\n});\n\nexport const AccountAddressFormRecipientNameDefinition = defineComponent<AccountAddressFormLabelProps>({\n name: 'AccountAddressFormRecipientName',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormRecipientName,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Recipient Name', category: 'input' },\n schema: {\n label: { type: 'string', label: 'Field label' },\n },\n guideline:\n \"The name of the person who receives the order. Required for every country. Place it first, before AccountAddressFormFields. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormFieldsDefinition = defineComponent<AccountAddressFormFieldsProps>({\n name: 'AccountAddressFormFields',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormFields,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Fields', category: 'input' },\n schema: {},\n guideline:\n \"One field per field the address's country asks for, in the order that country's form lists them, with its labels, limits and lists: Brazil's city is a list that follows its state. Changing a list clears the fields that depend on it. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormReferenceDefinition = defineComponent<AccountAddressFormLabelProps>({\n name: 'AccountAddressFormReference',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormReference,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Reference', category: 'input' },\n schema: {\n label: { type: 'string', label: 'Field label' },\n },\n guideline:\n \"A landmark that helps the carrier find the address. Optional. Place it after AccountAddressFormFields. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormErrorDefinition = defineComponent<AccountAddressFormErrorProps>({\n name: 'AccountAddressFormError',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormError,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Error', category: 'content' },\n schema: {\n unrenderedFieldMessage: { type: 'string', label: 'Field not shown message' },\n notFoundMessage: { type: 'string', label: 'Address gone message' },\n unauthorizedMessage: { type: 'string', label: 'Session expired message' },\n saveFailedMessage: { type: 'string', label: 'Save failed message' },\n rulesFailedMessage: { type: 'string', label: 'Form failed to load message' },\n countrySwitchFailedMessage: { type: 'string', label: 'Country change failed message' },\n unsupportedCountryMessage: { type: 'string', label: 'Country not delivered message' },\n },\n guideline:\n \"The error about the whole form, as an alert: a refusal on a field this form does not show, an address that no longer exists, an expired session, a failed save, a form that could not load, a country change that could not load, or a country the store doesn't deliver to. Renders nothing when there is none. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormSubmitDefinition = defineComponent<AccountAddressFormButtonProps>({\n name: 'AccountAddressFormSubmit',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormSubmit,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Submit', category: 'action' },\n schema: {\n label: { type: 'string', label: 'Button label' },\n },\n guideline:\n \"Saves the form. Disabled until the country's rules have loaded, while a country change loads, and while a save is in flight, and marked busy then. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormCancelDefinition = defineComponent<AccountAddressFormButtonProps>({\n name: 'AccountAddressFormCancel',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormCancel,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Cancel', category: 'action' },\n schema: {\n label: { type: 'string', label: 'Button label' },\n },\n guideline:\n 'Closes the form and drops what was typed. On its own page it goes to the returnHref of its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AAO;EAA+B,UAAU;CAAS;CACnE,QAAQ,EACN,OAAO;EAAE,MAAM;EAAU,OAAO;CAAe,EACjD;CACA,WACE;AACJ,CAAC"}
1
+ {"version":3,"file":"account-address-form.js","names":[],"sources":["../../../src/matter/account-address-book/account-address-form.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ContentValue,\n defineComponent,\n defineContentType,\n type MessageFieldName,\n type MessageLocaleProp,\n} from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n type ReactNode,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFormContext, useWatch } from 'react-hook-form';\nimport { Button } from '../../particles/button/button.js';\nimport {\n Field,\n FieldsetFieldContext,\n TEXT_FIELD_VALUE,\n useBoundField,\n useFieldsetField,\n useFieldsetFieldNames,\n} from '../../particles/field/field.js';\nimport { FormRoot, type FormUserError, useFormRegistry } from '../../particles/form/form.js';\nimport { Select } from '../../particles/select/select.js';\nimport { useToast } from '../../particles/toast/toast.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { addressFields } from '../../sdk/address/address-fields.js';\nimport { ACCOUNT_MAX_LENGTH } from '../../sdk/address/constants.js';\nimport { loadCountryRules } from '../../sdk/address/country-rules.js';\nimport type {\n AddressCreatePayload,\n AddressUpdatePayload,\n CustomerAddressUserError,\n} from '../../sdk/address/operations.js';\nimport { toAddressFieldName } from '../../sdk/address/server-fields.js';\nimport type {\n AddressFieldDescriptor,\n AddressFieldError,\n AddressFieldName,\n AddressLabelKey,\n CountryRules,\n} from '../../sdk/address/types.js';\nimport { validateAddress } from '../../sdk/address/validate-address.js';\nimport type { MessageFormatter } from '../../sdk/i18n/message-formatter.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport type { PageRef } from '../../sdk/navigation/types.js';\nimport { useStorefrontNavigation } from '../../sdk/navigation/use-storefront-navigation.js';\nimport { loggableErrorName } from '../../utils/loggable-error-name.js';\nimport { resolveSiteRelativeHref } from '../../utils/safe-href.js';\nimport { useSession } from '../session/session.js';\nimport { type AccountAddressBookItemSlice, useOptionalAccountAddressBook } from './account-address-book.js';\nimport {\n type AddressCountryMemory,\n applyCountrySwitch,\n initialAddressCountry,\n} from './account-address-country-switch.js';\nimport {\n type AccountAddressCountryChange,\n AccountAddressFormContext,\n type AccountAddressFormContextValue,\n type AccountAddressFormCountryChoice,\n type AccountAddressFormDraft,\n type AccountAddressFormErrorKind,\n type AccountAddressFormFieldErrors,\n type AccountAddressFormFieldLabel,\n type EditableField,\n useAccountAddressForm,\n} from './account-address-form-context.js';\nimport { dependentsOf, type FilledFields, usePostalCodeAutofill } from './account-address-postal-autofill.js';\nimport { useOptionalAccountAddressRecord } from './account-address-record.js';\n\n/**\n * The form that adds an address and corrects a saved one (specs/sfs-3441-address-book-form.md, RFC\n * REQ-02 and REQ-03). The Root renders `FormRoot` and registers one fieldset with it, under the\n * `accountAddress` namespace: react-hook-form holds the draft and knows what is dirty, and the\n * fieldset owns the field errors, the form-level error, the status message and the save. It holds no\n * country rule: the fields come from `addressFields`, the verdict from `validateAddress`, and the\n * writes go through `$actions.address`.\n */\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type AccountAddressFormRootProps = ComponentPropsWithRef<'form'> &\n MessageLocaleProp & {\n /** The form's parts. The root has no default anatomy. */\n children: ReactNode;\n /**\n * ISO 3166-1 alpha-3 country a new address prefers: taken when the store ships there or its list\n * is unknown. A blank value falls back to `BRA`.\n */\n defaultCountry?: string;\n $content?: ContentValue<typeof AccountAddressFormContent>;\n /** Where leaving the form goes when it stands on its own page. A page reference, or a site-relative string. A blank value falls back to the address page. */\n returnHref?: PageRef | string;\n /** Injected by the compiler from `actions: { address: [...] }`; the address write surface. */\n $actions?: ComponentActions;\n };\n\n/** `className` goes on every field's wrapper. */\nexport type AccountAddressFormFieldsProps = MessageLocaleProp &\n Readonly<{\n $content?: ContentValue<typeof AccountAddressFormFieldsContent>;\n className?: string;\n }>;\n\n/** RecipientName and Reference: their content types declare the same fields. */\nexport type AccountAddressFormLabelProps = MessageLocaleProp &\n Readonly<{\n $content?: ContentValue<typeof AccountAddressFormRecipientNameContent>;\n className?: string;\n }>;\n\nexport type AccountAddressFormErrorProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof AccountAddressFormErrorContent>;\n };\n\n/** Submit and Cancel: their content types declare the same field. */\nexport type AccountAddressFormButtonProps = Omit<ComponentPropsWithRef<'button'>, 'type'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof AccountAddressFormSubmitContent>;\n };\n\n// ---------------------------------------------------------------------------\n// Constants and helpers\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_COUNTRY = 'BRA';\n\nconst DEFAULT_RETURN_PAGE: PageRef = { standard: 'address' };\n\n/** The react-hook-form namespace every field of the form registers under. */\nconst ADDRESS_NAMESPACE = 'accountAddress';\n\n/** What `dispatch` hands `FormRoot` when it writes nothing because a write or a switch is in flight. */\nconst BUSY: readonly FormUserError[] = [{ code: 'ADDRESS_FORM_BUSY', message: '' }];\n\nconst EDITABLE_FIELDS: readonly EditableField[] = [\n 'recipientName',\n 'street',\n 'number',\n 'complement',\n 'neighborhood',\n 'city',\n 'state',\n 'postalCode',\n 'reference',\n];\n\nconst SERVER_REQUIRED: AddressFieldError = { code: 'required', message: 'required' };\nconst SERVER_INVALID: AddressFieldError = { code: 'invalid', message: 'invalid' };\n\nconst ERROR_FIELDS = {\n unrenderedField: 'unrenderedFieldMessage',\n notFound: 'notFoundMessage',\n unauthorized: 'unauthorizedMessage',\n saveFailed: 'saveFailedMessage',\n rulesFailed: 'rulesFailedMessage',\n countrySwitchFailed: 'countrySwitchFailedMessage',\n unsupportedCountry: 'unsupportedCountryMessage',\n} as const satisfies Record<AccountAddressFormErrorKind, MessageFieldName<typeof AccountAddressFormErrorContent>>;\n\nconst LABEL_FIELDS = {\n cep: 'cepLabel',\n city: 'cityLabel',\n commune: 'communeLabel',\n complement: 'complementLabel',\n county: 'countyLabel',\n department: 'departmentLabel',\n district: 'districtLabel',\n municipality: 'municipalityLabel',\n neighborhood: 'neighborhoodLabel',\n number: 'numberLabel',\n postalCode: 'postalCodeLabel',\n postcode: 'postcodeLabel',\n province: 'provinceLabel',\n region: 'regionLabel',\n state: 'stateLabel',\n street: 'streetLabel',\n town: 'townLabel',\n} as const satisfies Record<AddressLabelKey, MessageFieldName<typeof AccountAddressFormFieldsContent>>;\n\ntype Status =\n | Readonly<{ kind: 'fields'; count: number }>\n | Readonly<{ kind: 'failed' }>\n | Readonly<{ kind: 'filled'; count: number }>;\n\nfunction toDraft(address: AccountAddressBookItemSlice | null): AccountAddressFormDraft {\n if (!address) return {};\n return Object.fromEntries(EDITABLE_FIELDS.map((field) => [field, address[field] ?? '']));\n}\n\nfunction isBlankDraft(draft: AccountAddressFormDraft): boolean {\n return EDITABLE_FIELDS.every((field) => (draft[field] ?? '').trim() === '');\n}\n\nfunction toCountry(code: string | null | undefined): string {\n return (code?.trim() || DEFAULT_COUNTRY).toUpperCase();\n}\n\n/** A refusal's code decides the message when it names no field on screen; a named field reads as unrendered. */\nfunction toFormError({ code, field }: CustomerAddressUserError): AccountAddressFormErrorKind {\n if (code === 'UNSUPPORTED_COUNTRY') return 'unsupportedCountry';\n if (code === 'NOT_FOUND') return 'notFound';\n if (code === 'UNAUTHORIZED') return 'unauthorized';\n return field === null ? 'saveFailed' : 'unrenderedField';\n}\n\nfunction fieldPath(name: AddressFieldName): string {\n return `${ADDRESS_NAMESPACE}.${name}`;\n}\n\n/** The editable fields react-hook-form holds a value for, out of the namespace's raw values. */\nfunction pickEditable(values: unknown): AccountAddressFormDraft {\n if (typeof values !== 'object' || values === null) return {};\n const raw = values as Record<string, unknown>;\n return Object.fromEntries(\n EDITABLE_FIELDS.flatMap((field) => (typeof raw[field] === 'string' ? [[field, raw[field]]] : [])),\n );\n}\n\nfunction pick(draft: AccountAddressFormDraft, fields: readonly EditableField[]): Record<string, string> {\n return Object.fromEntries(fields.map((field) => [field, draft[field] ?? '']));\n}\n\nfunction changedFields(draft: AccountAddressFormDraft, seedDraft: AccountAddressFormDraft): EditableField[] {\n return EDITABLE_FIELDS.filter((field) => (draft[field] ?? '') !== (seedDraft[field] ?? ''));\n}\n\nfunction typedFields(draft: AccountAddressFormDraft): EditableField[] {\n return EDITABLE_FIELDS.filter((field) => (draft[field] ?? '').trim() !== '');\n}\n\ntype AddressWrite = (payload: Record<string, unknown>) => Promise<readonly CustomerAddressUserError[]>;\n\n/** The write a save sends, or `undefined` when the provider chain never delivered its action. */\nfunction resolveWrite(actions: ComponentActions | undefined, edit: boolean): AddressWrite | undefined {\n if (edit) {\n const update = actions?.address?.update;\n return update ? (payload) => update(payload as AddressUpdatePayload) : undefined;\n }\n const create = actions?.address?.create;\n return create ? (payload) => create(payload as AddressCreatePayload) : undefined;\n}\n\n/** Splits the draft's errors into those a control on screen can show, and a form-level error for any with none. */\nfunction splitByScreen(\n found: AccountAddressFormFieldErrors,\n controls: ReadonlySet<AddressFieldName>,\n): Readonly<{ onScreen: AccountAddressFormFieldErrors; formLevel: AccountAddressFormErrorKind | null }> {\n const onScreen: Partial<Record<AddressFieldName, AddressFieldError>> = {};\n let offScreen = false;\n for (const [name, error] of Object.entries(found) as [AddressFieldName, AddressFieldError][]) {\n if (controls.has(name)) onScreen[name] = error;\n else offScreen = true;\n }\n return { onScreen, formLevel: offScreen ? 'unrenderedField' : null };\n}\n\ntype FormMessages = MessageFormatter<typeof AccountAddressFormContent>;\n\nfunction describeStatus(status: Status | null, { format }: FormMessages): string {\n if (status === null) return '';\n if (status.kind === 'filled') return format('statusFilled', { count: status.count });\n if (status.kind === 'fields') return format('statusFields', { count: status.count });\n return format('statusFailed');\n}\n\nfunction focusFirstInvalid(form: HTMLFormElement | null, errors: AccountAddressFormFieldErrors) {\n if (!form) return;\n for (const wrapper of form.querySelectorAll<HTMLElement>('[data-fs-account-address-form-field]')) {\n const name = wrapper.dataset.fsAccountAddressFormField as AddressFieldName | undefined;\n if (name && errors[name]) {\n wrapper.querySelector<HTMLElement>('[data-fs-account-address-form-control]')?.focus();\n return;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\n/** Where the form stands decides its seed: the book's open edit form, then the record the page names, then nothing. */\nfunction useFormPlacement() {\n const book = useOptionalAccountAddressBook();\n const record = useOptionalAccountAddressRecord();\n const openForm = book?.openForm ?? null;\n const seed = (openForm?.mode === 'edit' ? openForm.address : null) ?? record?.address ?? null;\n return { book, record, seed, mode: seed ? ('edit' as const) : ('add' as const) };\n}\n\nexport function AccountAddressFormRoot({\n defaultCountry,\n $content,\n $locale,\n returnHref,\n $actions,\n className,\n children,\n ...props\n}: AccountAddressFormRootProps) {\n // Enforces the SessionRoot and ToastProvider ancestors: both hooks throw outside one.\n const { state: sessionState } = useSession();\n useToast();\n const { book, record, mode } = useFormPlacement();\n // Held here because `aria-busy` goes on FormRoot's <form>, which only this component renders.\n const [writing, setWriting] = useState(false);\n const setBookFormPending = book?.setFormPending;\n useEffect(() => {\n setBookFormPending?.(writing);\n return () => setBookFormPending?.(false);\n }, [writing, setBookFormPending]);\n const [switchTarget, setSwitchTarget] = useState<string | null>(null);\n\n if (sessionState !== 'loggedIn') return null;\n // A record that has not delivered its address must not read as \"add\": nothing renders until it does.\n if (!book && record && !record.address) return null;\n\n return (\n <FormRoot\n {...props}\n className={className}\n aria-busy={writing || switchTarget !== null || undefined}\n data-fs-account-address-form=\"\"\n data-fs-account-address-form-mode={mode}\n >\n <AccountAddressFieldset\n defaultCountry={defaultCountry}\n $content={$content}\n returnHref={returnHref}\n $actions={$actions}\n writing={writing}\n setWriting={setWriting}\n switchTarget={switchTarget}\n setSwitchTarget={setSwitchTarget}\n >\n {children}\n </AccountAddressFieldset>\n </FormRoot>\n );\n}\n\ntype AccountAddressFieldsetProps = Readonly<{\n defaultCountry?: string;\n $content?: ContentValue<typeof AccountAddressFormContent>;\n returnHref?: PageRef | string;\n $actions?: ComponentActions;\n writing: boolean;\n setWriting: (writing: boolean) => void;\n switchTarget: string | null;\n setSwitchTarget: (target: string | null) => void;\n children: ReactNode;\n}>;\n\n/**\n * The form's one fieldset under its FormRoot. It reads and writes the draft through react-hook-form,\n * and owns the rules, the errors, the country switch, the postal-code fill and the write.\n */\nfunction AccountAddressFieldset({\n defaultCountry,\n $content,\n returnHref,\n $actions: $actionsProp,\n writing,\n setWriting,\n switchTarget,\n setSwitchTarget,\n children,\n}: AccountAddressFieldsetProps) {\n const { registerFieldset } = useFormRegistry();\n const { getValues, setValue, subscribe } = useFormContext();\n const toast = useToast();\n const messages = useMessageFormatter(AccountAddressFormContent, $content);\n const $actions = useActionsOverride($actionsProp);\n const { push } = useStorefrontNavigation();\n const { book, seed, mode } = useFormPlacement();\n const preferredCountry = toCountry(seed?.country ?? defaultCountry);\n const seedDraft = useMemo(() => toDraft(seed), [seed]);\n const close = book?.close;\n\n const [offered, setOffered] = useState<readonly string[] | null | undefined>(undefined);\n const [chosenCountry, setChosenCountry] = useState<string | null>(null);\n const [lastChange, setLastChange] = useState<AccountAddressCountryChange | null>(null);\n const [rules, setRules] = useState<CountryRules | null>(null);\n const [fieldErrors, setFieldErrors] = useState<AccountAddressFormFieldErrors>({});\n const [formError, setFormError] = useState<AccountAddressFormErrorKind | null>(null);\n const [status, setStatus] = useState<Status | null>(null);\n const [fieldLabel, setFieldLabel] = useState<AccountAddressFormFieldLabel | null>(null);\n const pendingRef = useRef(false);\n // A save outlives the form that sent it when the shopper opens another address meanwhile. Only a\n // form that is still mounted may close the book's open form once the save settles.\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n const dispatched = useRef(false);\n const statusRef = useRef<HTMLOutputElement>(null);\n const offers = useRef(0);\n const switchedRef = useRef(false);\n const switchToken = useRef(0);\n const asideRef = useRef<AddressCountryMemory>({});\n\n const { registry, getFieldNames } = useFieldsetFieldNames(ADDRESS_NAMESPACE);\n const watched = useWatch({ name: ADDRESS_NAMESPACE });\n // A field with no control never reaches react-hook-form, so the seed fills what it does not hold.\n const draft = useMemo<AccountAddressFormDraft>(\n () => ({ ...seedDraft, ...pickEditable(watched) }),\n [seedDraft, watched],\n );\n\n // A new address has no country until the control's list resolves it, so only its chunk loads.\n const country = mode === 'edit' ? preferredCountry : (chosenCountry ?? '');\n const latest = useRef({ mode, country, rules, seedDraft });\n useLayoutEffect(() => {\n latest.current = { mode, country, rules, seedDraft };\n });\n\n /** The draft as react-hook-form holds it now, not as the last render saw it. */\n const readDraft = useCallback(\n (): AccountAddressFormDraft => ({ ...latest.current.seedDraft, ...pickEditable(getValues(ADDRESS_NAMESPACE)) }),\n [getValues],\n );\n\n /** Writes each field whose value changes. The country switch and the postal-code fill both write through here. */\n const writeDraft = useCallback(\n (values: AccountAddressFormDraft) => {\n const current = readDraft();\n for (const [name, value] of Object.entries(values) as [EditableField, string][]) {\n if ((current[name] ?? '') !== value) setValue(fieldPath(name), value, { shouldDirty: true });\n }\n },\n [readDraft, setValue],\n );\n\n const mountedFields = useCallback(\n () => new Set(getFieldNames().map((name) => name.slice(ADDRESS_NAMESPACE.length + 1) as AddressFieldName)),\n [getFieldNames],\n );\n\n /**\n * Loads `next`'s rules and applies the switch to the draft as it is then; only the latest call applies.\n * A `silent` switch is one the shopper did not ask for, so its failure shows no error.\n */\n const startSwitch = useCallback(\n (next: string, silent = false) => {\n const to = toCountry(next);\n if (latest.current.mode !== 'add') return;\n const token = ++switchToken.current;\n if (to === latest.current.country) {\n setSwitchTarget(null);\n return;\n }\n setSwitchTarget(to);\n loadCountryRules(to).then(\n (toRules) => {\n if (token !== switchToken.current) return;\n const { rules: fromRules } = latest.current;\n if (fromRules) {\n const result = applyCountrySwitch({\n draft: readDraft(),\n aside: asideRef.current,\n from: fromRules,\n to: toRules,\n });\n asideRef.current = result.aside;\n // Every editable field, so react-hook-form keeps no value the new country did not take.\n writeDraft(Object.fromEntries(EDITABLE_FIELDS.map((field) => [field, result.draft[field] ?? ''])));\n setLastChange(result.change);\n }\n setRules(toRules);\n setChosenCountry(to);\n setSwitchTarget(null);\n setFieldErrors({});\n setFormError(null);\n setStatus(null);\n },\n () => {\n if (token !== switchToken.current) return;\n setSwitchTarget(null);\n if (!silent) setFormError('countrySwitchFailed');\n },\n );\n },\n [readDraft, writeDraft, setSwitchTarget],\n );\n\n useEffect(\n () => () => {\n switchToken.current += 1;\n },\n [],\n );\n\n const change = useCallback(\n (to: string) => {\n if (pendingRef.current) return;\n switchedRef.current = true;\n startSwitch(to);\n },\n [startSwitch],\n );\n\n const offer = useCallback((countries: readonly string[] | null) => {\n offers.current += 1;\n setOffered(countries);\n return () => {\n offers.current -= 1;\n if (offers.current === 0) setOffered(undefined);\n };\n }, []);\n\n // The control's effect runs before this one, so a list it reports is in by the next render. With no\n // control, the preferred country applies. A later list moves the country only while the shopper has\n // neither switched nor typed, and silently.\n useEffect(() => {\n if (mode !== 'add') return;\n if (offered === undefined) {\n if (offers.current === 0) setChosenCountry((current) => current ?? preferredCountry);\n return;\n }\n const initial = initialAddressCountry(offered, preferredCountry);\n if (chosenCountry === null) setChosenCountry(initial);\n else if (!switchedRef.current && initial !== chosenCountry && isBlankDraft(readDraft())) {\n startSwitch(initial, true);\n }\n }, [mode, offered, preferredCountry, chosenCountry, startSwitch, readDraft]);\n\n // The rules load once the country is known. A failed load is not remembered by `loadCountryRules`,\n // so opening the form again retries it. An edit shows the saved address's gaps as soon as it can.\n useEffect(() => {\n if (!country) return;\n let current = true;\n loadCountryRules(country).then(\n (loaded) => {\n if (!current) return;\n setRules(loaded);\n if (seed) setFieldErrors(validateAddress(seedDraft, loaded));\n },\n () => {\n if (current) setFormError('rulesFailed');\n },\n );\n return () => {\n current = false;\n };\n }, [country, seed, seedDraft]);\n\n const registerField = useCallback(\n (name: AddressFieldName) => registry.registerFieldName(fieldPath(name)),\n [registry],\n );\n\n const registerFieldLabel = useCallback((label: AccountAddressFormFieldLabel) => {\n setFieldLabel(() => label);\n return () => setFieldLabel((current: AccountAddressFormFieldLabel | null) => (current === label ? null : current));\n }, []);\n\n const applyFill = useCallback(\n (filled: FilledFields) => {\n writeDraft(filled);\n setFieldErrors((previous) => {\n const next = Object.fromEntries(Object.entries(previous).filter(([name]) => !(name in filled)));\n return Object.keys(next).length === Object.keys(previous).length ? previous : next;\n });\n const count = Object.values(filled).filter((value) => value !== '').length;\n if (count > 0) setStatus({ kind: 'filled', count });\n },\n [writeDraft],\n );\n\n const autofill = usePostalCodeAutofill({ country, rules, draft, onFill: applyFill });\n const { fieldChanged, postalCodeChanged } = autofill;\n\n const setField = useCallback(\n (name: EditableField, value: string) => {\n fieldChanged(name);\n if (name === 'postalCode') postalCodeChanged(value);\n setValue(fieldPath(name), value, { shouldDirty: true });\n setFieldErrors((previous) => {\n if (!previous[name]) return previous;\n const { [name]: _cleared, ...rest } = previous;\n return rest;\n });\n setFormError((previous) => (previous === 'rulesFailed' ? previous : null));\n setStatus(null);\n },\n [fieldChanged, postalCodeChanged, setValue],\n );\n\n const destination = typeof returnHref === 'string' && returnHref.trim().length === 0 ? undefined : returnHref;\n\n // Under a book, leaving closes the form in place. On its own page there is nothing to close, so it\n // goes back to the list. A refused destination stays put: the save already happened.\n const closeForm = useCallback(() => {\n if (book) {\n close?.();\n return;\n }\n if (destination === undefined) {\n push(DEFAULT_RETURN_PAGE);\n } else if (typeof destination === 'string') {\n const target = resolveSiteRelativeHref(destination);\n if (target.safe) {\n push(target.href);\n } else {\n console.warn(`[AccountAddressFormRoot] returnHref refused (${target.reason}): ${destination}`);\n }\n } else {\n push(destination);\n }\n }, [book, close, destination, push]);\n\n function block(errors: AccountAddressFormFieldErrors, formLevel: AccountAddressFormErrorKind | null): Status {\n const count = Object.keys(errors).length;\n const blocked: Status = count > 0 ? { kind: 'fields', count } : { kind: 'failed' };\n setFieldErrors(errors);\n setFormError(formLevel);\n setStatus(blocked);\n focusFirstInvalid(statusRef.current?.closest('form') ?? null, errors);\n return blocked;\n }\n\n /** Blocks on the draft's errors and returns what `dispatch` hands `FormRoot`, or `null` when the draft passes. */\n function blockInvalid(current: AccountAddressFormDraft, currentRules: CountryRules): FormUserError[] | null {\n const { onScreen, formLevel } = splitByScreen(validateAddress(current, currentRules), mountedFields());\n if (formLevel === null && Object.keys(onScreen).length === 0) return null;\n const blocked = block(onScreen, formLevel);\n return [{ code: 'ADDRESS_FORM_BLOCKED', message: describeStatus(blocked, messages) }];\n }\n\n /**\n * Puts each refusal on the field it names, and the rest on the form: a save never fails silently.\n * Returns what `dispatch` hands `FormRoot`: the form's own status copy, never the server's `message`.\n */\n function refuse(userErrors: readonly CustomerAddressUserError[]): FormUserError[] {\n const errors: Partial<Record<AddressFieldName, AddressFieldError>> = {};\n const controls = mountedFields();\n let formLevel: AccountAddressFormErrorKind | null = null;\n\n for (const userError of userErrors) {\n const name = toAddressFieldName(userError.field);\n const onField = userError.code !== 'NOT_FOUND' && userError.code !== 'UNSUPPORTED_COUNTRY';\n if (name && controls.has(name) && onField) {\n errors[name] ??= userError.code === 'MISSING_REQUIRED_FIELD' ? SERVER_REQUIRED : SERVER_INVALID;\n } else {\n formLevel ??= toFormError(userError);\n }\n }\n // One status for the whole save, like the blocked path: FormError would repeat it once per refusal.\n return [{ code: userErrors[0]?.code, message: describeStatus(block(errors, formLevel), messages) }];\n }\n\n function toPayload(values: Record<string, unknown>): Record<string, unknown> {\n const current = { ...seedDraft, ...pickEditable(values) };\n if (seed) return { id: seed.id, ...pick(current, changedFields(current, seedDraft)) };\n return { country, ...pick(current, typedFields(current)) };\n }\n\n /** The form's only path to a write: FormRoot calls it when a mounted field is dirty, `settleUnsent` otherwise. */\n async function dispatch(payload: Record<string, unknown>): Promise<readonly FormUserError[]> {\n if (!rules || pendingRef.current || switchTarget !== null) return BUSY;\n\n const current = readDraft();\n const blocked = blockInvalid(current, rules);\n if (blocked) return blocked;\n if (seed && changedFields(current, seedDraft).length === 0) {\n setFieldErrors({});\n closeForm();\n return [];\n }\n\n setFieldErrors({});\n setFormError(null);\n setStatus(null);\n\n const write = resolveWrite($actions, seed !== null);\n if (!write) {\n // A composition gap (the provider chain never delivered the action) is otherwise a dead button.\n block({}, 'saveFailed');\n throw new Error('AccountAddressFormRoot requires $actions.address.');\n }\n\n pendingRef.current = true;\n setWriting(true);\n try {\n const userErrors = await write(payload);\n if (userErrors.length > 0) return refuse(userErrors);\n toast.add({ title: messages.format(seed === null ? 'addedMessage' : 'savedMessage'), type: 'success' });\n if (mountedRef.current) closeForm();\n return [];\n } catch (error) {\n // Log only the error name: a message can echo a typed address.\n console.error('[AccountAddressFormRoot] address write failed', loggableErrorName(error));\n block({}, 'saveFailed');\n throw error;\n } finally {\n pendingRef.current = false;\n setWriting(false);\n }\n }\n\n /**\n * A submit FormRoot settled without calling `dispatch`, because no mounted field is dirty. The draft\n * can still differ from what was saved: a value written before its control mounted is that control's\n * dirty baseline. So the save takes the same path, which writes only what changed.\n */\n function settleUnsent() {\n // `dispatch` has already put a failed write on the form.\n dispatch(toPayload(getValues(ADDRESS_NAMESPACE) ?? {})).catch(() => undefined);\n }\n\n const handlers = useRef({ toPayload, dispatch, settleUnsent });\n useLayoutEffect(() => {\n handlers.current = { toPayload, dispatch, settleUnsent };\n });\n\n useEffect(\n () =>\n registerFieldset({\n namespace: ADDRESS_NAMESPACE,\n getFieldNames,\n toPayload: (values) => handlers.current.toPayload(values),\n dispatch: (payload) => {\n dispatched.current = true;\n return handlers.current.dispatch(payload);\n },\n label: 'account-address',\n }),\n [registerFieldset, getFieldNames],\n );\n\n // FormRoot skips a fieldset with nothing dirty and says nothing; the end of the submit is the only sign.\n useEffect(() => {\n let seen = 0;\n return subscribe({\n formState: { submitCount: true },\n callback: ({ submitCount = 0 }) => {\n if (submitCount === seen) return;\n seen = submitCount;\n if (dispatched.current) dispatched.current = false;\n else handlers.current.settleUnsent();\n },\n });\n }, [subscribe]);\n\n const selected = switchTarget ?? country;\n const countryChoice = useMemo<AccountAddressFormCountryChoice>(\n () => ({ offer, selected, change, lastChange }),\n [offer, selected, change, lastChange],\n );\n\n const value = useMemo<AccountAddressFormContextValue>(\n () => ({\n mode,\n country,\n rules,\n draft,\n fieldErrors,\n formError,\n pending: writing,\n setField,\n registerField,\n close: closeForm,\n countryChoice,\n fieldLabel,\n registerFieldLabel,\n }),\n [\n mode,\n country,\n rules,\n draft,\n fieldErrors,\n formError,\n writing,\n setField,\n registerField,\n closeForm,\n countryChoice,\n fieldLabel,\n registerFieldLabel,\n ],\n );\n\n return (\n <FieldsetFieldContext value={registry}>\n <AccountAddressFormContext value={value}>\n {children}\n <output\n ref={statusRef}\n aria-live=\"polite\"\n data-fs-account-address-form-status=\"\"\n data-fs-sr-only=\"\"\n className=\"sr-only\"\n >\n {describeStatus(status, messages)}\n </output>\n </AccountAddressFormContext>\n </FieldsetFieldContext>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Fields\n// ---------------------------------------------------------------------------\n\n/** Words a field's error from the content of the part that owns the field. */\ntype FieldErrorText = (error: AddressFieldError) => string;\n\n/** RecipientName and Reference never get a postal-code error: only a country field does. */\nfunction labelFieldErrorText(\n { format }: MessageFormatter<typeof AccountAddressFormRecipientNameContent>,\n { message, values }: AddressFieldError,\n): string {\n if (message === 'required') return format('requiredError');\n if (message === 'tooLong') return format('tooLongError', { maxLength: String(values?.maxLength ?? '') });\n return format('invalidError');\n}\n\nfunction countryFieldErrorText(\n { format }: MessageFormatter<typeof AccountAddressFormFieldsContent>,\n { message, values }: AddressFieldError,\n): string {\n const example = String(values?.example ?? '');\n switch (message) {\n case 'required':\n return format('requiredError');\n case 'tooLong':\n return format('tooLongError', { maxLength: String(values?.maxLength ?? '') });\n case 'cep':\n return format('cepError', { example });\n case 'postalCode':\n return format('postalCodeError', { example });\n case 'invalid':\n return format('invalidError');\n }\n}\n\n/** Registers the field with the form while it is on screen and returns its value. */\nfunction useAddressFieldValue(name: EditableField): string {\n const { draft } = useAccountAddressForm();\n const { getValues } = useFormContext();\n const path = useFieldsetField(ADDRESS_NAMESPACE, name);\n // Adopting a seed resets the field to it, so the seed is what the field holds when it mounts: a\n // control that first mounts after a country switch keeps the value the switch carried.\n const [seed] = useState(() => {\n const live: unknown = getValues(path);\n return typeof live === 'string' ? live : (draft[name] ?? '');\n });\n return useBoundField({ name: path, defaultValue: seed }, TEXT_FIELD_VALUE).value;\n}\n\n/** Sets a list's option and empties the fields that read their options from it. The form's only dependent reset. */\nfunction chooseOption(\n setField: AccountAddressFormContextValue['setField'],\n name: EditableField,\n value: string,\n descriptors: readonly AddressFieldDescriptor[],\n) {\n setField(name, value);\n for (const dependent of dependentsOf(name, descriptors)) setField(dependent, '');\n}\n\ntype TextFieldProps = Readonly<{\n name: EditableField;\n label: string;\n errorText: FieldErrorText;\n maxLength: number;\n inputMode?: AddressFieldDescriptor['inputMode'];\n placeholder?: string;\n className?: string;\n}>;\n\nfunction AddressTextField({ name, label, errorText, maxLength, inputMode, placeholder, className }: TextFieldProps) {\n const { fieldErrors, setField } = useAccountAddressForm();\n const value = useAddressFieldValue(name);\n const error = fieldErrors[name];\n\n return (\n <Field.Root className={className} invalid={!!error} data-fs-account-address-form-field={name}>\n <Field.Label>{label}</Field.Label>\n <Field.Control\n value={value}\n onChange={(event) => setField(name, event.target.value)}\n maxLength={maxLength}\n inputMode={inputMode}\n placeholder={placeholder}\n data-fs-account-address-form-control=\"\"\n />\n {error ? <Field.Error match>{errorText(error)}</Field.Error> : null}\n </Field.Root>\n );\n}\n\ntype SelectFieldProps = Readonly<{\n name: EditableField;\n label: string;\n errorText: FieldErrorText;\n options: readonly Readonly<{ value: string; label: string }>[];\n placeholder?: string;\n className?: string;\n /** Called after the value changes, with the new value, so fields that depend on it can reset. */\n onChange: (value: string) => void;\n}>;\n\nfunction AddressSelectField({ name, label, errorText, options, placeholder, className, onChange }: SelectFieldProps) {\n const { fieldErrors } = useAccountAddressForm();\n const value = useAddressFieldValue(name);\n const errorId = useId();\n const error = fieldErrors[name];\n\n return (\n <div className={className} data-fs-account-address-form-field={name} {...(error ? { 'data-invalid': '' } : {})}>\n <Select.Root value={value} onValueChange={(next) => onChange(next ?? '')}>\n <Select.Label>{label}</Select.Label>\n <Select.Trigger\n aria-invalid={error ? true : undefined}\n aria-describedby={error ? errorId : undefined}\n data-fs-account-address-form-control=\"\"\n >\n <Select.Value placeholder={placeholder}>\n {(value) => options.find((option) => option.value === value)?.label ?? placeholder}\n </Select.Value>\n <Select.Icon />\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n <Select.List>\n {options.map((option) => (\n <Select.Item key={option.value} value={option.value} label={option.label}>\n <Select.ItemText>{option.label}</Select.ItemText>\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n {error ? (\n <p id={errorId} data-fs-account-address-form-field-error=\"\">\n {errorText(error)}\n </p>\n ) : null}\n </div>\n );\n}\n\nexport function AccountAddressFormRecipientName({ $content, className }: AccountAddressFormLabelProps) {\n const { rules } = useAccountAddressForm();\n const messages = useMessageFormatter(AccountAddressFormRecipientNameContent, $content);\n\n if (!rules) return null;\n\n return (\n <AddressTextField\n name=\"recipientName\"\n label={messages.format('label')}\n errorText={(error) => labelFieldErrorText(messages, error)}\n maxLength={ACCOUNT_MAX_LENGTH.recipientName}\n className={className}\n />\n );\n}\n\nexport function AccountAddressFormReference({ $content, className }: AccountAddressFormLabelProps) {\n const { rules } = useAccountAddressForm();\n const messages = useMessageFormatter(AccountAddressFormReferenceContent, $content);\n\n if (!rules) return null;\n\n return (\n <AddressTextField\n name=\"reference\"\n label={messages.format('label')}\n errorText={(error) => labelFieldErrorText(messages, error)}\n maxLength={ACCOUNT_MAX_LENGTH.reference}\n className={className}\n />\n );\n}\n\n/**\n * One field per descriptor the country's rules give for the draft, in the order the country's form lists them.\n * A complete postal code fills the empty state, city, neighborhood and street the shopper has not typed;\n * the fill is announced once. Its labels also word the country notice's list of fields left behind.\n */\nexport function AccountAddressFormFields({ $content, className }: AccountAddressFormFieldsProps) {\n const { rules, draft, setField, registerFieldLabel } = useAccountAddressForm();\n const messages = useMessageFormatter(AccountAddressFormFieldsContent, $content);\n const { format } = messages;\n const fieldLabel = useCallback((key: AddressLabelKey) => format(LABEL_FIELDS[key]), [format]);\n\n useEffect(() => registerFieldLabel(fieldLabel), [registerFieldLabel, fieldLabel]);\n\n if (!rules) return null;\n\n const descriptors = addressFields(rules, draft);\n const errorText = (error: AddressFieldError) => countryFieldErrorText(messages, error);\n\n return descriptors.map((descriptor) => {\n const { name, control, maxLength, inputMode, options, placeholder } = descriptor;\n const label = fieldLabel(descriptor.label);\n const hint =\n placeholder?.key === 'street'\n ? format('streetPlaceholder')\n : placeholder && format('postalCodePlaceholder', { example: placeholder.values.example ?? '' });\n\n if (control === 'select') {\n return (\n <AddressSelectField\n key={name}\n name={name}\n label={label}\n errorText={errorText}\n options={options ?? []}\n placeholder={hint}\n className={className}\n onChange={(value) => chooseOption(setField, name, value, descriptors)}\n />\n );\n }\n\n return (\n <AddressTextField\n key={name}\n name={name}\n label={label}\n errorText={errorText}\n maxLength={maxLength}\n inputMode={inputMode}\n placeholder={hint}\n className={className}\n />\n );\n });\n}\n\n// ---------------------------------------------------------------------------\n// Error, submit, cancel\n// ---------------------------------------------------------------------------\n\nexport function AccountAddressFormError({ $content, $locale, className, ...props }: AccountAddressFormErrorProps) {\n const { formError } = useAccountAddressForm();\n const { format } = useMessageFormatter(AccountAddressFormErrorContent, $content);\n\n if (!formError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-account-address-form-error={formError}>\n {format(ERROR_FIELDS[formError])}\n </div>\n );\n}\n\nexport function AccountAddressFormSubmit({\n $content,\n $locale,\n className,\n children,\n ...props\n}: AccountAddressFormButtonProps) {\n const { country, rules, formError, pending, countryChoice } = useAccountAddressForm();\n const { format } = useMessageFormatter(AccountAddressFormSubmitContent, $content);\n const switching = countryChoice.selected !== country;\n\n return (\n <Button\n {...props}\n type=\"submit\"\n className={className}\n disabled={rules === null || formError === 'rulesFailed' || pending || switching}\n aria-busy={pending || undefined}\n data-fs-account-address-form-submit=\"\"\n >\n {children ?? format('label')}\n </Button>\n );\n}\n\nexport function AccountAddressFormCancel({\n $content,\n $locale,\n className,\n children,\n onClick,\n ...props\n}: AccountAddressFormButtonProps) {\n const { close, pending } = useAccountAddressForm();\n const { format } = useMessageFormatter(AccountAddressFormCancelContent, $content);\n\n return (\n <Button\n {...props}\n type=\"button\"\n disabled={pending || props.disabled}\n className={className}\n onClick={(event) => {\n onClick?.(event);\n close();\n }}\n data-fs-account-address-form-cancel=\"\"\n >\n {children ?? format('label')}\n </Button>\n );\n}\n\nexport const AccountAddressFormContent = defineContentType({\n id: 'account-address-form',\n title: 'Account Address Form',\n description: 'The messages the address form shows or announces when a save ends or a postal code fills fields.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n addedMessage: {\n type: 'string',\n title: 'Address added message',\n format: 'icu-message',\n messageSource: 'Address added.',\n },\n savedMessage: {\n type: 'string',\n title: 'Address saved message',\n format: 'icu-message',\n messageSource: 'Address saved.',\n },\n statusFilled: {\n type: 'string',\n title: 'Fields filled from the postal code',\n format: 'icu-message',\n messageSource:\n '{count, plural, one {# field filled from the postal code.} other {# fields filled from the postal code.}}',\n messageArguments: { type: 'object', properties: { count: { type: 'integer' } } },\n messageExample: { count: 2 },\n },\n statusFields: {\n type: 'string',\n title: 'Save blocked by fields',\n format: 'icu-message',\n messageSource:\n 'Address not saved. {count, plural, one {# field needs attention.} other {# fields need attention.}}',\n messageArguments: { type: 'object', properties: { count: { type: 'integer' } } },\n messageExample: { count: 2 },\n },\n statusFailed: {\n type: 'string',\n title: 'Save failed',\n format: 'icu-message',\n messageSource: 'Address not saved.',\n },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const AccountAddressFormRootDefinition = defineComponent<AccountAddressFormRootProps>({\n name: 'AccountAddressFormRoot',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormRoot,\n content: AccountAddressFormContent,\n requiresContext: 'session',\n providesContext: 'account-address-form',\n actions: { address: ['create', 'update'] },\n editor: { label: 'Account Address Form', category: 'identity' },\n schema: {\n defaultCountry: { type: 'string', default: 'BRA', label: 'Preferred country (ISO-3)' },\n returnHref: { type: 'link', default: { standard: 'address' }, label: 'Return page' },\n },\n guideline:\n \"The form that adds an address or corrects a saved one, with the fields, order and options of the address's country. Opens through AccountAddressBookAddTrigger and AccountAddressBookEditTrigger, placed by AccountAddressBookFormSlot or AccountAddressBookFormDialog. Requires a SessionRoot and a mounted ToastProvider ancestor: saving shows a toast and closes the form. On its own page (add: no ancestor; edit: inside AccountAddressRecord) leaving the form, by a save, a save with no changes or Cancel, goes to returnHref instead, so mount the ToastProvider in the layout for the toast to outlive the navigation. A new address takes defaultCountry when the store ships there or the list is unknown, else the first country the store ships to; the shopper picks another through AddressCountryControl. A saved address keeps its own country, shown as text. A save the form or the server blocks marks each field, moves focus to the first one and announces it, and keeps what was typed. It renders only its children, so compose AddressCountryControl, AccountAddressCountryNotice, RecipientName, Fields, Reference, Error, Submit and Cancel in it. See account-address-book.md.\",\n});\n\nexport const AccountAddressFormRecipientNameContent = defineContentType({\n id: 'account-address-form-recipient-name',\n title: 'Account Address Form Recipient Name',\n description: \"The recipient name field's label and errors.\",\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Field label', format: 'icu-message', messageSource: 'Recipient name' },\n requiredError: {\n type: 'string',\n title: 'Required field error',\n format: 'icu-message',\n messageSource: 'This field is required.',\n },\n invalidError: {\n type: 'string',\n title: 'Invalid field error',\n format: 'icu-message',\n messageSource: 'Check this field.',\n },\n tooLongError: {\n type: 'string',\n title: 'Too long error',\n format: 'icu-message',\n messageSource: 'Use {maxLength} characters or fewer.',\n messageArguments: { type: 'object', properties: { maxLength: { type: 'string' } } },\n messageExample: { maxLength: '200' },\n },\n },\n },\n});\n\nexport const AccountAddressFormRecipientNameDefinition = defineComponent<AccountAddressFormLabelProps>({\n name: 'AccountAddressFormRecipientName',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormRecipientName,\n content: AccountAddressFormRecipientNameContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Recipient Name', category: 'input' },\n schema: {},\n guideline:\n \"The name of the person who receives the order. Required for every country. Place it first, before AccountAddressFormFields. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormFieldsContent = defineContentType({\n id: 'account-address-form-fields',\n title: 'Account Address Form Fields',\n description: \"Labels, placeholders and errors of the fields the address's country asks for.\",\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n cepLabel: { type: 'string', title: 'CEP label', format: 'icu-message', messageSource: 'CEP' },\n cityLabel: { type: 'string', title: 'City label', format: 'icu-message', messageSource: 'City' },\n communeLabel: { type: 'string', title: 'Commune label', format: 'icu-message', messageSource: 'Commune' },\n complementLabel: {\n type: 'string',\n title: 'Additional information label',\n format: 'icu-message',\n messageSource: 'Additional information (optional)',\n },\n countyLabel: { type: 'string', title: 'County label', format: 'icu-message', messageSource: 'County' },\n departmentLabel: {\n type: 'string',\n title: 'Department label',\n format: 'icu-message',\n messageSource: 'Department',\n },\n districtLabel: { type: 'string', title: 'District label', format: 'icu-message', messageSource: 'District' },\n municipalityLabel: {\n type: 'string',\n title: 'Municipality label',\n format: 'icu-message',\n messageSource: 'Municipality',\n },\n neighborhoodLabel: {\n type: 'string',\n title: 'Neighborhood label',\n format: 'icu-message',\n messageSource: 'Neighborhood',\n },\n numberLabel: { type: 'string', title: 'Number label', format: 'icu-message', messageSource: 'Number' },\n postalCodeLabel: {\n type: 'string',\n title: 'Postal code label',\n format: 'icu-message',\n messageSource: 'Postal code',\n },\n postcodeLabel: { type: 'string', title: 'Postcode label', format: 'icu-message', messageSource: 'Postcode' },\n provinceLabel: { type: 'string', title: 'Province label', format: 'icu-message', messageSource: 'Province' },\n regionLabel: { type: 'string', title: 'Region label', format: 'icu-message', messageSource: 'Region' },\n stateLabel: { type: 'string', title: 'State label', format: 'icu-message', messageSource: 'State' },\n streetLabel: {\n type: 'string',\n title: 'Street address label',\n format: 'icu-message',\n messageSource: 'Street address',\n },\n townLabel: { type: 'string', title: 'Town label', format: 'icu-message', messageSource: 'Town' },\n postalCodePlaceholder: {\n type: 'string',\n title: 'Postal code placeholder',\n format: 'icu-message',\n messageSource: 'Example: {example}',\n messageArguments: { type: 'object', properties: { example: { type: 'string' } } },\n messageExample: { example: '01310-100' },\n },\n streetPlaceholder: {\n type: 'string',\n title: 'Street placeholder',\n format: 'icu-message',\n messageSource: 'Address line 1',\n },\n cepError: {\n type: 'string',\n title: 'Invalid CEP error',\n format: 'icu-message',\n messageSource: 'Enter a valid CEP (example: {example}).',\n messageArguments: { type: 'object', properties: { example: { type: 'string' } } },\n messageExample: { example: '01310-100' },\n },\n postalCodeError: {\n type: 'string',\n title: 'Invalid postal code error',\n format: 'icu-message',\n messageSource: 'Enter a valid postal code (example: {example}).',\n messageArguments: { type: 'object', properties: { example: { type: 'string' } } },\n messageExample: { example: 'K1A 0A9' },\n },\n requiredError: {\n type: 'string',\n title: 'Required field error',\n format: 'icu-message',\n messageSource: 'This field is required.',\n },\n invalidError: {\n type: 'string',\n title: 'Invalid field error',\n format: 'icu-message',\n messageSource: 'Check this field.',\n },\n tooLongError: {\n type: 'string',\n title: 'Too long error',\n format: 'icu-message',\n messageSource: 'Use {maxLength} characters or fewer.',\n messageArguments: { type: 'object', properties: { maxLength: { type: 'string' } } },\n messageExample: { maxLength: '100' },\n },\n },\n },\n});\n\nexport const AccountAddressFormFieldsDefinition = defineComponent<AccountAddressFormFieldsProps>({\n name: 'AccountAddressFormFields',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormFields,\n content: AccountAddressFormFieldsContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Fields', category: 'input' },\n schema: {},\n guideline:\n \"One field per field the address's country asks for, in the order that country's form lists them, with its labels, limits and lists: Brazil's city is a list that follows its state. Changing a list clears the fields that depend on it. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormReferenceContent = defineContentType({\n id: 'account-address-form-reference',\n title: 'Account Address Form Reference',\n description: \"The reference field's label and errors.\",\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Field label', format: 'icu-message', messageSource: 'Reference (optional)' },\n requiredError: {\n type: 'string',\n title: 'Required field error',\n format: 'icu-message',\n messageSource: 'This field is required.',\n },\n invalidError: {\n type: 'string',\n title: 'Invalid field error',\n format: 'icu-message',\n messageSource: 'Check this field.',\n },\n tooLongError: {\n type: 'string',\n title: 'Too long error',\n format: 'icu-message',\n messageSource: 'Use {maxLength} characters or fewer.',\n messageArguments: { type: 'object', properties: { maxLength: { type: 'string' } } },\n messageExample: { maxLength: '750' },\n },\n },\n },\n});\n\nexport const AccountAddressFormReferenceDefinition = defineComponent<AccountAddressFormLabelProps>({\n name: 'AccountAddressFormReference',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormReference,\n content: AccountAddressFormReferenceContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Reference', category: 'input' },\n schema: {},\n guideline:\n \"A landmark that helps the carrier find the address. Optional. Place it after AccountAddressFormFields. Shown once the country's rules have loaded. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormErrorContent = defineContentType({\n id: 'account-address-form-error',\n title: 'Account Address Form Error',\n description: 'Messages for an error about the whole address form.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n unrenderedFieldMessage: {\n type: 'string',\n title: 'Field not shown message',\n format: 'icu-message',\n messageSource: \"This address needs details this form can't show, so it wasn't saved.\",\n },\n notFoundMessage: {\n type: 'string',\n title: 'Address gone message',\n format: 'icu-message',\n messageSource: 'This address no longer exists.',\n },\n unauthorizedMessage: {\n type: 'string',\n title: 'Session expired message',\n format: 'icu-message',\n messageSource: 'Your session expired. Sign in again to save this address.',\n },\n saveFailedMessage: {\n type: 'string',\n title: 'Save failed message',\n format: 'icu-message',\n messageSource: \"We couldn't save this address. Try again.\",\n },\n rulesFailedMessage: {\n type: 'string',\n title: 'Form failed to load message',\n format: 'icu-message',\n messageSource: \"We couldn't load this form. Close it and try again.\",\n },\n countrySwitchFailedMessage: {\n type: 'string',\n title: 'Country change failed message',\n format: 'icu-message',\n messageSource: \"We couldn't change the country. Try again.\",\n },\n unsupportedCountryMessage: {\n type: 'string',\n title: 'Country not delivered message',\n format: 'icu-message',\n messageSource: \"The store doesn't deliver to this country.\",\n },\n },\n },\n});\n\nexport const AccountAddressFormErrorDefinition = defineComponent<AccountAddressFormErrorProps>({\n name: 'AccountAddressFormError',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormError,\n content: AccountAddressFormErrorContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Error', category: 'content' },\n schema: {},\n guideline:\n \"The error about the whole form, as an alert: a refusal on a field this form does not show, an address that no longer exists, an expired session, a failed save, a form that could not load, a country change that could not load, or a country the store doesn't deliver to. Renders nothing when there is none. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormSubmitContent = defineContentType({\n id: 'account-address-form-submit',\n title: 'Account Address Form Submit',\n description: 'Label of the control that saves the address form.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label', format: 'icu-message', messageSource: 'Save' },\n },\n },\n});\n\nexport const AccountAddressFormSubmitDefinition = defineComponent<AccountAddressFormButtonProps>({\n name: 'AccountAddressFormSubmit',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormSubmit,\n content: AccountAddressFormSubmitContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Submit', category: 'action' },\n schema: {},\n guideline:\n \"Saves the form. Disabled until the country's rules have loaded, while a country change loads, and while a save is in flight, and marked busy then. Must be inside AccountAddressFormRoot.\",\n});\n\nexport const AccountAddressFormCancelContent = defineContentType({\n id: 'account-address-form-cancel',\n title: 'Account Address Form Cancel',\n description: 'Label of the control that closes the address form.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label', format: 'icu-message', messageSource: 'Cancel' },\n },\n },\n});\n\nexport const AccountAddressFormCancelDefinition = defineComponent<AccountAddressFormButtonProps>({\n name: 'AccountAddressFormCancel',\n importPath: '@vtex/faststore/components',\n component: AccountAddressFormCancel,\n content: AccountAddressFormCancelContent,\n requiresContext: 'account-address-form',\n editor: { label: 'Account Address Form Cancel', category: 'action' },\n schema: {},\n guideline:\n 'Closes the form and drops what was typed. On its own page it goes to the returnHref of its root. Must be inside AccountAddressFormRoot.',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,MAAM,kBAAkB;AAExB,MAAM,sBAA+B,EAAE,UAAU,UAAU;;AAG3D,MAAM,oBAAoB;;AAG1B,MAAM,OAAiC,CAAC;CAAE,MAAM;CAAqB,SAAS;AAAG,CAAC;AAElF,MAAM,kBAA4C;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,kBAAqC;CAAE,MAAM;CAAY,SAAS;AAAW;AACnF,MAAM,iBAAoC;CAAE,MAAM;CAAW,SAAS;AAAU;AAEhF,MAAM,eAAe;CACnB,iBAAiB;CACjB,UAAU;CACV,cAAc;CACd,YAAY;CACZ,aAAa;CACb,qBAAqB;CACrB,oBAAoB;AACtB;AAEA,MAAM,eAAe;CACnB,KAAK;CACL,MAAM;CACN,SAAS;CACT,YAAY;CACZ,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,cAAc;CACd,cAAc;CACd,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;AACR;AAOA,SAAS,QAAQ,SAAsE;CACrF,IAAI,CAAC,SAAS,OAAO,C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;AAED,MAAa,qCAAqC,gBAA+C;CAC/F,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA+B,UAAU;CAAS;CACnE,QAAQ,CAAC;CACT,WACE;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ContentValue, MessageLocaleProp } from "../../core/dist/define-content-type.js";
1
2
  import { ComponentDefinition } from "../../core/dist/define-component.js";
2
3
  import "../../core/dist/index.js";
3
4
  import { AccountAddressBookItemSlice } from "./account-address-book.js";
@@ -6,11 +7,8 @@ import { ComponentPropsWithRef } from "react";
6
7
  export type AccountAddressRecordProps = ComponentPropsWithRef<'div'> & {
7
8
  $data?: AccountAddressBookItemSlice | null;
8
9
  };
9
- export type AccountAddressRecordErrorProps = ComponentPropsWithRef<'div'> & {
10
- /** Shown when the address could not be read. A blank value falls back to the catalog copy. */
11
- message?: string;
12
- /** The retry control's text. A blank value falls back to the catalog copy. */
13
- retryLabel?: string;
10
+ export type AccountAddressRecordErrorProps = ComponentPropsWithRef<'div'> & MessageLocaleProp & {
11
+ $content?: ContentValue<typeof AccountAddressRecordErrorContent>;
14
12
  };
15
13
  export type AccountAddressRecordContextValue = Readonly<{
16
14
  /** The address the route names; `null` until it resolved or when the read failed. */
@@ -19,8 +17,31 @@ export type AccountAddressRecordContextValue = Readonly<{
19
17
  failed: boolean;
20
18
  }>;
21
19
  export declare function AccountAddressRecord({ $data: $dataProp, className, children, ...props }: AccountAddressRecordProps): import("react/jsx-runtime").JSX.Element | null;
22
- export declare function AccountAddressRecordError({ message, retryLabel, className, ...props }: AccountAddressRecordErrorProps): import("react/jsx-runtime").JSX.Element | null;
20
+ export declare function AccountAddressRecordError({ $content, $locale, className, ...props }: AccountAddressRecordErrorProps): import("react/jsx-runtime").JSX.Element | null;
23
21
  export declare const AccountAddressRecordDefinition: ComponentDefinition<AccountAddressRecordProps>;
22
+ export declare const AccountAddressRecordErrorContent: {
23
+ readonly id: "account-address-record-error";
24
+ readonly title: "Account Address Record Error";
25
+ readonly description: "Message and retry label shown when the address cannot be read.";
26
+ readonly schema: {
27
+ readonly type: "object";
28
+ readonly additionalProperties: false;
29
+ readonly properties: {
30
+ readonly message: {
31
+ readonly type: "string";
32
+ readonly title: "Error message";
33
+ readonly format: "icu-message";
34
+ readonly messageSource: "We couldn't load this address.";
35
+ };
36
+ readonly retryLabel: {
37
+ readonly type: "string";
38
+ readonly title: "Retry label";
39
+ readonly format: "icu-message";
40
+ readonly messageSource: "Try again";
41
+ };
42
+ };
43
+ };
44
+ };
24
45
  export declare const AccountAddressRecordErrorDefinition: ComponentDefinition<AccountAddressRecordErrorProps>;
25
46
  //#endregion
26
47
  //# sourceMappingURL=account-address-record.d.ts.map
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { defineComponent } from "../../core/dist/define-component.js";
3
+ import { defineContentType } from "../../core/dist/define-content-type.js";
3
4
  import "../../core/dist/index.js";
4
- import { useIntl } from "../../sdk/i18n/client.js";
5
+ import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
5
6
  import { useDataOverride } from "../../sdk/data/data-override-context.js";
6
- import { resolveAuthoredCopy } from "../../utils/resolve-authored-copy.js";
7
7
  import { useSession } from "../session/session.js";
8
8
  import { Button } from "../../particles/button/button.js";
9
9
  import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
@@ -75,9 +75,9 @@ function AccountAddressRecord({ $data: $dataProp, className, children, ...props
75
75
  function reloadPage() {
76
76
  globalThis.location.reload();
77
77
  }
78
- function AccountAddressRecordError({ message, retryLabel, className, ...props }) {
78
+ function AccountAddressRecordError({ $content, $locale, className, ...props }) {
79
79
  const { failed } = useAccountAddressRecord();
80
- const intl = useIntl();
80
+ const { format } = useMessageFormatter(AccountAddressRecordErrorContent, $content);
81
81
  if (!failed) return null;
82
82
  return /* @__PURE__ */ jsxs("div", {
83
83
  ...props,
@@ -86,12 +86,12 @@ function AccountAddressRecordError({ message, retryLabel, className, ...props })
86
86
  "data-fs-account-address-record-error": "",
87
87
  children: [/* @__PURE__ */ jsx("p", {
88
88
  "data-fs-account-address-record-error-message": "",
89
- children: resolveAuthoredCopy(message, intl.formatMessage({ id: "fs/address-record.error" }))
89
+ children: format("message")
90
90
  }), /* @__PURE__ */ jsx(Button, {
91
91
  type: "button",
92
92
  onClick: reloadPage,
93
93
  "data-fs-account-address-record-retry": "",
94
- children: resolveAuthoredCopy(retryLabel, intl.formatMessage({ id: "fs/address-book.retry" }))
94
+ children: format("retryLabel")
95
95
  })]
96
96
  });
97
97
  }
@@ -111,28 +111,43 @@ const AccountAddressRecordDefinition = defineComponent({
111
111
  schema: {},
112
112
  guideline: "The one saved address the page's route names, read by the route's [id] segment: place it on a page whose route ends in [id], around an AccountAddressFormRoot, which then opens in edit mode seeded with it. Renders nothing unless the session is logged in, so it needs a SessionRoot ancestor. An id that is not the shopper's, or that never existed, answers with the layout's not-found page and never reaches this component. Add AccountAddressRecordError to show a read that failed. While no address has resolved, the form beneath renders nothing, so it never falls back to adding. See account-address-book.md."
113
113
  });
114
+ const AccountAddressRecordErrorContent = defineContentType({
115
+ id: "account-address-record-error",
116
+ title: "Account Address Record Error",
117
+ description: "Message and retry label shown when the address cannot be read.",
118
+ schema: {
119
+ type: "object",
120
+ additionalProperties: false,
121
+ properties: {
122
+ message: {
123
+ type: "string",
124
+ title: "Error message",
125
+ format: "icu-message",
126
+ messageSource: "We couldn't load this address."
127
+ },
128
+ retryLabel: {
129
+ type: "string",
130
+ title: "Retry label",
131
+ format: "icu-message",
132
+ messageSource: "Try again"
133
+ }
134
+ }
135
+ }
136
+ });
114
137
  const AccountAddressRecordErrorDefinition = defineComponent({
115
138
  name: "AccountAddressRecordError",
116
139
  importPath: "@vtex/faststore/components",
117
140
  component: AccountAddressRecordError,
141
+ content: AccountAddressRecordErrorContent,
118
142
  requiresContext: "account-address-record",
119
143
  editor: {
120
144
  label: "Account Address Record Error",
121
145
  category: "content"
122
146
  },
123
- schema: {
124
- message: {
125
- type: "string",
126
- label: "Error message"
127
- },
128
- retryLabel: {
129
- type: "string",
130
- label: "Retry label"
131
- }
132
- },
147
+ schema: {},
133
148
  guideline: "Shown only when the address could not be read and none resolved: a message and a retry that reloads the page. Never shown for an id that does not exist, which is a not-found page. Must be inside AccountAddressRecord."
134
149
  });
135
150
  //#endregion
136
- export { AccountAddressRecord, AccountAddressRecordDefinition, AccountAddressRecordError, AccountAddressRecordErrorDefinition, useOptionalAccountAddressRecord };
151
+ export { AccountAddressRecord, AccountAddressRecordDefinition, AccountAddressRecordError, AccountAddressRecordErrorContent, AccountAddressRecordErrorDefinition, useOptionalAccountAddressRecord };
137
152
 
138
153
  //# sourceMappingURL=account-address-record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account-address-record.js","names":[],"sources":["../../../src/matter/account-address-book/account-address-record.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport { Button } from '../../particles/button/button.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { useIntl } from '../../sdk/i18n/client.js';\nimport { resolveAuthoredCopy } from '../../utils/resolve-authored-copy.js';\nimport { useSession } from '../session/session.js';\nimport { type AccountAddressBookItemSlice, AccountAddressBookSkeleton } from './account-address-book.js';\n\n/**\n * The one address an own page names (specs/sfs-3438-address-form-own-pages.md, RFC REQ-03). It reads\n * `customerAddress(id: $id)` through the page's reactive query and hands the result to the form\n * beneath it, which opens in edit mode seeded with it.\n *\n * It has no not-found state: a route-identified `null` already 404s on the server, through the\n * layout's not-found page, so a foreign id and a missing id are the same response by construction.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL fragment — a raw template literal, as the book's fragments are.\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment AccountAddressRecordData on Query {\n customerAddress(id: $id) {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type AccountAddressRecordProps = ComponentPropsWithRef<'div'> & {\n $data?: AccountAddressBookItemSlice | null;\n};\n\nexport type AccountAddressRecordErrorProps = ComponentPropsWithRef<'div'> & {\n /** Shown when the address could not be read. A blank value falls back to the catalog copy. */\n message?: string;\n /** The retry control's text. A blank value falls back to the catalog copy. */\n retryLabel?: string;\n};\n\nexport type AccountAddressRecordContextValue = Readonly<{\n /** The address the route names; `null` until it resolved or when the read failed. */\n address: AccountAddressBookItemSlice | null;\n /** The read failed and no address resolved. */\n failed: boolean;\n}>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst AccountAddressRecordContext = createContext<AccountAddressRecordContextValue | null>(null);\n\n/**\n * The record above the caller, or `null` when there is none. A record whose `address` is `null` is\n * still a record: the form must not read that as \"add\".\n */\nexport function useOptionalAccountAddressRecord(): AccountAddressRecordContextValue | null {\n return useContext(AccountAddressRecordContext);\n}\n\nfunction useAccountAddressRecord(): AccountAddressRecordContextValue {\n const value = useContext(AccountAddressRecordContext);\n if (!value) {\n throw new Error('Address record parts must be used inside an AccountAddressRecord.');\n }\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function AccountAddressRecord({ $data: $dataProp, className, children, ...props }: AccountAddressRecordProps) {\n const address = useDataOverride<AccountAddressBookItemSlice | null | undefined>($dataProp) ?? null;\n const { error } = useContext(ReactiveRootContext);\n const { state: sessionState } = useSession();\n const failed = address === null && Boolean(error);\n\n const value = useMemo(() => ({ address, failed }), [address, failed]);\n\n if (sessionState !== 'loggedIn') return null;\n\n return (\n <AccountAddressRecordContext value={value}>\n <div\n {...props}\n className={className}\n data-fs-account-address-record=\"\"\n {...(failed ? { 'data-fs-account-address-record-state': 'error' } : {})}\n >\n {children}\n </div>\n </AccountAddressRecordContext>\n );\n}\n\n/** Reloads the page: the read changes nothing, so it is safe, and the page re-runs its query. */\nfunction reloadPage() {\n globalThis.location.reload();\n}\n\nexport function AccountAddressRecordError({\n message,\n retryLabel,\n className,\n ...props\n}: AccountAddressRecordErrorProps) {\n const { failed } = useAccountAddressRecord();\n const intl = useIntl();\n\n if (!failed) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-account-address-record-error=\"\">\n <p data-fs-account-address-record-error-message=\"\">\n {resolveAuthoredCopy(message, intl.formatMessage({ id: 'fs/address-record.error' }))}\n </p>\n <Button type=\"button\" onClick={reloadPage} data-fs-account-address-record-retry=\"\">\n {resolveAuthoredCopy(retryLabel, intl.formatMessage({ id: 'fs/address-book.retry' }))}\n </Button>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const AccountAddressRecordDefinition = defineComponent<AccountAddressRecordProps>({\n name: 'AccountAddressRecord',\n importPath: '@vtex/faststore/components',\n component: AccountAddressRecord,\n fragment,\n fetchStrategy: 'reactive',\n requiresContext: 'session',\n providesContext: 'account-address-record',\n skeleton: AccountAddressBookSkeleton,\n editor: { label: 'Account Address Record', category: 'identity' },\n schema: {},\n guideline:\n \"The one saved address the page's route names, read by the route's [id] segment: place it on a page whose route ends in [id], around an AccountAddressFormRoot, which then opens in edit mode seeded with it. Renders nothing unless the session is logged in, so it needs a SessionRoot ancestor. An id that is not the shopper's, or that never existed, answers with the layout's not-found page and never reaches this component. Add AccountAddressRecordError to show a read that failed. While no address has resolved, the form beneath renders nothing, so it never falls back to adding. See account-address-book.md.\",\n});\n\nexport const AccountAddressRecordErrorDefinition = defineComponent<AccountAddressRecordErrorProps>({\n name: 'AccountAddressRecordError',\n importPath: '@vtex/faststore/components',\n component: AccountAddressRecordError,\n requiresContext: 'account-address-record',\n editor: { label: 'Account Address Record Error', category: 'content' },\n schema: {\n message: { type: 'string', label: 'Error message' },\n retryLabel: { type: 'string', label: 'Retry label' },\n },\n guideline:\n 'Shown only when the address could not be read and none resolved: a message and a retry that reloads the page. Never shown for an id that does not exist, which is a not-found page. Must be inside AccountAddressRecord.',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;AA6C/B,MAAM,8BAA8B,cAAuD,IAAI;;;;;AAM/F,SAAgB,kCAA2E;CACzF,OAAO,WAAW,2BAA2B;AAC/C;AAEA,SAAS,0BAA4D;CACnE,MAAM,QAAQ,WAAW,2BAA2B;CACpD,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,mEAAmE;CAErF,OAAO;AACT;AAMA,SAAgB,qBAAqB,EAAE,OAAO,WAAW,WAAW,UAAU,GAAG,SAAoC;CACnH,MAAM,UAAU,gBAAgE,SAAS,KAAK;CAC9F,MAAM,EAAE,UAAU,WAAW,mBAAmB;CAChD,MAAM,EAAE,OAAO,iBAAiB,WAAW;CAC3C,MAAM,SAAS,YAAY,QAAQ,QAAQ,KAAK;CAEhD,MAAM,QAAQ,eAAe;EAAE;EAAS;CAAO,IAAI,CAAC,SAAS,MAAM,CAAC;CAEpE,IAAI,iBAAiB,YAAY,OAAO;CAExC,OACE,oBAAC,6BAAD;EAAoC;EAClC,UAAA,oBAAC,OAAD;GACE,GAAI;GACO;GACX,kCAA+B;GAC/B,GAAK,SAAS,EAAE,wCAAwC,QAAQ,IAAI,CAAC;GAEpE;EACE,CAAA;CACsB,CAAA;AAEjC;;AAGA,SAAS,aAAa;CACpB,WAAW,SAAS,OAAO;AAC7B;AAEA,SAAgB,0BAA0B,EACxC,SACA,YACA,WACA,GAAG,SAC8B;CACjC,MAAM,EAAE,WAAW,wBAAwB;CAC3C,MAAM,OAAO,QAAQ;CAErB,IAAI,CAAC,QAAQ,OAAO;CAEpB,OACE,qBAAC,OAAD;EAAK,GAAI;EAAO,MAAK;EAAmB;EAAW,wCAAqC;EAAxF,UAAA,CACE,oBAAC,KAAD;GAAG,gDAA6C;GAC7C,UAAA,oBAAoB,SAAS,KAAK,cAAc,EAAE,IAAI,0BAA0B,CAAC,CAAC;EAClF,CAAA,GACH,oBAAC,QAAD;GAAQ,MAAK;GAAS,SAAS;GAAY,wCAAqC;GAC7E,UAAA,oBAAoB,YAAY,KAAK,cAAc,EAAE,IAAI,wBAAwB,CAAC,CAAC;EAC9E,CAAA,CACL;;AAET;AAMA,MAAa,iCAAiC,gBAA2C;CACvF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,eAAe;CACf,iBAAiB;CACjB,iBAAiB;CACjB,UAAU;CACV,QAAQ;EAAE,OAAO;EAA0B,UAAU;CAAW;CAChE,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,sCAAsC,gBAAgD;CACjG,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAgC,UAAU;CAAU;CACrE,QAAQ;EACN,SAAS;GAAE,MAAM;GAAU,OAAO;EAAgB;EAClD,YAAY;GAAE,MAAM;GAAU,OAAO;EAAc;CACrD;CACA,WACE;AACJ,CAAC"}
1
+ {"version":3,"file":"account-address-record.js","names":[],"sources":["../../../src/matter/account-address-book/account-address-record.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType, type MessageLocaleProp } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport { Button } from '../../particles/button/button.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport { useSession } from '../session/session.js';\nimport { type AccountAddressBookItemSlice, AccountAddressBookSkeleton } from './account-address-book.js';\n\n/**\n * The one address an own page names (specs/sfs-3438-address-form-own-pages.md, RFC REQ-03). It reads\n * `customerAddress(id: $id)` through the page's reactive query and hands the result to the form\n * beneath it, which opens in edit mode seeded with it.\n *\n * It has no not-found state: a route-identified `null` already 404s on the server, through the\n * layout's not-found page, so a foreign id and a missing id are the same response by construction.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL fragment — a raw template literal, as the book's fragments are.\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment AccountAddressRecordData on Query {\n customerAddress(id: $id) {\n __typename\n id\n country\n recipientName\n street\n number\n complement\n neighborhood\n city\n state\n postalCode\n reference\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type AccountAddressRecordProps = ComponentPropsWithRef<'div'> & {\n $data?: AccountAddressBookItemSlice | null;\n};\n\nexport type AccountAddressRecordErrorProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof AccountAddressRecordErrorContent>;\n };\n\nexport type AccountAddressRecordContextValue = Readonly<{\n /** The address the route names; `null` until it resolved or when the read failed. */\n address: AccountAddressBookItemSlice | null;\n /** The read failed and no address resolved. */\n failed: boolean;\n}>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst AccountAddressRecordContext = createContext<AccountAddressRecordContextValue | null>(null);\n\n/**\n * The record above the caller, or `null` when there is none. A record whose `address` is `null` is\n * still a record: the form must not read that as \"add\".\n */\nexport function useOptionalAccountAddressRecord(): AccountAddressRecordContextValue | null {\n return useContext(AccountAddressRecordContext);\n}\n\nfunction useAccountAddressRecord(): AccountAddressRecordContextValue {\n const value = useContext(AccountAddressRecordContext);\n if (!value) {\n throw new Error('Address record parts must be used inside an AccountAddressRecord.');\n }\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function AccountAddressRecord({ $data: $dataProp, className, children, ...props }: AccountAddressRecordProps) {\n const address = useDataOverride<AccountAddressBookItemSlice | null | undefined>($dataProp) ?? null;\n const { error } = useContext(ReactiveRootContext);\n const { state: sessionState } = useSession();\n const failed = address === null && Boolean(error);\n\n const value = useMemo(() => ({ address, failed }), [address, failed]);\n\n if (sessionState !== 'loggedIn') return null;\n\n return (\n <AccountAddressRecordContext value={value}>\n <div\n {...props}\n className={className}\n data-fs-account-address-record=\"\"\n {...(failed ? { 'data-fs-account-address-record-state': 'error' } : {})}\n >\n {children}\n </div>\n </AccountAddressRecordContext>\n );\n}\n\n/** Reloads the page: the read changes nothing, so it is safe, and the page re-runs its query. */\nfunction reloadPage() {\n globalThis.location.reload();\n}\n\nexport function AccountAddressRecordError({ $content, $locale, className, ...props }: AccountAddressRecordErrorProps) {\n const { failed } = useAccountAddressRecord();\n const { format } = useMessageFormatter(AccountAddressRecordErrorContent, $content);\n\n if (!failed) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-account-address-record-error=\"\">\n <p data-fs-account-address-record-error-message=\"\">{format('message')}</p>\n <Button type=\"button\" onClick={reloadPage} data-fs-account-address-record-retry=\"\">\n {format('retryLabel')}\n </Button>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const AccountAddressRecordDefinition = defineComponent<AccountAddressRecordProps>({\n name: 'AccountAddressRecord',\n importPath: '@vtex/faststore/components',\n component: AccountAddressRecord,\n fragment,\n fetchStrategy: 'reactive',\n requiresContext: 'session',\n providesContext: 'account-address-record',\n skeleton: AccountAddressBookSkeleton,\n editor: { label: 'Account Address Record', category: 'identity' },\n schema: {},\n guideline:\n \"The one saved address the page's route names, read by the route's [id] segment: place it on a page whose route ends in [id], around an AccountAddressFormRoot, which then opens in edit mode seeded with it. Renders nothing unless the session is logged in, so it needs a SessionRoot ancestor. An id that is not the shopper's, or that never existed, answers with the layout's not-found page and never reaches this component. Add AccountAddressRecordError to show a read that failed. While no address has resolved, the form beneath renders nothing, so it never falls back to adding. See account-address-book.md.\",\n});\n\nexport const AccountAddressRecordErrorContent = defineContentType({\n id: 'account-address-record-error',\n title: 'Account Address Record Error',\n description: 'Message and retry label shown when the address cannot be read.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n message: {\n type: 'string',\n title: 'Error message',\n format: 'icu-message',\n messageSource: \"We couldn't load this address.\",\n },\n retryLabel: { type: 'string', title: 'Retry label', format: 'icu-message', messageSource: 'Try again' },\n },\n },\n});\n\nexport const AccountAddressRecordErrorDefinition = defineComponent<AccountAddressRecordErrorProps>({\n name: 'AccountAddressRecordError',\n importPath: '@vtex/faststore/components',\n component: AccountAddressRecordError,\n content: AccountAddressRecordErrorContent,\n requiresContext: 'account-address-record',\n editor: { label: 'Account Address Record Error', category: 'content' },\n schema: {},\n guideline:\n 'Shown only when the address could not be read and none resolved: a message and a retry that reloads the page. Never shown for an id that does not exist, which is a not-found page. Must be inside AccountAddressRecord.',\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;AA2C/B,MAAM,8BAA8B,cAAuD,IAAI;;;;;AAM/F,SAAgB,kCAA2E;CACzF,OAAO,WAAW,2BAA2B;AAC/C;AAEA,SAAS,0BAA4D;CACnE,MAAM,QAAQ,WAAW,2BAA2B;CACpD,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,mEAAmE;CAErF,OAAO;AACT;AAMA,SAAgB,qBAAqB,EAAE,OAAO,WAAW,WAAW,UAAU,GAAG,SAAoC;CACnH,MAAM,UAAU,gBAAgE,SAAS,KAAK;CAC9F,MAAM,EAAE,UAAU,WAAW,mBAAmB;CAChD,MAAM,EAAE,OAAO,iBAAiB,WAAW;CAC3C,MAAM,SAAS,YAAY,QAAQ,QAAQ,KAAK;CAEhD,MAAM,QAAQ,eAAe;EAAE;EAAS;CAAO,IAAI,CAAC,SAAS,MAAM,CAAC;CAEpE,IAAI,iBAAiB,YAAY,OAAO;CAExC,OACE,oBAAC,6BAAD;EAAoC;EAClC,UAAA,oBAAC,OAAD;GACE,GAAI;GACO;GACX,kCAA+B;GAC/B,GAAK,SAAS,EAAE,wCAAwC,QAAQ,IAAI,CAAC;GAEpE;EAC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