@vtex/faststore 0.0.7 → 0.0.10

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 (498) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/actions.json +194 -1
  3. package/dist/catalog.json +3449 -1612
  4. package/dist/cli/index.d.ts +512 -63
  5. package/dist/cli/index.js +2098 -686
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/server-runtime.js +44 -24
  8. package/dist/cli/server-runtime.js.map +1 -1
  9. package/dist/client.d.ts +5 -1
  10. package/dist/client.js +5 -1
  11. package/dist/components.d.ts +42 -10
  12. package/dist/components.js +47 -15
  13. package/dist/content-types.json +823 -0
  14. package/dist/core/dist/define-component.d.ts +12 -2
  15. package/dist/docs/account-access-gate.md +4 -4
  16. package/dist/docs/account-address-book.md +519 -0
  17. package/dist/docs/account-entry-point.md +5 -5
  18. package/dist/docs/account-menu.md +7 -7
  19. package/dist/docs/account-saved-cards.md +301 -0
  20. package/dist/docs/alert-dialog.md +2 -2
  21. package/dist/docs/billing-address.md +17 -9
  22. package/dist/docs/binding-switcher.md +154 -0
  23. package/dist/docs/card-entry.md +38 -7
  24. package/dist/docs/card-summary.md +175 -0
  25. package/dist/docs/cardholder-document.md +16 -14
  26. package/dist/docs/cart-destination.md +238 -0
  27. package/dist/docs/cart-item.md +22 -4
  28. package/dist/docs/cart-totalizer.md +1 -1
  29. package/dist/docs/cart.md +126 -19
  30. package/dist/docs/client-profile-fieldset.md +7 -5
  31. package/dist/docs/copy-text.md +84 -0
  32. package/dist/docs/document-field.md +8 -8
  33. package/dist/docs/footer-link-group.md +2 -2
  34. package/dist/docs/footer-social.md +1 -1
  35. package/dist/docs/free-shipping-progress.md +13 -9
  36. package/dist/docs/header-root.md +1 -1
  37. package/dist/docs/incentives.md +4 -4
  38. package/dist/docs/logo.md +6 -6
  39. package/dist/docs/my-account-profile.md +4 -4
  40. package/dist/docs/navigation-link-list.md +2 -2
  41. package/dist/docs/navigation-link.md +3 -3
  42. package/dist/docs/order-cancel.md +52 -0
  43. package/dist/docs/order-delivery-address.md +63 -0
  44. package/dist/docs/order-delivery-group.md +83 -0
  45. package/dist/docs/order-details-back.md +41 -0
  46. package/dist/docs/order-details-header.md +48 -0
  47. package/dist/docs/order-list-row.md +46 -0
  48. package/dist/docs/order-list-search.md +101 -0
  49. package/dist/docs/order-list-views.md +97 -0
  50. package/dist/docs/order-list.md +94 -0
  51. package/dist/docs/order-payment.md +94 -0
  52. package/dist/docs/order-placed-date.md +49 -0
  53. package/dist/docs/order-placed-payment-summary.md +13 -15
  54. package/dist/docs/order-placed.md +225 -0
  55. package/dist/docs/order-progress.md +88 -0
  56. package/dist/docs/order-status-badge.md +91 -0
  57. package/dist/docs/order-summary.md +53 -0
  58. package/dist/docs/payment-method-badges.md +16 -5
  59. package/dist/docs/payment-methods.md +1 -1
  60. package/dist/docs/place-order.md +13 -9
  61. package/dist/docs/product-information.md +2 -2
  62. package/dist/docs/product-shelf.md +7 -0
  63. package/dist/docs/saved-cards.md +2 -2
  64. package/dist/docs/select.md +22 -10
  65. package/dist/docs/session.md +1 -1
  66. package/dist/docs/shipping-address.md +1 -1
  67. package/dist/docs/sign-in-redirect.md +7 -7
  68. package/dist/docs/toast.md +35 -13
  69. package/dist/index.d.ts +7 -2
  70. package/dist/index.js +2 -1
  71. package/dist/internal/client.d.ts +9 -1
  72. package/dist/internal/client.js +10 -2
  73. package/dist/internal/server.d.ts +8 -2
  74. package/dist/internal/server.js +8 -2
  75. package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
  76. package/dist/matter/account-access-gate/account-access-gate.js +19 -16
  77. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
  78. package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
  79. package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
  80. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
  81. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
  82. package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
  83. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
  84. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
  85. package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
  86. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
  87. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
  88. package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
  89. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
  90. package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
  91. package/dist/matter/account-address-book/account-address-book.js +469 -0
  92. package/dist/matter/account-address-book/account-address-book.js.map +1 -0
  93. package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
  94. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
  95. package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
  96. package/dist/matter/account-address-book/account-address-country.js +151 -0
  97. package/dist/matter/account-address-book/account-address-country.js.map +1 -0
  98. package/dist/matter/account-address-book/account-address-first-line.js +11 -0
  99. package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
  100. package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
  101. package/dist/matter/account-address-book/account-address-form-context.js +14 -0
  102. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
  103. package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
  104. package/dist/matter/account-address-book/account-address-form.js +946 -0
  105. package/dist/matter/account-address-book/account-address-form.js.map +1 -0
  106. package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
  107. package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
  108. package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
  109. package/dist/matter/account-address-book/account-address-record.js +138 -0
  110. package/dist/matter/account-address-book/account-address-record.js.map +1 -0
  111. package/dist/matter/account-entry-point/account-entry-point.js +11 -11
  112. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  113. package/dist/matter/account-menu/account-menu.d.ts +7 -3
  114. package/dist/matter/account-menu/account-menu.js +69 -28
  115. package/dist/matter/account-menu/account-menu.js.map +1 -1
  116. package/dist/matter/account-saved-cards/account-saved-cards.d.ts +383 -0
  117. package/dist/matter/account-saved-cards/account-saved-cards.js +956 -0
  118. package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
  119. package/dist/matter/billing-address/billing-address.d.ts +30 -17
  120. package/dist/matter/billing-address/billing-address.js +128 -33
  121. package/dist/matter/billing-address/billing-address.js.map +1 -1
  122. package/dist/matter/breadcrumb/breadcrumb.js +2 -2
  123. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  124. package/dist/matter/card-entry/card-capture.js +4 -3
  125. package/dist/matter/card-entry/card-capture.js.map +1 -1
  126. package/dist/matter/card-entry/card-entry.d.ts +5 -3
  127. package/dist/matter/card-entry/card-entry.js +77 -27
  128. package/dist/matter/card-entry/card-entry.js.map +1 -1
  129. package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
  130. package/dist/matter/cardholder-document/cardholder-document.js +36 -16
  131. package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
  132. package/dist/matter/cart/cart-namespace.d.ts +5 -1
  133. package/dist/matter/cart/cart-namespace.js +5 -1
  134. package/dist/matter/cart/cart-namespace.js.map +1 -1
  135. package/dist/matter/cart/cart.d.ts +41 -6
  136. package/dist/matter/cart/cart.js +267 -54
  137. package/dist/matter/cart/cart.js.map +1 -1
  138. package/dist/matter/cart-destination/cart-destination.d.ts +222 -0
  139. package/dist/matter/cart-destination/cart-destination.js +613 -0
  140. package/dist/matter/cart-destination/cart-destination.js.map +1 -0
  141. package/dist/matter/cart-item/cart-item.d.ts +4 -2
  142. package/dist/matter/cart-item/cart-item.js +76 -17
  143. package/dist/matter/cart-item/cart-item.js.map +1 -1
  144. package/dist/matter/cart-totalizer/cart-totalizer.js +3 -2
  145. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
  146. package/dist/matter/client-preferences/client-preferences-fieldset.js +1 -1
  147. package/dist/matter/client-profile-form/client-profile-fieldset.js +8 -5
  148. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  149. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +6 -3
  150. package/dist/matter/free-shipping-progress/free-shipping-progress.js +76 -33
  151. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
  152. package/dist/matter/identity-edit/identity-edit.js +3 -3
  153. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  154. package/dist/matter/identity-summary/identity-summary.js +2 -2
  155. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  156. package/dist/matter/my-account-profile/my-account-profile.d.ts +3 -3
  157. package/dist/matter/my-account-profile/my-account-profile.js +4 -4
  158. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  159. package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
  160. package/dist/matter/order-cancel/order-cancel.js +344 -0
  161. package/dist/matter/order-cancel/order-cancel.js.map +1 -0
  162. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
  163. package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
  164. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
  165. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
  166. package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
  167. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
  168. package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
  169. package/dist/matter/order-details-header/order-details-header.js +190 -0
  170. package/dist/matter/order-details-header/order-details-header.js.map +1 -0
  171. package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
  172. package/dist/matter/order-list/customer-orders-filter.js +30 -0
  173. package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
  174. package/dist/matter/order-list/order-list.d.ts +121 -0
  175. package/dist/matter/order-list/order-list.js +395 -0
  176. package/dist/matter/order-list/order-list.js.map +1 -0
  177. package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
  178. package/dist/matter/order-list-row/order-list-row.js +127 -0
  179. package/dist/matter/order-list-row/order-list-row.js.map +1 -0
  180. package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
  181. package/dist/matter/order-list-search/order-list-search.js +296 -0
  182. package/dist/matter/order-list-search/order-list-search.js.map +1 -0
  183. package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
  184. package/dist/matter/order-list-views/order-list-views.js +154 -0
  185. package/dist/matter/order-list-views/order-list-views.js.map +1 -0
  186. package/dist/matter/order-payment/order-payment.d.ts +83 -0
  187. package/dist/matter/order-payment/order-payment.js +258 -0
  188. package/dist/matter/order-payment/order-payment.js.map +1 -0
  189. package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
  190. package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
  191. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
  192. package/dist/matter/order-placed/order-placed.d.ts +122 -0
  193. package/dist/matter/order-placed/order-placed.js +452 -0
  194. package/dist/matter/order-placed/order-placed.js.map +1 -0
  195. package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
  196. package/dist/matter/order-placed-date/order-placed-date.js +92 -0
  197. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
  198. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
  199. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
  200. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  201. package/dist/matter/order-progress/order-progress.d.ts +85 -0
  202. package/dist/matter/order-progress/order-progress.js +203 -0
  203. package/dist/matter/order-progress/order-progress.js.map +1 -0
  204. package/dist/matter/order-summary/order-summary.d.ts +81 -0
  205. package/dist/matter/order-summary/order-summary.js +192 -0
  206. package/dist/matter/order-summary/order-summary.js.map +1 -0
  207. package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
  208. package/dist/matter/payment/cardholder-document-rule.js +35 -0
  209. package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
  210. package/dist/matter/payment/payment-card-capture.js +38 -23
  211. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  212. package/dist/matter/payment/payment-controller.js +11 -0
  213. package/dist/matter/payment/payment-controller.js.map +1 -1
  214. package/dist/matter/payment/payment-method-badges.js +4 -2
  215. package/dist/matter/payment/payment-method-badges.js.map +1 -1
  216. package/dist/matter/payment/payment.js +11 -0
  217. package/dist/matter/payment/payment.js.map +1 -1
  218. package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
  219. package/dist/matter/payment/use-payment-method-selection.js +30 -2
  220. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  221. package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
  222. package/dist/matter/payment/use-payment-submit-gate.js +42 -14
  223. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  224. package/dist/matter/place-order/place-order.d.ts +12 -7
  225. package/dist/matter/place-order/place-order.js +126 -103
  226. package/dist/matter/place-order/place-order.js.map +1 -1
  227. package/dist/matter/pricing/pricing.js +5 -5
  228. package/dist/matter/pricing/pricing.js.map +1 -1
  229. package/dist/matter/product-shelf/product-shelf.d.ts +7 -0
  230. package/dist/matter/product-shelf/product-shelf.js +115 -1
  231. package/dist/matter/product-shelf/product-shelf.js.map +1 -1
  232. package/dist/matter/region/region.js +1 -1
  233. package/dist/matter/saved-cards/saved-cards.js +26 -15
  234. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  235. package/dist/matter/session/session.js +2 -2
  236. package/dist/matter/session/session.js.map +1 -1
  237. package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
  238. package/dist/matter/shipping-address/country-descriptors.js +23 -1
  239. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  240. package/dist/matter/shipping-address/shipping-address.js +62 -14
  241. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  242. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +2 -2
  243. package/dist/matter/shipping-simulator/shipping-simulator.js +6 -2
  244. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  245. package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
  246. package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
  247. package/dist/matter/variant-selector/variant-selector.js +2 -2
  248. package/dist/matter/variant-selector/variant-selector.js.map +1 -1
  249. package/dist/particles/address-summary/address-summary.js +2 -2
  250. package/dist/particles/address-summary/address-summary.js.map +1 -1
  251. package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
  252. package/dist/particles/alert-dialog/alert-dialog.js +5 -2
  253. package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
  254. package/dist/particles/binding-switcher/binding-switcher.d.ts +38 -0
  255. package/dist/particles/binding-switcher/binding-switcher.js +183 -0
  256. package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
  257. package/dist/particles/card-summary/card-network.d.ts +17 -0
  258. package/dist/particles/card-summary/card-network.js +25 -0
  259. package/dist/particles/card-summary/card-network.js.map +1 -0
  260. package/dist/particles/card-summary/card-summary.d.ts +83 -0
  261. package/dist/particles/card-summary/card-summary.js +188 -0
  262. package/dist/particles/card-summary/card-summary.js.map +1 -0
  263. package/dist/particles/copy-text/copy-text.d.ts +28 -0
  264. package/dist/particles/copy-text/copy-text.js +140 -0
  265. package/dist/particles/copy-text/copy-text.js.map +1 -0
  266. package/dist/particles/document-field/document-field.d.ts +34 -5
  267. package/dist/particles/document-field/document-field.js +115 -19
  268. package/dist/particles/document-field/document-field.js.map +1 -1
  269. package/dist/particles/field/field.js +1 -1
  270. package/dist/particles/field/field.js.map +1 -1
  271. package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
  272. package/dist/particles/footer-link-group/footer-link-group.js +18 -7
  273. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  274. package/dist/particles/footer-social/footer-social.d.ts +1 -1
  275. package/dist/particles/footer-social/footer-social.js +1 -1
  276. package/dist/particles/footer-social/footer-social.js.map +1 -1
  277. package/dist/particles/incentives/incentives.d.ts +7 -3
  278. package/dist/particles/incentives/incentives.js +8 -3
  279. package/dist/particles/incentives/incentives.js.map +1 -1
  280. package/dist/particles/logo/logo.d.ts +3 -2
  281. package/dist/particles/logo/logo.js +20 -8
  282. package/dist/particles/logo/logo.js.map +1 -1
  283. package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
  284. package/dist/particles/navigation-link/navigation-link.js +4 -4
  285. package/dist/particles/navigation-link/navigation-link.js.map +1 -1
  286. package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
  287. package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
  288. package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
  289. package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
  290. package/dist/particles/order-details-back/order-details-back.js +52 -0
  291. package/dist/particles/order-details-back/order-details-back.js.map +1 -0
  292. package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
  293. package/dist/particles/order-status-badge/order-status-badge.js +50 -0
  294. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
  295. package/dist/particles/payment-methods/payment-methods.d.ts +1 -1
  296. package/dist/particles/payment-methods/payment-methods.js +1 -1
  297. package/dist/particles/payment-methods/payment-methods.js.map +1 -1
  298. package/dist/particles/phone-field/phone-field.js +2 -2
  299. package/dist/particles/phone-field/phone-field.js.map +1 -1
  300. package/dist/particles/select/select.js +6 -6
  301. package/dist/particles/select/select.js.map +1 -1
  302. package/dist/particles/toast/toast.d.ts +21 -7
  303. package/dist/particles/toast/toast.js +76 -8
  304. package/dist/particles/toast/toast.js.map +1 -1
  305. package/dist/schema.graphql +1376 -126
  306. package/dist/sdk/actions/address-action-provider.d.ts +16 -0
  307. package/dist/sdk/actions/address-action-provider.js +20 -0
  308. package/dist/sdk/actions/address-action-provider.js.map +1 -0
  309. package/dist/sdk/actions/analytics-action-provider.js +1 -1
  310. package/dist/sdk/actions/index.d.ts +5 -1
  311. package/dist/sdk/actions/index.js +5 -1
  312. package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
  313. package/dist/sdk/actions/locale-action-provider.js +20 -0
  314. package/dist/sdk/actions/locale-action-provider.js.map +1 -0
  315. package/dist/sdk/actions/order-action-provider.d.ts +12 -0
  316. package/dist/sdk/actions/order-action-provider.js +16 -0
  317. package/dist/sdk/actions/order-action-provider.js.map +1 -0
  318. package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
  319. package/dist/sdk/actions/saved-card-action-provider.js +16 -0
  320. package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
  321. package/dist/sdk/actions/types.d.ts +10 -2
  322. package/dist/sdk/address/address-fields.js +38 -0
  323. package/dist/sdk/address/address-fields.js.map +1 -0
  324. package/dist/sdk/address/checkout-readiness.js +17 -0
  325. package/dist/sdk/address/checkout-readiness.js.map +1 -0
  326. package/dist/sdk/address/constants.js +60 -0
  327. package/dist/sdk/address/constants.js.map +1 -0
  328. package/dist/sdk/address/country-display.js +19 -0
  329. package/dist/sdk/address/country-display.js.map +1 -0
  330. package/dist/sdk/address/country-rules.js +30 -0
  331. package/dist/sdk/address/country-rules.js.map +1 -0
  332. package/dist/sdk/address/format-address.js +18 -0
  333. package/dist/sdk/address/format-address.js.map +1 -0
  334. package/dist/sdk/address/iso-countries.js +262 -0
  335. package/dist/sdk/address/iso-countries.js.map +1 -0
  336. package/dist/sdk/address/layouts.js +56 -0
  337. package/dist/sdk/address/layouts.js.map +1 -0
  338. package/dist/sdk/address/messages.js +97 -0
  339. package/dist/sdk/address/messages.js.map +1 -0
  340. package/dist/sdk/address/operations.d.ts +54 -0
  341. package/dist/sdk/address/operations.js +83 -0
  342. package/dist/sdk/address/operations.js.map +1 -0
  343. package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
  344. package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
  345. package/dist/sdk/address/postal-code.js +11 -0
  346. package/dist/sdk/address/postal-code.js.map +1 -0
  347. package/dist/sdk/address/schema.js +14 -0
  348. package/dist/sdk/address/schema.js.map +1 -0
  349. package/dist/sdk/address/server-fields.js +25 -0
  350. package/dist/sdk/address/server-fields.js.map +1 -0
  351. package/dist/sdk/address/switch-country.js +57 -0
  352. package/dist/sdk/address/switch-country.js.map +1 -0
  353. package/dist/sdk/address/types.d.ts +26 -0
  354. package/dist/sdk/address/use-address-actions.d.ts +29 -0
  355. package/dist/sdk/address/use-address-actions.js +247 -0
  356. package/dist/sdk/address/use-address-actions.js.map +1 -0
  357. package/dist/sdk/address/use-address-by-postal-code.js +57 -0
  358. package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
  359. package/dist/sdk/address/validate-address.js +62 -0
  360. package/dist/sdk/address/validate-address.js.map +1 -0
  361. package/dist/sdk/cache/storefront-cache.js +30 -4
  362. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  363. package/dist/sdk/cart/operations.d.ts +2 -1
  364. package/dist/sdk/cart/operations.js +55 -1
  365. package/dist/sdk/cart/operations.js.map +1 -1
  366. package/dist/sdk/cart/optimistic.d.ts +30 -7
  367. package/dist/sdk/cart/optimistic.js +78 -41
  368. package/dist/sdk/cart/optimistic.js.map +1 -1
  369. package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
  370. package/dist/sdk/cart/use-cart-actions.js +61 -15
  371. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  372. package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
  373. package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
  374. package/dist/sdk/client/fetch-page-data.d.ts +11 -0
  375. package/dist/sdk/client/fetch-page-data.js +12 -1
  376. package/dist/sdk/client/fetch-page-data.js.map +1 -1
  377. package/dist/sdk/content/create-content-runtime.js +1 -8
  378. package/dist/sdk/content/create-content-runtime.js.map +1 -1
  379. package/dist/sdk/data/failed-fields.js +23 -0
  380. package/dist/sdk/data/failed-fields.js.map +1 -0
  381. package/dist/sdk/data/index.js +2 -2
  382. package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
  383. package/dist/sdk/data/page-reactive-data-root.js +88 -12
  384. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  385. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  386. package/dist/sdk/generated/fragment-types.js +2 -0
  387. package/dist/sdk/generated/fragment-types.js.map +1 -1
  388. package/dist/sdk/generated/gql.js +17 -11
  389. package/dist/sdk/generated/gql.js.map +1 -1
  390. package/dist/sdk/generated/graphql.d.ts +185 -46
  391. package/dist/sdk/generated/graphql.js +2587 -155
  392. package/dist/sdk/generated/graphql.js.map +1 -1
  393. package/dist/sdk/i18n/messages/en-US.js +157 -1
  394. package/dist/sdk/i18n/messages/en-US.json +157 -1
  395. package/dist/sdk/i18n/messages/en-US.json.d.ts +156 -0
  396. package/dist/sdk/i18n/messages/es-ES.js +157 -1
  397. package/dist/sdk/i18n/messages/es-ES.json +157 -1
  398. package/dist/sdk/i18n/messages/pt-BR.js +157 -1
  399. package/dist/sdk/i18n/messages/pt-BR.json +157 -1
  400. package/dist/sdk/i18n/provider.js +1 -1
  401. package/dist/sdk/i18n/provider.js.map +1 -1
  402. package/dist/sdk/locale/binding-switch-provider.d.ts +13 -0
  403. package/dist/sdk/locale/binding-switch-provider.js +20 -0
  404. package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
  405. package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
  406. package/dist/sdk/locale/use-locale-actions.js +70 -0
  407. package/dist/sdk/locale/use-locale-actions.js.map +1 -0
  408. package/dist/sdk/navigation/binding-switch.d.ts +39 -0
  409. package/dist/sdk/navigation/binding-switch.js +129 -0
  410. package/dist/sdk/navigation/binding-switch.js.map +1 -0
  411. package/dist/sdk/navigation/current-page.js +30 -0
  412. package/dist/sdk/navigation/current-page.js.map +1 -0
  413. package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
  414. package/dist/sdk/navigation/decode-route-params.js +32 -0
  415. package/dist/sdk/navigation/decode-route-params.js.map +1 -0
  416. package/dist/sdk/navigation/not-found-log.d.ts +28 -0
  417. package/dist/sdk/navigation/not-found-log.js +133 -0
  418. package/dist/sdk/navigation/not-found-log.js.map +1 -0
  419. package/dist/sdk/navigation/path.js +25 -0
  420. package/dist/sdk/navigation/path.js.map +1 -0
  421. package/dist/sdk/navigation/redirect.d.ts +11 -0
  422. package/dist/sdk/navigation/redirect.js +22 -0
  423. package/dist/sdk/navigation/redirect.js.map +1 -0
  424. package/dist/sdk/navigation/report.js +70 -0
  425. package/dist/sdk/navigation/report.js.map +1 -0
  426. package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
  427. package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
  428. package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
  429. package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
  430. package/dist/sdk/navigation/route-identity-provider.js +20 -0
  431. package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
  432. package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
  433. package/dist/sdk/navigation/route-map-provider.js +29 -0
  434. package/dist/sdk/navigation/route-map-provider.js.map +1 -0
  435. package/dist/sdk/navigation/storefront-link.d.ts +16 -0
  436. package/dist/sdk/navigation/storefront-link.js +66 -0
  437. package/dist/sdk/navigation/storefront-link.js.map +1 -0
  438. package/dist/sdk/navigation/types.d.ts +45 -0
  439. package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
  440. package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
  441. package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
  442. package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
  443. package/dist/sdk/navigation/use-storefront-route.js +87 -0
  444. package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
  445. package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
  446. package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
  447. package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
  448. package/dist/sdk/orders/completion-badge.d.ts +8 -0
  449. package/dist/sdk/orders/completion-badge.js +47 -0
  450. package/dist/sdk/orders/completion-badge.js.map +1 -0
  451. package/dist/sdk/orders/order-operations.d.ts +19 -0
  452. package/dist/sdk/orders/order-operations.js +21 -0
  453. package/dist/sdk/orders/order-operations.js.map +1 -0
  454. package/dist/sdk/orders/use-order-actions.d.ts +23 -0
  455. package/dist/sdk/orders/use-order-actions.js +62 -0
  456. package/dist/sdk/orders/use-order-actions.js.map +1 -0
  457. package/dist/sdk/payment/gateway-origin.js +26 -13
  458. package/dist/sdk/payment/gateway-origin.js.map +1 -1
  459. package/dist/sdk/payment/gateway.d.ts +14 -2
  460. package/dist/sdk/payment/gateway.js +32 -14
  461. package/dist/sdk/payment/gateway.js.map +1 -1
  462. package/dist/sdk/payment/operations.js +11 -0
  463. package/dist/sdk/payment/operations.js.map +1 -1
  464. package/dist/sdk/payment/submission-registry.d.ts +2 -1
  465. package/dist/sdk/payment/submission-registry.js +12 -8
  466. package/dist/sdk/payment/submission-registry.js.map +1 -1
  467. package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
  468. package/dist/sdk/payment/use-payment-actions.js +5 -2
  469. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  470. package/dist/sdk/payment/use-place-order.d.ts +6 -3
  471. package/dist/sdk/payment/use-place-order.js +333 -143
  472. package/dist/sdk/payment/use-place-order.js.map +1 -1
  473. package/dist/sdk/saved-cards/operations.d.ts +16 -0
  474. package/dist/sdk/saved-cards/operations.js +41 -0
  475. package/dist/sdk/saved-cards/operations.js.map +1 -0
  476. package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
  477. package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
  478. package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
  479. package/dist/sdk/seo/page-alternates.d.ts +57 -0
  480. package/dist/sdk/seo/page-alternates.js +127 -0
  481. package/dist/sdk/seo/page-alternates.js.map +1 -0
  482. package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
  483. package/dist/sdk/shipping/shipping-operations.js +13 -0
  484. package/dist/sdk/shipping/shipping-operations.js.map +1 -1
  485. package/dist/sdk/state/cart.d.ts +9 -2
  486. package/dist/sdk/state/cart.js +9 -2
  487. package/dist/sdk/state/cart.js.map +1 -1
  488. package/dist/utils/own-value.js +19 -0
  489. package/dist/utils/own-value.js.map +1 -0
  490. package/dist/utils/safe-href.d.ts +4 -4
  491. package/dist/utils/safe-href.js +31 -22
  492. package/dist/utils/safe-href.js.map +1 -1
  493. package/package.json +5 -1
  494. package/skills/storefront-asset/SKILL.md +111 -0
  495. package/skills/storefront-asset/references/api-side.md +153 -0
  496. package/skills/storefront-asset/references/findings.md +40 -0
  497. package/skills/storefront-asset/references/ui-side.md +94 -0
  498. package/src/styles/tailwind.css +28 -2
@@ -0,0 +1,452 @@
1
+ "use client";
2
+ import { defineComponent } from "../../core/dist/define-component.js";
3
+ import "../../core/dist/index.js";
4
+ import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
5
+ import { useDataOverride } from "../../sdk/data/data-override-context.js";
6
+ import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
7
+ import { formatPrice } from "../cart/cart.js";
8
+ import { substituteTemplate } from "../../utils/substitute-template.js";
9
+ import { createContext, useContext, useMemo } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { CombinedGraphQLErrors } from "@apollo/client/errors";
12
+ //#region src/matter/order-placed/order-placed.tsx
13
+ /**
14
+ * Order Placed matters (docs/features/order-placed/rfc-particles.md, Parts, part 2).
15
+ * `OrderPlacedRoot` owns the placed order: it reads `Query.order(orderGroup: $orderGroup)` once through
16
+ * its own fragment and provides it as the `order-placed` context, or shows an authored message in
17
+ * place of its children when the read is refused or fails. The leaves read the order's own record,
18
+ * never the live cart or profile, so a confirmation reopened later shows what the purchase carried.
19
+ */
20
+ const rootFragment = `
21
+ fragment OrderPlacedRootData on Query {
22
+ order(orderGroup: $orderGroup) {
23
+ __typename
24
+ id
25
+ reference
26
+ status
27
+ total {
28
+ amount
29
+ currencyCode
30
+ }
31
+ totals {
32
+ id
33
+ name
34
+ value {
35
+ amount
36
+ currencyCode
37
+ }
38
+ }
39
+ }
40
+ }
41
+ `;
42
+ const customerFragment = `
43
+ fragment OrderPlacedCustomerData on Query {
44
+ order(orderGroup: $orderGroup) {
45
+ __typename
46
+ id
47
+ customer {
48
+ firstName
49
+ lastName
50
+ email
51
+ phone
52
+ document
53
+ }
54
+ }
55
+ }
56
+ `;
57
+ const ORDER_PLACED_UNSET = Symbol("OrderPlacedContextUnset");
58
+ const OrderPlacedContext = createContext(ORDER_PLACED_UNSET);
59
+ /** The placed order, its loading flag and the root query's error, from the nearest OrderPlacedRoot. */
60
+ function useOrderPlaced() {
61
+ const ctx = useContext(OrderPlacedContext);
62
+ if (ctx === ORDER_PLACED_UNSET) throw new Error("useOrderPlaced() must be used inside an <OrderPlacedRoot> subtree.");
63
+ return ctx;
64
+ }
65
+ /**
66
+ * The API refuses the read with a top-level `UNAUTHORIZED`: without both checkout cookies, and when
67
+ * the order system answers 401 or 403, as it does after 15 minutes. Under `errorPolicy: 'all'` the
68
+ * refusal also carries `order: null`, so it is checked before the order is.
69
+ */
70
+ function isRefusal(error) {
71
+ if (!error || !CombinedGraphQLErrors.is(error)) return false;
72
+ return error.errors.some((graphQLError) => graphQLError.extensions?.code === "UNAUTHORIZED");
73
+ }
74
+ function resolveRootState({ order, loading, error }) {
75
+ if (isRefusal(error)) return "refused";
76
+ if (loading && order == null) return "loading";
77
+ if (order == null) return "unresolved";
78
+ return "order";
79
+ }
80
+ function isZero(money) {
81
+ return Number(money.amount) === 0;
82
+ }
83
+ function formatMoney(money, locale) {
84
+ return formatPrice(Number(money.amount), locale, money.currencyCode);
85
+ }
86
+ const OrderPlacedRootDefinition = defineComponent({
87
+ name: "OrderPlacedRoot",
88
+ importPath: "@vtex/faststore/components",
89
+ component: OrderPlacedRoot,
90
+ fragment: rootFragment,
91
+ fetchStrategy: "reactive",
92
+ skeleton: OrderPlacedRootSkeleton,
93
+ providesContext: "order-placed",
94
+ editor: {
95
+ label: "Order Placed Root",
96
+ category: "commerce"
97
+ },
98
+ schema: {
99
+ refusedOrderLabel: {
100
+ type: "string",
101
+ default: "This order can no longer be shown here",
102
+ label: "Refused order label"
103
+ },
104
+ unresolvedOrderLabel: {
105
+ type: "string",
106
+ default: "Could not load this order",
107
+ label: "Unresolved order label"
108
+ }
109
+ },
110
+ guideline: "Owner of an order confirmation page: reads the placed order (Query.order, keyed on the order group from the route) once and provides it as the order-placed context to OrderPlacedStatus, OrderPlacedReference, OrderPlacedCustomer, OrderPlacedTotals and the other order-placed blocks composed as its children. Renders its children only once the order resolves. While the read is in flight it shows a skeleton; when the API refuses the read (after 15 minutes, or from another browser) it shows refusedOrderLabel; when the read fails or the order group resolves to no order it shows unresolvedOrderLabel. Each message replaces every child. Never reads the cart or the live profile. See order-placed.md."
111
+ });
112
+ const OrderPlacedStatusDefinition = defineComponent({
113
+ name: "OrderPlacedStatus",
114
+ importPath: "@vtex/faststore/components",
115
+ component: OrderPlacedStatus,
116
+ requiresContext: "order-placed",
117
+ editor: {
118
+ label: "Order Placed Status",
119
+ category: "commerce"
120
+ },
121
+ schema: {
122
+ approvedTitle: {
123
+ type: "string",
124
+ default: "Your order is confirmed",
125
+ label: "Approved title"
126
+ },
127
+ approvedMessage: {
128
+ type: "string",
129
+ default: "Your payment was approved.",
130
+ label: "Approved message"
131
+ },
132
+ pendingTitle: {
133
+ type: "string",
134
+ default: "We're confirming your payment",
135
+ label: "Pending title"
136
+ },
137
+ pendingMessage: {
138
+ type: "string",
139
+ default: "Your order was placed, and its payment is still being processed or reviewed.",
140
+ label: "Pending message"
141
+ },
142
+ deniedTitle: {
143
+ type: "string",
144
+ default: "Your payment was not approved",
145
+ label: "Denied title"
146
+ },
147
+ deniedMessage: {
148
+ type: "string",
149
+ default: "This purchase did not go through. You can place a new order with another payment method.",
150
+ label: "Denied message"
151
+ }
152
+ },
153
+ guideline: "The payment outcome of the placed order, as a banner with a title and a message: approved, pending (which also covers a payment under anti-fraud review) or denied. Renders nothing when the outcome is unknown, so the page shows the order without asserting success or failure. Author the title and message of each outcome through the props (approvedTitle, approvedMessage, pendingTitle, pendingMessage, deniedTitle, deniedMessage); a blank value omits its line. Marks the outcome with data-fs-order-placed-status-approved, -pending or -denied, so the page styles each tone. An Icon composed as its child shows on every outcome, so never compose one that implies success. Must be inside OrderPlacedRoot. See order-placed.md."
154
+ });
155
+ const OrderPlacedReferenceDefinition = defineComponent({
156
+ name: "OrderPlacedReference",
157
+ importPath: "@vtex/faststore/components",
158
+ component: OrderPlacedReference,
159
+ requiresContext: "order-placed",
160
+ editor: {
161
+ label: "Order Placed Reference",
162
+ category: "commerce"
163
+ },
164
+ schema: { template: {
165
+ type: "string",
166
+ default: "Order #{reference}",
167
+ label: "Template"
168
+ } },
169
+ guideline: "The order number the shopper gives support: the order group, one per purchase even when it was split across sellers. Set template with a {reference} placeholder (e.g. \"Order #{reference}\"). Plain text, so it can be selected and copied. Must be inside OrderPlacedRoot. See order-placed.md."
170
+ });
171
+ const OrderPlacedCustomerDefinition = defineComponent({
172
+ name: "OrderPlacedCustomer",
173
+ importPath: "@vtex/faststore/components",
174
+ component: OrderPlacedCustomer,
175
+ fragment: customerFragment,
176
+ fetchStrategy: "reactive",
177
+ requiresContext: "order-placed",
178
+ editor: {
179
+ label: "Order Placed Customer",
180
+ category: "commerce"
181
+ },
182
+ schema: {
183
+ nameLabel: {
184
+ type: "string",
185
+ default: "Name",
186
+ label: "Name label"
187
+ },
188
+ emailLabel: {
189
+ type: "string",
190
+ default: "Email",
191
+ label: "Email label"
192
+ },
193
+ phoneLabel: {
194
+ type: "string",
195
+ default: "Phone",
196
+ label: "Phone label"
197
+ },
198
+ documentLabel: {
199
+ type: "string",
200
+ default: "Document",
201
+ label: "Document label"
202
+ }
203
+ },
204
+ guideline: "Who the order is for, as the order recorded them at placement, never the live profile: name, email, phone and document as label/value rows, each left out when empty. Selects the customer through its own fragment, so a page without this block never fetches the customer. Shows the values as the order system returns them, masked included (e.g. \"J*** D***\"). Must be inside OrderPlacedRoot. See order-placed.md."
205
+ });
206
+ const OrderPlacedTotalsDefinition = defineComponent({
207
+ name: "OrderPlacedTotals",
208
+ importPath: "@vtex/faststore/components",
209
+ component: OrderPlacedTotals,
210
+ requiresContext: "order-placed",
211
+ editor: {
212
+ label: "Order Placed Totals",
213
+ category: "commerce"
214
+ },
215
+ schema: {
216
+ itemsLabel: {
217
+ type: "string",
218
+ default: "Subtotal",
219
+ label: "Items label"
220
+ },
221
+ shippingLabel: {
222
+ type: "string",
223
+ default: "Shipping",
224
+ label: "Shipping label"
225
+ },
226
+ discountsLabel: {
227
+ type: "string",
228
+ default: "Discounts",
229
+ label: "Discounts label"
230
+ },
231
+ taxLabel: {
232
+ type: "string",
233
+ default: "Tax",
234
+ label: "Tax label"
235
+ },
236
+ totalLabel: {
237
+ type: "string",
238
+ default: "Total",
239
+ label: "Total label"
240
+ },
241
+ shippingZeroLabel: {
242
+ type: "string",
243
+ label: "Shipping zero label"
244
+ }
245
+ },
246
+ guideline: "What the shopper was charged: each money line of the placed order in the order the API returns them (subtotal, discounts, shipping, tax, any custom tax under its own name), then the total, each in the order's own currency. A zero discount line is left out; set shippingZeroLabel (e.g. \"Free\") to show it instead of a zero shipping value. No total row when the order has no total. Reads the order, never the cart, so it composes no CartTotalizerLine. Must be inside OrderPlacedRoot. See order-placed.md."
247
+ });
248
+ /** Placeholder for the order's blocks while the read is in flight. */
249
+ function OrderPlacedRootSkeleton() {
250
+ return /* @__PURE__ */ jsxs("div", {
251
+ "aria-hidden": "true",
252
+ "data-fs-order-placed-root-skeleton": "",
253
+ children: [
254
+ /* @__PURE__ */ jsx("span", {}),
255
+ /* @__PURE__ */ jsx("span", {}),
256
+ /* @__PURE__ */ jsx("span", {})
257
+ ]
258
+ });
259
+ }
260
+ /** Provides the placed order to its descendants, or a message in their place. Mirrors CartRoot's read side. */
261
+ function OrderPlacedRoot({ className, children, refusedOrderLabel = "This order can no longer be shown here", unresolvedOrderLabel = "Could not load this order", $data: $dataProp }) {
262
+ const order = useDataOverride($dataProp) ?? null;
263
+ const { loading, error } = useContext(ReactiveRootContext);
264
+ const value = useMemo(() => ({
265
+ order,
266
+ loading,
267
+ error: error ?? null
268
+ }), [
269
+ order,
270
+ loading,
271
+ error
272
+ ]);
273
+ const state = resolveRootState(value);
274
+ return /* @__PURE__ */ jsx(OrderPlacedContext, {
275
+ value,
276
+ children: /* @__PURE__ */ jsxs("div", {
277
+ className,
278
+ "data-fs-order-placed-root": "",
279
+ children: [
280
+ state === "order" ? children : null,
281
+ state === "loading" ? /* @__PURE__ */ jsx(OrderPlacedRootSkeleton, {}) : null,
282
+ state === "refused" ? /* @__PURE__ */ jsx("p", {
283
+ role: "alert",
284
+ "data-fs-order-placed-root-refused": "",
285
+ children: refusedOrderLabel
286
+ }) : null,
287
+ state === "unresolved" ? /* @__PURE__ */ jsx("p", {
288
+ role: "alert",
289
+ "data-fs-order-placed-root-unresolved": "",
290
+ children: unresolvedOrderLabel
291
+ }) : null
292
+ ]
293
+ })
294
+ });
295
+ }
296
+ const TONE_ATTRIBUTES = {
297
+ approved: { "data-fs-order-placed-status-approved": "" },
298
+ pending: { "data-fs-order-placed-status-pending": "" },
299
+ denied: { "data-fs-order-placed-status-denied": "" }
300
+ };
301
+ /**
302
+ * The outcome banner. `UNKNOWN` (seller orders that disagree, or a state the mapping does not
303
+ * classify) renders nothing, so the page shows the order without asserting success or failure.
304
+ */
305
+ function OrderPlacedStatus({ className, children, approvedTitle = "Your order is confirmed", approvedMessage = "Your payment was approved.", pendingTitle = "We're confirming your payment", pendingMessage = "Your order was placed, and its payment is still being processed or reviewed.", deniedTitle = "Your payment was not approved", deniedMessage = "This purchase did not go through. You can place a new order with another payment method." }) {
306
+ const { order } = useOrderPlaced();
307
+ const status = order?.status;
308
+ let copy;
309
+ if (status === "APPROVED") copy = {
310
+ tone: "approved",
311
+ title: approvedTitle,
312
+ message: approvedMessage
313
+ };
314
+ else if (status === "PENDING") copy = {
315
+ tone: "pending",
316
+ title: pendingTitle,
317
+ message: pendingMessage
318
+ };
319
+ else if (status === "DENIED") copy = {
320
+ tone: "denied",
321
+ title: deniedTitle,
322
+ message: deniedMessage
323
+ };
324
+ else return null;
325
+ return /* @__PURE__ */ jsxs("output", {
326
+ className,
327
+ "data-fs-order-placed-status": "",
328
+ ...TONE_ATTRIBUTES[copy.tone],
329
+ children: [
330
+ children,
331
+ copy.title?.trim() ? /* @__PURE__ */ jsx("span", {
332
+ "data-fs-order-placed-status-title": "",
333
+ children: copy.title
334
+ }) : null,
335
+ copy.message?.trim() ? /* @__PURE__ */ jsx("span", {
336
+ "data-fs-order-placed-status-message": "",
337
+ children: copy.message
338
+ }) : null
339
+ ]
340
+ });
341
+ }
342
+ /**
343
+ * The order group, the one reference a split purchase has, so support resolves the whole purchase
344
+ * from it rather than one seller's order.
345
+ */
346
+ function OrderPlacedReference({ className, template = "Order #{reference}" }) {
347
+ const { order } = useOrderPlaced();
348
+ if (!order) return null;
349
+ return /* @__PURE__ */ jsx("p", {
350
+ className,
351
+ "data-fs-order-placed-reference": "",
352
+ children: substituteTemplate(template, { reference: order.reference })
353
+ });
354
+ }
355
+ /**
356
+ * The customer as the order recorded them, never the live profile: masked values show as the order
357
+ * system returns them, and an empty field is left out.
358
+ */
359
+ function OrderPlacedCustomer({ className, nameLabel = "Name", emailLabel = "Email", phoneLabel = "Phone", documentLabel = "Document", $data: $dataProp }) {
360
+ useOrderPlaced();
361
+ const customer = useDataOverride($dataProp)?.customer;
362
+ if (!customer) return null;
363
+ const rows = [
364
+ {
365
+ key: "name",
366
+ term: nameLabel,
367
+ value: [customer.firstName, customer.lastName].map((part) => part?.trim()).filter(Boolean).join(" ")
368
+ },
369
+ {
370
+ key: "email",
371
+ term: emailLabel,
372
+ value: customer.email ?? ""
373
+ },
374
+ {
375
+ key: "phone",
376
+ term: phoneLabel,
377
+ value: customer.phone ?? ""
378
+ },
379
+ {
380
+ key: "document",
381
+ term: documentLabel,
382
+ value: customer.document ?? ""
383
+ }
384
+ ].filter((row) => row.value.trim() !== "");
385
+ if (rows.length === 0) return null;
386
+ return /* @__PURE__ */ jsx("dl", {
387
+ className,
388
+ "data-fs-order-placed-customer": "",
389
+ children: rows.map(({ key, term, value }) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", {
390
+ "data-fs-order-placed-customer-term": "",
391
+ children: term
392
+ }), /* @__PURE__ */ jsx("dd", {
393
+ "data-fs-order-placed-customer-value": "",
394
+ children: value
395
+ })] }, key))
396
+ });
397
+ }
398
+ /**
399
+ * The order's money lines in API order, then the total, each in its own currency. `Items`,
400
+ * `Shipping`, `Discounts` and `Tax` take the authored label, since the order system names them in
401
+ * English; any other line (a custom tax) shows its own name. The API sums lines on id and name, so
402
+ * two custom taxes that share an id are two rows.
403
+ */
404
+ function OrderPlacedTotals({ className, itemsLabel = "Subtotal", shippingLabel = "Shipping", discountsLabel = "Discounts", taxLabel = "Tax", totalLabel = "Total", shippingZeroLabel }) {
405
+ const { order } = useOrderPlaced();
406
+ const { locale } = useStorefrontContext();
407
+ if (!order) return null;
408
+ const labels = /* @__PURE__ */ new Map([
409
+ ["Items", itemsLabel],
410
+ ["Shipping", shippingLabel],
411
+ ["Discounts", discountsLabel],
412
+ ["Tax", taxLabel]
413
+ ]);
414
+ const rows = [];
415
+ order.totals.forEach((line, index) => {
416
+ if (line.id === "Discounts" && isZero(line.value)) return;
417
+ const value = line.id === "Shipping" && isZero(line.value) && shippingZeroLabel?.trim() ? shippingZeroLabel : formatMoney(line.value, locale);
418
+ rows.push({
419
+ key: `${line.id}:${line.name}:${index}`,
420
+ term: labels.get(line.id) ?? line.name,
421
+ value,
422
+ line: line.id
423
+ });
424
+ });
425
+ return /* @__PURE__ */ jsxs("dl", {
426
+ className,
427
+ "data-fs-order-placed-totals": "",
428
+ children: [rows.map(({ key, term, value, line }) => /* @__PURE__ */ jsxs("div", {
429
+ "data-fs-order-placed-totals-line": line,
430
+ children: [/* @__PURE__ */ jsx("dt", {
431
+ "data-fs-order-placed-totals-term": "",
432
+ children: term
433
+ }), /* @__PURE__ */ jsx("dd", {
434
+ "data-fs-order-placed-totals-value": "",
435
+ children: value
436
+ })]
437
+ }, key)), order.total ? /* @__PURE__ */ jsxs("div", {
438
+ "data-fs-order-placed-totals-total": "",
439
+ children: [/* @__PURE__ */ jsx("dt", {
440
+ "data-fs-order-placed-totals-term": "",
441
+ children: totalLabel
442
+ }), /* @__PURE__ */ jsx("dd", {
443
+ "data-fs-order-placed-totals-value": "",
444
+ children: formatMoney(order.total, locale)
445
+ })]
446
+ }) : null]
447
+ });
448
+ }
449
+ //#endregion
450
+ export { OrderPlacedCustomer, OrderPlacedCustomerDefinition, OrderPlacedReference, OrderPlacedReferenceDefinition, OrderPlacedRoot, OrderPlacedRootDefinition, OrderPlacedRootSkeleton, OrderPlacedStatus, OrderPlacedStatusDefinition, OrderPlacedTotals, OrderPlacedTotalsDefinition, useOrderPlaced };
451
+
452
+ //# sourceMappingURL=order-placed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-placed.js","names":[],"sources":["../../../src/matter/order-placed/order-placed.tsx"],"sourcesContent":["'use client';\n\nimport type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors } from '@apollo/client/errors';\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { substituteTemplate } from '../../utils/substitute-template.js';\nimport { formatPrice } from '../cart/cart.js';\n\n/**\n * Order Placed matters (docs/features/order-placed/rfc-particles.md, Parts, part 2).\n * `OrderPlacedRoot` owns the placed order: it reads `Query.order(orderGroup: $orderGroup)` once through\n * its own fragment and provides it as the `order-placed` context, or shows an authored message in\n * place of its children when the read is refused or fails. The leaves read the order's own record,\n * never the live cart or profile, so a confirmation reopened later shows what the purchase carried.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragments\n// ---------------------------------------------------------------------------\n\nconst rootFragment = /* GraphQL */ `\n fragment OrderPlacedRootData on Query {\n order(orderGroup: $orderGroup) {\n __typename\n id\n reference\n status\n total {\n amount\n currencyCode\n }\n totals {\n id\n name\n value {\n amount\n currencyCode\n }\n }\n }\n }\n`;\n\nconst customerFragment = /* GraphQL */ `\n fragment OrderPlacedCustomerData on Query {\n order(orderGroup: $orderGroup) {\n __typename\n id\n customer {\n firstName\n lastName\n email\n phone\n document\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** `amount` is the API's `Decimal`, a string (\"12.50\"). */\nexport type OrderPlacedMoney = { amount: string; currencyCode: string };\n\nexport type OrderPlacedStatusValue = 'APPROVED' | 'PENDING' | 'DENIED' | 'UNKNOWN';\n\nexport type OrderPlacedTotalLine = { id: string; name: string; value: OrderPlacedMoney };\n\n/**\n * The `$data` slice forwarded by the reactive runtime: the unwrapped `order` field, never a\n * `{ order: … }` wrapper (ADR-0015). `null` when the order group does not resolve.\n */\nexport type OrderPlacedData = {\n id: string;\n reference: string;\n status: OrderPlacedStatusValue;\n total?: OrderPlacedMoney | null;\n totals: readonly OrderPlacedTotalLine[];\n} | null;\n\n/** `OrderPlacedCustomer`'s own `$data` slice, the unwrapped `order` field of its fragment. */\nexport type OrderPlacedCustomerData = {\n customer?: {\n firstName?: string | null;\n lastName?: string | null;\n email?: string | null;\n phone?: string | null;\n document?: string | null;\n } | null;\n} | null;\n\nexport type OrderPlacedContextValue = Readonly<{\n order: OrderPlacedData;\n loading: boolean;\n error: ErrorLike | null;\n}>;\n\nexport type OrderPlacedRootProps = {\n className?: string;\n children?: ReactNode;\n /** Shown in place of the order when the read is refused: after 15 minutes, or from another browser. */\n refusedOrderLabel?: string;\n /** Shown in place of the order when the read fails or the order group resolves to no order. */\n unresolvedOrderLabel?: string;\n /** Unwrapped `Order` slice forwarded by the reactive runtime. */\n $data?: OrderPlacedData;\n};\n\nexport type OrderPlacedStatusProps = {\n className?: string;\n /** An optional `Icon`, shown on every outcome. */\n children?: ReactNode;\n approvedTitle?: string;\n approvedMessage?: string;\n pendingTitle?: string;\n pendingMessage?: string;\n deniedTitle?: string;\n deniedMessage?: string;\n};\n\nexport type OrderPlacedReferenceProps = {\n className?: string;\n /** `{reference}` placeholder. */\n template?: string;\n};\n\nexport type OrderPlacedCustomerProps = {\n className?: string;\n nameLabel?: string;\n emailLabel?: string;\n phoneLabel?: string;\n documentLabel?: string;\n /** Unwrapped `Order` slice of this component's own fragment. */\n $data?: OrderPlacedCustomerData;\n};\n\nexport type OrderPlacedTotalsProps = {\n className?: string;\n itemsLabel?: string;\n shippingLabel?: string;\n discountsLabel?: string;\n taxLabel?: string;\n totalLabel?: string;\n /** Shown instead of a zero shipping value. Omitted to show the formatted zero. */\n shippingZeroLabel?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst ORDER_PLACED_UNSET = Symbol('OrderPlacedContextUnset');\n\nconst OrderPlacedContext = createContext<OrderPlacedContextValue | typeof ORDER_PLACED_UNSET>(ORDER_PLACED_UNSET);\n\n/** The placed order, its loading flag and the root query's error, from the nearest OrderPlacedRoot. */\nexport function useOrderPlaced(): OrderPlacedContextValue {\n const ctx = useContext(OrderPlacedContext);\n if (ctx === ORDER_PLACED_UNSET) {\n throw new Error('useOrderPlaced() must be used inside an <OrderPlacedRoot> subtree.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Resolution\n// ---------------------------------------------------------------------------\n\ntype RootState = 'refused' | 'loading' | 'unresolved' | 'order';\n\n/**\n * The API refuses the read with a top-level `UNAUTHORIZED`: without both checkout cookies, and when\n * the order system answers 401 or 403, as it does after 15 minutes. Under `errorPolicy: 'all'` the\n * refusal also carries `order: null`, so it is checked before the order is.\n */\nfunction isRefusal(error: ErrorLike | null): boolean {\n if (!error || !CombinedGraphQLErrors.is(error)) return false;\n return error.errors.some((graphQLError) => graphQLError.extensions?.code === 'UNAUTHORIZED');\n}\n\nfunction resolveRootState({ order, loading, error }: OrderPlacedContextValue): RootState {\n if (isRefusal(error)) return 'refused';\n if (loading && order == null) return 'loading';\n if (order == null) return 'unresolved';\n return 'order';\n}\n\nfunction isZero(money: OrderPlacedMoney): boolean {\n return Number(money.amount) === 0;\n}\n\nfunction formatMoney(money: OrderPlacedMoney, locale: string): string {\n return formatPrice(Number(money.amount), locale, money.currencyCode);\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const OrderPlacedRootDefinition = defineComponent<OrderPlacedRootProps>({\n name: 'OrderPlacedRoot',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedRoot,\n fragment: rootFragment,\n fetchStrategy: 'reactive',\n skeleton: OrderPlacedRootSkeleton,\n providesContext: 'order-placed',\n editor: { label: 'Order Placed Root', category: 'commerce' },\n schema: {\n refusedOrderLabel: {\n type: 'string',\n default: 'This order can no longer be shown here',\n label: 'Refused order label',\n },\n unresolvedOrderLabel: { type: 'string', default: 'Could not load this order', label: 'Unresolved order label' },\n },\n guideline:\n 'Owner of an order confirmation page: reads the placed order (Query.order, keyed on the order group from the route) once and provides it as the order-placed context to OrderPlacedStatus, OrderPlacedReference, OrderPlacedCustomer, OrderPlacedTotals and the other order-placed blocks composed as its children. Renders its children only once the order resolves. While the read is in flight it shows a skeleton; when the API refuses the read (after 15 minutes, or from another browser) it shows refusedOrderLabel; when the read fails or the order group resolves to no order it shows unresolvedOrderLabel. Each message replaces every child. Never reads the cart or the live profile. See order-placed.md.',\n});\n\nexport const OrderPlacedStatusDefinition = defineComponent<OrderPlacedStatusProps>({\n name: 'OrderPlacedStatus',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedStatus,\n requiresContext: 'order-placed',\n editor: { label: 'Order Placed Status', category: 'commerce' },\n schema: {\n approvedTitle: { type: 'string', default: 'Your order is confirmed', label: 'Approved title' },\n approvedMessage: { type: 'string', default: 'Your payment was approved.', label: 'Approved message' },\n pendingTitle: { type: 'string', default: \"We're confirming your payment\", label: 'Pending title' },\n pendingMessage: {\n type: 'string',\n default: 'Your order was placed, and its payment is still being processed or reviewed.',\n label: 'Pending message',\n },\n deniedTitle: { type: 'string', default: 'Your payment was not approved', label: 'Denied title' },\n deniedMessage: {\n type: 'string',\n default: 'This purchase did not go through. You can place a new order with another payment method.',\n label: 'Denied message',\n },\n },\n guideline:\n 'The payment outcome of the placed order, as a banner with a title and a message: approved, pending (which also covers a payment under anti-fraud review) or denied. Renders nothing when the outcome is unknown, so the page shows the order without asserting success or failure. Author the title and message of each outcome through the props (approvedTitle, approvedMessage, pendingTitle, pendingMessage, deniedTitle, deniedMessage); a blank value omits its line. Marks the outcome with data-fs-order-placed-status-approved, -pending or -denied, so the page styles each tone. An Icon composed as its child shows on every outcome, so never compose one that implies success. Must be inside OrderPlacedRoot. See order-placed.md.',\n});\n\nexport const OrderPlacedReferenceDefinition = defineComponent<OrderPlacedReferenceProps>({\n name: 'OrderPlacedReference',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedReference,\n requiresContext: 'order-placed',\n editor: { label: 'Order Placed Reference', category: 'commerce' },\n schema: {\n template: { type: 'string', default: 'Order #{reference}', label: 'Template' },\n },\n guideline:\n 'The order number the shopper gives support: the order group, one per purchase even when it was split across sellers. Set template with a {reference} placeholder (e.g. \"Order #{reference}\"). Plain text, so it can be selected and copied. Must be inside OrderPlacedRoot. See order-placed.md.',\n});\n\nexport const OrderPlacedCustomerDefinition = defineComponent<OrderPlacedCustomerProps>({\n name: 'OrderPlacedCustomer',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedCustomer,\n fragment: customerFragment,\n fetchStrategy: 'reactive',\n requiresContext: 'order-placed',\n editor: { label: 'Order Placed Customer', category: 'commerce' },\n schema: {\n nameLabel: { type: 'string', default: 'Name', label: 'Name label' },\n emailLabel: { type: 'string', default: 'Email', label: 'Email label' },\n phoneLabel: { type: 'string', default: 'Phone', label: 'Phone label' },\n documentLabel: { type: 'string', default: 'Document', label: 'Document label' },\n },\n guideline:\n 'Who the order is for, as the order recorded them at placement, never the live profile: name, email, phone and document as label/value rows, each left out when empty. Selects the customer through its own fragment, so a page without this block never fetches the customer. Shows the values as the order system returns them, masked included (e.g. \"J*** D***\"). Must be inside OrderPlacedRoot. See order-placed.md.',\n});\n\nexport const OrderPlacedTotalsDefinition = defineComponent<OrderPlacedTotalsProps>({\n name: 'OrderPlacedTotals',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedTotals,\n requiresContext: 'order-placed',\n editor: { label: 'Order Placed Totals', category: 'commerce' },\n schema: {\n itemsLabel: { type: 'string', default: 'Subtotal', label: 'Items label' },\n shippingLabel: { type: 'string', default: 'Shipping', label: 'Shipping label' },\n discountsLabel: { type: 'string', default: 'Discounts', label: 'Discounts label' },\n taxLabel: { type: 'string', default: 'Tax', label: 'Tax label' },\n totalLabel: { type: 'string', default: 'Total', label: 'Total label' },\n shippingZeroLabel: { type: 'string', label: 'Shipping zero label' },\n },\n guideline:\n 'What the shopper was charged: each money line of the placed order in the order the API returns them (subtotal, discounts, shipping, tax, any custom tax under its own name), then the total, each in the order\\'s own currency. A zero discount line is left out; set shippingZeroLabel (e.g. \"Free\") to show it instead of a zero shipping value. No total row when the order has no total. Reads the order, never the cart, so it composes no CartTotalizerLine. Must be inside OrderPlacedRoot. See order-placed.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\n/** Placeholder for the order's blocks while the read is in flight. */\nexport function OrderPlacedRootSkeleton() {\n return (\n <div aria-hidden=\"true\" data-fs-order-placed-root-skeleton=\"\">\n <span />\n <span />\n <span />\n </div>\n );\n}\n\n/** Provides the placed order to its descendants, or a message in their place. Mirrors CartRoot's read side. */\nexport function OrderPlacedRoot({\n className,\n children,\n refusedOrderLabel = 'This order can no longer be shown here',\n unresolvedOrderLabel = 'Could not load this order',\n $data: $dataProp,\n}: Readonly<OrderPlacedRootProps>) {\n const order = useDataOverride($dataProp) ?? null;\n const { loading, error } = useContext(ReactiveRootContext);\n const value: OrderPlacedContextValue = useMemo(\n () => ({ order, loading, error: error ?? null }),\n [order, loading, error],\n );\n const state = resolveRootState(value);\n\n return (\n <OrderPlacedContext value={value}>\n <div className={className} data-fs-order-placed-root=\"\">\n {state === 'order' ? children : null}\n {state === 'loading' ? <OrderPlacedRootSkeleton /> : null}\n {state === 'refused' ? (\n <p role=\"alert\" data-fs-order-placed-root-refused=\"\">\n {refusedOrderLabel}\n </p>\n ) : null}\n {state === 'unresolved' ? (\n <p role=\"alert\" data-fs-order-placed-root-unresolved=\"\">\n {unresolvedOrderLabel}\n </p>\n ) : null}\n </div>\n </OrderPlacedContext>\n );\n}\n\nconst TONE_ATTRIBUTES = {\n approved: { 'data-fs-order-placed-status-approved': '' },\n pending: { 'data-fs-order-placed-status-pending': '' },\n denied: { 'data-fs-order-placed-status-denied': '' },\n} as const;\n\n/**\n * The outcome banner. `UNKNOWN` (seller orders that disagree, or a state the mapping does not\n * classify) renders nothing, so the page shows the order without asserting success or failure.\n */\nexport function OrderPlacedStatus({\n className,\n children,\n approvedTitle = 'Your order is confirmed',\n approvedMessage = 'Your payment was approved.',\n pendingTitle = \"We're confirming your payment\",\n pendingMessage = 'Your order was placed, and its payment is still being processed or reviewed.',\n deniedTitle = 'Your payment was not approved',\n deniedMessage = 'This purchase did not go through. You can place a new order with another payment method.',\n}: Readonly<OrderPlacedStatusProps>) {\n const { order } = useOrderPlaced();\n const status = order?.status;\n\n let copy: { tone: keyof typeof TONE_ATTRIBUTES; title?: string; message?: string };\n if (status === 'APPROVED') {\n copy = {\n tone: 'approved',\n title: approvedTitle,\n message: approvedMessage,\n };\n } else if (status === 'PENDING') {\n copy = {\n tone: 'pending',\n title: pendingTitle,\n message: pendingMessage,\n };\n } else if (status === 'DENIED') {\n copy = {\n tone: 'denied',\n title: deniedTitle,\n message: deniedMessage,\n };\n } else {\n return null;\n }\n\n return (\n <output className={className} data-fs-order-placed-status=\"\" {...TONE_ATTRIBUTES[copy.tone]}>\n {children}\n {copy.title?.trim() ? <span data-fs-order-placed-status-title=\"\">{copy.title}</span> : null}\n {copy.message?.trim() ? <span data-fs-order-placed-status-message=\"\">{copy.message}</span> : null}\n </output>\n );\n}\n\n/**\n * The order group, the one reference a split purchase has, so support resolves the whole purchase\n * from it rather than one seller's order.\n */\nexport function OrderPlacedReference({\n className,\n template = 'Order #{reference}',\n}: Readonly<OrderPlacedReferenceProps>) {\n const { order } = useOrderPlaced();\n if (!order) return null;\n return (\n <p className={className} data-fs-order-placed-reference=\"\">\n {substituteTemplate(template, { reference: order.reference })}\n </p>\n );\n}\n\ntype DefinitionRow = { key: string; term: string; value: string };\n\n/**\n * The customer as the order recorded them, never the live profile: masked values show as the order\n * system returns them, and an empty field is left out.\n */\nexport function OrderPlacedCustomer({\n className,\n nameLabel = 'Name',\n emailLabel = 'Email',\n phoneLabel = 'Phone',\n documentLabel = 'Document',\n $data: $dataProp,\n}: Readonly<OrderPlacedCustomerProps>) {\n // The call only enforces that the root is an ancestor; the root withholds its children until the\n // order resolves. The customer itself comes from this component's own fragment.\n useOrderPlaced();\n const customer = useDataOverride($dataProp)?.customer;\n if (!customer) return null;\n\n const name = [customer.firstName, customer.lastName]\n .map((part) => part?.trim())\n .filter(Boolean)\n .join(' ');\n const rows: DefinitionRow[] = [\n { key: 'name', term: nameLabel, value: name },\n { key: 'email', term: emailLabel, value: customer.email ?? '' },\n { key: 'phone', term: phoneLabel, value: customer.phone ?? '' },\n { key: 'document', term: documentLabel, value: customer.document ?? '' },\n ].filter((row) => row.value.trim() !== '');\n if (rows.length === 0) return null;\n\n return (\n <dl className={className} data-fs-order-placed-customer=\"\">\n {rows.map(({ key, term, value }) => (\n <div key={key}>\n <dt data-fs-order-placed-customer-term=\"\">{term}</dt>\n <dd data-fs-order-placed-customer-value=\"\">{value}</dd>\n </div>\n ))}\n </dl>\n );\n}\n\n/**\n * The order's money lines in API order, then the total, each in its own currency. `Items`,\n * `Shipping`, `Discounts` and `Tax` take the authored label, since the order system names them in\n * English; any other line (a custom tax) shows its own name. The API sums lines on id and name, so\n * two custom taxes that share an id are two rows.\n */\nexport function OrderPlacedTotals({\n className,\n itemsLabel = 'Subtotal',\n shippingLabel = 'Shipping',\n discountsLabel = 'Discounts',\n taxLabel = 'Tax',\n totalLabel = 'Total',\n shippingZeroLabel,\n}: Readonly<OrderPlacedTotalsProps>) {\n const { order } = useOrderPlaced();\n const { locale } = useStorefrontContext();\n if (!order) return null;\n\n // A Map, so an upstream id such as \"constructor\" never resolves to an Object.prototype member.\n const labels = new Map([\n ['Items', itemsLabel],\n ['Shipping', shippingLabel],\n ['Discounts', discountsLabel],\n ['Tax', taxLabel],\n ]);\n const rows: (DefinitionRow & { line: string })[] = [];\n order.totals.forEach((line, index) => {\n if (line.id === 'Discounts' && isZero(line.value)) return;\n const value =\n line.id === 'Shipping' && isZero(line.value) && shippingZeroLabel?.trim()\n ? shippingZeroLabel\n : formatMoney(line.value, locale);\n rows.push({\n key: `${line.id}:${line.name}:${index}`,\n term: labels.get(line.id) ?? line.name,\n value,\n line: line.id,\n });\n });\n\n return (\n <dl className={className} data-fs-order-placed-totals=\"\">\n {rows.map(({ key, term, value, line }) => (\n <div key={key} data-fs-order-placed-totals-line={line}>\n <dt data-fs-order-placed-totals-term=\"\">{term}</dt>\n <dd data-fs-order-placed-totals-value=\"\">{value}</dd>\n </div>\n ))}\n {order.total ? (\n <div data-fs-order-placed-totals-total=\"\">\n <dt data-fs-order-placed-totals-term=\"\">{totalLabel}</dt>\n <dd data-fs-order-placed-totals-value=\"\">{formatMoney(order.total, locale)}</dd>\n </div>\n ) : null}\n </dl>\n );\n}\n"],"mappings":";;;;;;;;;;;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GAAG,KAAK,KAAK,GAAG;GAChC,MAAM,OAAO,IAAI,KAAK,EAAE,KAAK,KAAK;GAClC;GACA,MAAM,KAAK;EACb,CAAC;CACH,CAAC;CAED,OACE,qBAAC,MAAD;EAAe;EAAW,+BAA4B;EAAtD,UAAA,CACG,KAAK,KAAK,EAAE,KAAK,MAAM,OAAO,WAC7B,qBAAC,OAAD;GAAe,oCAAkC;GAAjD,UAAA,CACE,oBAAC,MAAD;IAAI,oCAAiC;IAAI,UAAA;GAAS,CAAA,GAClD,oBAAC,MAAD;IAAI,qCAAkC;IAAI,UAAA;GAAU,CAAA,CACjD;EAHK,GAAA,GAGL,CACN,GACA,MAAM,QACL,qBAAC,OAAD;GAAK,qCAAkC;GAAvC,UAAA,CACE,oBAAC,MAAD;IAAI,oCAAiC;IAAI,UAAA;GAAe,CAAA,GACxD,oBAAC,MAAD;IAAI,qCAAkC;IAAI,UAAA,YAAY,MAAM,OAAO,MAAM;GAAM,CAAA,CAC5E;EACH,CAAA,IAAA,IACF;;AAER"}
@@ -0,0 +1,45 @@
1
+ import { ContentValue } from "../../core/dist/define-content-type.js";
2
+ import { ComponentDefinition } from "../../core/dist/define-component.js";
3
+ import "../../core/dist/index.js";
4
+ import { ComponentPropsWithRef, Ref } from "react";
5
+ //#region src/matter/order-placed-date/order-placed-date.d.ts
6
+ export declare const OrderPlacedDateContent: {
7
+ readonly id: "order-placed-date";
8
+ readonly title: "Order Placed Date";
9
+ readonly description: "The label beside the date the order was placed.";
10
+ readonly schema: {
11
+ readonly type: "object";
12
+ readonly additionalProperties: false;
13
+ readonly properties: {
14
+ readonly label: {
15
+ readonly type: "string";
16
+ readonly title: "Label";
17
+ };
18
+ };
19
+ };
20
+ };
21
+ export type OrderPlacedDateContentValue = ContentValue<typeof OrderPlacedDateContent>;
22
+ /**
23
+ * The `customerOrder` root the generator passes as `$data`. A single-root fragment is bound to
24
+ * that field's value, so this is the order itself, or null when the read resolves nothing.
25
+ */
26
+ export type OrderPlacedDateData = {
27
+ id: string;
28
+ placedAt: string | null;
29
+ } | null;
30
+ export type OrderPlacedDateProps = Readonly<{
31
+ $data?: OrderPlacedDateData | null;
32
+ $content?: OrderPlacedDateContentValue;
33
+ className?: string;
34
+ ref?: Ref<HTMLDivElement>;
35
+ }>;
36
+ export declare const OrderPlacedDateDefinition: ComponentDefinition<Readonly<{
37
+ $data?: OrderPlacedDateData | null;
38
+ $content?: OrderPlacedDateContentValue;
39
+ className?: string;
40
+ ref?: Ref<HTMLDivElement>;
41
+ }>>;
42
+ export declare function OrderPlacedDateSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>): import("react/jsx-runtime").JSX.Element;
43
+ export declare function OrderPlacedDate({ $data, $content, className, ref }: OrderPlacedDateProps): import("react/jsx-runtime").JSX.Element | null;
44
+ //#endregion
45
+ //# sourceMappingURL=order-placed-date.d.ts.map
@@ -0,0 +1,92 @@
1
+ "use client";
2
+ import { defineComponent } from "../../core/dist/define-component.js";
3
+ import { defineContentType } from "../../core/dist/define-content-type.js";
4
+ import "../../core/dist/index.js";
5
+ import { useStorefrontFormatters } from "../../sdk/format/client.js";
6
+ import { useIntl } from "../../sdk/i18n/client.js";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/matter/order-placed-date/order-placed-date.tsx
9
+ const fragment = `
10
+ fragment OrderPlacedDateData on Query {
11
+ customerOrder(id: $orderId) {
12
+ id
13
+ placedAt
14
+ }
15
+ }
16
+ `;
17
+ const OrderPlacedDateContent = defineContentType({
18
+ id: "order-placed-date",
19
+ title: "Order Placed Date",
20
+ description: "The label beside the date the order was placed.",
21
+ schema: {
22
+ type: "object",
23
+ additionalProperties: false,
24
+ properties: { label: {
25
+ type: "string",
26
+ title: "Label"
27
+ } }
28
+ }
29
+ });
30
+ const OrderPlacedDateDefinition = defineComponent({
31
+ name: "OrderPlacedDate",
32
+ importPath: "@vtex/faststore/components",
33
+ component: OrderPlacedDate,
34
+ content: OrderPlacedDateContent,
35
+ fragment,
36
+ fetchStrategy: "static",
37
+ skeleton: OrderPlacedDateSkeleton,
38
+ editor: {
39
+ label: "Order Placed Date",
40
+ category: "content"
41
+ },
42
+ schema: {},
43
+ guideline: "The date and time one order was placed, formatted for the page locale. The label is content; a blank field keeps the catalogue. Place it anywhere on the order details page; it renders nothing when the order has no placed date."
44
+ });
45
+ function authored(value, fallback) {
46
+ return value?.trim() || fallback;
47
+ }
48
+ const PLACED_FORMAT = {
49
+ year: "numeric",
50
+ month: "numeric",
51
+ day: "numeric",
52
+ hour: "numeric",
53
+ minute: "2-digit"
54
+ };
55
+ function instant(value) {
56
+ if (!value) return null;
57
+ const date = new Date(value);
58
+ return Number.isNaN(date.getTime()) ? null : date;
59
+ }
60
+ function OrderPlacedDateSkeleton({ className, ...props }) {
61
+ return /* @__PURE__ */ jsxs("div", {
62
+ ...props,
63
+ className,
64
+ "data-fs-order-placed-date-skeleton": "",
65
+ "aria-hidden": "true",
66
+ children: [/* @__PURE__ */ jsx("span", { "data-fs-order-placed-date-skeleton-fact": "" }), /* @__PURE__ */ jsx("span", { "data-fs-order-placed-date-skeleton-fact": "" })]
67
+ });
68
+ }
69
+ function OrderPlacedDate({ $data, $content, className, ref }) {
70
+ const intl = useIntl();
71
+ const { formatDate } = useStorefrontFormatters();
72
+ const placedAt = $data?.placedAt;
73
+ const placed = instant(placedAt);
74
+ if (!placed) return null;
75
+ return /* @__PURE__ */ jsxs("div", {
76
+ ref,
77
+ className,
78
+ "data-fs-order-placed-date": "",
79
+ children: [/* @__PURE__ */ jsx("span", {
80
+ "data-fs-order-placed-date-label": "",
81
+ children: authored($content?.label, intl.formatMessage({ id: "fs/order.placed-at" }))
82
+ }), /* @__PURE__ */ jsx("time", {
83
+ dateTime: placedAt ?? void 0,
84
+ "data-fs-order-placed-date-value": "",
85
+ children: formatDate(placed, PLACED_FORMAT)
86
+ })]
87
+ });
88
+ }
89
+ //#endregion
90
+ export { OrderPlacedDate, OrderPlacedDateContent, OrderPlacedDateDefinition, OrderPlacedDateSkeleton };
91
+
92
+ //# sourceMappingURL=order-placed-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-placed-date.js","names":[],"sources":["../../../src/matter/order-placed-date/order-placed-date.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef, Ref } from 'react';\nimport { useStorefrontFormatters } from '../../sdk/format/client.js';\nimport { useIntl } from '../../sdk/i18n/client.js';\n\nconst fragment = /* GraphQL */ `\n fragment OrderPlacedDateData on Query {\n customerOrder(id: $orderId) {\n id\n placedAt\n }\n }\n`;\n\nexport const OrderPlacedDateContent = defineContentType({\n id: 'order-placed-date',\n title: 'Order Placed Date',\n description: 'The label beside the date the order was placed.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Label' },\n },\n },\n});\n\nexport type OrderPlacedDateContentValue = ContentValue<typeof OrderPlacedDateContent>;\n\n/**\n * The `customerOrder` root the generator passes as `$data`. A single-root fragment is bound to\n * that field's value, so this is the order itself, or null when the read resolves nothing.\n */\nexport type OrderPlacedDateData = {\n id: string;\n placedAt: string | null;\n} | null;\n\nexport type OrderPlacedDateProps = Readonly<{\n $data?: OrderPlacedDateData | null;\n $content?: OrderPlacedDateContentValue;\n className?: string;\n ref?: Ref<HTMLDivElement>;\n}>;\n\nexport const OrderPlacedDateDefinition = defineComponent<OrderPlacedDateProps>({\n name: 'OrderPlacedDate',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedDate,\n content: OrderPlacedDateContent,\n fragment,\n fetchStrategy: 'static',\n skeleton: OrderPlacedDateSkeleton,\n editor: { label: 'Order Placed Date', category: 'content' },\n schema: {},\n guideline:\n 'The date and time one order was placed, formatted for the page locale. The label is content; a blank field keeps the catalogue. Place it anywhere on the order details page; it renders nothing when the order has no placed date.',\n});\n\nfunction authored(value: string | undefined, fallback: string): string {\n const trimmed = value?.trim();\n return trimmed || fallback;\n}\n\nconst PLACED_FORMAT: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n};\n\nfunction instant(value: string | null | undefined): Date | null {\n if (!value) {\n return null;\n }\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\nexport function OrderPlacedDateSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>) {\n return (\n <div {...props} className={className} data-fs-order-placed-date-skeleton=\"\" aria-hidden=\"true\">\n <span data-fs-order-placed-date-skeleton-fact=\"\" />\n <span data-fs-order-placed-date-skeleton-fact=\"\" />\n </div>\n );\n}\n\nexport function OrderPlacedDate({ $data, $content, className, ref }: OrderPlacedDateProps) {\n const intl = useIntl();\n const { formatDate } = useStorefrontFormatters();\n const placedAt = $data?.placedAt;\n const placed = instant(placedAt);\n\n if (!placed) {\n return null;\n }\n\n return (\n <div ref={ref} className={className} data-fs-order-placed-date=\"\">\n <span data-fs-order-placed-date-label=\"\">\n {authored($content?.label, intl.formatMessage({ id: 'fs/order.placed-at' }))}\n </span>\n <time dateTime={placedAt ?? undefined} data-fs-order-placed-date-value=\"\">\n {formatDate(placed, PLACED_FORMAT)}\n </time>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,WAAyB;;;;;;;;AAS/B,MAAa,yBAAyB,kBAAkB;CACtD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY,EACV,OAAO;GAAE,MAAM;GAAU,OAAO;EAAQ,EAC1C;CACF;AACF,CAAC;AAoBD,MAAa,4BAA4B,gBAAsC;CAC7E,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT;CACA,eAAe;CACf,UAAU;CACV,QAAQ;EAAE,OAAO;EAAqB,UAAU;CAAU;CAC1D,QAAQ,CAAC;CACT,WACE;AACJ,CAAC;AAED,SAAS,SAAS,OAA2B,UAA0B;CAErE,OADgB,OAAO,KAAK,KACV;AACpB;AA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