@vtex/faststore 0.0.1

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 (538) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +95 -0
  4. package/dist/actions.json +334 -0
  5. package/dist/catalog.json +6615 -0
  6. package/dist/client.d.ts +17 -0
  7. package/dist/client.js +8 -0
  8. package/dist/components.d.ts +87 -0
  9. package/dist/components.js +87 -0
  10. package/dist/content-types.json +684 -0
  11. package/dist/core/dist/actions/mock-action.d.ts +24 -0
  12. package/dist/core/dist/actions/mock-action.js +28 -0
  13. package/dist/core/dist/actions/mock-action.js.map +1 -0
  14. package/dist/core/dist/actions/registry.d.ts +24 -0
  15. package/dist/core/dist/actions/registry.js +28 -0
  16. package/dist/core/dist/actions/registry.js.map +1 -0
  17. package/dist/core/dist/define-component.d.ts +100 -0
  18. package/dist/core/dist/define-component.js +8 -0
  19. package/dist/core/dist/define-component.js.map +1 -0
  20. package/dist/core/dist/define-content-type.d.ts +95 -0
  21. package/dist/core/dist/define-content-type.js +283 -0
  22. package/dist/core/dist/define-content-type.js.map +1 -0
  23. package/dist/core/dist/index.d.ts +7 -0
  24. package/dist/core/dist/index.js +5 -0
  25. package/dist/core/dist/schema/generated/schema.d.ts +28 -0
  26. package/dist/core/dist/types.d.ts +1 -0
  27. package/dist/docs/access-code-field.md +100 -0
  28. package/dist/docs/access-code-sign-in.md +174 -0
  29. package/dist/docs/account-entry-point.md +155 -0
  30. package/dist/docs/address-summary.md +50 -0
  31. package/dist/docs/buy-button.md +162 -0
  32. package/dist/docs/carousel.md +105 -0
  33. package/dist/docs/cart-item.md +162 -0
  34. package/dist/docs/cart-totalizer.md +197 -0
  35. package/dist/docs/cart.md +495 -0
  36. package/dist/docs/client-preferences.md +184 -0
  37. package/dist/docs/client-profile-form.md +192 -0
  38. package/dist/docs/client-profile.md +117 -0
  39. package/dist/docs/container.md +97 -0
  40. package/dist/docs/document-field.md +97 -0
  41. package/dist/docs/email-field.md +93 -0
  42. package/dist/docs/email-identification.md +102 -0
  43. package/dist/docs/footer-copyright.md +112 -0
  44. package/dist/docs/footer-link-group.md +162 -0
  45. package/dist/docs/footer-root.md +145 -0
  46. package/dist/docs/footer-social.md +151 -0
  47. package/dist/docs/free-shipping-progress.md +87 -0
  48. package/dist/docs/gallery.md +84 -0
  49. package/dist/docs/header-root.md +150 -0
  50. package/dist/docs/identity-edit.md +88 -0
  51. package/dist/docs/identity-summary.md +106 -0
  52. package/dist/docs/incentives.md +151 -0
  53. package/dist/docs/logo.md +135 -0
  54. package/dist/docs/meter.md +67 -0
  55. package/dist/docs/navigation-link-list.md +171 -0
  56. package/dist/docs/navigation-link.md +163 -0
  57. package/dist/docs/navigation-menu.md +264 -0
  58. package/dist/docs/payment-methods.md +139 -0
  59. package/dist/docs/phone-field.md +106 -0
  60. package/dist/docs/postal-code-field.md +126 -0
  61. package/dist/docs/pricing.md +499 -0
  62. package/dist/docs/product-gallery.md +409 -0
  63. package/dist/docs/product-information.md +295 -0
  64. package/dist/docs/product-list.md +170 -0
  65. package/dist/docs/product-quantity.md +88 -0
  66. package/dist/docs/product-shelf.md +141 -0
  67. package/dist/docs/promotion.md +109 -0
  68. package/dist/docs/region.md +225 -0
  69. package/dist/docs/session.md +123 -0
  70. package/dist/docs/shipping-address.md +390 -0
  71. package/dist/docs/shipping-simulator.md +147 -0
  72. package/dist/docs/sign-in-form.md +117 -0
  73. package/dist/docs/tabs.md +176 -0
  74. package/dist/docs/toast.md +124 -0
  75. package/dist/docs/variant-selector.md +450 -0
  76. package/dist/graphql/define-subgraph.d.ts +12 -0
  77. package/dist/graphql/define-subgraph.js +15 -0
  78. package/dist/graphql/define-subgraph.js.map +1 -0
  79. package/dist/graphql/gql.d.ts +10 -0
  80. package/dist/graphql/gql.js +16 -0
  81. package/dist/graphql/gql.js.map +1 -0
  82. package/dist/graphql/types.d.ts +88 -0
  83. package/dist/graphql.d.ts +4 -0
  84. package/dist/graphql.js +3 -0
  85. package/dist/index.d.ts +19 -0
  86. package/dist/index.js +5 -0
  87. package/dist/internal/client.d.ts +24 -0
  88. package/dist/internal/client.js +23 -0
  89. package/dist/internal/content.d.ts +2 -0
  90. package/dist/internal/content.js +2 -0
  91. package/dist/internal/server.d.ts +7 -0
  92. package/dist/internal/server.js +6 -0
  93. package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +111 -0
  94. package/dist/matter/access-code-sign-in/access-code-sign-in.js +387 -0
  95. package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -0
  96. package/dist/matter/account-entry-point/account-entry-point.d.ts +64 -0
  97. package/dist/matter/account-entry-point/account-entry-point.js +151 -0
  98. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -0
  99. package/dist/matter/breadcrumb/breadcrumb.d.ts +40 -0
  100. package/dist/matter/breadcrumb/breadcrumb.js +155 -0
  101. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -0
  102. package/dist/matter/buy-button/buy-button.d.ts +95 -0
  103. package/dist/matter/buy-button/buy-button.js +259 -0
  104. package/dist/matter/buy-button/buy-button.js.map +1 -0
  105. package/dist/matter/cart/cart-namespace.d.ts +48 -0
  106. package/dist/matter/cart/cart-namespace.js +50 -0
  107. package/dist/matter/cart/cart-namespace.js.map +1 -0
  108. package/dist/matter/cart/cart.d.ts +312 -0
  109. package/dist/matter/cart/cart.js +1034 -0
  110. package/dist/matter/cart/cart.js.map +1 -0
  111. package/dist/matter/cart-item/cart-item.d.ts +103 -0
  112. package/dist/matter/cart-item/cart-item.js +672 -0
  113. package/dist/matter/cart-item/cart-item.js.map +1 -0
  114. package/dist/matter/cart-item-compositions/cart-item-compositions.d.ts +49 -0
  115. package/dist/matter/cart-item-compositions/cart-item-compositions.js +165 -0
  116. package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -0
  117. package/dist/matter/cart-item-customizations/cart-item-customizations.d.ts +28 -0
  118. package/dist/matter/cart-item-customizations/cart-item-customizations.js +73 -0
  119. package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -0
  120. package/dist/matter/cart-item-discounts/cart-item-discounts.d.ts +33 -0
  121. package/dist/matter/cart-item-discounts/cart-item-discounts.js +70 -0
  122. package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -0
  123. package/dist/matter/cart-item-seller-info/cart-item-seller-info.d.ts +24 -0
  124. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +54 -0
  125. package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -0
  126. package/dist/matter/cart-item-variations/cart-item-variations.d.ts +27 -0
  127. package/dist/matter/cart-item-variations/cart-item-variations.js +69 -0
  128. package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -0
  129. package/dist/matter/cart-totalizer/cart-totalizer.d.ts +78 -0
  130. package/dist/matter/cart-totalizer/cart-totalizer.js +220 -0
  131. package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -0
  132. package/dist/matter/client-preferences/client-preferences.d.ts +50 -0
  133. package/dist/matter/client-preferences/client-preferences.js +206 -0
  134. package/dist/matter/client-preferences/client-preferences.js.map +1 -0
  135. package/dist/matter/client-profile/client-profile.d.ts +59 -0
  136. package/dist/matter/client-profile/client-profile.js +185 -0
  137. package/dist/matter/client-profile/client-profile.js.map +1 -0
  138. package/dist/matter/client-profile-form/client-profile-form.d.ts +126 -0
  139. package/dist/matter/client-profile-form/client-profile-form.js +660 -0
  140. package/dist/matter/client-profile-form/client-profile-form.js.map +1 -0
  141. package/dist/matter/delivery-options/delivery-options-accordion.d.ts +30 -0
  142. package/dist/matter/delivery-options/delivery-options-accordion.js +189 -0
  143. package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -0
  144. package/dist/matter/delivery-options/delivery-options-controller.d.ts +49 -0
  145. package/dist/matter/delivery-options/delivery-options-controller.js +203 -0
  146. package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -0
  147. package/dist/matter/delivery-options/delivery-options.d.ts +31 -0
  148. package/dist/matter/delivery-options/delivery-options.js +103 -0
  149. package/dist/matter/delivery-options/delivery-options.js.map +1 -0
  150. package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +9 -0
  151. package/dist/matter/delivery-options/use-delivery-option-selection.js +76 -0
  152. package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -0
  153. package/dist/matter/email-identification/email-identification.d.ts +37 -0
  154. package/dist/matter/email-identification/email-identification.js +111 -0
  155. package/dist/matter/email-identification/email-identification.js.map +1 -0
  156. package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +44 -0
  157. package/dist/matter/free-shipping-progress/free-shipping-progress.js +170 -0
  158. package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -0
  159. package/dist/matter/identity-edit/identity-edit.d.ts +52 -0
  160. package/dist/matter/identity-edit/identity-edit.js +148 -0
  161. package/dist/matter/identity-edit/identity-edit.js.map +1 -0
  162. package/dist/matter/identity-summary/identity-summary.d.ts +128 -0
  163. package/dist/matter/identity-summary/identity-summary.js +344 -0
  164. package/dist/matter/identity-summary/identity-summary.js.map +1 -0
  165. package/dist/matter/pricing/pricing.d.ts +162 -0
  166. package/dist/matter/pricing/pricing.js +793 -0
  167. package/dist/matter/pricing/pricing.js.map +1 -0
  168. package/dist/matter/product-gallery/product-gallery.d.ts +23 -0
  169. package/dist/matter/product-gallery/product-gallery.js +188 -0
  170. package/dist/matter/product-gallery/product-gallery.js.map +1 -0
  171. package/dist/matter/product-information/product-information.d.ts +61 -0
  172. package/dist/matter/product-information/product-information.js +355 -0
  173. package/dist/matter/product-information/product-information.js.map +1 -0
  174. package/dist/matter/product-list/product-list.d.ts +86 -0
  175. package/dist/matter/product-list/product-list.js +342 -0
  176. package/dist/matter/product-list/product-list.js.map +1 -0
  177. package/dist/matter/product-quantity/product-quantity.d.ts +50 -0
  178. package/dist/matter/product-quantity/product-quantity.js +111 -0
  179. package/dist/matter/product-quantity/product-quantity.js.map +1 -0
  180. package/dist/matter/product-shelf/product-shelf.d.ts +125 -0
  181. package/dist/matter/product-shelf/product-shelf.js +376 -0
  182. package/dist/matter/product-shelf/product-shelf.js.map +1 -0
  183. package/dist/matter/region/region.d.ts +211 -0
  184. package/dist/matter/region/region.js +579 -0
  185. package/dist/matter/region/region.js.map +1 -0
  186. package/dist/matter/session/session.d.ts +58 -0
  187. package/dist/matter/session/session.js +112 -0
  188. package/dist/matter/session/session.js.map +1 -0
  189. package/dist/matter/shipping-address/country-descriptors.js +101 -0
  190. package/dist/matter/shipping-address/country-descriptors.js.map +1 -0
  191. package/dist/matter/shipping-address/shipping-address.d.ts +284 -0
  192. package/dist/matter/shipping-address/shipping-address.js +1036 -0
  193. package/dist/matter/shipping-address/shipping-address.js.map +1 -0
  194. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +143 -0
  195. package/dist/matter/shipping-simulator/shipping-simulator.js +644 -0
  196. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -0
  197. package/dist/matter/sign-in-form/sign-in-form.d.ts +79 -0
  198. package/dist/matter/sign-in-form/sign-in-form.js +226 -0
  199. package/dist/matter/sign-in-form/sign-in-form.js.map +1 -0
  200. package/dist/matter/variant-selector/variant-selector.d.ts +183 -0
  201. package/dist/matter/variant-selector/variant-selector.js +840 -0
  202. package/dist/matter/variant-selector/variant-selector.js.map +1 -0
  203. package/dist/message-locales.json +7 -0
  204. package/dist/particles/access-code-field/access-code-field.d.ts +33 -0
  205. package/dist/particles/access-code-field/access-code-field.js +95 -0
  206. package/dist/particles/access-code-field/access-code-field.js.map +1 -0
  207. package/dist/particles/accordion/accordion.d.ts +45 -0
  208. package/dist/particles/accordion/accordion.js +156 -0
  209. package/dist/particles/accordion/accordion.js.map +1 -0
  210. package/dist/particles/address-summary/address-summary.d.ts +50 -0
  211. package/dist/particles/address-summary/address-summary.js +129 -0
  212. package/dist/particles/address-summary/address-summary.js.map +1 -0
  213. package/dist/particles/badge/badge.d.ts +10 -0
  214. package/dist/particles/badge/badge.js +27 -0
  215. package/dist/particles/badge/badge.js.map +1 -0
  216. package/dist/particles/button/button.d.ts +18 -0
  217. package/dist/particles/button/button.js +37 -0
  218. package/dist/particles/button/button.js.map +1 -0
  219. package/dist/particles/carousel/carousel.d.ts +60 -0
  220. package/dist/particles/carousel/carousel.js +335 -0
  221. package/dist/particles/carousel/carousel.js.map +1 -0
  222. package/dist/particles/checkbox/checkbox.d.ts +40 -0
  223. package/dist/particles/checkbox/checkbox.js +82 -0
  224. package/dist/particles/checkbox/checkbox.js.map +1 -0
  225. package/dist/particles/container/container.d.ts +20 -0
  226. package/dist/particles/container/container.js +36 -0
  227. package/dist/particles/container/container.js.map +1 -0
  228. package/dist/particles/dialog/dialog.d.ts +54 -0
  229. package/dist/particles/dialog/dialog.js +192 -0
  230. package/dist/particles/dialog/dialog.js.map +1 -0
  231. package/dist/particles/document-field/document-field.d.ts +61 -0
  232. package/dist/particles/document-field/document-field.js +146 -0
  233. package/dist/particles/document-field/document-field.js.map +1 -0
  234. package/dist/particles/drawer/drawer.d.ts +52 -0
  235. package/dist/particles/drawer/drawer.js +183 -0
  236. package/dist/particles/drawer/drawer.js.map +1 -0
  237. package/dist/particles/email-field/email-field.d.ts +37 -0
  238. package/dist/particles/email-field/email-field.js +106 -0
  239. package/dist/particles/email-field/email-field.js.map +1 -0
  240. package/dist/particles/field/field.d.ts +50 -0
  241. package/dist/particles/field/field.js +133 -0
  242. package/dist/particles/field/field.js.map +1 -0
  243. package/dist/particles/fieldset/fieldset.d.ts +16 -0
  244. package/dist/particles/fieldset/fieldset.js +52 -0
  245. package/dist/particles/fieldset/fieldset.js.map +1 -0
  246. package/dist/particles/footer-copyright/footer-copyright.d.ts +32 -0
  247. package/dist/particles/footer-copyright/footer-copyright.js +50 -0
  248. package/dist/particles/footer-copyright/footer-copyright.js.map +1 -0
  249. package/dist/particles/footer-link-group/footer-link-group.d.ts +66 -0
  250. package/dist/particles/footer-link-group/footer-link-group.js +154 -0
  251. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -0
  252. package/dist/particles/footer-root/footer-root.d.ts +21 -0
  253. package/dist/particles/footer-root/footer-root.js +38 -0
  254. package/dist/particles/footer-root/footer-root.js.map +1 -0
  255. package/dist/particles/footer-social/footer-social.d.ts +79 -0
  256. package/dist/particles/footer-social/footer-social.js +176 -0
  257. package/dist/particles/footer-social/footer-social.js.map +1 -0
  258. package/dist/particles/gallery/gallery.d.ts +181 -0
  259. package/dist/particles/gallery/gallery.js +920 -0
  260. package/dist/particles/gallery/gallery.js.map +1 -0
  261. package/dist/particles/header-root/header-root.d.ts +21 -0
  262. package/dist/particles/header-root/header-root.js +38 -0
  263. package/dist/particles/header-root/header-root.js.map +1 -0
  264. package/dist/particles/icon/icon.d.ts +22 -0
  265. package/dist/particles/icon/icon.js +48 -0
  266. package/dist/particles/icon/icon.js.map +1 -0
  267. package/dist/particles/image/image.d.ts +13 -0
  268. package/dist/particles/image/image.js +59 -0
  269. package/dist/particles/image/image.js.map +1 -0
  270. package/dist/particles/incentives/incentives.d.ts +85 -0
  271. package/dist/particles/incentives/incentives.js +200 -0
  272. package/dist/particles/incentives/incentives.js.map +1 -0
  273. package/dist/particles/input/input.d.ts +9 -0
  274. package/dist/particles/input/input.js +28 -0
  275. package/dist/particles/input/input.js.map +1 -0
  276. package/dist/particles/logo/logo.d.ts +55 -0
  277. package/dist/particles/logo/logo.js +96 -0
  278. package/dist/particles/logo/logo.js.map +1 -0
  279. package/dist/particles/menu/menu.d.ts +103 -0
  280. package/dist/particles/menu/menu.js +409 -0
  281. package/dist/particles/menu/menu.js.map +1 -0
  282. package/dist/particles/menubar/menubar.d.ts +18 -0
  283. package/dist/particles/menubar/menubar.js +42 -0
  284. package/dist/particles/menubar/menubar.js.map +1 -0
  285. package/dist/particles/meter/meter.d.ts +36 -0
  286. package/dist/particles/meter/meter.js +132 -0
  287. package/dist/particles/meter/meter.js.map +1 -0
  288. package/dist/particles/navigation-link/navigation-link.d.ts +43 -0
  289. package/dist/particles/navigation-link/navigation-link.js +82 -0
  290. package/dist/particles/navigation-link/navigation-link.js.map +1 -0
  291. package/dist/particles/navigation-link-list/navigation-link-list.d.ts +59 -0
  292. package/dist/particles/navigation-link-list/navigation-link-list.js +103 -0
  293. package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -0
  294. package/dist/particles/navigation-menu/navigation-menu.d.ts +78 -0
  295. package/dist/particles/navigation-menu/navigation-menu.js +295 -0
  296. package/dist/particles/navigation-menu/navigation-menu.js.map +1 -0
  297. package/dist/particles/number-field/number-field.d.ts +46 -0
  298. package/dist/particles/number-field/number-field.js +169 -0
  299. package/dist/particles/number-field/number-field.js.map +1 -0
  300. package/dist/particles/password-field/password-field.d.ts +31 -0
  301. package/dist/particles/password-field/password-field.js +109 -0
  302. package/dist/particles/password-field/password-field.js.map +1 -0
  303. package/dist/particles/payment-methods/payment-methods.d.ts +72 -0
  304. package/dist/particles/payment-methods/payment-methods.js +151 -0
  305. package/dist/particles/payment-methods/payment-methods.js.map +1 -0
  306. package/dist/particles/phone-field/phone-field.d.ts +67 -0
  307. package/dist/particles/phone-field/phone-field.js +250 -0
  308. package/dist/particles/phone-field/phone-field.js.map +1 -0
  309. package/dist/particles/popover/popover.d.ts +68 -0
  310. package/dist/particles/popover/popover.js +284 -0
  311. package/dist/particles/popover/popover.js.map +1 -0
  312. package/dist/particles/postal-code-field/postal-code-field.d.ts +75 -0
  313. package/dist/particles/postal-code-field/postal-code-field.js +169 -0
  314. package/dist/particles/postal-code-field/postal-code-field.js.map +1 -0
  315. package/dist/particles/promotion/promotion.d.ts +46 -0
  316. package/dist/particles/promotion/promotion.js +78 -0
  317. package/dist/particles/promotion/promotion.js.map +1 -0
  318. package/dist/particles/quantity-selector/quantity-selector.d.ts +30 -0
  319. package/dist/particles/quantity-selector/quantity-selector.js +116 -0
  320. package/dist/particles/quantity-selector/quantity-selector.js.map +1 -0
  321. package/dist/particles/radio/radio.d.ts +36 -0
  322. package/dist/particles/radio/radio.js +76 -0
  323. package/dist/particles/radio/radio.js.map +1 -0
  324. package/dist/particles/scroll-area/scroll-area.d.ts +36 -0
  325. package/dist/particles/scroll-area/scroll-area.js +145 -0
  326. package/dist/particles/scroll-area/scroll-area.js.map +1 -0
  327. package/dist/particles/select/select.d.ts +125 -0
  328. package/dist/particles/select/select.js +478 -0
  329. package/dist/particles/select/select.js.map +1 -0
  330. package/dist/particles/separator/separator.d.ts +12 -0
  331. package/dist/particles/separator/separator.js +33 -0
  332. package/dist/particles/separator/separator.js.map +1 -0
  333. package/dist/particles/shared/input-mask.d.ts +5 -0
  334. package/dist/particles/shared/input-mask.js +58 -0
  335. package/dist/particles/shared/input-mask.js.map +1 -0
  336. package/dist/particles/spinner/spinner.d.ts +13 -0
  337. package/dist/particles/spinner/spinner.js +31 -0
  338. package/dist/particles/spinner/spinner.js.map +1 -0
  339. package/dist/particles/switch/switch.d.ts +27 -0
  340. package/dist/particles/switch/switch.js +59 -0
  341. package/dist/particles/switch/switch.js.map +1 -0
  342. package/dist/particles/tabs/tabs.d.ts +45 -0
  343. package/dist/particles/tabs/tabs.js +164 -0
  344. package/dist/particles/tabs/tabs.js.map +1 -0
  345. package/dist/particles/text/text.d.ts +24 -0
  346. package/dist/particles/text/text.js +40 -0
  347. package/dist/particles/text/text.js.map +1 -0
  348. package/dist/particles/toast/toast.d.ts +83 -0
  349. package/dist/particles/toast/toast.js +194 -0
  350. package/dist/particles/toast/toast.js.map +1 -0
  351. package/dist/particles/toggle/toggle.d.ts +26 -0
  352. package/dist/particles/toggle/toggle.js +61 -0
  353. package/dist/particles/toggle/toggle.js.map +1 -0
  354. package/dist/particles/tooltip/tooltip.d.ts +61 -0
  355. package/dist/particles/tooltip/tooltip.js +240 -0
  356. package/dist/particles/tooltip/tooltip.js.map +1 -0
  357. package/dist/schema.graphql +2953 -0
  358. package/dist/sdk/actions/cart-action-provider.d.ts +19 -0
  359. package/dist/sdk/actions/cart-action-provider.js +23 -0
  360. package/dist/sdk/actions/cart-action-provider.js.map +1 -0
  361. package/dist/sdk/actions/identity-action-provider.d.ts +15 -0
  362. package/dist/sdk/actions/identity-action-provider.js +19 -0
  363. package/dist/sdk/actions/identity-action-provider.js.map +1 -0
  364. package/dist/sdk/actions/index.d.ts +7 -0
  365. package/dist/sdk/actions/index.js +6 -0
  366. package/dist/sdk/actions/inject-actions.d.ts +14 -0
  367. package/dist/sdk/actions/inject-actions.js +36 -0
  368. package/dist/sdk/actions/inject-actions.js.map +1 -0
  369. package/dist/sdk/actions/region-action-provider.d.ts +15 -0
  370. package/dist/sdk/actions/region-action-provider.js +19 -0
  371. package/dist/sdk/actions/region-action-provider.js.map +1 -0
  372. package/dist/sdk/actions/session-action-provider.d.ts +15 -0
  373. package/dist/sdk/actions/session-action-provider.js +19 -0
  374. package/dist/sdk/actions/session-action-provider.js.map +1 -0
  375. package/dist/sdk/actions/shipping-action-provider.d.ts +15 -0
  376. package/dist/sdk/actions/shipping-action-provider.js +19 -0
  377. package/dist/sdk/actions/shipping-action-provider.js.map +1 -0
  378. package/dist/sdk/actions/types.d.ts +21 -0
  379. package/dist/sdk/cache/storefront-cache.js +35 -0
  380. package/dist/sdk/cache/storefront-cache.js.map +1 -0
  381. package/dist/sdk/cart/operations.d.ts +31 -0
  382. package/dist/sdk/cart/operations.js +215 -0
  383. package/dist/sdk/cart/operations.js.map +1 -0
  384. package/dist/sdk/cart/optimistic.d.ts +24 -0
  385. package/dist/sdk/cart/optimistic.js +164 -0
  386. package/dist/sdk/cart/optimistic.js.map +1 -0
  387. package/dist/sdk/cart/use-cart-actions.d.ts +56 -0
  388. package/dist/sdk/cart/use-cart-actions.js +348 -0
  389. package/dist/sdk/cart/use-cart-actions.js.map +1 -0
  390. package/dist/sdk/cart/use-cart-validate-on-open.js +50 -0
  391. package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -0
  392. package/dist/sdk/cart/write-gate.js +54 -0
  393. package/dist/sdk/cart/write-gate.js.map +1 -0
  394. package/dist/sdk/client/assert-api-url.js +20 -0
  395. package/dist/sdk/client/assert-api-url.js.map +1 -0
  396. package/dist/sdk/client/create-client.d.ts +23 -0
  397. package/dist/sdk/client/create-client.js +46 -0
  398. package/dist/sdk/client/create-client.js.map +1 -0
  399. package/dist/sdk/client/fetch-page-data.d.ts +39 -0
  400. package/dist/sdk/client/fetch-page-data.js +33 -0
  401. package/dist/sdk/client/fetch-page-data.js.map +1 -0
  402. package/dist/sdk/client/register-preload-query.d.ts +24 -0
  403. package/dist/sdk/client/register-preload-query.js +33 -0
  404. package/dist/sdk/client/register-preload-query.js.map +1 -0
  405. package/dist/sdk/content/create-content-runtime.d.ts +68 -0
  406. package/dist/sdk/content/create-content-runtime.js +503 -0
  407. package/dist/sdk/content/create-content-runtime.js.map +1 -0
  408. package/dist/sdk/context/headers.d.ts +15 -0
  409. package/dist/sdk/context/headers.js +21 -0
  410. package/dist/sdk/context/headers.js.map +1 -0
  411. package/dist/sdk/context/storefront-context.d.ts +11 -0
  412. package/dist/sdk/context/storefront-context.js +29 -0
  413. package/dist/sdk/context/storefront-context.js.map +1 -0
  414. package/dist/sdk/data/data-override-context.d.ts +12 -0
  415. package/dist/sdk/data/data-override-context.js +19 -0
  416. package/dist/sdk/data/data-override-context.js.map +1 -0
  417. package/dist/sdk/data/entity-subscriber.js +28 -0
  418. package/dist/sdk/data/entity-subscriber.js.map +1 -0
  419. package/dist/sdk/data/hot-data-provider.d.ts +19 -0
  420. package/dist/sdk/data/hot-data-provider.js +33 -0
  421. package/dist/sdk/data/hot-data-provider.js.map +1 -0
  422. package/dist/sdk/data/index.d.ts +8 -0
  423. package/dist/sdk/data/index.js +8 -0
  424. package/dist/sdk/data/list-item-ref-context.d.ts +20 -0
  425. package/dist/sdk/data/list-item-ref-context.js +11 -0
  426. package/dist/sdk/data/list-item-ref-context.js.map +1 -0
  427. package/dist/sdk/data/multiple-reactive-data-provider.d.ts +32 -0
  428. package/dist/sdk/data/multiple-reactive-data-provider.js +20 -0
  429. package/dist/sdk/data/multiple-reactive-data-provider.js.map +1 -0
  430. package/dist/sdk/data/page-reactive-data-root.d.ts +53 -0
  431. package/dist/sdk/data/page-reactive-data-root.js +153 -0
  432. package/dist/sdk/data/page-reactive-data-root.js.map +1 -0
  433. package/dist/sdk/data/reactive-data-provider.d.ts +25 -0
  434. package/dist/sdk/data/reactive-data-provider.js +24 -0
  435. package/dist/sdk/data/reactive-data-provider.js.map +1 -0
  436. package/dist/sdk/data/reactive-list-item-data-provider.d.ts +26 -0
  437. package/dist/sdk/data/reactive-list-item-data-provider.js +42 -0
  438. package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -0
  439. package/dist/sdk/data/use-reactive-entity.js +40 -0
  440. package/dist/sdk/data/use-reactive-entity.js.map +1 -0
  441. package/dist/sdk/format/client.d.ts +12 -0
  442. package/dist/sdk/format/client.js +20 -0
  443. package/dist/sdk/format/client.js.map +1 -0
  444. package/dist/sdk/format/formatters.d.ts +32 -0
  445. package/dist/sdk/format/formatters.js +45 -0
  446. package/dist/sdk/format/formatters.js.map +1 -0
  447. package/dist/sdk/generated/fragment-types.js +23 -0
  448. package/dist/sdk/generated/fragment-types.js.map +1 -0
  449. package/dist/sdk/generated/gql.js +51 -0
  450. package/dist/sdk/generated/gql.js.map +1 -0
  451. package/dist/sdk/generated/graphql.d.ts +622 -0
  452. package/dist/sdk/generated/graphql.js +11917 -0
  453. package/dist/sdk/generated/graphql.js.map +1 -0
  454. package/dist/sdk/graphql-tag.d.ts +10 -0
  455. package/dist/sdk/graphql-tag.js +21 -0
  456. package/dist/sdk/graphql-tag.js.map +1 -0
  457. package/dist/sdk/i18n/client.d.ts +4 -0
  458. package/dist/sdk/i18n/client.js +4 -0
  459. package/dist/sdk/i18n/locales.d.ts +8 -0
  460. package/dist/sdk/i18n/locales.js +57 -0
  461. package/dist/sdk/i18n/locales.js.map +1 -0
  462. package/dist/sdk/i18n/messages/en-US.js +24 -0
  463. package/dist/sdk/i18n/messages/en-US.js.map +1 -0
  464. package/dist/sdk/i18n/messages/en-US.json +19 -0
  465. package/dist/sdk/i18n/messages/en-US.json.d.ts +23 -0
  466. package/dist/sdk/i18n/messages/es-ES.js +24 -0
  467. package/dist/sdk/i18n/messages/es-ES.js.map +1 -0
  468. package/dist/sdk/i18n/messages/es-ES.json +19 -0
  469. package/dist/sdk/i18n/messages/pt-BR.js +24 -0
  470. package/dist/sdk/i18n/messages/pt-BR.js.map +1 -0
  471. package/dist/sdk/i18n/messages/pt-BR.json +19 -0
  472. package/dist/sdk/i18n/provider.d.ts +1 -0
  473. package/dist/sdk/i18n/provider.js +30 -0
  474. package/dist/sdk/i18n/provider.js.map +1 -0
  475. package/dist/sdk/i18n/server.d.ts +28 -0
  476. package/dist/sdk/i18n/server.js +59 -0
  477. package/dist/sdk/i18n/server.js.map +1 -0
  478. package/dist/sdk/identity/operations.d.ts +34 -0
  479. package/dist/sdk/identity/operations.js +78 -0
  480. package/dist/sdk/identity/operations.js.map +1 -0
  481. package/dist/sdk/identity/use-identity-actions.d.ts +62 -0
  482. package/dist/sdk/identity/use-identity-actions.js +180 -0
  483. package/dist/sdk/identity/use-identity-actions.js.map +1 -0
  484. package/dist/sdk/provider/index.d.ts +2 -0
  485. package/dist/sdk/provider/index.js +2 -0
  486. package/dist/sdk/provider/storefront-provider.d.ts +32 -0
  487. package/dist/sdk/provider/storefront-provider.js +111 -0
  488. package/dist/sdk/provider/storefront-provider.js.map +1 -0
  489. package/dist/sdk/region/operations.d.ts +6 -0
  490. package/dist/sdk/region/region-operations.d.ts +30 -0
  491. package/dist/sdk/region/region-operations.js +23 -0
  492. package/dist/sdk/region/region-operations.js.map +1 -0
  493. package/dist/sdk/region/use-region-actions.d.ts +23 -0
  494. package/dist/sdk/region/use-region-actions.js +66 -0
  495. package/dist/sdk/region/use-region-actions.js.map +1 -0
  496. package/dist/sdk/seller.js +11 -0
  497. package/dist/sdk/seller.js.map +1 -0
  498. package/dist/sdk/session/auth-operations.d.ts +47 -0
  499. package/dist/sdk/session/auth-operations.js +79 -0
  500. package/dist/sdk/session/auth-operations.js.map +1 -0
  501. package/dist/sdk/session/operations.d.ts +6 -0
  502. package/dist/sdk/session/use-session-actions.d.ts +27 -0
  503. package/dist/sdk/session/use-session-actions.js +126 -0
  504. package/dist/sdk/session/use-session-actions.js.map +1 -0
  505. package/dist/sdk/shipping/cart-operations.d.ts +3 -0
  506. package/dist/sdk/shipping/cart-operations.js +33 -0
  507. package/dist/sdk/shipping/cart-operations.js.map +1 -0
  508. package/dist/sdk/shipping/operations.d.ts +3 -0
  509. package/dist/sdk/shipping/operations.js +33 -0
  510. package/dist/sdk/shipping/operations.js.map +1 -0
  511. package/dist/sdk/shipping/option-select-operations.d.ts +24 -0
  512. package/dist/sdk/shipping/option-select-operations.js +45 -0
  513. package/dist/sdk/shipping/option-select-operations.js.map +1 -0
  514. package/dist/sdk/shipping/request-timeout.js +41 -0
  515. package/dist/sdk/shipping/request-timeout.js.map +1 -0
  516. package/dist/sdk/shipping/shipping-operations.d.ts +38 -0
  517. package/dist/sdk/shipping/shipping-operations.js +77 -0
  518. package/dist/sdk/shipping/shipping-operations.js.map +1 -0
  519. package/dist/sdk/shipping/use-cart-shipping-simulation.d.ts +7 -0
  520. package/dist/sdk/shipping/use-cart-shipping-simulation.js +72 -0
  521. package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -0
  522. package/dist/sdk/shipping/use-shipping-actions.d.ts +27 -0
  523. package/dist/sdk/shipping/use-shipping-actions.js +113 -0
  524. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -0
  525. package/dist/sdk/shipping/use-shipping-simulation.d.ts +7 -0
  526. package/dist/sdk/shipping/use-shipping-simulation.js +72 -0
  527. package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -0
  528. package/dist/sdk/state/cart.d.ts +42 -0
  529. package/dist/sdk/state/cart.js +64 -0
  530. package/dist/sdk/state/cart.js.map +1 -0
  531. package/dist/sdk/state/index.js +3 -0
  532. package/dist/sdk/state/variant-selector.d.ts +17 -0
  533. package/dist/sdk/state/variant-selector.js +14 -0
  534. package/dist/sdk/state/variant-selector.js.map +1 -0
  535. package/dist/utils/safe-href.js +63 -0
  536. package/dist/utils/safe-href.js.map +1 -0
  537. package/package.json +84 -0
  538. package/src/styles/tailwind.css +32 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-simulator.js","names":[],"sources":["../../../src/matter/shipping-simulator/shipping-simulator.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { FormattedMessage, type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { CartShippingSimulateInput } from '../../sdk/shipping/cart-operations.js';\nimport type { ShippingSimulateInput } from '../../sdk/shipping/operations.js';\nimport { useCartShippingSimulation } from '../../sdk/shipping/use-cart-shipping-simulation.js';\nimport { useShippingSimulation } from '../../sdk/shipping/use-shipping-simulation.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ShippingSimulatorData on Query {\n productBySlug(slug: $slug) {\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawShippingSimulatorData = {\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Domain types (mirror the shippingSimulation GraphQL contract)\n// ---------------------------------------------------------------------------\n\ntype MoneyValue = { amount: number; currencyCode: string };\n\ntype DeliveryChannel = 'DELIVERY' | 'PICKUP' | 'UNKNOWN';\n\ntype ShippingEstimateUnit = 'BUSINESS_DAYS' | 'DAYS' | 'HOURS' | 'MINUTES';\n\ntype ShippingEstimate = { value: number; unit: ShippingEstimateUnit };\n\n// Exported alongside `ShippingSimulatorContextValue` so `DeliveryOptionsRoot`\n// (matter/delivery-options) can type against the exact shape the reused leaves expect, with no\n// structural duplication (specs/delivery-options-step.md Decision 2).\nexport type ShippingOption = {\n id: string;\n name: string;\n channel: DeliveryChannel;\n shippingEstimate: ShippingEstimate;\n price: MoneyValue;\n listPrice: MoneyValue;\n};\n\ntype ShippingSimulateErrorCode = 'INVALID_POSTAL_CODE' | 'UNKNOWN';\n\n// Exported with `ShippingSimulationPayload` so the `./client` entry can name the simulate callback's\n// whole contract — the SDK hooks return it and a store writing its own `onSimulate` has to name it.\nexport type ShippingSimulateError = {\n code: ShippingSimulateErrorCode;\n message: string;\n};\n\nexport type ShippingSimulationPayload = {\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n};\n\ntype Status = 'idle' | 'loading' | 'success' | 'error';\n\nexport type ShippingSimulatorContextValue = {\n postalCode: string;\n setPostalCode: (value: string) => void;\n status: Status;\n shippingOptions: ShippingOption[] | null;\n userErrors: ShippingSimulateError[];\n submit: () => void;\n};\n\nconst SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol('ShippingSimulatorContextUnset');\n\nexport type ShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n quantity?: number;\n variantId?: string;\n seller?: string;\n $data?: RawShippingSimulatorData | null;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: ShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type CartShippingSimulatorRootProps = ComponentPropsWithRef<'div'> & {\n country?: string;\n shippingOptions?: ShippingOption[];\n userErrors?: ShippingSimulateError[];\n onSimulate?: (input: CartShippingSimulateInput) => Promise<ShippingSimulationPayload>;\n onResult?: (result: ShippingSimulationPayload) => void;\n};\n\nexport type ShippingSimulatorFormProps = ComponentPropsWithRef<'form'>;\n\nexport type ShippingSimulatorInputProps = Omit<ComponentPropsWithRef<'input'>, 'value' | 'onChange'> & {\n format?: boolean;\n};\n\nexport type ShippingSimulatorSubmitProps = ComponentPropsWithRef<'button'>;\n\nexport type ShippingSimulatorLoadingProps = ComponentPropsWithRef<'output'>;\n\nexport type ShippingSimulatorErrorProps = ComponentPropsWithRef<'div'>;\n\nexport type ShippingSimulatorOptionsProps = ComponentPropsWithRef<'ul'> & {\n sortBy?: 'price' | 'estimate';\n maxOptions?: number;\n};\n\nexport type ShippingSimulatorOptionProps = ComponentPropsWithRef<'li'>;\n\nexport type ShippingSimulatorOptionNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionEstimateProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorOptionFreeBadgeProps = ComponentPropsWithRef<'span'>;\n\nexport type ShippingSimulatorEmptyProps = ComponentPropsWithRef<'output'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Exported so `DeliveryOptionsRoot` can become a third provider by importing these same Context\n// objects directly (context matching is by identity, not shape). The two hooks below stay\n// module-private — providers need the objects, not the consumer API (Decision 2).\nexport const ShippingSimulatorContext = createContext<\n ShippingSimulatorContextValue | typeof SHIPPING_SIMULATOR_CONTEXT_UNSET\n>(SHIPPING_SIMULATOR_CONTEXT_UNSET);\n\nexport const OptionItemContext = createContext<ShippingOption | null>(null);\n\nfunction useShippingSimulator(): ShippingSimulatorContextValue {\n const ctx = useContext(ShippingSimulatorContext);\n if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) {\n throw new Error('ShippingSimulator components must be used inside ShippingSimulatorRoot.');\n }\n return ctx;\n}\n\nfunction useOptionItem(): ShippingOption {\n const ctx = useContext(OptionItemContext);\n if (!ctx) {\n throw new Error('ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Each unit's whole sentence, and the variable that sentence names.\n//\n// Whole sentence, not a unit fragment interpolated into a wrapper: interpolating a translated\n// fragment into a translated wrapper freezes \"preposition + noun\" order into every language, and\n// hands the translator `em {estimate}` with no way to agree preposition, article or case with a noun\n// they cannot see. The variable is named after what it counts (`{days}`, `{hours}`) rather than a\n// generic `{count}`, for the same reason.\n//\n// A `Record` and not a `switch` with a default: a fifth unit arriving in the GraphQL schema is a\n// type error here, not a silent fallback to the wrong sentence.\n//\n// `variable` is the union of the names those sentences read, never `string`: widened, a typo passes\n// typecheck, lint and every test, and the shopper gets the raw ICU pattern because `onIntlError` is\n// silent in production. The parity assertion in the test file closes the other half of the gap — that\n// the name written here is the one the catalog's message actually names.\nexport const ESTIMATE_MESSAGE: Record<ShippingEstimateUnit, { id: MessageId; variable: 'days' | 'hours' | 'minutes' }> =\n {\n BUSINESS_DAYS: { id: 'fs/shipping.estimate.in-business-days', variable: 'days' },\n DAYS: { id: 'fs/shipping.estimate.in-days', variable: 'days' },\n HOURS: { id: 'fs/shipping.estimate.in-hours', variable: 'hours' },\n MINUTES: { id: 'fs/shipping.estimate.in-minutes', variable: 'minutes' },\n };\n\n// Business days weigh the same as calendar days: exact wall-clock conversion is unknowable and\n// the ranking only needs a consistent order.\nconst ESTIMATE_UNIT_MINUTES: Record<ShippingEstimateUnit, number> = {\n MINUTES: 1,\n HOURS: 60,\n DAYS: 1440,\n BUSINESS_DAYS: 1440,\n};\n\nfunction sortShippingOptions(options: readonly ShippingOption[], sortBy: 'price' | 'estimate'): ShippingOption[] {\n const rank =\n sortBy === 'price'\n ? (option: ShippingOption) => Number(option.price.amount)\n : (option: ShippingOption) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];\n return [...options].sort((a, b) => rank(a) - rank(b));\n}\n\nfunction normalizePostalCode(value: string): string {\n return value.replace(/\\D/g, '').slice(0, 8);\n}\n\nfunction formatPostalCode(value: string): string {\n const digits = normalizePostalCode(value);\n return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;\n}\n\nfunction extractProductFromData(data: RawShippingSimulatorData | null | undefined): {\n variantId: string | null;\n seller: string | null;\n} {\n if (!data) return { variantId: null, seller: null };\n const edge = data.variants?.edges?.[0];\n if (!edge) return { variantId: null, seller: null };\n const { id, sellers } = edge.node;\n const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];\n return { variantId: id ?? null, seller: defaultSeller?.id ?? null };\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulatorRootDefinition = defineComponent<ShippingSimulatorRootProps>({\n name: 'ShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorRoot,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n quantity: { type: 'number', default: 1, label: 'Quantity' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one.',\n});\n\nexport const CartShippingSimulatorRootDefinition = defineComponent<CartShippingSimulatorRootProps>({\n name: 'CartShippingSimulatorRoot',\n importPath: '@vtex/faststore/components',\n component: CartShippingSimulatorRoot,\n editor: { label: 'Cart Shipping Simulator', category: 'commerce' },\n schema: {\n country: { type: 'string', default: 'BRA', label: 'Country (ISO-3)' },\n },\n providesContext: 'shipping-simulator',\n guideline:\n 'Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one.',\n});\n\nexport const ShippingSimulatorFormDefinition = defineComponent<ShippingSimulatorFormProps>({\n name: 'ShippingSimulatorForm',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorForm,\n editor: { label: 'Shipping Simulator Form', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorInputDefinition = defineComponent<ShippingSimulatorInputProps>({\n name: 'ShippingSimulatorInput',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorInput,\n editor: { label: 'Shipping Simulator Input', category: 'action' },\n schema: {\n format: { type: 'boolean', default: false, label: 'Auto-format CEP (00000-000)' },\n },\n requiresContext: 'shipping-simulator',\n guideline:\n 'Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorSubmitDefinition = defineComponent<ShippingSimulatorSubmitProps>({\n name: 'ShippingSimulatorSubmit',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorSubmit,\n editor: { label: 'Shipping Simulator Submit', category: 'action' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline: 'Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm.',\n});\n\nexport const ShippingSimulatorLoadingDefinition = defineComponent<ShippingSimulatorLoadingProps>({\n name: 'ShippingSimulatorLoading',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorLoading,\n editor: { label: 'Shipping Simulator Loading', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorErrorDefinition = defineComponent<ShippingSimulatorErrorProps>({\n name: 'ShippingSimulatorError',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorError,\n editor: { label: 'Shipping Simulator Error', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot.',\n});\n\nexport const ShippingSimulatorOptionsDefinition = defineComponent<ShippingSimulatorOptionsProps>({\n name: 'ShippingSimulatorOptions',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptions,\n editor: { label: 'Shipping Simulator Options', category: 'commerce' },\n schema: {\n sortBy: { type: ['price', 'estimate'] as const, label: 'Sort by' },\n maxOptions: { type: 'number', label: 'Max options' },\n },\n requiresContext: 'shipping-simulator',\n providesContext: 'shipping-simulator-option',\n guideline:\n 'List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md.',\n});\n\nexport const ShippingSimulatorOptionDefinition = defineComponent<ShippingSimulatorOptionProps>({\n name: 'ShippingSimulatorOption',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOption,\n editor: { label: 'Shipping Simulator Option', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions.',\n});\n\nexport const ShippingSimulatorOptionNameDefinition = defineComponent<ShippingSimulatorOptionNameProps>({\n name: 'ShippingSimulatorOptionName',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionName,\n editor: { label: 'Option Name', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionEstimateDefinition = defineComponent<ShippingSimulatorOptionEstimateProps>({\n name: 'ShippingSimulatorOptionEstimate',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionEstimate,\n editor: { label: 'Option Estimate', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionPriceDefinition = defineComponent<ShippingSimulatorOptionPriceProps>({\n name: 'ShippingSimulatorOptionPrice',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionPrice,\n editor: { label: 'Option Price', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption.',\n});\n\nexport const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent<ShippingSimulatorOptionFreeBadgeProps>({\n name: 'ShippingSimulatorOptionFreeBadge',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorOptionFreeBadge,\n editor: { label: 'Option Free Badge', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator-option',\n guideline:\n 'Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice.',\n});\n\nexport const ShippingSimulatorEmptyDefinition = defineComponent<ShippingSimulatorEmptyProps>({\n name: 'ShippingSimulatorEmpty',\n importPath: '@vtex/faststore/components',\n component: ShippingSimulatorEmpty,\n editor: { label: 'Shipping Simulator Empty', category: 'commerce' },\n schema: {},\n requiresContext: 'shipping-simulator',\n guideline:\n 'Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ShippingSimulatorRoot({\n country = 'BRA',\n quantity = 1,\n variantId: variantIdProp,\n seller: sellerProp,\n $data: $dataProp,\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: ShippingSimulatorRootProps) {\n const defaultSimulate = useShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const $data = useDataOverride($dataProp);\n const extracted = extractProductFromData($data);\n const variantId = variantIdProp ?? extracted.variantId;\n const seller = sellerProp ?? extracted.seller;\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n if (!onSimulate || !variantId || !seller) return;\n\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country, variantId, quantity, seller })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode, quantity, seller, variantId]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function CartShippingSimulatorRoot({\n country = 'BRA',\n shippingOptions: shippingOptionsProp,\n userErrors: userErrorsProp,\n onSimulate: onSimulateProp,\n onResult,\n className,\n children,\n ...props\n}: CartShippingSimulatorRootProps) {\n const defaultSimulate = useCartShippingSimulation();\n const onSimulate = onSimulateProp ?? defaultSimulate;\n const intl = useIntl();\n\n const [postalCode, setPostalCode] = useState('');\n const [status, setStatus] = useState<Status>(() => {\n if (userErrorsProp?.length) return 'error';\n if (shippingOptionsProp) return 'success';\n return 'idle';\n });\n const [shippingOptions, setShippingOptions] = useState<ShippingOption[] | null>(shippingOptionsProp ?? null);\n const [userErrors, setUserErrors] = useState<ShippingSimulateError[]>(userErrorsProp ?? []);\n\n const submissionToken = useRef(0);\n\n const submit = useCallback(() => {\n const normalizedCep = normalizePostalCode(postalCode);\n if (normalizedCep.length !== 8) return;\n\n const token = ++submissionToken.current;\n setStatus('loading');\n setShippingOptions(null);\n setUserErrors([]);\n\n onSimulate({ postalCode: normalizedCep, country })\n .then((result) => {\n if (submissionToken.current !== token) return;\n setShippingOptions(result.shippingOptions);\n setUserErrors(result.userErrors);\n setStatus(result.userErrors.length > 0 ? 'error' : 'success');\n onResult?.(result);\n })\n .catch(() => {\n if (submissionToken.current !== token) return;\n // In a handler, not a render: the message goes into state, where only a string fits.\n const fallback: ShippingSimulateError = {\n code: 'UNKNOWN',\n message: intl.formatMessage({ id: 'fs/shipping.calculation-failed' }),\n };\n setShippingOptions(null);\n setUserErrors([fallback]);\n setStatus('error');\n onResult?.({ shippingOptions: null, userErrors: [fallback] });\n });\n }, [country, intl, onResult, onSimulate, postalCode]);\n\n const contextValue = useMemo<ShippingSimulatorContextValue>(\n () => ({\n postalCode,\n setPostalCode,\n status,\n shippingOptions,\n userErrors,\n submit,\n }),\n [postalCode, status, shippingOptions, userErrors, submit],\n );\n\n return (\n <ShippingSimulatorContext value={contextValue}>\n <div {...props} className={className} data-fs-shipping-simulator=\"\">\n {children}\n </div>\n </ShippingSimulatorContext>\n );\n}\n\nexport function ShippingSimulatorForm({ className, children, ...props }: ShippingSimulatorFormProps) {\n const { submit } = useShippingSimulator();\n\n return (\n <form\n {...props}\n className={className}\n data-fs-shipping-simulator-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n );\n}\n\nexport function ShippingSimulatorInput({\n className,\n placeholder,\n 'aria-label': ariaLabel,\n format = false,\n ...props\n}: ShippingSimulatorInputProps) {\n const { postalCode, setPostalCode } = useShippingSimulator();\n const intl = useIntl();\n const displayValue = format ? formatPostalCode(postalCode) : postalCode;\n\n return (\n <input\n {...props}\n aria-label={ariaLabel ?? intl.formatMessage({ id: 'fs/shipping.postal-code.aria-label' })}\n className={className}\n data-fs-shipping-simulator-input=\"\"\n type=\"text\"\n value={displayValue}\n onChange={(event) => setPostalCode(normalizePostalCode(event.target.value))}\n placeholder={placeholder ?? intl.formatMessage({ id: 'fs/shipping.postal-code.placeholder' })}\n pattern=\"\\d{5}-?\\d{3}\"\n maxLength={9}\n inputMode=\"numeric\"\n required\n />\n );\n}\n\nexport function ShippingSimulatorSubmit({ className, children, disabled, ...props }: ShippingSimulatorSubmitProps) {\n const { status } = useShippingSimulator();\n const isLoading = status === 'loading';\n\n return (\n <button\n {...props}\n type=\"submit\"\n className={className}\n data-fs-shipping-simulator-submit=\"\"\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n >\n {children}\n </button>\n );\n}\n\nexport function ShippingSimulatorLoading({ className, children, ...props }: ShippingSimulatorLoadingProps) {\n const { status } = useShippingSimulator();\n if (status !== 'loading') return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-loading=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.calculating\" />}\n </output>\n );\n}\n\nexport function ShippingSimulatorError({ className, children, ...props }: ShippingSimulatorErrorProps) {\n const { userErrors } = useShippingSimulator();\n const [firstError] = userErrors;\n if (!firstError) return null;\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-shipping-simulator-error=\"\">\n {children ?? firstError.message}\n </div>\n );\n}\n\nexport function ShippingSimulatorOptions({\n sortBy,\n maxOptions,\n className,\n children,\n ...props\n}: ShippingSimulatorOptionsProps) {\n const { shippingOptions } = useShippingSimulator();\n\n const visibleOptions = useMemo(() => {\n if (!shippingOptions) return null;\n const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;\n return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;\n }, [shippingOptions, sortBy, maxOptions]);\n\n if (!visibleOptions || visibleOptions.length === 0) return null;\n\n return (\n <ul {...props} className={className} data-fs-shipping-simulator-options=\"\">\n {visibleOptions.map((option) => (\n <OptionItemContext key={option.id} value={option}>\n {children}\n </OptionItemContext>\n ))}\n </ul>\n );\n}\n\nexport function ShippingSimulatorOption({ className, children, ...props }: ShippingSimulatorOptionProps) {\n const option = useOptionItem();\n\n return (\n <li\n {...props}\n className={className}\n data-fs-shipping-simulator-option=\"\"\n data-fs-shipping-simulator-option-channel={option.channel}\n >\n {children}\n </li>\n );\n}\n\nexport function ShippingSimulatorOptionName({ className, children, ...props }: ShippingSimulatorOptionNameProps) {\n const option = useOptionItem();\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-name=\"\">\n {children ?? option.name}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionEstimate({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionEstimateProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { value, unit } = option.shippingEstimate;\n const { id, variable } = ESTIMATE_MESSAGE[unit];\n const text =\n value === 0\n ? intl.formatMessage({ id: 'fs/shipping.estimate.today' })\n : intl.formatMessage({ id }, { [variable]: value });\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-estimate=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionPrice({ className, children, ...props }: ShippingSimulatorOptionPriceProps) {\n const option = useOptionItem();\n const intl = useIntl();\n const { locale, currency } = useStorefrontContext();\n const text =\n option.price.amount === 0\n ? intl.formatMessage({ id: 'fs/shipping.free-price' })\n : formatPrice(option.price.amount, locale, currency);\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-price=\"\">\n {children ?? text}\n </span>\n );\n}\n\nexport function ShippingSimulatorOptionFreeBadge({\n className,\n children,\n ...props\n}: ShippingSimulatorOptionFreeBadgeProps) {\n const option = useOptionItem();\n if (option.price.amount !== 0) return null;\n\n return (\n <span {...props} className={className} data-fs-shipping-simulator-option-free-badge=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.free-badge\" />}\n </span>\n );\n}\n\nexport function ShippingSimulatorEmpty({ className, children, ...props }: ShippingSimulatorEmptyProps) {\n const { shippingOptions, userErrors } = useShippingSimulator();\n // Idle (null) → nothing; error → nothing (Error owns it); options present → nothing.\n const simulatedEmpty = Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0;\n if (!simulatedEmpty) return null;\n\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-shipping-simulator-empty=\"\">\n {children ?? <FormattedMessage id=\"fs/shipping.no-options\" />}\n </output>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ShippingSimulator = {\n Root: ShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n\nexport const CartShippingSimulator = {\n Root: CartShippingSimulatorRoot,\n Form: ShippingSimulatorForm,\n Input: ShippingSimulatorInput,\n Submit: ShippingSimulatorSubmit,\n Loading: ShippingSimulatorLoading,\n Error: ShippingSimulatorError,\n Options: ShippingSimulatorOptions,\n Option: ShippingSimulatorOption,\n OptionName: ShippingSimulatorOptionName,\n OptionEstimate: ShippingSimulatorOptionEstimate,\n OptionPrice: ShippingSimulatorOptionPrice,\n OptionFreeBadge: ShippingSimulatorOptionFreeBadge,\n Empty: ShippingSimulatorEmpty,\n};\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAqF/B,MAAM,mCAAmC,OAAO,+BAA+B;AA0D/E,MAAa,2BAA2B,cAEtC,gCAAgC;AAElC,MAAa,oBAAoB,cAAqC,IAAI;AAE1E,SAAS,uBAAsD;CAC7D,MAAM,MAAM,WAAW,wBAAwB;CAC/C,IAAI,QAAQ,kCACV,MAAM,IAAI,MAAM,yEAAyE;CAE3F,OAAO;AACT;AAEA,SAAS,gBAAgC;CACvC,MAAM,MAAM,WAAW,iBAAiB;CACxC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,kFAAkF;CAEpG,OAAO;AACT;AAMA,SAAS,YAAY,OAAe,QAAgB,UAA0B;CAC5E,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,OAAO;EAAY;CAAS,CAAC,CAAC,CAAC,OAAO,KAAK;AACpF;AAiBA,MAAa,mBACX;CACE,eAAe;EAAE,IAAI;EAAyC,UAAU;CAAO;CAC/E,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 import "../../core/dist/index.js";
3
+ import { SessionUserError } from "../../sdk/session/auth-operations.js";
4
+ import { ComponentActions } from "../../sdk/actions/types.js";
5
+ //#region src/matter/sign-in-form/sign-in-form.d.ts
6
+ /** ClientProfile slice forwarded by the reactive runtime — only `email` is consumed for pre-fill. */
7
+ export type SignInFormSlice = Readonly<{
8
+ email?: string | null;
9
+ }>;
10
+ export type SignInFormMessages = Readonly<{
11
+ invalidCredentialsMessage: string;
12
+ blockedMessage: string;
13
+ networkErrorMessage: string;
14
+ genericErrorMessage: string;
15
+ }>;
16
+ export type SignInFormProps = Readonly<{
17
+ emailLabel?: string;
18
+ emailPlaceholder?: string;
19
+ passwordLabel?: string;
20
+ passwordPlaceholder?: string;
21
+ showPasswordLabel?: string;
22
+ hidePasswordLabel?: string;
23
+ submitLabel?: string;
24
+ /** Inline error for an invalid email format (mirrors EmailIdentificationControl). */
25
+ invalidEmailMessage?: string;
26
+ /** Inline error when the password field is submitted empty (this form owns the presence check). */
27
+ passwordRequiredMessage?: string;
28
+ invalidCredentialsMessage?: string;
29
+ blockedMessage?: string;
30
+ networkErrorMessage?: string;
31
+ genericErrorMessage?: string;
32
+ /** ClientProfile slice forwarded by the reactive runtime; `null` until the entity resolves. */
33
+ $data?: SignInFormSlice | null;
34
+ /** Compiler-injected action surface; carries `session.loginWithPassword`. */
35
+ $actions?: ComponentActions;
36
+ className?: string;
37
+ }>;
38
+ /**
39
+ * Maps the first resolved SessionUserError to caller-configurable copy. INVALID_ACCESS_CODE,
40
+ * ACCESS_CODE_SEND_LIMIT, and MISSING_AUTH_CONTEXT are contractually unreachable from
41
+ * loginWithPassword but share the untyped `code: string` field, so they fall through to the
42
+ * generic message defensively, alongside any future/unknown code.
43
+ */
44
+ export declare function mapSessionErrorMessage(error: SessionUserError | undefined, messages: SignInFormMessages): string | null;
45
+ export declare const SignInFormDefinition: ComponentDefinition<Readonly<{
46
+ emailLabel?: string;
47
+ emailPlaceholder?: string;
48
+ passwordLabel?: string;
49
+ passwordPlaceholder?: string;
50
+ showPasswordLabel?: string;
51
+ hidePasswordLabel?: string;
52
+ submitLabel?: string;
53
+ /** Inline error for an invalid email format (mirrors EmailIdentificationControl). */
54
+ invalidEmailMessage?: string;
55
+ /** Inline error when the password field is submitted empty (this form owns the presence check). */
56
+ passwordRequiredMessage?: string;
57
+ invalidCredentialsMessage?: string;
58
+ blockedMessage?: string;
59
+ networkErrorMessage?: string;
60
+ genericErrorMessage?: string;
61
+ /** ClientProfile slice forwarded by the reactive runtime; `null` until the entity resolves. */
62
+ $data?: SignInFormSlice | null;
63
+ /** Compiler-injected action surface; carries `session.loginWithPassword`. */
64
+ $actions?: ComponentActions;
65
+ className?: string;
66
+ }>>;
67
+ /**
68
+ * Matter that composes `EmailField` + `PasswordField` under one submit and dispatches
69
+ * `$actions.session.loginWithPassword`. Reads the email pre-fill from `clientProfile.email`
70
+ * (colocated reactive fragment) and the identity tri-state from `useSession()` (which also
71
+ * enforces the `SessionRoot` ancestor), self-gating to `null` once the shopper is `loggedIn`.
72
+ * Client-side validation (email format, password presence) blocks the dispatch before any network
73
+ * round trip; the awaited dispatch's `userErrors` map to one form-level inline message, distinct
74
+ * from any ancestor `UNAUTHORIZED` gate. While the write is in flight the form is disabled and
75
+ * `data-fs-sign-in-form-pending` is present so a checkout-CTA guard can block.
76
+ */
77
+ export declare function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel, invalidEmailMessage, passwordRequiredMessage, invalidCredentialsMessage, blockedMessage, networkErrorMessage, genericErrorMessage, $data: $dataProp, $actions, className }: SignInFormProps): import("react/jsx-runtime").JSX.Element | null;
78
+ //#endregion
79
+ //# sourceMappingURL=sign-in-form.d.ts.map
@@ -0,0 +1,226 @@
1
+ "use client";
2
+ import { defineComponent } from "../../core/dist/define-component.js";
3
+ import "../../core/dist/index.js";
4
+ import { EmailField, isValidEmail } from "../../particles/email-field/email-field.js";
5
+ import { useDataOverride } from "../../sdk/data/data-override-context.js";
6
+ import { useSession } from "../session/session.js";
7
+ import { Button } from "../../particles/button/button.js";
8
+ import { PasswordField } from "../../particles/password-field/password-field.js";
9
+ import { useEffect, useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/matter/sign-in-form/sign-in-form.tsx
12
+ const fragment = `
13
+ fragment SignInFormData on Query {
14
+ clientProfile {
15
+ __typename
16
+ id
17
+ email
18
+ }
19
+ }
20
+ `;
21
+ /**
22
+ * Maps the first resolved SessionUserError to caller-configurable copy. INVALID_ACCESS_CODE,
23
+ * ACCESS_CODE_SEND_LIMIT, and MISSING_AUTH_CONTEXT are contractually unreachable from
24
+ * loginWithPassword but share the untyped `code: string` field, so they fall through to the
25
+ * generic message defensively, alongside any future/unknown code.
26
+ */
27
+ function mapSessionErrorMessage(error, messages) {
28
+ if (!error) return null;
29
+ switch (error.code) {
30
+ case "INVALID_CREDENTIALS": return messages.invalidCredentialsMessage;
31
+ case "BLOCKED": return messages.blockedMessage;
32
+ case "NETWORK_ERROR": return messages.networkErrorMessage;
33
+ default: return messages.genericErrorMessage;
34
+ }
35
+ }
36
+ const SignInFormDefinition = defineComponent({
37
+ name: "SignInForm",
38
+ importPath: "@vtex/faststore/components",
39
+ component: SignInForm,
40
+ fragment,
41
+ fetchStrategy: "reactive",
42
+ actions: { session: ["loginWithPassword"] },
43
+ requiresContext: "session",
44
+ editor: {
45
+ label: "Sign In Form",
46
+ category: "identity"
47
+ },
48
+ schema: {
49
+ emailLabel: {
50
+ type: "string",
51
+ default: "Email",
52
+ label: "Email label"
53
+ },
54
+ emailPlaceholder: {
55
+ type: "string",
56
+ default: "you@example.com",
57
+ label: "Email placeholder"
58
+ },
59
+ passwordLabel: {
60
+ type: "string",
61
+ default: "Password",
62
+ label: "Password label"
63
+ },
64
+ passwordPlaceholder: {
65
+ type: "string",
66
+ default: "",
67
+ label: "Password placeholder"
68
+ },
69
+ showPasswordLabel: {
70
+ type: "string",
71
+ default: "Show password",
72
+ label: "Show password label"
73
+ },
74
+ hidePasswordLabel: {
75
+ type: "string",
76
+ default: "Hide password",
77
+ label: "Hide password label"
78
+ },
79
+ submitLabel: {
80
+ type: "string",
81
+ default: "Sign In",
82
+ label: "Submit label"
83
+ },
84
+ invalidEmailMessage: {
85
+ type: "string",
86
+ default: "Enter a valid email address.",
87
+ label: "Invalid email message"
88
+ },
89
+ passwordRequiredMessage: {
90
+ type: "string",
91
+ default: "Enter your password.",
92
+ label: "Password required message"
93
+ },
94
+ invalidCredentialsMessage: {
95
+ type: "string",
96
+ default: "Incorrect email or password. Please try again.",
97
+ label: "Invalid credentials message"
98
+ },
99
+ blockedMessage: {
100
+ type: "string",
101
+ default: "This account has been blocked. Please contact support.",
102
+ label: "Blocked account message"
103
+ },
104
+ networkErrorMessage: {
105
+ type: "string",
106
+ default: "Unable to complete the request. Please try again.",
107
+ label: "Network error message"
108
+ },
109
+ genericErrorMessage: {
110
+ type: "string",
111
+ default: "Unable to sign in. Please try again.",
112
+ label: "Generic error message"
113
+ }
114
+ },
115
+ guideline: "Combined email+password sign-in form dispatching $actions.session.loginWithPassword; pre-fills the email from clientProfile.email, self-hides once the session is loggedIn, and exposes data-fs-sign-in-form-pending while the submit is in flight. Must be inside SessionRoot. See sign-in-form.md."
116
+ });
117
+ /**
118
+ * Matter that composes `EmailField` + `PasswordField` under one submit and dispatches
119
+ * `$actions.session.loginWithPassword`. Reads the email pre-fill from `clientProfile.email`
120
+ * (colocated reactive fragment) and the identity tri-state from `useSession()` (which also
121
+ * enforces the `SessionRoot` ancestor), self-gating to `null` once the shopper is `loggedIn`.
122
+ * Client-side validation (email format, password presence) blocks the dispatch before any network
123
+ * round trip; the awaited dispatch's `userErrors` map to one form-level inline message, distinct
124
+ * from any ancestor `UNAUTHORIZED` gate. While the write is in flight the form is disabled and
125
+ * `data-fs-sign-in-form-pending` is present so a checkout-CTA guard can block.
126
+ */
127
+ function SignInForm({ emailLabel, emailPlaceholder, passwordLabel, passwordPlaceholder, showPasswordLabel, hidePasswordLabel, submitLabel = "Sign In", invalidEmailMessage = "Enter a valid email address.", passwordRequiredMessage = "Enter your password.", invalidCredentialsMessage = "Incorrect email or password. Please try again.", blockedMessage = "This account has been blocked. Please contact support.", networkErrorMessage = "Unable to complete the request. Please try again.", genericErrorMessage = "Unable to sign in. Please try again.", $data: $dataProp, $actions, className }) {
128
+ const $data = useDataOverride($dataProp);
129
+ const { state } = useSession();
130
+ const savedEmail = $data?.email ?? "";
131
+ const [email, setEmail] = useState(savedEmail);
132
+ const [password, setPassword] = useState("");
133
+ const [pending, setPending] = useState(false);
134
+ const [emailError, setEmailError] = useState(null);
135
+ const [passwordError, setPasswordError] = useState(null);
136
+ const [formError, setFormError] = useState(null);
137
+ useEffect(() => {
138
+ setEmail(savedEmail);
139
+ }, [savedEmail]);
140
+ if (state === "loggedIn") return null;
141
+ function handleEmailChange(next) {
142
+ setEmail(next);
143
+ if (emailError) setEmailError(null);
144
+ }
145
+ function handlePasswordChange(next) {
146
+ setPassword(next);
147
+ if (passwordError) setPasswordError(null);
148
+ }
149
+ async function handleSubmit(event) {
150
+ event.preventDefault();
151
+ const trimmedEmail = email.trim();
152
+ if (!isValidEmail(trimmedEmail)) {
153
+ setEmailError(invalidEmailMessage);
154
+ return;
155
+ }
156
+ if (password.length === 0) {
157
+ setPasswordError(passwordRequiredMessage);
158
+ return;
159
+ }
160
+ setEmailError(null);
161
+ setPasswordError(null);
162
+ setFormError(null);
163
+ setPending(true);
164
+ try {
165
+ const errors = await $actions?.session?.loginWithPassword?.({
166
+ email: trimmedEmail,
167
+ password
168
+ }) ?? [];
169
+ if (errors.length > 0) {
170
+ setFormError(mapSessionErrorMessage(errors[0], {
171
+ invalidCredentialsMessage,
172
+ blockedMessage,
173
+ networkErrorMessage,
174
+ genericErrorMessage
175
+ }));
176
+ setPassword("");
177
+ }
178
+ } finally {
179
+ setPending(false);
180
+ }
181
+ }
182
+ return /* @__PURE__ */ jsxs("form", {
183
+ className,
184
+ "data-fs-sign-in-form": "",
185
+ ...pending ? { "data-fs-sign-in-form-pending": "" } : {},
186
+ onSubmit: handleSubmit,
187
+ children: [
188
+ /* @__PURE__ */ jsx(EmailField, {
189
+ label: emailLabel,
190
+ placeholder: emailPlaceholder,
191
+ value: email,
192
+ disabled: pending,
193
+ invalid: emailError != null,
194
+ errorMessage: emailError ?? void 0,
195
+ onValueChange: handleEmailChange,
196
+ required: true
197
+ }),
198
+ /* @__PURE__ */ jsx(PasswordField, {
199
+ label: passwordLabel,
200
+ placeholder: passwordPlaceholder,
201
+ value: password,
202
+ disabled: pending,
203
+ invalid: passwordError != null,
204
+ errorMessage: passwordError ?? void 0,
205
+ showPasswordLabel,
206
+ hidePasswordLabel,
207
+ onValueChange: handlePasswordChange
208
+ }),
209
+ formError ? /* @__PURE__ */ jsx("div", {
210
+ "data-fs-sign-in-form-error": "",
211
+ role: "alert",
212
+ children: formError
213
+ }) : null,
214
+ /* @__PURE__ */ jsx(Button, {
215
+ type: "submit",
216
+ disabled: pending,
217
+ "data-fs-sign-in-form-submit": "",
218
+ children: submitLabel
219
+ })
220
+ ]
221
+ });
222
+ }
223
+ //#endregion
224
+ export { SignInForm, SignInFormDefinition, mapSessionErrorMessage };
225
+
226
+ //# sourceMappingURL=sign-in-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in-form.js","names":[],"sources":["../../../src/matter/sign-in-form/sign-in-form.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { FormEvent } from 'react';\nimport { useEffect, useState } from 'react';\nimport { Button } from '../../particles/button/button.js';\nimport { EmailField, isValidEmail } from '../../particles/email-field/email-field.js';\nimport { PasswordField } from '../../particles/password-field/password-field.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport type { SessionUserError } from '../../sdk/session/auth-operations.js';\nimport { useSession } from '../session/session.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment (colocated, ADR-0011) — reads only clientProfile.email, the minimal slice this\n// matter owns for the pre-fill. Authored as a raw string (not the codegen graphql() factory),\n// mirroring EmailIdentificationControl; the compiler derives the entity fragment on `clientProfile`\n// and subscribes reactively.\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment SignInFormData on Query {\n clientProfile {\n __typename\n id\n email\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** ClientProfile slice forwarded by the reactive runtime — only `email` is consumed for pre-fill. */\nexport type SignInFormSlice = Readonly<{ email?: string | null }>;\n\nexport type SignInFormMessages = Readonly<{\n invalidCredentialsMessage: string;\n blockedMessage: string;\n networkErrorMessage: string;\n genericErrorMessage: string;\n}>;\n\nexport type SignInFormProps = Readonly<{\n emailLabel?: string;\n emailPlaceholder?: string;\n passwordLabel?: string;\n passwordPlaceholder?: string;\n showPasswordLabel?: string;\n hidePasswordLabel?: string;\n submitLabel?: string;\n /** Inline error for an invalid email format (mirrors EmailIdentificationControl). */\n invalidEmailMessage?: string;\n /** Inline error when the password field is submitted empty (this form owns the presence check). */\n passwordRequiredMessage?: string;\n invalidCredentialsMessage?: string;\n blockedMessage?: string;\n networkErrorMessage?: string;\n genericErrorMessage?: string;\n /** ClientProfile slice forwarded by the reactive runtime; `null` until the entity resolves. */\n $data?: SignInFormSlice | null;\n /** Compiler-injected action surface; carries `session.loginWithPassword`. */\n $actions?: ComponentActions;\n className?: string;\n}>;\n\n// ---------------------------------------------------------------------------\n// Error mapping — pure, unit-tested.\n// ---------------------------------------------------------------------------\n\n/**\n * Maps the first resolved SessionUserError to caller-configurable copy. INVALID_ACCESS_CODE,\n * ACCESS_CODE_SEND_LIMIT, and MISSING_AUTH_CONTEXT are contractually unreachable from\n * loginWithPassword but share the untyped `code: string` field, so they fall through to the\n * generic message defensively, alongside any future/unknown code.\n */\nexport function mapSessionErrorMessage(\n error: SessionUserError | undefined,\n messages: SignInFormMessages,\n): string | null {\n if (!error) return null;\n switch (error.code) {\n case 'INVALID_CREDENTIALS':\n return messages.invalidCredentialsMessage;\n case 'BLOCKED':\n return messages.blockedMessage;\n case 'NETWORK_ERROR':\n return messages.networkErrorMessage;\n default:\n return messages.genericErrorMessage;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const SignInFormDefinition = defineComponent<SignInFormProps>({\n name: 'SignInForm',\n importPath: '@vtex/faststore/components',\n component: SignInForm,\n fragment,\n fetchStrategy: 'reactive',\n actions: { session: ['loginWithPassword'] },\n requiresContext: 'session',\n editor: { label: 'Sign In Form', category: 'identity' },\n schema: {\n emailLabel: { type: 'string', default: 'Email', label: 'Email label' },\n emailPlaceholder: { type: 'string', default: 'you@example.com', label: 'Email placeholder' },\n passwordLabel: { type: 'string', default: 'Password', label: 'Password label' },\n passwordPlaceholder: { type: 'string', default: '', label: 'Password placeholder' },\n showPasswordLabel: { type: 'string', default: 'Show password', label: 'Show password label' },\n hidePasswordLabel: { type: 'string', default: 'Hide password', label: 'Hide password label' },\n submitLabel: { type: 'string', default: 'Sign In', label: 'Submit label' },\n invalidEmailMessage: { type: 'string', default: 'Enter a valid email address.', label: 'Invalid email message' },\n passwordRequiredMessage: {\n type: 'string',\n default: 'Enter your password.',\n label: 'Password required message',\n },\n invalidCredentialsMessage: {\n type: 'string',\n default: 'Incorrect email or password. Please try again.',\n label: 'Invalid credentials message',\n },\n blockedMessage: {\n type: 'string',\n default: 'This account has been blocked. Please contact support.',\n label: 'Blocked account message',\n },\n networkErrorMessage: {\n type: 'string',\n default: 'Unable to complete the request. Please try again.',\n label: 'Network error message',\n },\n genericErrorMessage: {\n type: 'string',\n default: 'Unable to sign in. Please try again.',\n label: 'Generic error message',\n },\n },\n guideline:\n 'Combined email+password sign-in form dispatching $actions.session.loginWithPassword; pre-fills the email from clientProfile.email, self-hides once the session is loggedIn, and exposes data-fs-sign-in-form-pending while the submit is in flight. Must be inside SessionRoot. See sign-in-form.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Matter that composes `EmailField` + `PasswordField` under one submit and dispatches\n * `$actions.session.loginWithPassword`. Reads the email pre-fill from `clientProfile.email`\n * (colocated reactive fragment) and the identity tri-state from `useSession()` (which also\n * enforces the `SessionRoot` ancestor), self-gating to `null` once the shopper is `loggedIn`.\n * Client-side validation (email format, password presence) blocks the dispatch before any network\n * round trip; the awaited dispatch's `userErrors` map to one form-level inline message, distinct\n * from any ancestor `UNAUTHORIZED` gate. While the write is in flight the form is disabled and\n * `data-fs-sign-in-form-pending` is present so a checkout-CTA guard can block.\n */\nexport function SignInForm({\n emailLabel,\n emailPlaceholder,\n passwordLabel,\n passwordPlaceholder,\n showPasswordLabel,\n hidePasswordLabel,\n submitLabel = 'Sign In',\n invalidEmailMessage = 'Enter a valid email address.',\n passwordRequiredMessage = 'Enter your password.',\n invalidCredentialsMessage = 'Incorrect email or password. Please try again.',\n blockedMessage = 'This account has been blocked. Please contact support.',\n networkErrorMessage = 'Unable to complete the request. Please try again.',\n genericErrorMessage = 'Unable to sign in. Please try again.',\n $data: $dataProp,\n $actions,\n className,\n}: SignInFormProps) {\n const $data = useDataOverride($dataProp);\n // Reads the tri-state for self-gating and, as a side effect, throws when rendered outside\n // <SessionRoot> — called unconditionally, before any early return.\n const { state } = useSession();\n\n const savedEmail = $data?.email ?? '';\n const [email, setEmail] = useState(savedEmail);\n const [password, setPassword] = useState('');\n const [pending, setPending] = useState(false);\n const [emailError, setEmailError] = useState<string | null>(null);\n const [passwordError, setPasswordError] = useState<string | null>(null);\n const [formError, setFormError] = useState<string | null>(null);\n\n // Sync the pre-fill when the saved profile email resolves or changes, mirroring\n // EmailIdentificationControl's pre-fill sync.\n useEffect(() => {\n setEmail(savedEmail);\n }, [savedEmail]);\n\n // An already-authenticated shopper is never offered a sign-in form.\n if (state === 'loggedIn') return null;\n\n function handleEmailChange(next: string) {\n setEmail(next);\n if (emailError) setEmailError(null);\n }\n\n function handlePasswordChange(next: string) {\n setPassword(next);\n if (passwordError) setPasswordError(null);\n }\n\n async function handleSubmit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n\n const trimmedEmail = email.trim();\n if (!isValidEmail(trimmedEmail)) {\n setEmailError(invalidEmailMessage);\n return;\n }\n\n if (password.length === 0) {\n setPasswordError(passwordRequiredMessage);\n return;\n }\n\n // Client-side checks passed — clear any prior field-level/form-level errors before dispatching.\n setEmailError(null);\n setPasswordError(null);\n setFormError(null);\n setPending(true);\n\n try {\n // Awaited (async/pessimistic): the cache flip is read on the next render via useSession(),\n // never assumed here.\n const errors = (await $actions?.session?.loginWithPassword?.({ email: trimmedEmail, password })) ?? [];\n\n if (errors.length > 0) {\n setFormError(\n mapSessionErrorMessage(errors[0], {\n invalidCredentialsMessage,\n blockedMessage,\n networkErrorMessage,\n genericErrorMessage,\n }),\n );\n // Credential hygiene: drop the rejected password, keep the email.\n setPassword('');\n }\n } finally {\n setPending(false);\n }\n }\n\n return (\n <form\n className={className}\n data-fs-sign-in-form=\"\"\n {...(pending ? { 'data-fs-sign-in-form-pending': '' } : {})}\n onSubmit={handleSubmit}\n >\n <EmailField\n label={emailLabel}\n placeholder={emailPlaceholder}\n value={email}\n disabled={pending}\n invalid={emailError != null}\n errorMessage={emailError ?? undefined}\n onValueChange={handleEmailChange}\n required\n />\n <PasswordField\n label={passwordLabel}\n placeholder={passwordPlaceholder}\n value={password}\n disabled={pending}\n invalid={passwordError != null}\n errorMessage={passwordError ?? undefined}\n showPasswordLabel={showPasswordLabel}\n hidePasswordLabel={hidePasswordLabel}\n onValueChange={handlePasswordChange}\n />\n {formError ? (\n <div data-fs-sign-in-form-error=\"\" role=\"alert\">\n {formError}\n </div>\n ) : null}\n <Button type=\"submit\" disabled={pending} data-fs-sign-in-form-submit=\"\">\n {submitLabel}\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,WAAyB;;;;;;;;;;;;;;;A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AE;GAChB;EACF,UAAU;GACR,WAAW,KAAK;EAClB;CACF;CAEA,OACE,qBAAC,QAAD;EACa;EACX,wBAAqB;EACrB,GAAK,UAAU,EAAE,gCAAgC,GAAG,IAAI,CAAC;EACzD,UAAU;EAJZ,UAAA;GAME,oBAAC,YAAD;IACE,OAAO;IACP,aAAa;IACb,OAAO;IACP,UAAU;IACV,SAAS,cAAc;IACvB,cAAc,cAAc,KAAA;IAC5B,eAAe;IACf,UAAA;GACD,CAAA;GACD,oBAAC,eAAD;IACE,OAAO;IACP,aAAa;IACb,OAAO;IACP,UAAU;IACV,SAAS,iBAAiB;IAC1B,cAAc,iBAAiB,KAAA;IACZ;IACA;IACnB,eAAe;GAChB,CAAA;GACA,YACC,oBAAC,OAAD;IAAK,8BAA2B;IAAG,MAAK;IACrC,UAAA;GACE,CAAA,IACH;GACJ,oBAAC,QAAD;IAAQ,MAAK;IAAS,UAAU;IAAS,+BAA4B;IAClE,UAAA;GACK,CAAA;EACJ;;AAEV"}
@@ -0,0 +1,183 @@
1
+ import { ComponentDefinition } from "../../core/dist/define-component.js";
2
+ import "../../core/dist/index.js";
3
+ import { VariantSelectorDataFragment } from "../../sdk/generated/graphql.js";
4
+ import { ComponentPropsWithRef, FunctionComponent } from "react";
5
+ //#region src/matter/variant-selector/variant-selector.d.ts
6
+ type ProductSlice = NonNullable<VariantSelectorDataFragment['productBySlug']>;
7
+ /** Per-value swatch media. `imageUrl`/`alt` are derived from the matching variant's primary image
8
+ * (`Variant.images`) so the `image`/`auto` display modes work from live data. `hexColor` has no
9
+ * Core Graph source (`ProductOption.values: [String!]!`) and is populated only when a host injects
10
+ * it through context — see specs/sku-selector.md gap row 2. */
11
+ export type VariantSelectorSwatch = {
12
+ hexColor?: string;
13
+ imageUrl?: string;
14
+ alt?: string;
15
+ };
16
+ export type VariantSelectorOptionData = {
17
+ value: string;
18
+ available: boolean;
19
+ variantId: string | null;
20
+ swatch?: VariantSelectorSwatch;
21
+ };
22
+ export type VariantSelectorAxis = {
23
+ name: string;
24
+ activeValue: string | null;
25
+ options: VariantSelectorOptionData[];
26
+ };
27
+ export type VariantSelectorContextValue = {
28
+ axes: VariantSelectorAxis[];
29
+ selectedVariantId: string | null;
30
+ select: (axisName: string, value: string) => void;
31
+ } | null;
32
+ /** Provided by `VariantSelectorOptionGroup` to its composed parts (title, swatch list, overflow, and the
33
+ * options the list renders). The group owns the axis binding and the collapse/expand state; the parts read
34
+ * what they need from here, so the author can place them freely — e.g. the title in an accordion header
35
+ * and the swatch list in its panel. */
36
+ type VariantSelectorGroupContextValue = {
37
+ axis: VariantSelectorAxis;
38
+ /** Stable id shared by the title (`id`) and the swatch list (`aria-labelledby`) to label the radiogroup. */
39
+ titleId: string;
40
+ /** Whether a `VariantSelectorGroupTitle` is composed in this group. The swatch list points its
41
+ * `aria-labelledby` at the title only when one exists; otherwise it relies on the `aria-label`
42
+ * axis-name floor, so the radiogroup is never labelled by a dangling idref. */
43
+ hasTitle: boolean;
44
+ /** Registers a mounted `VariantSelectorGroupTitle`, returning an unregister for cleanup. Ref-counted so
45
+ * the title can be placed freely (e.g. an accordion header) and still flip `hasTitle`. */
46
+ registerTitle: () => () => void;
47
+ /** Registers a mounted `VariantSelectorOverflow`, returning an unregister for cleanup. Ref-counted like
48
+ * `registerTitle`, so the trigger can be placed freely and still flip `hasOverflow`. Space-based collapse
49
+ * runs only while a trigger is composed, so hidden swatches always have a reveal affordance. */
50
+ registerOverflow: () => () => void;
51
+ /** Whether a `VariantSelectorOverflow` is composed in this group — gates the measured collapse. */
52
+ hasOverflow: boolean;
53
+ /** Ref callback the swatch list hands its container element to, so the group can measure the row width. */
54
+ registerListElement: (el: HTMLElement | null) => void;
55
+ visibleOptions: VariantSelectorOptionData[];
56
+ hiddenCount: number;
57
+ overflowing: boolean;
58
+ expand: () => void;
59
+ /** Activates `value` on this group's axis. */
60
+ select: (value: string) => void;
61
+ ImageComponent: FunctionComponent<{
62
+ src: string;
63
+ alt: string;
64
+ }>;
65
+ };
66
+ export type VariantSelectorRootProps = ComponentPropsWithRef<'div'> & {
67
+ $data?: ProductSlice | null;
68
+ /** Pre-selects the variant the page is showing (the viewed SKU) before the shopper interacts.
69
+ * `productBySlug` resolves to the product group, so the page supplies the viewed variant id here
70
+ * — mirroring `ProductGalleryRoot.selectedVariantId`. The published `selectedVariantVar` wins
71
+ * once a swatch is activated; this prop is only the initial fallback. */
72
+ selectedVariantId?: string;
73
+ };
74
+ export type VariantSelectorOptionGroupProps = ComponentPropsWithRef<'div'> & {
75
+ /** Catalog `ProductOption.name` this group binds (e.g. `"Color"`). Matched case/accent/whitespace-
76
+ * insensitively but otherwise exactly — the runtime does no plural or translation guessing. Use this
77
+ * only when the exact catalog name is known; otherwise bind by `optionIndex`. When both are given, a
78
+ * successful name match wins and `optionIndex` is the fallback. */
79
+ optionName?: string;
80
+ /** Zero-based axis position, in the order the product defines its options. The preferred binding for
81
+ * generated schemas: the author places one group per axis in visual top-to-bottom order, which lines
82
+ * up with the product's option order — reliable even when the on-image label differs from the catalog
83
+ * name. Used when `optionName` is absent or does not match any axis. */
84
+ optionIndex?: number;
85
+ /** Reserve space for the `VariantSelectorOverflow` trigger in the fit calculation. Off by default: the
86
+ * trigger is a sibling of the swatch list (its own space), so the swatches use the full row width. Turn
87
+ * it on only when the trigger is styled inline at the end of the swatch row (content-sized) so it stays
88
+ * on the line — its measured width is then subtracted from the space available to the swatches. */
89
+ reserveTriggerSpace?: boolean;
90
+ /** Image renderer used by image/color swatches; defaults to a plain `<img>`. Hosts inject e.g. next/image. */
91
+ ImageComponent?: FunctionComponent<{
92
+ src: string;
93
+ alt: string;
94
+ }>;
95
+ };
96
+ /** Title for a `VariantSelectorOptionGroup`: renders the axis name (or your `label`). Reads the axis from
97
+ * group context, so it can be placed anywhere inside the group (e.g. an accordion header). Compose a
98
+ * `VariantSelectorGroupValue` beside it to echo the live selection — the separator, weight, and spacing
99
+ * between the two are brand styling on the `data-fs-*` hooks, not baked into this component. */
100
+ export type VariantSelectorGroupTitleProps = Omit<ComponentPropsWithRef<'span'>, 'children'> & {
101
+ /** Overrides the displayed axis name. Defaults to the catalog axis name (e.g. `"Color"`). Use it to match
102
+ * a design's prompt copy such as `"Selecione a cor"`; it never changes which axis the group binds. Any
103
+ * separator (e.g. a trailing colon) is styling — add it to the title's `data-fs-*` hook, not the text. */
104
+ label?: string;
105
+ };
106
+ /** The live selected value of a `VariantSelectorOptionGroup`, as a standalone placeable part (e.g. beside
107
+ * the title inside a container). Decorative/`aria-hidden`: the selection is already announced per option,
108
+ * so echoing it here would make the group's accessible name churn on every change. */
109
+ export type VariantSelectorGroupValueProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;
110
+ /** The swatch list for a `VariantSelectorOptionGroup`: a radiogroup of the axis' option swatches,
111
+ * auto-rendered from the product data. The component chooses the swatch look — `VariantSelectorSwatches`
112
+ * infers it, the explicit variants fix it — so the kind is selected by composition, not a prop. */
113
+ export type VariantSelectorSwatchesProps = Omit<ComponentPropsWithRef<'div'>, 'children' | 'defaultValue'>;
114
+ /** The "+N more" trigger for a `VariantSelectorOptionGroup`: composing it opts the group into measured,
115
+ * space-based collapse, and it renders only while the row actually overflows, expanding it in place.
116
+ * Reads the hidden count and expand action from group context. */
117
+ export type VariantSelectorOverflowProps = Omit<ComponentPropsWithRef<'button'>, 'children'>;
118
+ export type VariantSelectorOptionProps = {
119
+ value: string;
120
+ className?: string;
121
+ ImageComponent?: FunctionComponent<{
122
+ src: string;
123
+ alt: string;
124
+ }>;
125
+ };
126
+ /** Exposed for advanced composition and tests that mount group/option in isolation. */
127
+ export declare const VariantSelectorContext: React.Context<VariantSelectorContextValue>;
128
+ export declare const VariantSelectorGroupContext: import("react").Context<VariantSelectorGroupContextValue | null>;
129
+ export declare const VariantSelectorRootDefinition: ComponentDefinition<VariantSelectorRootProps>;
130
+ export declare const VariantSelectorOptionGroupDefinition: ComponentDefinition<VariantSelectorOptionGroupProps>;
131
+ export declare const VariantSelectorGroupTitleDefinition: ComponentDefinition<VariantSelectorGroupTitleProps>;
132
+ export declare const VariantSelectorGroupValueDefinition: ComponentDefinition<VariantSelectorGroupValueProps>;
133
+ export declare const VariantSelectorSwatchesDefinition: ComponentDefinition<VariantSelectorSwatchesProps>;
134
+ export declare const VariantSelectorLabelSwatchesDefinition: ComponentDefinition<VariantSelectorSwatchesProps>;
135
+ export declare const VariantSelectorImageSwatchesDefinition: ComponentDefinition<VariantSelectorSwatchesProps>;
136
+ export declare const VariantSelectorColorSwatchesDefinition: ComponentDefinition<VariantSelectorSwatchesProps>;
137
+ export declare const VariantSelectorRadioSwatchesDefinition: ComponentDefinition<VariantSelectorSwatchesProps>;
138
+ export declare const VariantSelectorOverflowDefinition: ComponentDefinition<VariantSelectorOverflowProps>;
139
+ export declare const VariantSelectorOptionDefinition: ComponentDefinition<VariantSelectorOptionProps>;
140
+ export declare function VariantSelectorRoot({ $data: $dataProp, selectedVariantId, className, children, ...props }: VariantSelectorRootProps): import("react/jsx-runtime").JSX.Element;
141
+ /** Axis container: binds the axis and owns the collapse/expand state, then renders whatever the author
142
+ * composes inside it (title, a swatch list, an overflow trigger). The parts read the axis and overflow
143
+ * state from the group context it provides, so they can be placed freely. */
144
+ export declare function VariantSelectorOptionGroup({ optionName, optionIndex, reserveTriggerSpace, ImageComponent, className, children, ...props }: VariantSelectorOptionGroupProps): import("react/jsx-runtime").JSX.Element | null;
145
+ /** The axis name (the catalog axis name or `label`). Reads the axis from group context, so it reflects
146
+ * the bound axis wherever it is placed (including an accordion header). It is a `<span>`, not a `<label>`:
147
+ * it names the radiogroup via `aria-labelledby`, not a single control. Compose a `VariantSelectorGroupValue`
148
+ * beside it to echo the selection; the separator and value weight are styling on the `data-fs-*` hooks. */
149
+ export declare function VariantSelectorGroupTitle({ label, className, ...props }: VariantSelectorGroupTitleProps): import("react/jsx-runtime").JSX.Element;
150
+ /** The live selected value of the group's axis, as a standalone placeable part. Decorative (`aria-hidden`):
151
+ * the selection is announced per option, so it never participates in the group's accessible name. */
152
+ export declare function VariantSelectorGroupValue({ className, ...props }: VariantSelectorGroupValueProps): import("react/jsx-runtime").JSX.Element;
153
+ /** Auto-inferring swatch list: derives the look from the option data (color/image/label, never radio).
154
+ * Use an explicit sibling list to fix the look instead of inferring it. */
155
+ export declare function VariantSelectorSwatches(props: VariantSelectorSwatchesProps): import("react/jsx-runtime").JSX.Element;
156
+ /** Swatch list with text-label swatches. */
157
+ export declare function VariantSelectorLabelSwatches(props: VariantSelectorSwatchesProps): import("react/jsx-runtime").JSX.Element;
158
+ /** Swatch list with image (thumbnail) swatches. */
159
+ export declare function VariantSelectorImageSwatches(props: VariantSelectorSwatchesProps): import("react/jsx-runtime").JSX.Element;
160
+ /** Swatch list with color-chip swatches (degrades per value to image, then label). */
161
+ export declare function VariantSelectorColorSwatches(props: VariantSelectorSwatchesProps): import("react/jsx-runtime").JSX.Element;
162
+ /** Swatch list rendered as a radio-dot list (control circle + dot + label). */
163
+ export declare function VariantSelectorRadioSwatches(props: VariantSelectorSwatchesProps): import("react/jsx-runtime").JSX.Element;
164
+ /** The "+N more" trigger: composing it opts the group into space-based collapse (via `registerOverflow`),
165
+ * and it renders only while the row overflows, expanding it in place when clicked. Registers in a
166
+ * layout effect so the group can measure and collapse before the browser paints (no full-row flash). */
167
+ export declare function VariantSelectorOverflow({ className, ...props }: VariantSelectorOverflowProps): import("react/jsx-runtime").JSX.Element | null;
168
+ export declare function VariantSelectorOption({ value, ImageComponent, className }: Readonly<VariantSelectorOptionProps>): import("react/jsx-runtime").JSX.Element | null;
169
+ export declare const VariantSelector: {
170
+ Root: typeof VariantSelectorRoot;
171
+ OptionGroup: typeof VariantSelectorOptionGroup;
172
+ Title: typeof VariantSelectorGroupTitle;
173
+ Value: typeof VariantSelectorGroupValue;
174
+ Swatches: typeof VariantSelectorSwatches;
175
+ LabelSwatches: typeof VariantSelectorLabelSwatches;
176
+ ImageSwatches: typeof VariantSelectorImageSwatches;
177
+ ColorSwatches: typeof VariantSelectorColorSwatches;
178
+ RadioSwatches: typeof VariantSelectorRadioSwatches;
179
+ Overflow: typeof VariantSelectorOverflow;
180
+ Option: typeof VariantSelectorOption;
181
+ };
182
+ //#endregion
183
+ //# sourceMappingURL=variant-selector.d.ts.map