@vtex/faststore 0.0.8 → 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 (568) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +0 -1
  3. package/dist/actions.json +48 -1
  4. package/dist/catalog.json +1397 -1594
  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 +67 -56
  13. package/dist/components.js +64 -53
  14. package/dist/content-types.json +5886 -555
  15. package/dist/core/dist/define-component.d.ts +7 -2
  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-entry-point.md +4 -4
  24. package/dist/docs/account-menu.md +16 -17
  25. package/dist/docs/account-saved-cards.md +306 -0
  26. package/dist/docs/alert-dialog.md +3 -1
  27. package/dist/docs/avatar.md +4 -2
  28. package/dist/docs/billing-address.md +99 -30
  29. package/dist/docs/binding-switcher.md +157 -0
  30. package/dist/docs/buy-button.md +7 -8
  31. package/dist/docs/card-entry.md +42 -29
  32. package/dist/docs/card-summary.md +185 -0
  33. package/dist/docs/cardholder-document.md +5 -3
  34. package/dist/docs/carousel.md +5 -4
  35. package/dist/docs/cart-destination.md +251 -0
  36. package/dist/docs/cart-item.md +48 -15
  37. package/dist/docs/cart-totalizer.md +8 -6
  38. package/dist/docs/cart.md +240 -39
  39. package/dist/docs/challenge-return.md +135 -0
  40. package/dist/docs/client-preferences-fieldset.md +10 -5
  41. package/dist/docs/client-preferences.md +31 -8
  42. package/dist/docs/client-profile-fieldset.md +20 -6
  43. package/dist/docs/client-profile.md +12 -3
  44. package/dist/docs/copy-text.md +9 -7
  45. package/dist/docs/document-field.md +1 -1
  46. package/dist/docs/email-field.md +2 -1
  47. package/dist/docs/email-identification.md +12 -2
  48. package/dist/docs/footer-copyright.md +4 -2
  49. package/dist/docs/footer-social.md +1 -1
  50. package/dist/docs/form.md +54 -18
  51. package/dist/docs/free-shipping-progress.md +18 -13
  52. package/dist/docs/identity-edit.md +8 -2
  53. package/dist/docs/identity-summary.md +18 -5
  54. package/dist/docs/incentives.md +2 -2
  55. package/dist/docs/installments.md +46 -32
  56. package/dist/docs/logo.md +1 -1
  57. package/dist/docs/my-account-profile.md +16 -11
  58. package/dist/docs/navigation-link.md +5 -3
  59. package/dist/docs/order-cancel.md +3 -1
  60. package/dist/docs/order-delivery-address.md +7 -5
  61. package/dist/docs/order-delivery-group.md +1 -3
  62. package/dist/docs/order-details-back.md +1 -1
  63. package/dist/docs/order-details-header.md +1 -4
  64. package/dist/docs/order-invoice-download.md +60 -0
  65. package/dist/docs/order-list-row.md +1 -1
  66. package/dist/docs/order-list-search.md +13 -20
  67. package/dist/docs/order-list-views.md +11 -17
  68. package/dist/docs/order-list.md +12 -5
  69. package/dist/docs/order-payment.md +9 -7
  70. package/dist/docs/order-placed-date.md +1 -1
  71. package/dist/docs/order-placed-payment-summary.md +28 -15
  72. package/dist/docs/order-placed.md +49 -14
  73. package/dist/docs/order-progress.md +1 -1
  74. package/dist/docs/order-status-badge.md +20 -9
  75. package/dist/docs/order-summary.md +2 -2
  76. package/dist/docs/order-tracking-link.md +58 -0
  77. package/dist/docs/payment-method-badges.md +32 -6
  78. package/dist/docs/payment-methods.md +2 -2
  79. package/dist/docs/payment.md +36 -17
  80. package/dist/docs/phone-field.md +4 -4
  81. package/dist/docs/place-order.md +84 -36
  82. package/dist/docs/postal-code-field.md +3 -1
  83. package/dist/docs/pricing.md +21 -23
  84. package/dist/docs/product-gallery.md +19 -20
  85. package/dist/docs/product-information.md +14 -10
  86. package/dist/docs/product-list.md +7 -6
  87. package/dist/docs/product-shelf.md +7 -1
  88. package/dist/docs/promotion.md +4 -2
  89. package/dist/docs/region.md +23 -15
  90. package/dist/docs/save-card.md +7 -6
  91. package/dist/docs/saved-cards.md +65 -36
  92. package/dist/docs/select.md +3 -4
  93. package/dist/docs/shipping-address.md +57 -21
  94. package/dist/docs/shipping-simulator.md +53 -15
  95. package/dist/docs/sign-in-disclosure.md +176 -0
  96. package/dist/docs/sign-in-form.md +78 -47
  97. package/dist/docs/sign-in-redirect.md +5 -3
  98. package/dist/docs/sign-in.md +173 -0
  99. package/dist/docs/toast.md +45 -16
  100. package/dist/docs/variant-selector.md +15 -11
  101. package/dist/graphql/types.d.ts +4 -14
  102. package/dist/index.d.ts +3 -2
  103. package/dist/internal/client.d.ts +4 -3
  104. package/dist/internal/client.js +5 -2
  105. package/dist/internal/server.d.ts +10 -5
  106. package/dist/internal/server.js +9 -4
  107. package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +250 -66
  108. package/dist/matter/access-code-sign-in/access-code-sign-in.js +459 -188
  109. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
  110. package/dist/matter/account-address-book/account-address-book-delete.d.ts +78 -40
  111. package/dist/matter/account-address-book/account-address-book-delete.js +86 -50
  112. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -1
  113. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +21 -4
  114. package/dist/matter/account-address-book/account-address-book-deliverability.js +45 -17
  115. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -1
  116. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +74 -19
  117. package/dist/matter/account-address-book/account-address-book-form-parts.js +77 -26
  118. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -1
  119. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +27 -6
  120. package/dist/matter/account-address-book/account-address-book-profile-notice.js +55 -28
  121. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -1
  122. package/dist/matter/account-address-book/account-address-book.d.ts +67 -14
  123. package/dist/matter/account-address-book/account-address-book.js +74 -33
  124. package/dist/matter/account-address-book/account-address-book.js.map +1 -1
  125. package/dist/matter/account-address-book/account-address-country-switch.js +3 -3
  126. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -1
  127. package/dist/matter/account-address-book/account-address-country.d.ts +66 -20
  128. package/dist/matter/account-address-book/account-address-country.js +83 -49
  129. package/dist/matter/account-address-book/account-address-country.js.map +1 -1
  130. package/dist/matter/account-address-book/account-address-form-context.d.ts +8 -4
  131. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -1
  132. package/dist/matter/account-address-book/account-address-form.d.ts +468 -45
  133. package/dist/matter/account-address-book/account-address-form.js +518 -155
  134. package/dist/matter/account-address-book/account-address-form.js.map +1 -1
  135. package/dist/matter/account-address-book/account-address-record.d.ts +27 -6
  136. package/dist/matter/account-address-book/account-address-record.js +32 -17
  137. package/dist/matter/account-address-book/account-address-record.js.map +1 -1
  138. package/dist/matter/account-menu/account-menu.d.ts +34 -17
  139. package/dist/matter/account-menu/account-menu.js +46 -54
  140. package/dist/matter/account-menu/account-menu.js.map +1 -1
  141. package/dist/matter/account-menu-identity/account-menu-identity.js +1 -1
  142. package/dist/matter/account-saved-cards/account-saved-cards.d.ts +463 -0
  143. package/dist/matter/account-saved-cards/account-saved-cards.js +1011 -0
  144. package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
  145. package/dist/matter/billing-address/billing-address.d.ts +156 -74
  146. package/dist/matter/billing-address/billing-address.js +227 -156
  147. package/dist/matter/billing-address/billing-address.js.map +1 -1
  148. package/dist/matter/breadcrumb/breadcrumb.d.ts +21 -3
  149. package/dist/matter/breadcrumb/breadcrumb.js +24 -9
  150. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  151. package/dist/matter/buy-button/buy-button.d.ts +8 -11
  152. package/dist/matter/buy-button/buy-button.js +10 -19
  153. package/dist/matter/buy-button/buy-button.js.map +1 -1
  154. package/dist/matter/card-entry/card-capture.js +12 -4
  155. package/dist/matter/card-entry/card-capture.js.map +1 -1
  156. package/dist/matter/card-entry/card-entry.d.ts +123 -32
  157. package/dist/matter/card-entry/card-entry.js +348 -221
  158. package/dist/matter/card-entry/card-entry.js.map +1 -1
  159. package/dist/matter/cart/cart-namespace.d.ts +11 -1
  160. package/dist/matter/cart/cart-namespace.js +11 -1
  161. package/dist/matter/cart/cart-namespace.js.map +1 -1
  162. package/dist/matter/cart/cart.d.ts +416 -45
  163. package/dist/matter/cart/cart.js +782 -101
  164. package/dist/matter/cart/cart.js.map +1 -1
  165. package/dist/matter/cart-destination/cart-destination.d.ts +233 -0
  166. package/dist/matter/cart-destination/cart-destination.js +703 -0
  167. package/dist/matter/cart-destination/cart-destination.js.map +1 -0
  168. package/dist/matter/cart-item/cart-item.d.ts +145 -16
  169. package/dist/matter/cart-item/cart-item.js +230 -54
  170. package/dist/matter/cart-item/cart-item.js.map +1 -1
  171. package/dist/matter/cart-item-compositions/cart-item-compositions.js +1 -1
  172. package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -1
  173. package/dist/matter/cart-item-customizations/cart-item-customizations.js +1 -1
  174. package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -1
  175. package/dist/matter/cart-item-discounts/cart-item-discounts.js +1 -1
  176. package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -1
  177. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +1 -1
  178. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -1
  179. package/dist/matter/cart-item-variations/cart-item-variations.js +1 -1
  180. package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -1
  181. package/dist/matter/cart-totalizer/cart-totalizer.d.ts +43 -9
  182. package/dist/matter/cart-totalizer/cart-totalizer.js +49 -19
  183. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
  184. package/dist/matter/challenge-return/challenge-return.d.ts +62 -0
  185. package/dist/matter/challenge-return/challenge-return.js +241 -0
  186. package/dist/matter/challenge-return/challenge-return.js.map +1 -0
  187. package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +86 -17
  188. package/dist/matter/client-preferences/client-preferences-fieldset.js +126 -54
  189. package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -1
  190. package/dist/matter/client-preferences/client-preferences.d.ts +50 -7
  191. package/dist/matter/client-preferences/client-preferences.js +84 -15
  192. package/dist/matter/client-preferences/client-preferences.js.map +1 -1
  193. package/dist/matter/client-profile/client-profile.d.ts +44 -9
  194. package/dist/matter/client-profile/client-profile.js +64 -24
  195. package/dist/matter/client-profile/client-profile.js.map +1 -1
  196. package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -22
  197. package/dist/matter/client-profile-form/client-profile-fieldset.js +161 -73
  198. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  199. package/dist/matter/delivery-options/delivery-options-accordion.d.ts +49 -4
  200. package/dist/matter/delivery-options/delivery-options-accordion.js +67 -14
  201. package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
  202. package/dist/matter/delivery-options/delivery-options-controller.d.ts +69 -9
  203. package/dist/matter/delivery-options/delivery-options-controller.js +80 -14
  204. package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
  205. package/dist/matter/delivery-options/delivery-options.d.ts +37 -2
  206. package/dist/matter/delivery-options/delivery-options.js +75 -12
  207. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  208. package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +1 -0
  209. package/dist/matter/delivery-options/use-delivery-option-selection.js +1 -1
  210. package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -1
  211. package/dist/matter/email-identification/email-identification.d.ts +25 -3
  212. package/dist/matter/email-identification/email-identification.js +49 -12
  213. package/dist/matter/email-identification/email-identification.js.map +1 -1
  214. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +85 -10
  215. package/dist/matter/free-shipping-progress/free-shipping-progress.js +153 -53
  216. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
  217. package/dist/matter/identity-edit/identity-edit.d.ts +52 -10
  218. package/dist/matter/identity-edit/identity-edit.js +47 -19
  219. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  220. package/dist/matter/identity-summary/identity-summary.d.ts +76 -22
  221. package/dist/matter/identity-summary/identity-summary.js +95 -45
  222. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  223. package/dist/matter/installments/installments-select.d.ts +98 -16
  224. package/dist/matter/installments/installments-select.js +156 -48
  225. package/dist/matter/installments/installments-select.js.map +1 -1
  226. package/dist/matter/installments/installments.d.ts +96 -16
  227. package/dist/matter/installments/installments.js +115 -40
  228. package/dist/matter/installments/installments.js.map +1 -1
  229. package/dist/matter/installments/use-installments-selection.d.ts +1 -0
  230. package/dist/matter/installments/use-installments-selection.js +8 -3
  231. package/dist/matter/installments/use-installments-selection.js.map +1 -1
  232. package/dist/matter/my-account-profile/my-account-profile.d.ts +358 -103
  233. package/dist/matter/my-account-profile/my-account-profile.js +370 -174
  234. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  235. package/dist/matter/order-cancel/order-cancel.d.ts +65 -19
  236. package/dist/matter/order-cancel/order-cancel.js +118 -51
  237. package/dist/matter/order-cancel/order-cancel.js.map +1 -1
  238. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +8 -18
  239. package/dist/matter/order-delivery-address/order-delivery-address.js +14 -23
  240. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -1
  241. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +40 -24
  242. package/dist/matter/order-delivery-group/order-delivery-group.js +64 -74
  243. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -1
  244. package/dist/matter/order-details-header/order-details-header.d.ts +32 -15
  245. package/dist/matter/order-details-header/order-details-header.js +66 -58
  246. package/dist/matter/order-details-header/order-details-header.js.map +1 -1
  247. package/dist/matter/order-invoice-download/order-invoice-download.d.ts +78 -0
  248. package/dist/matter/order-invoice-download/order-invoice-download.js +173 -0
  249. package/dist/matter/order-invoice-download/order-invoice-download.js.map +1 -0
  250. package/dist/matter/order-list/order-list.d.ts +164 -19
  251. package/dist/matter/order-list/order-list.js +229 -87
  252. package/dist/matter/order-list/order-list.js.map +1 -1
  253. package/dist/matter/order-list-row/order-list-row.d.ts +6 -1
  254. package/dist/matter/order-list-row/order-list-row.js +3 -2
  255. package/dist/matter/order-list-row/order-list-row.js.map +1 -1
  256. package/dist/matter/order-list-search/order-list-search.d.ts +18 -26
  257. package/dist/matter/order-list-search/order-list-search.js +30 -69
  258. package/dist/matter/order-list-search/order-list-search.js.map +1 -1
  259. package/dist/matter/order-list-views/order-list-views.d.ts +15 -22
  260. package/dist/matter/order-list-views/order-list-views.js +22 -68
  261. package/dist/matter/order-list-views/order-list-views.js.map +1 -1
  262. package/dist/matter/order-payment/order-payment.d.ts +33 -10
  263. package/dist/matter/order-payment/order-payment.js +44 -39
  264. package/dist/matter/order-payment/order-payment.js.map +1 -1
  265. package/dist/matter/order-placed/order-placed-deliveries.d.ts +144 -12
  266. package/dist/matter/order-placed/order-placed-deliveries.js +115 -40
  267. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -1
  268. package/dist/matter/order-placed/order-placed.d.ts +198 -31
  269. package/dist/matter/order-placed/order-placed.js +230 -139
  270. package/dist/matter/order-placed/order-placed.js.map +1 -1
  271. package/dist/matter/order-placed-date/order-placed-date.d.ts +5 -8
  272. package/dist/matter/order-placed-date/order-placed-date.js +7 -8
  273. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -1
  274. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +90 -17
  275. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +93 -117
  276. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  277. package/dist/matter/order-progress/order-progress.d.ts +19 -8
  278. package/dist/matter/order-progress/order-progress.js +37 -45
  279. package/dist/matter/order-progress/order-progress.js.map +1 -1
  280. package/dist/matter/order-summary/order-summary.d.ts +19 -9
  281. package/dist/matter/order-summary/order-summary.js +38 -44
  282. package/dist/matter/order-summary/order-summary.js.map +1 -1
  283. package/dist/matter/order-tracking-link/order-tracking-link.d.ts +43 -0
  284. package/dist/matter/order-tracking-link/order-tracking-link.js +107 -0
  285. package/dist/matter/order-tracking-link/order-tracking-link.js.map +1 -0
  286. package/dist/matter/payment/payment-card-capture.js +17 -10
  287. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  288. package/dist/matter/payment/payment-controller.d.ts +4 -2
  289. package/dist/matter/payment/payment-controller.js +30 -9
  290. package/dist/matter/payment/payment-controller.js.map +1 -1
  291. package/dist/matter/payment/payment-method-badges.js +1 -1
  292. package/dist/matter/payment/payment.d.ts +69 -19
  293. package/dist/matter/payment/payment.js +101 -35
  294. package/dist/matter/payment/payment.js.map +1 -1
  295. package/dist/matter/payment/use-payment-method-selection.d.ts +25 -4
  296. package/dist/matter/payment/use-payment-method-selection.js +94 -32
  297. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  298. package/dist/matter/payment/use-payment-submit-gate.d.ts +14 -3
  299. package/dist/matter/payment/use-payment-submit-gate.js +47 -8
  300. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  301. package/dist/matter/place-order/place-order.d.ts +171 -57
  302. package/dist/matter/place-order/place-order.js +376 -185
  303. package/dist/matter/place-order/place-order.js.map +1 -1
  304. package/dist/matter/pricing/pricing.d.ts +152 -13
  305. package/dist/matter/pricing/pricing.js +153 -52
  306. package/dist/matter/pricing/pricing.js.map +1 -1
  307. package/dist/matter/product-information/product-information.d.ts +27 -4
  308. package/dist/matter/product-information/product-information.js +32 -15
  309. package/dist/matter/product-information/product-information.js.map +1 -1
  310. package/dist/matter/product-list/product-list.d.ts +24 -6
  311. package/dist/matter/product-list/product-list.js +32 -26
  312. package/dist/matter/product-list/product-list.js.map +1 -1
  313. package/dist/matter/product-shelf/product-shelf.d.ts +8 -3
  314. package/dist/matter/product-shelf/product-shelf.js +111 -10
  315. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  316. package/dist/matter/region/region.d.ts +33 -16
  317. package/dist/matter/region/region.js +59 -52
  318. package/dist/matter/region/region.js.map +1 -1
  319. package/dist/matter/save-card/save-card.d.ts +43 -8
  320. package/dist/matter/save-card/save-card.js +61 -23
  321. package/dist/matter/save-card/save-card.js.map +1 -1
  322. package/dist/matter/saved-cards/saved-cards.d.ts +113 -21
  323. package/dist/matter/saved-cards/saved-cards.js +349 -77
  324. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  325. package/dist/matter/shipping-address/address-payload.js +25 -0
  326. package/dist/matter/shipping-address/address-payload.js.map +1 -0
  327. package/dist/matter/shipping-address/country-descriptors.js +71 -71
  328. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  329. package/dist/matter/shipping-address/library-country-descriptors.js +136 -0
  330. package/dist/matter/shipping-address/library-country-descriptors.js.map +1 -0
  331. package/dist/matter/shipping-address/shipping-address.d.ts +312 -45
  332. package/dist/matter/shipping-address/shipping-address.js +443 -188
  333. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  334. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +251 -25
  335. package/dist/matter/shipping-simulator/shipping-simulator.js +261 -51
  336. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  337. package/dist/matter/sign-in/sign-in.d.ts +108 -0
  338. package/dist/matter/sign-in/sign-in.js +285 -0
  339. package/dist/matter/sign-in/sign-in.js.map +1 -0
  340. package/dist/matter/sign-in-disclosure/sign-in-disclosure.d.ts +81 -0
  341. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js +232 -0
  342. package/dist/matter/sign-in-disclosure/sign-in-disclosure.js.map +1 -0
  343. package/dist/matter/sign-in-form/sign-in-form.d.ts +93 -62
  344. package/dist/matter/sign-in-form/sign-in-form.js +134 -144
  345. package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
  346. package/dist/particles/binding-switcher/binding-switcher.d.ts +59 -0
  347. package/dist/particles/binding-switcher/binding-switcher.js +194 -0
  348. package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
  349. package/dist/particles/card-summary/card-network.d.ts +17 -0
  350. package/dist/particles/card-summary/card-network.js +25 -0
  351. package/dist/particles/card-summary/card-network.js.map +1 -0
  352. package/dist/particles/card-summary/card-summary.d.ts +113 -0
  353. package/dist/particles/card-summary/card-summary.js +221 -0
  354. package/dist/particles/card-summary/card-summary.js.map +1 -0
  355. package/dist/particles/carousel/carousel.d.ts +99 -11
  356. package/dist/particles/carousel/carousel.js +103 -35
  357. package/dist/particles/carousel/carousel.js.map +1 -1
  358. package/dist/particles/copy-text/copy-text.js +5 -15
  359. package/dist/particles/copy-text/copy-text.js.map +1 -1
  360. package/dist/particles/dialog/dialog.d.ts +14 -6
  361. package/dist/particles/dialog/dialog.js +6 -3
  362. package/dist/particles/dialog/dialog.js.map +1 -1
  363. package/dist/particles/drawer/drawer.js +1 -1
  364. package/dist/particles/drawer/drawer.js.map +1 -1
  365. package/dist/particles/email-field/email-field.d.ts +2 -1
  366. package/dist/particles/email-field/email-field.js +2 -1
  367. package/dist/particles/email-field/email-field.js.map +1 -1
  368. package/dist/particles/footer-link-group/footer-link-group.js +1 -0
  369. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  370. package/dist/particles/footer-social/footer-social.d.ts +1 -1
  371. package/dist/particles/footer-social/footer-social.js +1 -1
  372. package/dist/particles/footer-social/footer-social.js.map +1 -1
  373. package/dist/particles/form/form.d.ts +85 -13
  374. package/dist/particles/form/form.js +91 -42
  375. package/dist/particles/form/form.js.map +1 -1
  376. package/dist/particles/gallery/gallery.d.ts +129 -12
  377. package/dist/particles/gallery/gallery.js +121 -34
  378. package/dist/particles/gallery/gallery.js.map +1 -1
  379. package/dist/particles/incentives/incentives.d.ts +1 -1
  380. package/dist/particles/incentives/incentives.js +1 -1
  381. package/dist/particles/incentives/incentives.js.map +1 -1
  382. package/dist/particles/order-details-back/order-details-back.d.ts +5 -3
  383. package/dist/particles/order-details-back/order-details-back.js +8 -10
  384. package/dist/particles/order-details-back/order-details-back.js.map +1 -1
  385. package/dist/particles/order-status-badge/order-status-badge.d.ts +3 -3
  386. package/dist/particles/order-status-badge/order-status-badge.js +4 -20
  387. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -1
  388. package/dist/particles/password-field/password-field.d.ts +1 -1
  389. package/dist/particles/password-field/password-field.js +2 -4
  390. package/dist/particles/password-field/password-field.js.map +1 -1
  391. package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
  392. package/dist/particles/payment-methods/payment-methods.js +1 -1
  393. package/dist/particles/payment-methods/payment-methods.js.map +1 -1
  394. package/dist/particles/phone-field/phone-field.d.ts +4 -4
  395. package/dist/particles/phone-field/phone-field.js +8 -11
  396. package/dist/particles/phone-field/phone-field.js.map +1 -1
  397. package/dist/particles/spinner/spinner.d.ts +24 -4
  398. package/dist/particles/spinner/spinner.js +25 -9
  399. package/dist/particles/spinner/spinner.js.map +1 -1
  400. package/dist/particles/switch/switch.d.ts +4 -1
  401. package/dist/particles/switch/switch.js +3 -1
  402. package/dist/particles/switch/switch.js.map +1 -1
  403. package/dist/particles/toast/toast.d.ts +49 -9
  404. package/dist/particles/toast/toast.js +81 -15
  405. package/dist/particles/toast/toast.js.map +1 -1
  406. package/dist/schema.graphql +461 -89
  407. package/dist/sdk/actions/index.d.ts +3 -1
  408. package/dist/sdk/actions/index.js +3 -1
  409. package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
  410. package/dist/sdk/actions/locale-action-provider.js +20 -0
  411. package/dist/sdk/actions/locale-action-provider.js.map +1 -0
  412. package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
  413. package/dist/sdk/actions/saved-card-action-provider.js +16 -0
  414. package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
  415. package/dist/sdk/actions/types.d.ts +6 -2
  416. package/dist/sdk/address/address-fields.js +4 -4
  417. package/dist/sdk/address/address-fields.js.map +1 -1
  418. package/dist/sdk/address/constants.js +1 -6
  419. package/dist/sdk/address/constants.js.map +1 -1
  420. package/dist/sdk/address/messages.js +44 -44
  421. package/dist/sdk/address/messages.js.map +1 -1
  422. package/dist/sdk/address/postal-code.js +15 -2
  423. package/dist/sdk/address/postal-code.js.map +1 -1
  424. package/dist/sdk/address/types.d.ts +5 -3
  425. package/dist/sdk/address/validate-address.js +3 -3
  426. package/dist/sdk/address/validate-address.js.map +1 -1
  427. package/dist/sdk/analytics/use-analytics-actions.d.ts +1 -1
  428. package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
  429. package/dist/sdk/cache/storefront-cache.js +2 -1
  430. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  431. package/dist/sdk/cart/operations.d.ts +2 -1
  432. package/dist/sdk/cart/operations.js +55 -1
  433. package/dist/sdk/cart/operations.js.map +1 -1
  434. package/dist/sdk/cart/optimistic.d.ts +30 -7
  435. package/dist/sdk/cart/optimistic.js +78 -41
  436. package/dist/sdk/cart/optimistic.js.map +1 -1
  437. package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
  438. package/dist/sdk/cart/use-cart-actions.js +61 -15
  439. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  440. package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
  441. package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
  442. package/dist/sdk/data/index.js +2 -2
  443. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  444. package/dist/sdk/generated/gql.js +16 -12
  445. package/dist/sdk/generated/gql.js.map +1 -1
  446. package/dist/sdk/generated/graphql.d.ts +197 -51
  447. package/dist/sdk/generated/graphql.js +2318 -91
  448. package/dist/sdk/generated/graphql.js.map +1 -1
  449. package/dist/sdk/i18n/format-error-code.js +23 -0
  450. package/dist/sdk/i18n/format-error-code.js.map +1 -0
  451. package/dist/sdk/i18n/message-formatter.d.ts +22 -0
  452. package/dist/sdk/i18n/message-formatter.js +140 -0
  453. package/dist/sdk/i18n/message-formatter.js.map +1 -0
  454. package/dist/sdk/i18n/use-message-formatter.d.ts +8 -0
  455. package/dist/sdk/i18n/use-message-formatter.js +18 -0
  456. package/dist/sdk/i18n/use-message-formatter.js.map +1 -0
  457. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  458. package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
  459. package/dist/sdk/locale/binding-switch-provider.js +20 -0
  460. package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
  461. package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
  462. package/dist/sdk/locale/use-locale-actions.js +70 -0
  463. package/dist/sdk/locale/use-locale-actions.js.map +1 -0
  464. package/dist/sdk/navigation/binding-switch.d.ts +39 -0
  465. package/dist/sdk/navigation/binding-switch.js +129 -0
  466. package/dist/sdk/navigation/binding-switch.js.map +1 -0
  467. package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
  468. package/dist/sdk/navigation/decode-route-params.js +32 -0
  469. package/dist/sdk/navigation/decode-route-params.js.map +1 -0
  470. package/dist/sdk/navigation/redirect.d.ts +2 -0
  471. package/dist/sdk/navigation/redirect.js +19 -1
  472. package/dist/sdk/navigation/redirect.js.map +1 -1
  473. package/dist/sdk/navigation/types.d.ts +13 -0
  474. package/dist/sdk/payment/bin-format.js +20 -0
  475. package/dist/sdk/payment/bin-format.js.map +1 -0
  476. package/dist/sdk/payment/challenge-return.js +37 -0
  477. package/dist/sdk/payment/challenge-return.js.map +1 -0
  478. package/dist/sdk/payment/confirmation-last-four.js +39 -0
  479. package/dist/sdk/payment/confirmation-last-four.js.map +1 -0
  480. package/dist/sdk/payment/gateway.d.ts +1 -1
  481. package/dist/sdk/payment/gateway.js +8 -2
  482. package/dist/sdk/payment/gateway.js.map +1 -1
  483. package/dist/sdk/payment/operations.d.ts +1 -0
  484. package/dist/sdk/payment/operations.js +28 -6
  485. package/dist/sdk/payment/operations.js.map +1 -1
  486. package/dist/sdk/payment/resumed-purchase.d.ts +1 -0
  487. package/dist/sdk/payment/resumed-purchase.js +119 -0
  488. package/dist/sdk/payment/resumed-purchase.js.map +1 -0
  489. package/dist/sdk/payment/security-code-mask.js +16 -23
  490. package/dist/sdk/payment/security-code-mask.js.map +1 -1
  491. package/dist/sdk/payment/submission-registry.js +6 -2
  492. package/dist/sdk/payment/submission-registry.js.map +1 -1
  493. package/dist/sdk/payment/use-payment-actions.d.ts +18 -3
  494. package/dist/sdk/payment/use-payment-actions.js +23 -3
  495. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  496. package/dist/sdk/payment/use-place-order.d.ts +10 -2
  497. package/dist/sdk/payment/use-place-order.js +138 -76
  498. package/dist/sdk/payment/use-place-order.js.map +1 -1
  499. package/dist/sdk/provider/storefront-provider.d.ts +1 -7
  500. package/dist/sdk/provider/storefront-provider.js +4 -11
  501. package/dist/sdk/provider/storefront-provider.js.map +1 -1
  502. package/dist/sdk/saved-cards/operations.d.ts +16 -0
  503. package/dist/sdk/saved-cards/operations.js +41 -0
  504. package/dist/sdk/saved-cards/operations.js.map +1 -0
  505. package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
  506. package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
  507. package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
  508. package/dist/sdk/seo/entity-landing.d.ts +24 -0
  509. package/dist/sdk/seo/entity-landing.js +30 -0
  510. package/dist/sdk/seo/entity-landing.js.map +1 -0
  511. package/dist/sdk/seo/page-alternates.d.ts +8 -5
  512. package/dist/sdk/seo/page-alternates.js +11 -14
  513. package/dist/sdk/seo/page-alternates.js.map +1 -1
  514. package/dist/sdk/seo/search-landing.d.ts +42 -0
  515. package/dist/sdk/seo/search-landing.js +85 -0
  516. package/dist/sdk/seo/search-landing.js.map +1 -0
  517. package/dist/sdk/session/mock-session.d.ts +9 -0
  518. package/dist/sdk/session/mock-session.js +31 -0
  519. package/dist/sdk/session/mock-session.js.map +1 -0
  520. package/dist/sdk/session/read-server-session.d.ts +3 -0
  521. package/dist/sdk/session/read-server-session.js +5 -0
  522. package/dist/sdk/session/read-server-session.js.map +1 -1
  523. package/dist/sdk/session/return-path-segment.d.ts +10 -0
  524. package/dist/sdk/session/return-path-segment.js +15 -0
  525. package/dist/sdk/session/return-path-segment.js.map +1 -0
  526. package/dist/sdk/session/use-session-actions.js.map +1 -1
  527. package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
  528. package/dist/sdk/shipping/shipping-operations.js +13 -0
  529. package/dist/sdk/shipping/shipping-operations.js.map +1 -1
  530. package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -1
  531. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  532. package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -1
  533. package/dist/sdk/state/cart.d.ts +9 -2
  534. package/dist/sdk/state/cart.js +9 -2
  535. package/dist/sdk/state/cart.js.map +1 -1
  536. package/dist/utils/safe-href.d.ts +2 -0
  537. package/package.json +4 -3
  538. package/skills/storefront-asset/SKILL.md +2 -2
  539. package/skills/storefront-asset/references/api-side.md +27 -14
  540. package/skills/storefront-asset/references/findings.md +5 -2
  541. package/src/styles/tailwind.css +9 -2
  542. package/dist/matter/shipping-address/country-descriptors.d.ts +0 -1
  543. package/dist/message-locales.json +0 -7
  544. package/dist/sdk/i18n/client.d.ts +0 -4
  545. package/dist/sdk/i18n/client.js +0 -4
  546. package/dist/sdk/i18n/locales.d.ts +0 -8
  547. package/dist/sdk/i18n/locales.js +0 -57
  548. package/dist/sdk/i18n/locales.js.map +0 -1
  549. package/dist/sdk/i18n/messages/en-US.js +0 -164
  550. package/dist/sdk/i18n/messages/en-US.js.map +0 -1
  551. package/dist/sdk/i18n/messages/en-US.json +0 -159
  552. package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -163
  553. package/dist/sdk/i18n/messages/es-ES.js +0 -164
  554. package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
  555. package/dist/sdk/i18n/messages/es-ES.json +0 -159
  556. package/dist/sdk/i18n/messages/pt-BR.js +0 -164
  557. package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
  558. package/dist/sdk/i18n/messages/pt-BR.json +0 -159
  559. package/dist/sdk/i18n/provider.d.ts +0 -1
  560. package/dist/sdk/i18n/provider.js +0 -30
  561. package/dist/sdk/i18n/provider.js.map +0 -1
  562. package/dist/sdk/i18n/server.d.ts +0 -28
  563. package/dist/sdk/i18n/server.js +0 -59
  564. package/dist/sdk/i18n/server.js.map +0 -1
  565. package/dist/utils/resolve-authored-copy.js +0 -18
  566. package/dist/utils/resolve-authored-copy.js.map +0 -1
  567. package/dist/utils/substitute-template.js +0 -33
  568. package/dist/utils/substitute-template.js.map +0 -1
@@ -1,19 +1,83 @@
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
5
  import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
6
+ import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
5
7
  import { useDataOverride } from "../../sdk/data/data-override-context.js";
8
+ import { isFiniteAmount } from "../cart/cart.js";
6
9
  import { Meter } from "../../particles/meter/meter.js";
7
10
  import { createContext, useContext } from "react";
8
11
  import { jsx } from "react/jsx-runtime";
9
12
  //#region src/matter/free-shipping-progress/free-shipping-progress.tsx
13
+ const FreeShippingProgressMessageContent = defineContentType({
14
+ id: "free-shipping-progress-message",
15
+ title: "Free Shipping Progress Message",
16
+ description: "The below-threshold and earned free-shipping messages.",
17
+ schema: {
18
+ type: "object",
19
+ additionalProperties: false,
20
+ properties: {
21
+ label: {
22
+ type: "string",
23
+ title: "Below-threshold label",
24
+ description: "Shown while the cart is below the threshold; value is the formatted amount still missing.",
25
+ format: "icu-message",
26
+ messageSource: "{value} away from free shipping",
27
+ messageArguments: {
28
+ type: "object",
29
+ properties: { value: { type: "string" } }
30
+ },
31
+ messageExample: { value: "$25.00" }
32
+ },
33
+ qualifiedLabel: {
34
+ type: "string",
35
+ title: "Qualified label",
36
+ format: "icu-message",
37
+ messageSource: "You got free shipping!"
38
+ }
39
+ }
40
+ }
41
+ });
42
+ const FreeShippingProgressBarContent = defineContentType({
43
+ id: "free-shipping-progress-bar",
44
+ title: "Free Shipping Progress Bar",
45
+ description: "The value text a screen reader announces for the progress bar.",
46
+ schema: {
47
+ type: "object",
48
+ additionalProperties: false,
49
+ properties: {
50
+ valueText: {
51
+ type: "string",
52
+ title: "Below-threshold value text",
53
+ description: "Announced while the cart is below the threshold; value is the formatted amount still missing.",
54
+ format: "icu-message",
55
+ messageSource: "{value} left for free shipping",
56
+ messageArguments: {
57
+ type: "object",
58
+ properties: { value: { type: "string" } }
59
+ },
60
+ messageExample: { value: "$25.00" }
61
+ },
62
+ qualifiedValueText: {
63
+ type: "string",
64
+ title: "Qualified value text",
65
+ format: "icu-message",
66
+ messageSource: "Free shipping earned"
67
+ }
68
+ }
69
+ }
70
+ });
10
71
  const fragment = `
11
72
  fragment FreeShippingProgressData on Query {
12
73
  cart {
13
74
  id
14
- total {
15
- amount
16
- currencyCode
75
+ totalizers {
76
+ id
77
+ value {
78
+ amount
79
+ currencyCode
80
+ }
17
81
  }
18
82
  freeShippingProgress {
19
83
  threshold {
@@ -45,6 +109,62 @@ function formatCurrency(value, locale, currency) {
45
109
  function clamp01(value) {
46
110
  return Math.min(Math.max(value, 0), 1);
47
111
  }
112
+ function previewCart({ threshold, remaining, qualified, itemsTotal }, currency) {
113
+ if (qualified === void 0 && threshold === void 0 && remaining === void 0 && itemsTotal === void 0) return null;
114
+ return {
115
+ id: "preview",
116
+ totalizers: itemsTotal === void 0 ? [] : [{
117
+ id: "Items",
118
+ value: {
119
+ amount: itemsTotal,
120
+ currencyCode: currency
121
+ }
122
+ }],
123
+ freeShippingProgress: {
124
+ threshold: threshold == null ? null : {
125
+ amount: threshold,
126
+ currencyCode: currency
127
+ },
128
+ remaining: {
129
+ amount: remaining ?? threshold ?? 0,
130
+ currencyCode: currency
131
+ },
132
+ qualified: qualified ?? false
133
+ }
134
+ };
135
+ }
136
+ function itemsSubtotal(cart) {
137
+ const itemsAmount = cart.totalizers?.find((totalizer) => totalizer.id === "Items")?.value.amount;
138
+ return isFiniteAmount(itemsAmount) ? Number(itemsAmount) : null;
139
+ }
140
+ function usableThreshold(threshold) {
141
+ if (threshold == null) return null;
142
+ const parsed = Number(threshold.amount);
143
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
144
+ }
145
+ function fillRatio(isQualified, thresholdAmount, covered) {
146
+ if (isQualified) return 1;
147
+ if (thresholdAmount === null) return 0;
148
+ return clamp01(covered / thresholdAmount);
149
+ }
150
+ function computeProgress(fsp, items, thresholdAmount) {
151
+ if (items === null) {
152
+ const isQualified = fsp.qualified;
153
+ const liveRemaining = !isQualified && isFiniteAmount(fsp.remaining.amount) ? Math.max(Number(fsp.remaining.amount), 0) : 0;
154
+ return {
155
+ isQualified,
156
+ fill: fillRatio(isQualified, thresholdAmount, (thresholdAmount ?? 0) - liveRemaining),
157
+ liveRemaining
158
+ };
159
+ }
160
+ const isQualified = fsp.qualified || thresholdAmount !== null && items >= thresholdAmount;
161
+ const liveRemaining = isQualified || thresholdAmount === null ? 0 : Math.max(thresholdAmount - items, 0);
162
+ return {
163
+ isQualified,
164
+ fill: fillRatio(isQualified, thresholdAmount, items),
165
+ liveRemaining
166
+ };
167
+ }
48
168
  const FreeShippingProgressRootDefinition = defineComponent({
49
169
  name: "FreeShippingProgressRoot",
50
170
  importPath: "@vtex/faststore/components",
@@ -62,69 +182,43 @@ const FreeShippingProgressBarDefinition = defineComponent({
62
182
  name: "FreeShippingProgressBar",
63
183
  importPath: "@vtex/faststore/components",
64
184
  component: FreeShippingProgressBar,
185
+ content: FreeShippingProgressBarContent,
65
186
  editor: {
66
187
  label: "Free Shipping Progress Bar",
67
188
  category: "commerce"
68
189
  },
69
190
  schema: {},
70
- guideline: "Meter bar that fills toward the free-shipping goal, full when earned. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md."
191
+ guideline: "Meter bar that fills toward the free-shipping goal, full when earned; screen readers announce the $content fields valueText ({value} is the formatted remaining amount) and qualifiedValueText. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md."
71
192
  });
72
193
  const FreeShippingProgressMessageDefinition = defineComponent({
73
194
  name: "FreeShippingProgressMessage",
74
195
  importPath: "@vtex/faststore/components",
75
196
  component: FreeShippingProgressMessage,
197
+ content: FreeShippingProgressMessageContent,
76
198
  editor: {
77
199
  label: "Free Shipping Progress Message",
78
200
  category: "commerce"
79
201
  },
80
- schema: {
81
- label: {
82
- type: "string",
83
- default: "faltam {value} para frete grátis",
84
- label: "Below-threshold Label"
85
- },
86
- qualifiedLabel: {
87
- type: "string",
88
- default: "você ganhou frete grátis!",
89
- label: "Qualified Label"
90
- }
91
- },
92
- guideline: "Below-threshold vs earned copy, front-formatted from the active storefront context. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md."
202
+ schema: {},
203
+ guideline: "Below-threshold vs earned copy from the $content fields label ({value} is the formatted remaining amount) and qualifiedLabel; children replace both. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md."
93
204
  });
94
- function FreeShippingProgressRoot({ threshold, remaining, qualified, cartTotal, $data: $dataProp, className, children, ...props }) {
205
+ function FreeShippingProgressRoot({ threshold, remaining, qualified, itemsTotal, $data: $dataProp, className, children, ...props }) {
95
206
  const { currency } = useStorefrontContext();
96
- const cart = useDataOverride($dataProp) ?? (qualified !== void 0 || threshold !== void 0 || remaining !== void 0 || cartTotal !== void 0 ? {
97
- id: "preview",
98
- total: {
99
- amount: cartTotal ?? 0,
100
- currencyCode: currency
101
- },
102
- freeShippingProgress: {
103
- threshold: threshold != null ? {
104
- amount: threshold,
105
- currencyCode: currency
106
- } : null,
107
- remaining: {
108
- amount: remaining ?? 0,
109
- currencyCode: currency
110
- },
111
- qualified: qualified ?? false
112
- }
113
- } : null);
207
+ const cart = useDataOverride($dataProp) ?? previewCart({
208
+ threshold,
209
+ remaining,
210
+ qualified,
211
+ itemsTotal
212
+ }, currency);
114
213
  const fsp = cart?.freeShippingProgress;
115
214
  if (!cart || fsp == null) return null;
116
- const parsedThreshold = fsp.threshold != null ? Number(fsp.threshold.amount) : null;
117
- const cartTotalAmount = Number(cart.total?.amount ?? 0);
118
- const thresholdAmount = parsedThreshold != null && Number.isFinite(parsedThreshold) && parsedThreshold > 0 ? parsedThreshold : null;
119
- const isQualified = fsp.qualified || thresholdAmount != null && cartTotalAmount >= thresholdAmount;
120
- const liveRemaining = isQualified || thresholdAmount == null ? 0 : Math.max(thresholdAmount - cartTotalAmount, 0);
121
- const value = {
122
- isQualified,
123
- fill: isQualified ? 1 : thresholdAmount != null ? clamp01(cartTotalAmount / thresholdAmount) : 0,
124
- liveRemaining
125
- };
215
+ const { isQualified, fill, liveRemaining } = computeProgress(fsp, itemsSubtotal(cart), usableThreshold(fsp.threshold));
126
216
  return /* @__PURE__ */ jsx(FreeShippingProgressContext, {
127
- value,
217
+ value: {
218
+ isQualified,
219
+ fill,
220
+ liveRemaining
221
+ },
128
222
  children: /* @__PURE__ */ jsx("div", {
129
223
  ...props,
130
224
  className,
@@ -133,11 +227,13 @@ function FreeShippingProgressRoot({ threshold, remaining, qualified, cartTotal,
133
227
  })
134
228
  });
135
229
  }
136
- function FreeShippingProgressBar({ className, ...props }) {
230
+ function FreeShippingProgressBar({ $content, $locale, className, ...props }) {
137
231
  const { fill, isQualified, liveRemaining } = useFreeShippingProgress();
138
232
  const { locale, currency } = useStorefrontContext();
139
- const ariaValueText = isQualified ? "frete grátis conquistado" : `${formatCurrency(liveRemaining, locale, currency)} restantes para frete grátis`;
233
+ const { format } = useMessageFormatter(FreeShippingProgressBarContent, $content);
234
+ const ariaValueText = isQualified ? format("qualifiedValueText") : format("valueText", { value: formatCurrency(liveRemaining, locale, currency) });
140
235
  return /* @__PURE__ */ jsx(Meter.Root, {
236
+ "aria-label": "Progresso para frete grátis",
141
237
  ...props,
142
238
  value: Math.round(fill * 100),
143
239
  min: 0,
@@ -148,15 +244,19 @@ function FreeShippingProgressBar({ className, ...props }) {
148
244
  children: /* @__PURE__ */ jsx(Meter.Track, { children: /* @__PURE__ */ jsx(Meter.Indicator, {}) })
149
245
  });
150
246
  }
151
- function FreeShippingProgressMessage({ label = "faltam {value} para frete grátis", qualifiedLabel = "você ganhou frete grátis!", className, children, ...props }) {
247
+ function FreeShippingProgressMessage({ $content, $locale, className, children, ...props }) {
152
248
  const { isQualified, liveRemaining } = useFreeShippingProgress();
153
249
  const { locale, currency } = useStorefrontContext();
154
- const text = isQualified ? qualifiedLabel : label.replace("{value}", formatCurrency(liveRemaining, locale, currency));
250
+ const { format } = useMessageFormatter(FreeShippingProgressMessageContent, $content);
251
+ function message() {
252
+ if (isQualified) return format("qualifiedLabel");
253
+ return format("label", { value: formatCurrency(liveRemaining, locale, currency) });
254
+ }
155
255
  return /* @__PURE__ */ jsx("div", {
156
256
  ...props,
157
257
  className,
158
258
  "data-fs-free-shipping-progress-message": "",
159
- children: children ?? text
259
+ children: children ?? message()
160
260
  });
161
261
  }
162
262
  const FreeShippingProgress = {
@@ -165,6 +265,6 @@ const FreeShippingProgress = {
165
265
  Message: FreeShippingProgressMessage
166
266
  };
167
267
  //#endregion
168
- export { FreeShippingProgress, FreeShippingProgressBar, FreeShippingProgressBarDefinition, FreeShippingProgressMessage, FreeShippingProgressMessageDefinition, FreeShippingProgressRoot, FreeShippingProgressRootDefinition };
268
+ export { FreeShippingProgress, FreeShippingProgressBar, FreeShippingProgressBarContent, FreeShippingProgressBarDefinition, FreeShippingProgressMessage, FreeShippingProgressMessageContent, FreeShippingProgressMessageDefinition, FreeShippingProgressRoot, FreeShippingProgressRootDefinition };
169
269
 
170
270
  //# sourceMappingURL=free-shipping-progress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"free-shipping-progress.js","names":[],"sources":["../../../src/matter/free-shipping-progress/free-shipping-progress.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext } from 'react';\nimport { Meter } from '../../particles/meter/meter.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number | string; currencyCode: string };\n\ntype FreeShippingProgressData = {\n cart?: {\n id: string;\n total?: MoneyValue | null;\n freeShippingProgress?: {\n threshold: MoneyValue | null;\n remaining: MoneyValue;\n qualified: boolean;\n } | null;\n } | null;\n};\n\ntype FreeShippingProgressContextValue = {\n isQualified: boolean;\n fill: number;\n liveRemaining: number;\n};\n\nexport type FreeShippingProgressRootProps = ComponentPropsWithRef<'div'> & {\n threshold?: number;\n remaining?: number;\n qualified?: boolean;\n cartTotal?: number;\n $data?: FreeShippingProgressData['cart'] | null;\n};\n\nexport type FreeShippingProgressBarProps = ComponentPropsWithRef<'div'>;\nexport type FreeShippingProgressMessageProps = ComponentPropsWithRef<'div'> & {\n label?: string;\n qualifiedLabel?: string;\n};\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — narrow cart slice (total + freeShippingProgress)\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment FreeShippingProgressData on Query {\n cart {\n id\n total {\n amount\n currencyCode\n }\n freeShippingProgress {\n threshold {\n amount\n currencyCode\n }\n remaining {\n amount\n currencyCode\n }\n qualified\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst FSP_CONTEXT_UNSET = Symbol('FreeShippingProgressContextUnset');\n\nconst FreeShippingProgressContext = createContext<FreeShippingProgressContextValue | typeof FSP_CONTEXT_UNSET>(\n FSP_CONTEXT_UNSET,\n);\n\nfunction useFreeShippingProgress(): FreeShippingProgressContextValue {\n const ctx = useContext(FreeShippingProgressContext);\n if (ctx === FSP_CONTEXT_UNSET) {\n throw new Error('useFreeShippingProgress() must be used inside a <FreeShippingProgressRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatCurrency(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\nfunction clamp01(value: number): number {\n return Math.min(Math.max(value, 0), 1);\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const FreeShippingProgressRootDefinition = defineComponent<FreeShippingProgressRootProps>({\n name: 'FreeShippingProgressRoot',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Free Shipping Progress', category: 'commerce' },\n schema: {},\n guideline:\n 'Free-shipping progress bar for the top of a cart/mini-cart drawer: shows how much more to spend for free shipping and flips to an earned state when met. Renders nothing until a destination and an eligible promotion exist (self-hides on null). See free-shipping-progress.md.',\n});\n\nexport const FreeShippingProgressBarDefinition = defineComponent<FreeShippingProgressBarProps>({\n name: 'FreeShippingProgressBar',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressBar,\n editor: { label: 'Free Shipping Progress Bar', category: 'commerce' },\n schema: {},\n guideline:\n 'Meter bar that fills toward the free-shipping goal, full when earned. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md.',\n});\n\nexport const FreeShippingProgressMessageDefinition = defineComponent<FreeShippingProgressMessageProps>({\n name: 'FreeShippingProgressMessage',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressMessage,\n editor: { label: 'Free Shipping Progress Message', category: 'commerce' },\n schema: {\n label: { type: 'string', default: 'faltam {value} para frete grátis', label: 'Below-threshold Label' },\n qualifiedLabel: { type: 'string', default: 'você ganhou frete grátis!', label: 'Qualified Label' },\n },\n guideline:\n 'Below-threshold vs earned copy, front-formatted from the active storefront context. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function FreeShippingProgressRoot({\n threshold,\n remaining,\n qualified,\n cartTotal,\n $data: $dataProp,\n className,\n children,\n ...props\n}: FreeShippingProgressRootProps) {\n // Only the synthesized preview cart below needs it; the leaves read the context where they format.\n const { currency } = useStorefrontContext();\n const $data = useDataOverride($dataProp);\n\n // Story / presentational overrides synthesize the field when no live cart is present.\n const cart =\n $data ??\n (qualified !== undefined || threshold !== undefined || remaining !== undefined || cartTotal !== undefined\n ? {\n id: 'preview',\n total: { amount: cartTotal ?? 0, currencyCode: currency },\n freeShippingProgress: {\n threshold: threshold != null ? { amount: threshold, currencyCode: currency } : null,\n remaining: { amount: remaining ?? 0, currencyCode: currency },\n qualified: qualified ?? false,\n },\n }\n : null);\n\n const fsp = cart?.freeShippingProgress;\n if (!cart || fsp == null) return null;\n\n const parsedThreshold = fsp.threshold != null ? Number(fsp.threshold.amount) : null;\n const cartTotalAmount = Number(cart.total?.amount ?? 0);\n // Usable threshold: present, finite, positive. Null/NaN/zero → no fill, no remaining.\n const thresholdAmount =\n parsedThreshold != null && Number.isFinite(parsedThreshold) && parsedThreshold > 0 ? parsedThreshold : null;\n\n const isQualified = fsp.qualified || (thresholdAmount != null && cartTotalAmount >= thresholdAmount);\n const liveRemaining = isQualified || thresholdAmount == null ? 0 : Math.max(thresholdAmount - cartTotalAmount, 0);\n const fill = isQualified ? 1 : thresholdAmount != null ? clamp01(cartTotalAmount / thresholdAmount) : 0;\n\n const value: FreeShippingProgressContextValue = { isQualified, fill, liveRemaining };\n\n return (\n <FreeShippingProgressContext value={value}>\n <div {...props} className={className} data-fs-free-shipping-progress-root=\"\">\n {children}\n </div>\n </FreeShippingProgressContext>\n );\n}\n\nexport function FreeShippingProgressBar({ className, ...props }: FreeShippingProgressBarProps) {\n const { fill, isQualified, liveRemaining } = useFreeShippingProgress();\n const { locale, currency } = useStorefrontContext();\n const ariaValueText = isQualified\n ? 'frete grátis conquistado'\n : `${formatCurrency(liveRemaining, locale, currency)} restantes para frete grátis`;\n\n return (\n <Meter.Root\n {...props}\n value={Math.round(fill * 100)}\n min={0}\n max={100}\n getAriaValueText={() => ariaValueText}\n className={className}\n data-fs-free-shipping-progress-bar=\"\"\n >\n <Meter.Track>\n <Meter.Indicator />\n </Meter.Track>\n </Meter.Root>\n );\n}\n\nexport function FreeShippingProgressMessage({\n label = 'faltam {value} para frete grátis',\n qualifiedLabel = 'você ganhou frete grátis!',\n className,\n children,\n ...props\n}: FreeShippingProgressMessageProps) {\n const { isQualified, liveRemaining } = useFreeShippingProgress();\n const { locale, currency } = useStorefrontContext();\n const text = isQualified ? qualifiedLabel : label.replace('{value}', formatCurrency(liveRemaining, locale, currency));\n\n return (\n <div {...props} className={className} data-fs-free-shipping-progress-message=\"\">\n {children ?? text}\n </div>\n );\n}\n\nexport const FreeShippingProgress = {\n Root: FreeShippingProgressRoot,\n Bar: FreeShippingProgressBar,\n Message: FreeShippingProgressMessage,\n};\n"],"mappings":";;;;;;;;;AAkDA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;AA2B/B,MAAM,oBAAoB,OAAO,kCAAkC;AAEnE,MAAM,8BAA8B,cAClC,iBACF;AAEA,SAAS,0BAA4D;CACnE,MAAM,MAAM,WAAW,2BAA2B;CAClD,IAAI,QAAQ,mBACV,MAAM,IAAI,MAAM,qFAAqF;CAEvG,OAAO;AACT;AAMA,SAAS,eAAe,OAAe,QAAgB,UAA0B;CAC/E,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY;CAAS,CAAC,CAAC,CAAC,OAAO,KAAK;AACpF;AAEA,SAAS,QAAQ,OAAuB;CACtC,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;AACvC;AAMA,MAAa,qCAAqC,gBAA+C;CAC/F,MAAM;CACN,YAAY;CACZ,WAAW;CAC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free-shipping-progress.js","names":[],"sources":["../../../src/matter/free-shipping-progress/free-shipping-progress.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType, type MessageLocaleProp } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext } from 'react';\nimport { Meter } from '../../particles/meter/meter.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport { isFiniteAmount } from '../cart/cart.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number | string; currencyCode: string };\n\ntype FreeShippingProgressData = {\n cart?: {\n id: string;\n totalizers?: { id: string; value: MoneyValue }[] | null;\n freeShippingProgress?: {\n threshold: MoneyValue | null;\n remaining: MoneyValue;\n qualified: boolean;\n } | null;\n } | null;\n};\n\ntype FreeShippingProgressContextValue = {\n isQualified: boolean;\n fill: number;\n liveRemaining: number;\n};\n\nexport type FreeShippingProgressRootProps = ComponentPropsWithRef<'div'> & {\n threshold?: number;\n remaining?: number;\n qualified?: boolean;\n itemsTotal?: number;\n $data?: FreeShippingProgressData['cart'] | null;\n};\n\nexport const FreeShippingProgressMessageContent = defineContentType({\n id: 'free-shipping-progress-message',\n title: 'Free Shipping Progress Message',\n description: 'The below-threshold and earned free-shipping messages.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: {\n type: 'string',\n title: 'Below-threshold label',\n description: 'Shown while the cart is below the threshold; value is the formatted amount still missing.',\n format: 'icu-message',\n messageSource: '{value} away from free shipping',\n messageArguments: { type: 'object', properties: { value: { type: 'string' } } },\n messageExample: { value: '$25.00' },\n },\n qualifiedLabel: {\n type: 'string',\n title: 'Qualified label',\n format: 'icu-message',\n messageSource: 'You got free shipping!',\n },\n },\n },\n});\n\nexport const FreeShippingProgressBarContent = defineContentType({\n id: 'free-shipping-progress-bar',\n title: 'Free Shipping Progress Bar',\n description: 'The value text a screen reader announces for the progress bar.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n valueText: {\n type: 'string',\n title: 'Below-threshold value text',\n description: 'Announced while the cart is below the threshold; value is the formatted amount still missing.',\n format: 'icu-message',\n messageSource: '{value} left for free shipping',\n messageArguments: { type: 'object', properties: { value: { type: 'string' } } },\n messageExample: { value: '$25.00' },\n },\n qualifiedValueText: {\n type: 'string',\n title: 'Qualified value text',\n format: 'icu-message',\n messageSource: 'Free shipping earned',\n },\n },\n },\n});\n\nexport type FreeShippingProgressBarProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof FreeShippingProgressBarContent>;\n };\nexport type FreeShippingProgressMessageProps = ComponentPropsWithRef<'div'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof FreeShippingProgressMessageContent>;\n };\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — narrow cart slice (Items totalizer + freeShippingProgress)\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment FreeShippingProgressData on Query {\n cart {\n id\n totalizers {\n id\n value {\n amount\n currencyCode\n }\n }\n freeShippingProgress {\n threshold {\n amount\n currencyCode\n }\n remaining {\n amount\n currencyCode\n }\n qualified\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst FSP_CONTEXT_UNSET = Symbol('FreeShippingProgressContextUnset');\n\nconst FreeShippingProgressContext = createContext<FreeShippingProgressContextValue | typeof FSP_CONTEXT_UNSET>(\n FSP_CONTEXT_UNSET,\n);\n\nfunction useFreeShippingProgress(): FreeShippingProgressContextValue {\n const ctx = useContext(FreeShippingProgressContext);\n if (ctx === FSP_CONTEXT_UNSET) {\n throw new Error('useFreeShippingProgress() must be used inside a <FreeShippingProgressRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatCurrency(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\nfunction clamp01(value: number): number {\n return Math.min(Math.max(value, 0), 1);\n}\n\ntype FreeShippingProgressCart = NonNullable<FreeShippingProgressData['cart']>;\ntype FreeShippingProgressState = NonNullable<FreeShippingProgressCart['freeShippingProgress']>;\n\nfunction previewCart(\n {\n threshold,\n remaining,\n qualified,\n itemsTotal,\n }: Pick<FreeShippingProgressRootProps, 'threshold' | 'remaining' | 'qualified' | 'itemsTotal'>,\n currency: string,\n): FreeShippingProgressCart | null {\n if (qualified === undefined && threshold === undefined && remaining === undefined && itemsTotal === undefined) {\n return null;\n }\n return {\n id: 'preview',\n totalizers:\n itemsTotal === undefined ? [] : [{ id: 'Items', value: { amount: itemsTotal, currencyCode: currency } }],\n freeShippingProgress: {\n threshold: threshold == null ? null : { amount: threshold, currencyCode: currency },\n remaining: { amount: remaining ?? threshold ?? 0, currencyCode: currency },\n qualified: qualified ?? false,\n },\n };\n}\n\n// The server measures the Items totalizer, never the grand total (shipping and discounts do not count).\nfunction itemsSubtotal(cart: FreeShippingProgressCart): number | null {\n const itemsAmount = cart.totalizers?.find((totalizer) => totalizer.id === 'Items')?.value.amount;\n return isFiniteAmount(itemsAmount) ? Number(itemsAmount) : null;\n}\n\n// Usable threshold: present, finite, positive. Null/NaN/zero → no fill, no remaining.\nfunction usableThreshold(threshold: MoneyValue | null): number | null {\n if (threshold == null) return null;\n const parsed = Number(threshold.amount);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n}\n\nfunction fillRatio(isQualified: boolean, thresholdAmount: number | null, covered: number): number {\n if (isQualified) return 1;\n if (thresholdAmount === null) return 0;\n return clamp01(covered / thresholdAmount);\n}\n\nfunction computeProgress(\n fsp: FreeShippingProgressState,\n items: number | null,\n thresholdAmount: number | null,\n): FreeShippingProgressContextValue {\n if (items === null) {\n // No usable Items amount: show the server's own answer rather than guess.\n const isQualified = fsp.qualified;\n const liveRemaining =\n !isQualified && isFiniteAmount(fsp.remaining.amount) ? Math.max(Number(fsp.remaining.amount), 0) : 0;\n const fill = fillRatio(isQualified, thresholdAmount, (thresholdAmount ?? 0) - liveRemaining);\n return { isQualified, fill, liveRemaining };\n }\n\n const isQualified = fsp.qualified || (thresholdAmount !== null && items >= thresholdAmount);\n const liveRemaining = isQualified || thresholdAmount === null ? 0 : Math.max(thresholdAmount - items, 0);\n return { isQualified, fill: fillRatio(isQualified, thresholdAmount, items), liveRemaining };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const FreeShippingProgressRootDefinition = defineComponent<FreeShippingProgressRootProps>({\n name: 'FreeShippingProgressRoot',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Free Shipping Progress', category: 'commerce' },\n schema: {},\n guideline:\n 'Free-shipping progress bar for the top of a cart/mini-cart drawer: shows how much more to spend for free shipping and flips to an earned state when met. Renders nothing until a destination and an eligible promotion exist (self-hides on null). See free-shipping-progress.md.',\n});\n\nexport const FreeShippingProgressBarDefinition = defineComponent<FreeShippingProgressBarProps>({\n name: 'FreeShippingProgressBar',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressBar,\n content: FreeShippingProgressBarContent,\n editor: { label: 'Free Shipping Progress Bar', category: 'commerce' },\n schema: {},\n guideline:\n 'Meter bar that fills toward the free-shipping goal, full when earned; screen readers announce the $content fields valueText ({value} is the formatted remaining amount) and qualifiedValueText. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md.',\n});\n\nexport const FreeShippingProgressMessageDefinition = defineComponent<FreeShippingProgressMessageProps>({\n name: 'FreeShippingProgressMessage',\n importPath: '@vtex/faststore/components',\n component: FreeShippingProgressMessage,\n content: FreeShippingProgressMessageContent,\n editor: { label: 'Free Shipping Progress Message', category: 'commerce' },\n schema: {},\n guideline:\n 'Below-threshold vs earned copy from the $content fields label ({value} is the formatted remaining amount) and qualifiedLabel; children replace both. Must be inside FreeShippingProgressRoot. See free-shipping-progress.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function FreeShippingProgressRoot({\n threshold,\n remaining,\n qualified,\n itemsTotal,\n $data: $dataProp,\n className,\n children,\n ...props\n}: FreeShippingProgressRootProps) {\n // Only the synthesized preview cart below needs it; the leaves read the context where they format.\n const { currency } = useStorefrontContext();\n const $data = useDataOverride($dataProp);\n\n // Story / presentational overrides synthesize the field when no live cart is present.\n const cart = $data ?? previewCart({ threshold, remaining, qualified, itemsTotal }, currency);\n\n const fsp = cart?.freeShippingProgress;\n if (!cart || fsp == null) return null;\n\n const { isQualified, fill, liveRemaining } = computeProgress(\n fsp,\n itemsSubtotal(cart),\n usableThreshold(fsp.threshold),\n );\n\n const value: FreeShippingProgressContextValue = { isQualified, fill, liveRemaining };\n\n return (\n <FreeShippingProgressContext value={value}>\n <div {...props} className={className} data-fs-free-shipping-progress-root=\"\">\n {children}\n </div>\n </FreeShippingProgressContext>\n );\n}\n\nexport function FreeShippingProgressBar({ $content, $locale, className, ...props }: FreeShippingProgressBarProps) {\n const { fill, isQualified, liveRemaining } = useFreeShippingProgress();\n const { locale, currency } = useStorefrontContext();\n const { format } = useMessageFormatter(FreeShippingProgressBarContent, $content);\n const ariaValueText = isQualified\n ? format('qualifiedValueText')\n : format('valueText', { value: formatCurrency(liveRemaining, locale, currency) });\n\n return (\n <Meter.Root\n aria-label=\"Progresso para frete grátis\"\n {...props}\n value={Math.round(fill * 100)}\n min={0}\n max={100}\n getAriaValueText={() => ariaValueText}\n className={className}\n data-fs-free-shipping-progress-bar=\"\"\n >\n <Meter.Track>\n <Meter.Indicator />\n </Meter.Track>\n </Meter.Root>\n );\n}\n\nexport function FreeShippingProgressMessage({\n $content,\n $locale,\n className,\n children,\n ...props\n}: FreeShippingProgressMessageProps) {\n const { isQualified, liveRemaining } = useFreeShippingProgress();\n const { locale, currency } = useStorefrontContext();\n const { format } = useMessageFormatter(FreeShippingProgressMessageContent, $content);\n\n function message(): string {\n if (isQualified) return format('qualifiedLabel');\n return format('label', { value: formatCurrency(liveRemaining, locale, currency) });\n }\n\n return (\n <div {...props} className={className} data-fs-free-shipping-progress-message=\"\">\n {children ?? message()}\n </div>\n );\n}\n\nexport const FreeShippingProgress = {\n Root: FreeShippingProgressRoot,\n Bar: FreeShippingProgressBar,\n Message: FreeShippingProgressMessage,\n};\n"],"mappings":";;;;;;;;;;;;AA0CA,MAAa,qCAAqC,kBAAkB;CAClE,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,OAAO;IACL,MAAM;IACN,OAAO;IACP,aAAa;IACb,QAAQ;IACR,eAAe;IACf,kBAAkB;KAAE,MAAM;KAAU,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,EAAE;IAAE;IAC9E,gBAAgB,EAAE,OAAO,SAAS;GACpC;GACA,gBAAgB;IACd,MAAM;IACN,OAAO;IACP,QAAQ;IACR,eAAe;GACjB;EACF;CACF;AACF,CAAC;AAED,MAAa,iCAAiC,kBAAkB;CAC9D,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,WAAW;IACT,MAAM;IACN,OAAO;IACP,aAAa;IACb,QAAQ;IACR,eAAe;IACf,kBAAkB;KAAE,MAAM;KAAU,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,EAAE;IAAE;IAC9E,gBAAgB,EAAE,OAAO,SAAS;GACpC;GACA,oBAAoB;IAClB,MAAM;IACN,OAAO;IACP,QAAQ;IACR,eAAe;GACjB;EACF;CACF;AACF,CAAC;AAeD,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;;;;AA8B/B,MAAM,oBAAoB,OAAO,kCAAkC;AAEnE,MAAM,8BAA8B,cAClC,iBACF;AAEA,SAAS,0BAA4D;CACnE,MAAM,MAAM,WA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;AAEA,MAAa,uBAAuB;CAClC,MAAM;CACN,KAAK;CACL,SAAS;AACX"}
@@ -1,25 +1,67 @@
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 { ReactNode } from "react";
4
5
  //#region src/matter/identity-edit/identity-edit.d.ts
6
+ export declare const IdentityEditButtonContent: {
7
+ readonly id: "identity-edit-button";
8
+ readonly title: "Identity Edit Button";
9
+ readonly description: "The label of the button that opens the identity form.";
10
+ readonly schema: {
11
+ readonly type: "object";
12
+ readonly additionalProperties: false;
13
+ readonly properties: {
14
+ readonly label: {
15
+ readonly type: "string";
16
+ readonly title: "Button label";
17
+ readonly format: "icu-message";
18
+ readonly messageSource: "Edit";
19
+ };
20
+ };
21
+ };
22
+ };
23
+ export declare const IdentityEditCancelButtonContent: {
24
+ readonly id: "identity-edit-cancel-button";
25
+ readonly title: "Identity Edit Cancel Button";
26
+ readonly description: "The label of the button that closes the identity form without saving.";
27
+ readonly schema: {
28
+ readonly type: "object";
29
+ readonly additionalProperties: false;
30
+ readonly properties: {
31
+ readonly label: {
32
+ readonly type: "string";
33
+ readonly title: "Button label";
34
+ readonly format: "icu-message";
35
+ readonly messageSource: "Cancel";
36
+ };
37
+ };
38
+ };
39
+ };
5
40
  export type IdentityEditControllerProps = {
6
41
  children?: ReactNode;
7
42
  };
8
43
  export type IdentityEditPanelProps = {
9
44
  children?: ReactNode;
10
45
  };
11
- export type IdentityEditButtonProps = {
12
- /** Text shown when no children are composed. */
13
- label?: string;
46
+ export type IdentityEditButtonProps = MessageLocaleProp & {
47
+ className?: string;
48
+ /** Compose custom button content (e.g. an Icon plus text); falls back to the `label` message. */
49
+ children?: ReactNode;
50
+ /** The label shown when no children are composed. */
51
+ $content?: ContentValue<typeof IdentityEditButtonContent>;
52
+ };
53
+ export type IdentityEditCancelButtonProps = MessageLocaleProp & {
14
54
  className?: string;
15
- /** Compose custom button content (e.g. an Icon plus text); falls back to `label`. */
55
+ /** Compose custom button content; falls back to the `label` message. */
16
56
  children?: ReactNode;
57
+ /** The label shown when no children are composed. */
58
+ $content?: ContentValue<typeof IdentityEditCancelButtonContent>;
17
59
  };
18
60
  export declare const IdentityEditControllerDefinition: ComponentDefinition<IdentityEditControllerProps>;
19
61
  export declare const IdentitySummaryViewDefinition: ComponentDefinition<IdentityEditPanelProps>;
20
62
  export declare const IdentityEditFormDefinition: ComponentDefinition<IdentityEditPanelProps>;
21
63
  export declare const IdentityEditButtonDefinition: ComponentDefinition<IdentityEditButtonProps>;
22
- export declare const IdentityEditCancelButtonDefinition: ComponentDefinition<IdentityEditButtonProps>;
64
+ export declare const IdentityEditCancelButtonDefinition: ComponentDefinition<IdentityEditCancelButtonProps>;
23
65
  /**
24
66
  * Owns the identity section's mode and provides it to descendants. Renders no DOM of its own.
25
67
  *
@@ -32,10 +74,10 @@ export declare function IdentityEditController({ children }: IdentityEditControl
32
74
  export declare function IdentitySummaryView({ children }: IdentityEditPanelProps): import("react/jsx-runtime").JSX.Element | null;
33
75
  /** Renders its children only while the section shows the form. */
34
76
  export declare function IdentityEditForm({ children }: IdentityEditPanelProps): import("react/jsx-runtime").JSX.Element | null;
35
- /** Opens the form. Renders `children` or the `label` fallback. */
36
- export declare function IdentityEditButton({ label, className, children }: IdentityEditButtonProps): import("react/jsx-runtime").JSX.Element;
37
- /** Returns to the summary without saving. Renders `children` or the `label` fallback. */
38
- export declare function IdentityEditCancelButton({ label, className, children }: IdentityEditButtonProps): import("react/jsx-runtime").JSX.Element;
77
+ /** Opens the form. Renders `children` or the `label` message. */
78
+ export declare function IdentityEditButton({ $content, $locale, className, children }: IdentityEditButtonProps): import("react/jsx-runtime").JSX.Element;
79
+ /** Returns to the summary without saving. Renders `children` or the `label` message. */
80
+ export declare function IdentityEditCancelButton({ $content, $locale, className, children }: IdentityEditCancelButtonProps): import("react/jsx-runtime").JSX.Element;
39
81
  export declare const IdentityEdit: {
40
82
  Controller: typeof IdentityEditController;
41
83
  ControllerDefinition: ComponentDefinition<IdentityEditControllerProps>;
@@ -46,7 +88,7 @@ export declare const IdentityEdit: {
46
88
  EditButton: typeof IdentityEditButton;
47
89
  EditButtonDefinition: ComponentDefinition<IdentityEditButtonProps>;
48
90
  CancelButton: typeof IdentityEditCancelButton;
49
- CancelButtonDefinition: ComponentDefinition<IdentityEditButtonProps>;
91
+ CancelButtonDefinition: ComponentDefinition<IdentityEditCancelButtonProps>;
50
92
  };
51
93
  //#endregion
52
94
  //# sourceMappingURL=identity-edit.d.ts.map
@@ -1,6 +1,8 @@
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";
5
+ import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
4
6
  import { createContext, useContext, useMemo, useState } from "react";
5
7
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
6
8
  //#region src/matter/identity-edit/identity-edit.tsx
@@ -10,6 +12,36 @@ function useIdentityEditContext() {
10
12
  if (!ctx) throw new Error("IdentitySummaryView, IdentityEditForm and the edit buttons must be used inside an IdentityEditController.");
11
13
  return ctx;
12
14
  }
15
+ const IdentityEditButtonContent = defineContentType({
16
+ id: "identity-edit-button",
17
+ title: "Identity Edit Button",
18
+ description: "The label of the button that opens the identity form.",
19
+ schema: {
20
+ type: "object",
21
+ additionalProperties: false,
22
+ properties: { label: {
23
+ type: "string",
24
+ title: "Button label",
25
+ format: "icu-message",
26
+ messageSource: "Edit"
27
+ } }
28
+ }
29
+ });
30
+ const IdentityEditCancelButtonContent = defineContentType({
31
+ id: "identity-edit-cancel-button",
32
+ title: "Identity Edit Cancel Button",
33
+ description: "The label of the button that closes the identity form without saving.",
34
+ schema: {
35
+ type: "object",
36
+ additionalProperties: false,
37
+ properties: { label: {
38
+ type: "string",
39
+ title: "Button label",
40
+ format: "icu-message",
41
+ messageSource: "Cancel"
42
+ } }
43
+ }
44
+ });
13
45
  const IdentityEditControllerDefinition = defineComponent({
14
46
  name: "IdentityEditController",
15
47
  importPath: "@vtex/faststore/components",
@@ -50,33 +82,27 @@ const IdentityEditButtonDefinition = defineComponent({
50
82
  name: "IdentityEditButton",
51
83
  importPath: "@vtex/faststore/components",
52
84
  component: IdentityEditButton,
85
+ content: IdentityEditButtonContent,
53
86
  requiresContext: "identity-edit",
54
87
  editor: {
55
88
  label: "Identity Edit Button",
56
89
  category: "action"
57
90
  },
58
- schema: { label: {
59
- type: "string",
60
- default: "editar",
61
- label: "Button label"
62
- } },
63
- guideline: "Opens the identity form. Place it in the section heading, inside an IdentitySummaryView so it disappears while the form is open. Compose an Icon plus text as children, or rely on `label`. Must be inside an IdentityEditController."
91
+ schema: {},
92
+ guideline: "Opens the identity form. Place it in the section heading, inside an IdentitySummaryView so it disappears while the form is open. Compose an Icon plus text as children, or rely on the $content field label. Must be inside an IdentityEditController."
64
93
  });
65
94
  const IdentityEditCancelButtonDefinition = defineComponent({
66
95
  name: "IdentityEditCancelButton",
67
96
  importPath: "@vtex/faststore/components",
68
97
  component: IdentityEditCancelButton,
98
+ content: IdentityEditCancelButtonContent,
69
99
  requiresContext: "identity-edit",
70
100
  editor: {
71
101
  label: "Identity Edit Cancel Button",
72
102
  category: "action"
73
103
  },
74
- schema: { label: {
75
- type: "string",
76
- default: "cancelar",
77
- label: "Button label"
78
- } },
79
- guideline: "Returns the identity section to its summary without saving. Place it inside an IdentityEditForm. Must be inside an IdentityEditController."
104
+ schema: {},
105
+ guideline: "Returns the identity section to its summary without saving. Its label is the $content field label unless children are composed. Place it inside an IdentityEditForm. Must be inside an IdentityEditController."
80
106
  });
81
107
  /**
82
108
  * Owns the identity section's mode and provides it to descendants. Renders no DOM of its own.
@@ -108,26 +134,28 @@ function IdentityEditForm({ children }) {
108
134
  if (mode !== "edit") return null;
109
135
  return /* @__PURE__ */ jsx(Fragment$1, { children });
110
136
  }
111
- /** Opens the form. Renders `children` or the `label` fallback. */
112
- function IdentityEditButton({ label = "editar", className, children }) {
137
+ /** Opens the form. Renders `children` or the `label` message. */
138
+ function IdentityEditButton({ $content, $locale, className, children }) {
113
139
  const { setMode } = useIdentityEditContext();
140
+ const { format } = useMessageFormatter(IdentityEditButtonContent, $content);
114
141
  return /* @__PURE__ */ jsx("button", {
115
142
  type: "button",
116
143
  "data-fs-identity-edit-button": "",
117
144
  className,
118
145
  onClick: () => setMode("edit"),
119
- children: children ?? label
146
+ children: children ?? format("label")
120
147
  });
121
148
  }
122
- /** Returns to the summary without saving. Renders `children` or the `label` fallback. */
123
- function IdentityEditCancelButton({ label = "cancelar", className, children }) {
149
+ /** Returns to the summary without saving. Renders `children` or the `label` message. */
150
+ function IdentityEditCancelButton({ $content, $locale, className, children }) {
124
151
  const { setMode } = useIdentityEditContext();
152
+ const { format } = useMessageFormatter(IdentityEditCancelButtonContent, $content);
125
153
  return /* @__PURE__ */ jsx("button", {
126
154
  type: "button",
127
155
  "data-fs-identity-edit-cancel-button": "",
128
156
  className,
129
157
  onClick: () => setMode("view"),
130
- children: children ?? label
158
+ children: children ?? format("label")
131
159
  });
132
160
  }
133
161
  const IdentityEdit = {
@@ -143,6 +171,6 @@ const IdentityEdit = {
143
171
  CancelButtonDefinition: IdentityEditCancelButtonDefinition
144
172
  };
145
173
  //#endregion
146
- export { IdentityEdit, IdentityEditButton, IdentityEditButtonDefinition, IdentityEditCancelButton, IdentityEditCancelButtonDefinition, IdentityEditController, IdentityEditControllerDefinition, IdentityEditForm, IdentityEditFormDefinition, IdentitySummaryView, IdentitySummaryViewDefinition };
174
+ export { IdentityEdit, IdentityEditButton, IdentityEditButtonContent, IdentityEditButtonDefinition, IdentityEditCancelButton, IdentityEditCancelButtonContent, IdentityEditCancelButtonDefinition, IdentityEditController, IdentityEditControllerDefinition, IdentityEditForm, IdentityEditFormDefinition, IdentitySummaryView, IdentitySummaryViewDefinition };
147
175
 
148
176
  //# sourceMappingURL=identity-edit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity-edit.js","names":[],"sources":["../../../src/matter/identity-edit/identity-edit.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo, useState } from 'react';\n\n// ---------------------------------------------------------------------------\n// Identity view/edit toggle.\n//\n// The identity section shows a summary of who the shopper is until they ask to change it, and returns to\n// the summary when they say so — this component owns the mode rather than a page authoring it\n// (ADR-0006). Saving does not move it; whether it should is a sequencing question left to the\n// flow-of-steps RFC (#611). The delivery section owns no such mode of its own — its view/edit toggle\n// was removed with no replacement, so ShippingAddressFieldset always renders once resolved. See\n// identity-edit.md.\n// ---------------------------------------------------------------------------\n\n/** Internal: the section's two states never reach the schema, because each has its own component. */\ntype IdentityEditMode = 'view' | 'edit';\n\ntype IdentityEditContextValue = {\n mode: IdentityEditMode;\n setMode: (mode: IdentityEditMode) => void;\n};\n\nconst IdentityEditContext = createContext<IdentityEditContextValue | undefined>(undefined);\n\nfunction useIdentityEditContext(): IdentityEditContextValue {\n const ctx = useContext(IdentityEditContext);\n if (!ctx) {\n throw new Error(\n 'IdentitySummaryView, IdentityEditForm and the edit buttons must be used inside an IdentityEditController.',\n );\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type IdentityEditControllerProps = {\n children?: ReactNode;\n};\n\nexport type IdentityEditPanelProps = {\n children?: ReactNode;\n};\n\nexport type IdentityEditButtonProps = {\n /** Text shown when no children are composed. */\n label?: string;\n className?: string;\n /** Compose custom button content (e.g. an Icon plus text); falls back to `label`. */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const IdentityEditControllerDefinition = defineComponent<IdentityEditControllerProps>({\n name: 'IdentityEditController',\n importPath: '@vtex/faststore/components',\n component: IdentityEditController,\n providesContext: 'identity-edit',\n editor: { label: 'Identity Edit Controller', category: 'commerce' },\n schema: {},\n guideline:\n \"Owns the identity section's summary/form toggle: starts on the summary, opens on IdentityEditButton and returns on IdentityEditCancelButton. Saving does not move it, so the form stays open and no descendant needs to know about a section around it. Self-contained: collapsing tells nothing else, so no other section opens as a result. Compose an IdentitySummaryView holding the summary parts and an IdentityEditForm holding a FormRoot over ClientProfileFieldset, plus an IdentityEditButton in the heading and an IdentityEditCancelButton next to the form. No state is named anywhere: which state a part belongs to is which component it is. Renders no DOM of its own.\",\n});\n\nexport const IdentitySummaryViewDefinition = defineComponent<IdentityEditPanelProps>({\n name: 'IdentitySummaryView',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryView,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Summary View', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the identity section shows the summary, and nothing while it shows the form. Takes no props: which state it gates is which component it is. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditFormDefinition = defineComponent<IdentityEditPanelProps>({\n name: 'IdentityEditForm',\n importPath: '@vtex/faststore/components',\n component: IdentityEditForm,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Form', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the identity section shows the form, and nothing while it shows the summary. Compose a FormRoot holding ClientProfileFieldset and its controls inside, plus an IdentityEditCancelButton. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditButtonDefinition = defineComponent<IdentityEditButtonProps>({\n name: 'IdentityEditButton',\n importPath: '@vtex/faststore/components',\n component: IdentityEditButton,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'editar', label: 'Button label' },\n },\n guideline:\n 'Opens the identity form. Place it in the section heading, inside an IdentitySummaryView so it disappears while the form is open. Compose an Icon plus text as children, or rely on `label`. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditCancelButtonDefinition = defineComponent<IdentityEditButtonProps>({\n name: 'IdentityEditCancelButton',\n importPath: '@vtex/faststore/components',\n component: IdentityEditCancelButton,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Cancel Button', category: 'action' },\n schema: {\n label: { type: 'string', default: 'cancelar', label: 'Button label' },\n },\n guideline:\n 'Returns the identity section to its summary without saving. Place it inside an IdentityEditForm. Must be inside an IdentityEditController.',\n});\n\n// ---------------------------------------------------------------------------\n// Components\n// ---------------------------------------------------------------------------\n\n/**\n * Owns the identity section's mode and provides it to descendants. Renders no DOM of its own.\n *\n * The mode moves only when the shopper presses one of this section's own buttons. Saving the form does\n * not close the section — the confirmation stays readable, and whether finishing a form should collapse\n * anything is a sequencing question this component deliberately has no opinion on.\n */\nexport function IdentityEditController({ children }: IdentityEditControllerProps) {\n const [mode, setMode] = useState<IdentityEditMode>('view');\n\n const value = useMemo<IdentityEditContextValue>(() => ({ mode, setMode }), [mode]);\n\n return <IdentityEditContext.Provider value={value}>{children}</IdentityEditContext.Provider>;\n}\n\n/** Renders its children only while the section shows the summary. */\nexport function IdentitySummaryView({ children }: IdentityEditPanelProps) {\n const { mode } = useIdentityEditContext();\n if (mode !== 'view') return null;\n return <>{children}</>;\n}\n\n/** Renders its children only while the section shows the form. */\nexport function IdentityEditForm({ children }: IdentityEditPanelProps) {\n const { mode } = useIdentityEditContext();\n if (mode !== 'edit') return null;\n return <>{children}</>;\n}\n\n/** Opens the form. Renders `children` or the `label` fallback. */\nexport function IdentityEditButton({ label = 'editar', className, children }: IdentityEditButtonProps) {\n const { setMode } = useIdentityEditContext();\n return (\n <button type=\"button\" data-fs-identity-edit-button=\"\" className={className} onClick={() => setMode('edit')}>\n {children ?? label}\n </button>\n );\n}\n\n/** Returns to the summary without saving. Renders `children` or the `label` fallback. */\nexport function IdentityEditCancelButton({ label = 'cancelar', className, children }: IdentityEditButtonProps) {\n const { setMode } = useIdentityEditContext();\n return (\n <button type=\"button\" data-fs-identity-edit-cancel-button=\"\" className={className} onClick={() => setMode('view')}>\n {children ?? label}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const IdentityEdit = {\n Controller: IdentityEditController,\n ControllerDefinition: IdentityEditControllerDefinition,\n SummaryView: IdentitySummaryView,\n SummaryViewDefinition: IdentitySummaryViewDefinition,\n Form: IdentityEditForm,\n FormDefinition: IdentityEditFormDefinition,\n EditButton: IdentityEditButton,\n EditButtonDefinition: IdentityEditButtonDefinition,\n CancelButton: IdentityEditCancelButton,\n CancelButtonDefinition: IdentityEditCancelButtonDefinition,\n};\n"],"mappings":";;;;;;AAwBA,MAAM,sBAAsB,cAAoD,KAAA,CAAS;AAEzF,SAAS,yBAAmD;CAC1D,MAAM,MAAM,WAAW,mBAAmB;CAC1C,IAAI,CAAC,KACH,MAAM,IAAI,MACR,2GACF;CAEF,OAAO;AACT;AA0BA,MAAa,mCAAmC,gBAA6C;CAC3F,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAA4B,UAAU;CAAW;CAClE,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,gCAAgC,gBAAwC;CACnF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAyB,UAAU;CAAW;CAC/D,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,6BAA6B,gBAAwC;CAChF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAsB,UAAU;CAAW;CAC5D,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,MAAa,+BAA+B,gBAAyC;CACnF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,iBAAiB;CACjB,QAAQ;EAAE,OAAO;EAAwB,UAAU;CAAS;CAC5D,QAAQ,EACN,OAAO;EAAE,MAAM;EAAU,SAAS;EAAU,OAAO;CAAe,EACpE;CACA,WACE;AACJ,CAAC;AAED,MAAa,qCAAqC,gBAAyC;CACzF,MAAM;CACN,YAA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sB;CACtB,cAAc;CACd,wBAAwB;AAC1B"}
1
+ {"version":3,"file":"identity-edit.js","names":[],"sources":["../../../src/matter/identity-edit/identity-edit.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType, type MessageLocaleProp } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo, useState } from 'react';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\n\n// ---------------------------------------------------------------------------\n// Identity view/edit toggle.\n//\n// The identity section shows a summary of who the shopper is until they ask to change it, and returns to\n// the summary when they say so — this component owns the mode rather than a page authoring it\n// (ADR-0006). Saving does not move it; whether it should is a sequencing question left to the\n// flow-of-steps RFC (#611). The delivery section owns no such mode of its own — its view/edit toggle\n// was removed with no replacement, so ShippingAddressFieldset always renders once resolved. See\n// identity-edit.md.\n// ---------------------------------------------------------------------------\n\n/** Internal: the section's two states never reach the schema, because each has its own component. */\ntype IdentityEditMode = 'view' | 'edit';\n\ntype IdentityEditContextValue = {\n mode: IdentityEditMode;\n setMode: (mode: IdentityEditMode) => void;\n};\n\nconst IdentityEditContext = createContext<IdentityEditContextValue | undefined>(undefined);\n\nfunction useIdentityEditContext(): IdentityEditContextValue {\n const ctx = useContext(IdentityEditContext);\n if (!ctx) {\n throw new Error(\n 'IdentitySummaryView, IdentityEditForm and the edit buttons must be used inside an IdentityEditController.',\n );\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Content model\n// ---------------------------------------------------------------------------\n\nexport const IdentityEditButtonContent = defineContentType({\n id: 'identity-edit-button',\n title: 'Identity Edit Button',\n description: 'The label of the button that opens the identity form.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label', format: 'icu-message', messageSource: 'Edit' },\n },\n },\n});\n\nexport const IdentityEditCancelButtonContent = defineContentType({\n id: 'identity-edit-cancel-button',\n title: 'Identity Edit Cancel Button',\n description: 'The label of the button that closes the identity form without saving.',\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\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type IdentityEditControllerProps = {\n children?: ReactNode;\n};\n\nexport type IdentityEditPanelProps = {\n children?: ReactNode;\n};\n\nexport type IdentityEditButtonProps = MessageLocaleProp & {\n className?: string;\n /** Compose custom button content (e.g. an Icon plus text); falls back to the `label` message. */\n children?: ReactNode;\n /** The label shown when no children are composed. */\n $content?: ContentValue<typeof IdentityEditButtonContent>;\n};\n\nexport type IdentityEditCancelButtonProps = MessageLocaleProp & {\n className?: string;\n /** Compose custom button content; falls back to the `label` message. */\n children?: ReactNode;\n /** The label shown when no children are composed. */\n $content?: ContentValue<typeof IdentityEditCancelButtonContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const IdentityEditControllerDefinition = defineComponent<IdentityEditControllerProps>({\n name: 'IdentityEditController',\n importPath: '@vtex/faststore/components',\n component: IdentityEditController,\n providesContext: 'identity-edit',\n editor: { label: 'Identity Edit Controller', category: 'commerce' },\n schema: {},\n guideline:\n \"Owns the identity section's summary/form toggle: starts on the summary, opens on IdentityEditButton and returns on IdentityEditCancelButton. Saving does not move it, so the form stays open and no descendant needs to know about a section around it. Self-contained: collapsing tells nothing else, so no other section opens as a result. Compose an IdentitySummaryView holding the summary parts and an IdentityEditForm holding a FormRoot over ClientProfileFieldset, plus an IdentityEditButton in the heading and an IdentityEditCancelButton next to the form. No state is named anywhere: which state a part belongs to is which component it is. Renders no DOM of its own.\",\n});\n\nexport const IdentitySummaryViewDefinition = defineComponent<IdentityEditPanelProps>({\n name: 'IdentitySummaryView',\n importPath: '@vtex/faststore/components',\n component: IdentitySummaryView,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Summary View', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the identity section shows the summary, and nothing while it shows the form. Takes no props: which state it gates is which component it is. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditFormDefinition = defineComponent<IdentityEditPanelProps>({\n name: 'IdentityEditForm',\n importPath: '@vtex/faststore/components',\n component: IdentityEditForm,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Form', category: 'commerce' },\n schema: {},\n guideline:\n 'Renders its children only while the identity section shows the form, and nothing while it shows the summary. Compose a FormRoot holding ClientProfileFieldset and its controls inside, plus an IdentityEditCancelButton. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditButtonDefinition = defineComponent<IdentityEditButtonProps>({\n name: 'IdentityEditButton',\n importPath: '@vtex/faststore/components',\n component: IdentityEditButton,\n content: IdentityEditButtonContent,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Button', category: 'action' },\n schema: {},\n guideline:\n 'Opens the identity form. Place it in the section heading, inside an IdentitySummaryView so it disappears while the form is open. Compose an Icon plus text as children, or rely on the $content field label. Must be inside an IdentityEditController.',\n});\n\nexport const IdentityEditCancelButtonDefinition = defineComponent<IdentityEditCancelButtonProps>({\n name: 'IdentityEditCancelButton',\n importPath: '@vtex/faststore/components',\n component: IdentityEditCancelButton,\n content: IdentityEditCancelButtonContent,\n requiresContext: 'identity-edit',\n editor: { label: 'Identity Edit Cancel Button', category: 'action' },\n schema: {},\n guideline:\n 'Returns the identity section to its summary without saving. Its label is the $content field label unless children are composed. Place it inside an IdentityEditForm. Must be inside an IdentityEditController.',\n});\n\n// ---------------------------------------------------------------------------\n// Components\n// ---------------------------------------------------------------------------\n\n/**\n * Owns the identity section's mode and provides it to descendants. Renders no DOM of its own.\n *\n * The mode moves only when the shopper presses one of this section's own buttons. Saving the form does\n * not close the section — the confirmation stays readable, and whether finishing a form should collapse\n * anything is a sequencing question this component deliberately has no opinion on.\n */\nexport function IdentityEditController({ children }: IdentityEditControllerProps) {\n const [mode, setMode] = useState<IdentityEditMode>('view');\n\n const value = useMemo<IdentityEditContextValue>(() => ({ mode, setMode }), [mode]);\n\n return <IdentityEditContext.Provider value={value}>{children}</IdentityEditContext.Provider>;\n}\n\n/** Renders its children only while the section shows the summary. */\nexport function IdentitySummaryView({ children }: IdentityEditPanelProps) {\n const { mode } = useIdentityEditContext();\n if (mode !== 'view') return null;\n return <>{children}</>;\n}\n\n/** Renders its children only while the section shows the form. */\nexport function IdentityEditForm({ children }: IdentityEditPanelProps) {\n const { mode } = useIdentityEditContext();\n if (mode !== 'edit') return null;\n return <>{children}</>;\n}\n\n/** Opens the form. Renders `children` or the `label` message. */\nexport function IdentityEditButton({ $content, $locale, className, children }: IdentityEditButtonProps) {\n const { setMode } = useIdentityEditContext();\n const { format } = useMessageFormatter(IdentityEditButtonContent, $content);\n return (\n <button type=\"button\" data-fs-identity-edit-button=\"\" className={className} onClick={() => setMode('edit')}>\n {children ?? format('label')}\n </button>\n );\n}\n\n/** Returns to the summary without saving. Renders `children` or the `label` message. */\nexport function IdentityEditCancelButton({ $content, $locale, className, children }: IdentityEditCancelButtonProps) {\n const { setMode } = useIdentityEditContext();\n const { format } = useMessageFormatter(IdentityEditCancelButtonContent, $content);\n return (\n <button type=\"button\" data-fs-identity-edit-cancel-button=\"\" className={className} onClick={() => setMode('view')}>\n {children ?? format('label')}\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace Export\n// ---------------------------------------------------------------------------\n\nexport const IdentityEdit = {\n Controller: IdentityEditController,\n ControllerDefinition: IdentityEditControllerDefinition,\n SummaryView: IdentitySummaryView,\n SummaryViewDefinition: IdentitySummaryViewDefinition,\n Form: IdentityEditForm,\n FormDefinition: IdentityEditFormDefinition,\n EditButton: IdentityEditButton,\n EditButtonDefinition: IdentityEditButtonDefinition,\n CancelButton: IdentityEditCancelButton,\n CancelButtonDefinition: IdentityEditCancelButtonDefinition,\n};\n"],"mappings":";;;;;;;;AAyBA,MAAM,sBAAsB,cAAoD,KAAA,CAAS;AAEzF,SAAS,yBAAmD;CAC1D,MAAM,MAAM,WAAW,mBAAmB;CAC1C,IA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