@zonos/elements 1.3.5 → 1.3.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/dist/cjs/ILanguage-d247b45b.js +26 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/{localization-d43e1540.js → cart-ecc80eb0.js} +1086 -2
  4. package/dist/cjs/{getBorderRadius-cd7ef574.js → getBorderRadius-834c321d.js} +8 -4
  5. package/dist/cjs/index.cjs.js +0 -21
  6. package/dist/cjs/{isDarkColor-5eda1323.js → isDarkColor-924e6a7a.js} +1 -1
  7. package/dist/cjs/loader.cjs.js +5 -3
  8. package/dist/cjs/{submitGtag-bd6e9b42.js → submitGtag-907e71d3.js} +3 -3
  9. package/dist/cjs/zonos-address_4.cjs.entry.js +301 -0
  10. package/dist/cjs/zonos-badge_2.cjs.entry.js +57 -0
  11. package/dist/cjs/zonos-banner.cjs.entry.js +4 -9
  12. package/dist/cjs/{zonos-button_2.cjs.entry.js → zonos-button_3.cjs.entry.js} +42 -15
  13. package/dist/cjs/zonos-card_2.cjs.entry.js +28 -14
  14. package/dist/cjs/{zonos-cart-items_10.cjs.entry.js → zonos-cart-items_9.cjs.entry.js} +98 -99
  15. package/dist/cjs/zonos-checkout.cjs.entry.js +25 -27
  16. package/dist/cjs/zonos-component.cjs.entry.js +2 -2
  17. package/dist/cjs/zonos-controller.cjs.entry.js +29 -30
  18. package/dist/cjs/zonos-country-flag.cjs.entry.js +42 -0
  19. package/dist/cjs/{zonos-country-flag_4.cjs.entry.js → zonos-country-select_3.cjs.entry.js} +31 -56
  20. package/dist/cjs/zonos-elements.cjs.js +6 -4
  21. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +29 -22
  22. package/dist/cjs/zonos-hello.cjs.entry.js +35 -33
  23. package/dist/cjs/zonos-logo.cjs.entry.js +32 -0
  24. package/dist/cjs/zonos-notification.cjs.entry.js +5 -6
  25. package/dist/cjs/zonos-payment.cjs.entry.js +6 -7
  26. package/dist/cjs/zonos-select-dialog-header_2.cjs.entry.js +45 -0
  27. package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +4 -4
  28. package/dist/cjs/zonos-text.cjs.entry.js +4 -6
  29. package/dist/cjs/{zonosStore-b88b5671.js → zonosStore-49d4c92a.js} +5 -5
  30. package/dist/collection/collection-manifest.json +6 -1
  31. package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +1 -1
  32. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +13 -8
  33. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/chevronDownIcon.svg +1 -0
  34. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/globe.svg +3 -0
  35. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/assets/zonosIcon.svg +5 -0
  36. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.css +126 -0
  37. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.js +60 -0
  38. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +1 -1
  39. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.css +12 -21
  40. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -5
  41. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.css +11 -1
  42. package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
  43. package/dist/collection/components/checkout/zonos-checkout/zonos-review/zonos-review.js +3 -3
  44. package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +1 -1
  45. package/dist/collection/components/common/zonos-badge/zonos-badge.js +7 -26
  46. package/dist/collection/components/common/zonos-banner/zonos-banner.js +2 -25
  47. package/dist/collection/components/common/zonos-button/zonos-button.css +18 -0
  48. package/dist/collection/components/common/zonos-button/zonos-button.js +9 -28
  49. package/dist/collection/components/common/zonos-card/zonos-card.js +2 -20
  50. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.css +82 -0
  51. package/dist/collection/components/common/zonos-checkbox/zonos-checkbox.js +218 -0
  52. package/dist/collection/components/common/zonos-collapse/zonos-collapse.js +15 -2
  53. package/dist/collection/components/common/zonos-country-flag/zonos-country-flag.js +1 -20
  54. package/dist/collection/components/common/zonos-country-select/assets/greenCheckDuotone.svg +4 -0
  55. package/dist/collection/components/common/zonos-country-select/zonos-country-select.css +11 -10
  56. package/dist/collection/components/common/zonos-country-select/zonos-country-select.js +7 -11
  57. package/dist/collection/components/common/zonos-custom-message/zonos-custom-message.js +2 -2
  58. package/dist/collection/components/common/zonos-dialog/zonos-dialog.js +3 -3
  59. package/dist/collection/components/common/zonos-icon/zonos-icon.js +4 -4
  60. package/dist/collection/components/common/zonos-language-select/assets/greenCheckDuotone.svg +4 -0
  61. package/dist/collection/components/common/zonos-language-select/zonos-language-select.css +61 -0
  62. package/dist/collection/components/common/zonos-language-select/zonos-language-select.js +58 -0
  63. package/dist/collection/components/common/zonos-logo/zonos-logo.js +2 -21
  64. package/dist/collection/components/common/zonos-notification/zonos-notification.js +3 -26
  65. package/dist/collection/components/common/zonos-select-dialog-header/assets/removeIcon.svg +1 -0
  66. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.css +45 -0
  67. package/dist/collection/components/common/zonos-select-dialog-header/zonos-select-dialog-header.js +68 -0
  68. package/dist/collection/components/common/zonos-shipping-rich-radio/zonos-shipping-rich-radio.js +1 -1
  69. package/dist/collection/components/common/zonos-spinner/zonos-spinner.js +4 -4
  70. package/dist/collection/components/common/zonos-text/zonos-text.js +4 -24
  71. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.css +55 -0
  72. package/dist/collection/components/common/zonos-tooltip/zonos-tooltip.js +72 -0
  73. package/dist/collection/components/common/zonos-v-stack/zonos-v-stack.js +2 -21
  74. package/dist/collection/components/component-template/zonos-component/zonos-component.js +1 -1
  75. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/assets/globe.svg +3 -0
  76. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.css +10 -0
  77. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.js +27 -5
  78. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.css +16 -2
  79. package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +11 -5
  80. package/dist/collection/components/main/zonos-controller.js +1 -1
  81. package/dist/collection/components/store/checkout/stripe.js +31 -7
  82. package/dist/collection/components/store/hello/localization.js +32 -2
  83. package/dist/collection/components/store/translationStore/strings.arabic.js +18 -0
  84. package/dist/collection/components/store/translationStore/strings.base.js +18 -0
  85. package/dist/collection/components/store/translationStore/strings.chinese.js +18 -0
  86. package/dist/collection/components/store/translationStore/strings.danish.js +18 -0
  87. package/dist/collection/components/store/translationStore/strings.dutch.js +18 -0
  88. package/dist/collection/components/store/translationStore/strings.french.js +18 -0
  89. package/dist/collection/components/store/translationStore/strings.german.js +18 -0
  90. package/dist/collection/components/store/translationStore/strings.hebrew.js +18 -0
  91. package/dist/collection/components/store/translationStore/strings.indonesian.js +18 -0
  92. package/dist/collection/components/store/translationStore/strings.italian.js +18 -0
  93. package/dist/collection/components/store/translationStore/strings.japanese.js +18 -0
  94. package/dist/collection/components/store/translationStore/strings.korean.js +18 -0
  95. package/dist/collection/components/store/translationStore/strings.norwegian.js +18 -0
  96. package/dist/collection/components/store/translationStore/strings.polish.js +18 -0
  97. package/dist/collection/components/store/translationStore/strings.portuguese.js +18 -0
  98. package/dist/collection/components/store/translationStore/strings.russian.js +18 -0
  99. package/dist/collection/components/store/translationStore/strings.spanish.js +18 -0
  100. package/dist/collection/components/store/translationStore/strings.swedish.js +18 -0
  101. package/dist/collection/components/store/translationStore/strings.turkish.js +18 -0
  102. package/dist/collection/components/store/translationStore/strings.vietnamese.js +18 -0
  103. package/dist/collection/components/store/zonosStore.js +4 -4
  104. package/dist/collection/components/stripe/zonos-address/zonos-address.js +63 -24
  105. package/dist/collection/components/stripe/zonos-link-authentication/zonos-link-authentication.js +1 -1
  106. package/dist/collection/components/stripe/zonos-payment/zonos-payment.js +1 -1
  107. package/dist/collection/components/utils/api/prepCalculateLandedCost.js +19 -1
  108. package/dist/collection/components/utils/api/triggerBuildLandedCost.js +11 -5
  109. package/dist/collection/components/utils/getBorderRadius.js +7 -3
  110. package/dist/collection/types/ILanguage.js +22 -0
  111. package/dist/collection/types/generated/graphql.customer.types.js +19 -0
  112. package/dist/collection/types/index.js +0 -1
  113. package/dist/collection/types/styles/Color.js +9 -0
  114. package/dist/components/ILanguage.js +24 -0
  115. package/dist/components/getBorderRadius.js +7 -3
  116. package/dist/components/index.js +0 -1
  117. package/dist/components/isDarkColor.js +1 -1
  118. package/dist/components/{localization.js → stripe.js} +1070 -2
  119. package/dist/components/submitGtag.js +1 -1
  120. package/dist/components/zonos-address2.js +64 -26
  121. package/dist/components/zonos-badge2.js +8 -10
  122. package/dist/components/zonos-banner2.js +3 -9
  123. package/dist/components/zonos-button2.js +10 -12
  124. package/dist/components/zonos-card2.js +3 -5
  125. package/dist/components/zonos-cart-items2.js +1 -1
  126. package/dist/components/zonos-cart-subtotal2.js +14 -9
  127. package/dist/components/zonos-checkbox.d.ts +11 -0
  128. package/dist/components/zonos-checkbox.js +6 -0
  129. package/dist/components/zonos-checkbox2.js +87 -0
  130. package/dist/components/zonos-checkout-finish2.js +15 -7
  131. package/dist/components/zonos-checkout-footer.d.ts +11 -0
  132. package/dist/components/zonos-checkout-footer.js +6 -0
  133. package/dist/components/zonos-checkout-footer2.js +109 -0
  134. package/dist/components/zonos-checkout-payment2.js +2 -3
  135. package/dist/components/zonos-checkout.js +74 -52
  136. package/dist/components/zonos-collapse2.js +16 -3
  137. package/dist/components/zonos-component.js +1 -1
  138. package/dist/components/zonos-controller.js +3 -4
  139. package/dist/components/zonos-country-flag2.js +3 -5
  140. package/dist/components/zonos-country-select2.js +26 -19
  141. package/dist/components/zonos-custom-message2.js +3 -3
  142. package/dist/components/zonos-customer-info2.js +30 -11
  143. package/dist/components/zonos-dialog2.js +4 -4
  144. package/dist/components/zonos-hello-dialog-footer2.js +23 -10
  145. package/dist/components/zonos-hello-dialog2.js +41 -23
  146. package/dist/components/zonos-hello.js +31 -19
  147. package/dist/components/zonos-icon2.js +4 -4
  148. package/dist/components/zonos-language-select.d.ts +11 -0
  149. package/dist/components/zonos-language-select.js +6 -0
  150. package/dist/components/zonos-language-select2.js +87 -0
  151. package/dist/components/zonos-link-authentication2.js +2 -2
  152. package/dist/components/zonos-logo.js +44 -1
  153. package/dist/components/zonos-notification2.js +4 -6
  154. package/dist/components/zonos-payment2.js +2 -2
  155. package/dist/components/zonos-review2.js +4 -5
  156. package/dist/components/zonos-select-dialog-header.d.ts +11 -0
  157. package/dist/components/zonos-select-dialog-header.js +6 -0
  158. package/dist/components/zonos-select-dialog-header2.js +71 -0
  159. package/dist/components/zonos-shipping-rich-radio2.js +2 -2
  160. package/dist/components/zonos-shipping2.js +2 -3
  161. package/dist/components/zonos-spinner2.js +3 -3
  162. package/dist/components/zonos-text2.js +4 -7
  163. package/dist/components/zonos-tooltip.d.ts +11 -0
  164. package/dist/components/zonos-tooltip.js +6 -0
  165. package/dist/components/zonos-tooltip2.js +48 -0
  166. package/dist/components/zonos-v-stack2.js +4 -6
  167. package/dist/components/zonosStore.js +5 -5
  168. package/dist/esm/ILanguage-97790bee.js +24 -0
  169. package/dist/esm/app-globals-0f993ce5.js +3 -0
  170. package/dist/esm/{localization-5d83fde2.js → cart-2a0a6871.js} +1071 -3
  171. package/dist/esm/getBorderRadius-0c7dfcf0.js +20 -0
  172. package/dist/esm/index.js +1 -6
  173. package/dist/esm/{isDarkColor-8696cb70.js → isDarkColor-d0a57fd2.js} +1 -1
  174. package/dist/esm/loader.js +6 -4
  175. package/dist/esm/{submitGtag-776c5e10.js → submitGtag-a38aed23.js} +2 -2
  176. package/dist/esm/zonos-address_4.entry.js +294 -0
  177. package/dist/esm/zonos-badge_2.entry.js +52 -0
  178. package/dist/esm/zonos-banner.entry.js +4 -9
  179. package/dist/esm/{zonos-button_2.entry.js → zonos-button_3.entry.js} +42 -16
  180. package/dist/esm/zonos-card_2.entry.js +28 -14
  181. package/dist/esm/{zonos-cart-items_10.entry.js → zonos-cart-items_9.entry.js} +86 -86
  182. package/dist/esm/zonos-checkout.entry.js +11 -13
  183. package/dist/esm/zonos-component.entry.js +2 -2
  184. package/dist/esm/zonos-controller.entry.js +6 -7
  185. package/dist/esm/zonos-country-flag.entry.js +38 -0
  186. package/dist/esm/{zonos-country-flag_4.entry.js → zonos-country-select_3.entry.js} +31 -55
  187. package/dist/esm/zonos-elements.js +7 -5
  188. package/dist/esm/zonos-hello-dialog.entry.js +15 -8
  189. package/dist/esm/zonos-hello.entry.js +5 -3
  190. package/dist/esm/zonos-logo.entry.js +28 -0
  191. package/dist/esm/zonos-notification.entry.js +5 -6
  192. package/dist/esm/zonos-payment.entry.js +6 -7
  193. package/dist/esm/zonos-select-dialog-header_2.entry.js +40 -0
  194. package/dist/esm/zonos-shipping-rich-radio.entry.js +4 -4
  195. package/dist/esm/zonos-text.entry.js +4 -6
  196. package/dist/esm/{zonosStore-e59617f8.js → zonosStore-dec6bd7e.js} +5 -5
  197. package/dist/esm-es5/ILanguage-97790bee.js +1 -0
  198. package/dist/esm-es5/app-globals-0f993ce5.js +1 -0
  199. package/dist/esm-es5/cart-2a0a6871.js +1 -0
  200. package/dist/esm-es5/getBorderRadius-0c7dfcf0.js +1 -0
  201. package/dist/esm-es5/index.js +0 -1
  202. package/dist/esm-es5/{isDarkColor-8696cb70.js → isDarkColor-d0a57fd2.js} +1 -1
  203. package/dist/esm-es5/loader.js +1 -1
  204. package/dist/esm-es5/submitGtag-a38aed23.js +1 -0
  205. package/dist/esm-es5/zonos-address_4.entry.js +1 -0
  206. package/dist/esm-es5/zonos-badge_2.entry.js +1 -0
  207. package/dist/esm-es5/zonos-banner.entry.js +1 -1
  208. package/dist/esm-es5/zonos-button_3.entry.js +1 -0
  209. package/dist/esm-es5/zonos-card_2.entry.js +1 -1
  210. package/dist/esm-es5/zonos-cart-items_9.entry.js +1 -0
  211. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  212. package/dist/esm-es5/zonos-component.entry.js +1 -1
  213. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  214. package/dist/esm-es5/zonos-country-flag.entry.js +1 -0
  215. package/dist/esm-es5/zonos-country-select_3.entry.js +1 -0
  216. package/dist/esm-es5/zonos-elements.js +1 -1
  217. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  218. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  219. package/dist/esm-es5/zonos-logo.entry.js +1 -0
  220. package/dist/esm-es5/zonos-notification.entry.js +1 -1
  221. package/dist/esm-es5/zonos-payment.entry.js +1 -1
  222. package/dist/esm-es5/zonos-select-dialog-header_2.entry.js +1 -0
  223. package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
  224. package/dist/esm-es5/zonos-text.entry.js +1 -1
  225. package/dist/esm-es5/{zonosStore-e59617f8.js → zonosStore-dec6bd7e.js} +1 -1
  226. package/dist/scripts/insertTranslations.js +1 -0
  227. package/dist/scripts/loadZonos.js +1 -1
  228. package/dist/scripts/zonos.js +1 -1
  229. package/dist/scripts/zonosBase.js +1 -1
  230. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +2 -1
  231. package/dist/types/components/checkout/zonos-checkout/zonos-checkout-footer/zonos-checkout-footer.d.ts +7 -0
  232. package/dist/types/components/common/zonos-badge/zonos-badge.d.ts +1 -5
  233. package/dist/types/components/common/zonos-banner/zonos-banner.d.ts +0 -4
  234. package/dist/types/components/common/zonos-button/zonos-button.d.ts +1 -5
  235. package/dist/types/components/common/zonos-card/zonos-card.d.ts +0 -4
  236. package/dist/types/components/common/zonos-checkbox/zonos-checkbox.d.ts +42 -0
  237. package/dist/types/components/common/zonos-country-flag/zonos-country-flag.d.ts +0 -4
  238. package/dist/types/components/common/zonos-country-select/zonos-country-select.d.ts +1 -1
  239. package/dist/types/components/common/zonos-icon/zonos-icon.d.ts +1 -1
  240. package/dist/types/components/common/zonos-language-select/zonos-language-select.d.ts +9 -0
  241. package/dist/types/components/common/zonos-logo/zonos-logo.d.ts +0 -4
  242. package/dist/types/components/common/zonos-notification/zonos-notification.d.ts +0 -4
  243. package/dist/types/components/common/zonos-select-dialog-header/zonos-select-dialog-header.d.ts +12 -0
  244. package/dist/types/components/common/zonos-spinner/zonos-spinner.d.ts +1 -1
  245. package/dist/types/components/common/zonos-text/zonos-text.d.ts +1 -5
  246. package/dist/types/components/common/zonos-tooltip/zonos-tooltip.d.ts +12 -0
  247. package/dist/types/components/common/zonos-v-stack/zonos-v-stack.d.ts +0 -4
  248. package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog-footer/zonos-hello-dialog-footer.d.ts +5 -0
  249. package/dist/types/components/hello/zonos-hello-dialog/zonos-hello-dialog.d.ts +2 -0
  250. package/dist/types/components/store/checkout/stripe.d.ts +12 -0
  251. package/dist/types/components/store/hello/localization.d.ts +2 -1
  252. package/dist/types/components/store/translationStore/strings.arabic.d.ts +18 -0
  253. package/dist/types/components/store/translationStore/strings.base.d.ts +18 -0
  254. package/dist/types/components/store/translationStore/strings.chinese.d.ts +18 -0
  255. package/dist/types/components/store/translationStore/strings.danish.d.ts +18 -0
  256. package/dist/types/components/store/translationStore/strings.dutch.d.ts +18 -0
  257. package/dist/types/components/store/translationStore/strings.french.d.ts +18 -0
  258. package/dist/types/components/store/translationStore/strings.german.d.ts +18 -0
  259. package/dist/types/components/store/translationStore/strings.hebrew.d.ts +18 -0
  260. package/dist/types/components/store/translationStore/strings.indonesian.d.ts +18 -0
  261. package/dist/types/components/store/translationStore/strings.italian.d.ts +18 -0
  262. package/dist/types/components/store/translationStore/strings.japanese.d.ts +18 -0
  263. package/dist/types/components/store/translationStore/strings.korean.d.ts +18 -0
  264. package/dist/types/components/store/translationStore/strings.norwegian.d.ts +18 -0
  265. package/dist/types/components/store/translationStore/strings.polish.d.ts +18 -0
  266. package/dist/types/components/store/translationStore/strings.portuguese.d.ts +18 -0
  267. package/dist/types/components/store/translationStore/strings.russian.d.ts +18 -0
  268. package/dist/types/components/store/translationStore/strings.spanish.d.ts +18 -0
  269. package/dist/types/components/store/translationStore/strings.swedish.d.ts +18 -0
  270. package/dist/types/components/store/translationStore/strings.turkish.d.ts +18 -0
  271. package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +18 -0
  272. package/dist/types/components/store/zonosStore.d.ts +1 -1
  273. package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +3 -0
  274. package/dist/types/components/utils/api/triggerBuildLandedCost.d.ts +18 -2
  275. package/dist/types/components/utils/changeDeepProperty.d.ts +1 -1
  276. package/dist/types/components/utils/changeDeepPropertyAtIndex.d.ts +1 -1
  277. package/dist/types/components/utils/getBorderRadius.d.ts +1 -1
  278. package/dist/types/components/utils/hello/currencyConversion/getLanguageCode.d.ts +1 -1
  279. package/dist/types/components.d.ts +242 -116
  280. package/dist/types/types/ICountryJson.d.ts +2 -1
  281. package/dist/types/types/ILanguage.d.ts +81 -0
  282. package/dist/types/types/checkout/CheckoutConfig.d.ts +3 -3
  283. package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +13 -0
  284. package/dist/types/types/generated/graphql.customer.types.d.ts +31 -4
  285. package/dist/types/types/generated/graphql.customer.types.ts +45 -4
  286. package/dist/types/types/generated/graphql.frontend.types.d.ts +5 -5
  287. package/dist/types/types/generated/graphql.frontend.types.ts +13 -3
  288. package/dist/types/types/index.d.ts +1 -1
  289. package/dist/types/types/styles/Color.d.ts +2 -0
  290. package/dist/zonos-elements/index.esm.js +0 -1
  291. package/dist/zonos-elements/p-0057e374.entry.js +1 -0
  292. package/dist/zonos-elements/{p-120df5be.system.entry.js → p-06652d87.system.entry.js} +1 -1
  293. package/dist/zonos-elements/p-066c5893.system.js +1 -0
  294. package/dist/zonos-elements/p-0c72fb79.system.entry.js +1 -0
  295. package/dist/zonos-elements/p-16ad90ca.js +1 -0
  296. package/dist/zonos-elements/p-1f85a98c.system.entry.js +1 -0
  297. package/dist/zonos-elements/p-290c3670.entry.js +1 -0
  298. package/dist/zonos-elements/p-2d2e1831.entry.js +1 -0
  299. package/dist/zonos-elements/p-2f1e1cbb.system.entry.js +1 -0
  300. package/dist/zonos-elements/p-33080cde.system.entry.js +1 -0
  301. package/dist/zonos-elements/{p-0024f8c2.js → p-34c03be2.js} +1 -1
  302. package/dist/zonos-elements/p-34efed1d.entry.js +1 -0
  303. package/dist/zonos-elements/p-375c472a.system.entry.js +1 -0
  304. package/dist/zonos-elements/p-50ea2036.system.js +1 -0
  305. package/dist/zonos-elements/p-549c181b.system.js +1 -0
  306. package/dist/zonos-elements/{p-be23cc91.system.entry.js → p-55970b10.system.entry.js} +1 -1
  307. package/dist/zonos-elements/p-561e44d6.entry.js +1 -0
  308. package/dist/zonos-elements/p-56ba5cbf.system.js +1 -0
  309. package/dist/zonos-elements/{p-dc09ca69.system.js → p-591eb6dd.system.js} +1 -1
  310. package/dist/zonos-elements/p-5b44abc8.system.js +1 -0
  311. package/dist/zonos-elements/p-5c4dc123.js +1 -0
  312. package/dist/zonos-elements/p-656c836b.entry.js +1 -0
  313. package/dist/zonos-elements/p-67737613.system.entry.js +1 -0
  314. package/dist/zonos-elements/p-79b910bf.system.entry.js +1 -0
  315. package/dist/zonos-elements/p-7d1d862f.system.entry.js +1 -0
  316. package/dist/zonos-elements/{p-5a0264e8.system.entry.js → p-88a55076.system.entry.js} +1 -1
  317. package/dist/zonos-elements/p-8aeb4679.system.entry.js +1 -0
  318. package/dist/zonos-elements/p-8d645a00.entry.js +1 -0
  319. package/dist/zonos-elements/p-9878a770.js +1 -0
  320. package/dist/zonos-elements/p-a219689f.entry.js +1 -0
  321. package/dist/zonos-elements/p-a3d72a33.entry.js +1 -0
  322. package/dist/zonos-elements/{p-aca66e4b.entry.js → p-a4de3fb2.entry.js} +1 -1
  323. package/dist/zonos-elements/p-a93c594f.entry.js +1 -0
  324. package/dist/zonos-elements/p-a95c034c.entry.js +1 -0
  325. package/dist/zonos-elements/p-abe7524f.system.js +1 -0
  326. package/dist/zonos-elements/p-afe40057.entry.js +1 -0
  327. package/dist/zonos-elements/p-b10ff468.entry.js +1 -0
  328. package/dist/zonos-elements/p-b6992dc2.system.entry.js +1 -0
  329. package/dist/zonos-elements/{p-af910392.js → p-bce46c41.js} +1 -1
  330. package/dist/zonos-elements/p-c56d4a44.entry.js +1 -0
  331. package/dist/zonos-elements/p-c7098c3b.entry.js +1 -0
  332. package/dist/zonos-elements/{p-ead79548.system.js → p-cbb1e700.system.js} +1 -1
  333. package/dist/zonos-elements/p-cc63a29f.system.entry.js +1 -0
  334. package/dist/zonos-elements/p-cd8bd5e9.system.entry.js +1 -0
  335. package/dist/zonos-elements/p-d36faf87.system.entry.js +1 -0
  336. package/dist/zonos-elements/p-dfd3edcf.entry.js +1 -0
  337. package/dist/zonos-elements/p-e1255160.js +1 -0
  338. package/dist/zonos-elements/p-e161a08c.entry.js +1 -0
  339. package/dist/zonos-elements/p-e2770968.system.entry.js +1 -0
  340. package/dist/zonos-elements/p-e2c6ad57.entry.js +1 -0
  341. package/dist/zonos-elements/{p-73174d0c.system.entry.js → p-e855966f.system.entry.js} +1 -1
  342. package/dist/zonos-elements/p-ea93943a.system.entry.js +1 -0
  343. package/dist/zonos-elements/{p-7f68c103.system.js → p-ec4d08b3.system.js} +1 -1
  344. package/dist/zonos-elements/{p-e8da4463.js → p-f455e08c.js} +1 -1
  345. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  346. package/dist/zonos-elements/zonos-elements.js +1 -1
  347. package/package.json +17 -18
  348. package/dist/cjs/cart-c1b0915c.js +0 -655
  349. package/dist/cjs/zonos-address_2.cjs.entry.js +0 -161
  350. package/dist/cjs/zonos-badge.cjs.entry.js +0 -38
  351. package/dist/cjs/zonos-icon.cjs.entry.js +0 -35
  352. package/dist/collection/components/common/zonos-country-select/assets/arrowLeftBlue.svg +0 -1
  353. package/dist/components/cart.js +0 -637
  354. package/dist/components/zonos-logo2.js +0 -48
  355. package/dist/esm/cart-7e7c7585.js +0 -637
  356. package/dist/esm/getBorderRadius-9e4cb3b1.js +0 -16
  357. package/dist/esm/zonos-address_2.entry.js +0 -156
  358. package/dist/esm/zonos-badge.entry.js +0 -34
  359. package/dist/esm/zonos-icon.entry.js +0 -31
  360. package/dist/esm-es5/cart-7e7c7585.js +0 -1
  361. package/dist/esm-es5/getBorderRadius-9e4cb3b1.js +0 -1
  362. package/dist/esm-es5/localization-5d83fde2.js +0 -1
  363. package/dist/esm-es5/submitGtag-776c5e10.js +0 -1
  364. package/dist/esm-es5/zonos-address_2.entry.js +0 -1
  365. package/dist/esm-es5/zonos-badge.entry.js +0 -1
  366. package/dist/esm-es5/zonos-button_2.entry.js +0 -1
  367. package/dist/esm-es5/zonos-cart-items_10.entry.js +0 -1
  368. package/dist/esm-es5/zonos-country-flag_4.entry.js +0 -1
  369. package/dist/esm-es5/zonos-icon.entry.js +0 -1
  370. package/dist/zonos-elements/p-027abb50.entry.js +0 -1
  371. package/dist/zonos-elements/p-09c5dc1b.system.entry.js +0 -1
  372. package/dist/zonos-elements/p-1156ae5d.system.entry.js +0 -1
  373. package/dist/zonos-elements/p-12ecf765.system.js +0 -1
  374. package/dist/zonos-elements/p-174239da.system.js +0 -1
  375. package/dist/zonos-elements/p-18e09138.system.entry.js +0 -1
  376. package/dist/zonos-elements/p-1c00ffea.system.entry.js +0 -1
  377. package/dist/zonos-elements/p-21793192.entry.js +0 -1
  378. package/dist/zonos-elements/p-2589a038.system.entry.js +0 -1
  379. package/dist/zonos-elements/p-28d7b75d.entry.js +0 -1
  380. package/dist/zonos-elements/p-31fa76da.entry.js +0 -1
  381. package/dist/zonos-elements/p-3319e4db.entry.js +0 -1
  382. package/dist/zonos-elements/p-357f0c61.entry.js +0 -1
  383. package/dist/zonos-elements/p-410045c5.system.entry.js +0 -1
  384. package/dist/zonos-elements/p-4d0861e9.system.js +0 -1
  385. package/dist/zonos-elements/p-54ef8ff3.entry.js +0 -1
  386. package/dist/zonos-elements/p-626b5a52.system.entry.js +0 -1
  387. package/dist/zonos-elements/p-6444a4b9.entry.js +0 -1
  388. package/dist/zonos-elements/p-65f4af1a.system.entry.js +0 -1
  389. package/dist/zonos-elements/p-661bc488.entry.js +0 -1
  390. package/dist/zonos-elements/p-6c47083f.entry.js +0 -1
  391. package/dist/zonos-elements/p-6d454281.entry.js +0 -1
  392. package/dist/zonos-elements/p-7748735d.entry.js +0 -1
  393. package/dist/zonos-elements/p-78886ed6.system.entry.js +0 -1
  394. package/dist/zonos-elements/p-8ebc0b64.js +0 -1
  395. package/dist/zonos-elements/p-a6f2e282.system.js +0 -1
  396. package/dist/zonos-elements/p-b035f9e5.system.js +0 -1
  397. package/dist/zonos-elements/p-b1ffb37b.entry.js +0 -1
  398. package/dist/zonos-elements/p-b58d2231.entry.js +0 -1
  399. package/dist/zonos-elements/p-bd02a65c.entry.js +0 -1
  400. package/dist/zonos-elements/p-bea31a7b.system.entry.js +0 -1
  401. package/dist/zonos-elements/p-cfe4a318.js +0 -1
  402. package/dist/zonos-elements/p-e4a2a1b0.system.entry.js +0 -1
  403. package/dist/zonos-elements/p-eb631432.system.entry.js +0 -1
  404. package/dist/zonos-elements/p-f2733cc7.js +0 -1
  405. package/dist/zonos-elements/p-f342e7c7.entry.js +0 -1
  406. package/dist/zonos-elements/p-f82e000f.system.entry.js +0 -1
  407. /package/dist/cjs/{index-3ead02fe.js → index-72767498.js} +0 -0
  408. /package/dist/esm/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
  409. /package/dist/esm-es5/{index-81a199ef.js → index-b5be4dc3.js} +0 -0
  410. /package/dist/zonos-elements/{p-4d8545e1.js → p-58127116.js} +0 -0
  411. /package/dist/zonos-elements/{p-4d39efb6.system.js → p-d1ab0823.system.js} +0 -0
@@ -1,637 +0,0 @@
1
- import { z as zonosStore, c as createStore } from './zonosStore-e59617f8.js';
2
- import { h as handleFetch, l as log, a as localizationStore, b as logError, t as translate } from './localization-5d83fde2.js';
3
- import { i as isDarkColor } from './isDarkColor-8696cb70.js';
4
- import { g as getBorderRadius } from './getBorderRadius-9e4cb3b1.js';
5
-
6
- const prepCalculateLandedCost = () => {
7
- // maybe we don't need email now for prefetch the landed cost
8
- const stripeLinkData = stripeStore.stripeLinkEventData;
9
- const stripeAddressData = stripeStore.stripeAddressEventData;
10
- if (!stripeAddressData || !stripeAddressData.complete) {
11
- throw new Error('Missing stripe address data');
12
- }
13
- return {
14
- checkoutSessionId: cartStore.checkoutSessionId || '',
15
- contact: {
16
- email: (stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email) || '',
17
- // firstName and lastName should be valid now since stripe only mark
18
- // the address as complete when both fields are filled.
19
- firstName: stripeAddressData.value.firstName || '',
20
- lastName: stripeAddressData.value.lastName || '',
21
- phone: stripeAddressData.value.phone || '',
22
- },
23
- items: cartStore.items.map(item => item),
24
- shippingAddress: {
25
- addressLine1: stripeAddressData.value.address.line1,
26
- addressLine2: stripeAddressData.value.address.line2 || '',
27
- city: stripeAddressData.value.address.city,
28
- country: stripeAddressData.value.address.country,
29
- postalCode: stripeAddressData.value.address.postal_code,
30
- state: stripeAddressData.value.address.state,
31
- },
32
- };
33
- };
34
-
35
- const triggerBuildLandedCost = async (buildLandedCost) => {
36
- var _a;
37
- const data = prepCalculateLandedCost();
38
- const landedCost = await buildLandedCost(data.checkoutSessionId, data.contact, data.shippingAddress);
39
- if (!landedCost) {
40
- throw new Error('Failed to build landed cost');
41
- }
42
- // Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
43
- const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/validate-landed-cost`, {
44
- body: landedCost,
45
- headers: {
46
- 'Content-Type': 'application/json',
47
- },
48
- method: 'POST',
49
- });
50
- if (!json || errors.length) {
51
- throw new Error(`Invalid landed cost object: ${((_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
52
- }
53
- return landedCost;
54
- };
55
-
56
- const calculateLandedCost = async (abortController) => {
57
- var _a;
58
- // If buildLandedCost callback is supplied, use that instead of our regular request to '/calculate-landed-cost'
59
- const buildLandedCost = zonosStore.checkoutSettings.buildLandedCost;
60
- if (buildLandedCost) {
61
- const json = await triggerBuildLandedCost(buildLandedCost);
62
- return json;
63
- }
64
- // request to get landed cost info
65
- const url = `${"https://v1.route.js.zonos.com"}/api/zonos-elements/calculate-landed-cost`;
66
- const { errors, json } = await handleFetch(url, {
67
- body: prepCalculateLandedCost(),
68
- method: 'POST',
69
- signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
70
- });
71
- if (errors.length || !json) {
72
- const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
73
- const errorMessage = isAbortedRequest
74
- ? 'The landed cost calculation request was aborted to initiate a new one.'
75
- : 'Failed to calculate landed cost';
76
- throw new Error(errorMessage);
77
- }
78
- return json;
79
- };
80
-
81
- const addressRuleStyle = ({ theme, }) => {
82
- switch (theme) {
83
- default:
84
- return {
85
- '.Input': {
86
- // need to reset everything and the paddingTop to default, otherwise the paddingTop will not be updated.
87
- padding: '0',
88
- paddingBottom: '8px',
89
- paddingLeft: '16px',
90
- paddingRight: '8px',
91
- // any value here will be add up to the default paddingTop (20px).
92
- paddingTop: '6px',
93
- },
94
- };
95
- }
96
- };
97
-
98
- const defaultVariable = ({ borderStyle, theme, }) => {
99
- switch (theme) {
100
- case 'DARK':
101
- return {
102
- borderRadius: getBorderRadius(borderStyle),
103
- colorBackground: '#101117',
104
- colorBackgroundText: '#C5C6CA',
105
- colorText: '#C5C6CA',
106
- colorTextPlaceholder: '#C5C6CA',
107
- };
108
- default:
109
- return {
110
- borderRadius: getBorderRadius(borderStyle),
111
- };
112
- }
113
- };
114
-
115
- const { onChange: onChange$1, reset: reset$1, state: stripeStore, } = createStore(() => ({
116
- clientSecret: sessionStorage.getItem('zonos--client-secret') || null,
117
- fetchingLandedCostAbordController: null,
118
- isFetchingLandedCost: false,
119
- isFetchingSession: false,
120
- stripe: null,
121
- stripeAddressElement: null,
122
- stripeAddressEventData: null,
123
- stripeAddressUsedWhenFetchingLC: null,
124
- stripeBillingAddressElement: null,
125
- stripeElements: null,
126
- stripeElementsOptions: null,
127
- stripeLinkElement: null,
128
- stripeLinkEventData: null,
129
- stripeLinkUsedWhenFetchingLC: null,
130
- stripePaymentElement: null,
131
- stripePaymentEventData: null,
132
- }));
133
- const getStripeOptions = ({ clientSecret, overrideBorderRaidus, overridePrimaryColor, overrideSecondaryColor, overrideTheme, }) => {
134
- const primaryColor = overridePrimaryColor || zonosStore.appearance.colorPrimary;
135
- const secondaryColor = overrideSecondaryColor || zonosStore.appearance.colorSecondary;
136
- const themeBasedColor = primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';
137
- // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
138
- const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
139
- return {
140
- appearance: {
141
- labels: 'floating',
142
- rules: Object.assign({}, addressRuleStyle({ theme: 'LIGHT' })),
143
- // get contrast theme color base on primary color
144
- theme: overrideTheme ? theme : themeBasedColor,
145
- variables: Object.assign(Object.assign({}, defaultVariable({
146
- borderStyle: overrideBorderRaidus,
147
- theme: 'LIGHT',
148
- })), {
149
- // use the button background color for input glow color
150
- colorPrimary: secondaryColor }),
151
- },
152
- clientSecret,
153
- locale: localizationStore.selectedLocale,
154
- };
155
- };
156
- const initStripeElements = async (props) => {
157
- var _a;
158
- const clientSecret = stripeStore.clientSecret;
159
- if (!stripeStore.stripe) {
160
- log('Skip. Stripe is not initialized');
161
- return;
162
- }
163
- if (clientSecret) {
164
- const stripeOptions = getStripeOptions({
165
- clientSecret,
166
- overrideBorderRaidus: props === null || props === void 0 ? void 0 : props.overrideBorderRaidus,
167
- overridePrimaryColor: props === null || props === void 0 ? void 0 : props.overridePrimaryColor,
168
- overrideSecondaryColor: props === null || props === void 0 ? void 0 : props.overrideSecondaryColor,
169
- overrideTheme: props === null || props === void 0 ? void 0 : props.overrideTheme,
170
- });
171
- // compare with the previous options to see if we need to update
172
- const isSameOptions = JSON.stringify(stripeOptions) ===
173
- JSON.stringify(stripeStore.stripeElementsOptions);
174
- if (!stripeStore.stripeElements) {
175
- // init stripe elements if it doesn't exist
176
- stripeStore.stripeElements = (_a = stripeStore.stripe) === null || _a === void 0 ? void 0 : _a.elements(stripeOptions);
177
- // save stripe elements options for later comparison
178
- stripeStore.stripeElementsOptions = stripeOptions;
179
- log('Stripe elements initialized');
180
- return;
181
- }
182
- if (!isSameOptions) {
183
- // update elements with new option if it already exists
184
- stripeStore.stripeElements.update(stripeOptions);
185
- // save stripe elements options for later comparison
186
- stripeStore.stripeElementsOptions = stripeOptions;
187
- }
188
- log('Stripe elements initialized');
189
- }
190
- };
191
- const stripeStoreReset = () => {
192
- // clean clientSecret so that we can start the new one.
193
- sessionStorage.removeItem('zonos--client-secret');
194
- // cleanup stripe elements
195
- reset$1();
196
- // set stripe back to window.Zonos.stripe
197
- stripeStore.stripe = window.Zonos.stripe;
198
- };
199
- /**
200
- * Check if the address and email info used when fetching landed cost with the current email and address info are different
201
- * Purpose is to resend the request if the info used when fetching landed cost is different from the current info
202
- */
203
- const isPrefetchInfoOutdated = () => {
204
- var _a, _b, _c, _d;
205
- const hasAbortController = stripeStore.fetchingLandedCostAbordController;
206
- if (!hasAbortController) {
207
- // if there is no abort controller, this is a new request
208
- return false;
209
- }
210
- const isLinkDataDirty = JSON.stringify((_a = stripeStore.stripeLinkUsedWhenFetchingLC) === null || _a === void 0 ? void 0 : _a.value) !==
211
- JSON.stringify((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value);
212
- const isAddressDataDirty = JSON.stringify((_c = stripeStore.stripeAddressUsedWhenFetchingLC) === null || _c === void 0 ? void 0 : _c.value) !==
213
- JSON.stringify((_d = stripeStore.stripeAddressEventData) === null || _d === void 0 ? void 0 : _d.value);
214
- return isLinkDataDirty || isAddressDataDirty;
215
- };
216
- const stripeStorePrefetchLandedCost = async () => {
217
- var _a, _b, _c, _d;
218
- const stripeAddressReady = !!((_a = stripeStore.stripeAddressEventData) === null || _a === void 0 ? void 0 : _a.complete);
219
- const stripeLinkReady = !!((_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.complete);
220
- const shouldRefetch = isPrefetchInfoOutdated();
221
- if (shouldRefetch) {
222
- // if the info used when fetching landed cost is different from the current info, abort the previous request
223
- (_c = stripeStore.fetchingLandedCostAbordController) === null || _c === void 0 ? void 0 : _c.abort();
224
- stripeStore.fetchingLandedCostAbordController = null;
225
- }
226
- // only fetch if we are not fetching or we need to refetch
227
- if (stripeAddressReady &&
228
- stripeLinkReady &&
229
- (shouldRefetch || !stripeStore.isFetchingLandedCost)) {
230
- stripeStore.isFetchingLandedCost = true;
231
- if (stripeStore.stripeAddressEventData) {
232
- stripeStore.stripeAddressUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeAddressEventData);
233
- }
234
- if (stripeStore.stripeLinkEventData) {
235
- stripeStore.stripeLinkUsedWhenFetchingLC = Object.assign({}, stripeStore.stripeLinkEventData);
236
- }
237
- try {
238
- const abortController = new AbortController();
239
- stripeStore.fetchingLandedCostAbordController = abortController;
240
- const { checkoutSessionWorkflow, shipmentRatingCalculateWorkflow } = await calculateLandedCost(abortController);
241
- // reset abort controller after we are done
242
- stripeStore.fetchingLandedCostAbordController = null;
243
- // update cart store with landed cost info
244
- cartStore.landedCostData =
245
- (checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.filter(Boolean)) || null;
246
- cartStore.shippingData =
247
- (shipmentRatingCalculateWorkflow === null || shipmentRatingCalculateWorkflow === void 0 ? void 0 : shipmentRatingCalculateWorkflow.filter(Boolean)) || null;
248
- // apply new subtotal and total, this is mainly to show items in the presentment currency
249
- const firstLandedCostData = (_d = cartStore.landedCostData) === null || _d === void 0 ? void 0 : _d.find(Boolean);
250
- const subtotals = !!firstLandedCostData
251
- ? firstLandedCostData.subtotals
252
- : null;
253
- if (subtotals) {
254
- // prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
255
- cartStoreApplySubtotals({
256
- exchangeRate: subtotals.exchangeRate,
257
- items: subtotals.items,
258
- landedCostTotal: 0,
259
- presentmentCurrencyCode: subtotals.presentmentCurrencyCode,
260
- shipping: 0,
261
- total: subtotals.items,
262
- });
263
- }
264
- }
265
- catch (err) {
266
- logError(err);
267
- }
268
- stripeStore.isFetchingLandedCost = false;
269
- }
270
- };
271
- const getStripeMessageBasedOnStatus = (status) => {
272
- let messages = [];
273
- let isError = true;
274
- // Inspect the PaymentIntent `status` to indicate the status of the payment
275
- // to your customer.
276
- //
277
- // Some payment methods will [immediately succeed or fail][0] upon
278
- // confirmation, while others will first enter a `processing` state.
279
- //
280
- // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification
281
- switch (status) {
282
- case 'succeeded': {
283
- messages = [
284
- translate('Your payment went through successfully! Thank you for shopping with us! We hope you had an enjoyable experience and your support means the world to us.'),
285
- '',
286
- '',
287
- translate("We've sent an email confirmation of the order details for your review. And our team is carefully preparing your order so it arrives on time."),
288
- ];
289
- isError = false;
290
- break;
291
- }
292
- case 'requires_capture':
293
- case 'processing': {
294
- messages = [
295
- translate("Payment processing. We'll update you when payment is received."),
296
- ];
297
- isError = false;
298
- break;
299
- }
300
- case 'requires_payment_method': {
301
- messages = [
302
- translate('Payment failed. Please try another payment method.'),
303
- ];
304
- break;
305
- }
306
- default: {
307
- messages = [translate('Something went wrong.')];
308
- break;
309
- }
310
- }
311
- return {
312
- isError,
313
- messages,
314
- };
315
- };
316
- const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybookForceStatus, }) => {
317
- if (storybookForceStatus) {
318
- // return status right away if we are in storybook mode
319
- const { isError, messages } = getStripeMessageBasedOnStatus(storybookForceStatus);
320
- return { error: isError, messages };
321
- }
322
- const clientSecret = _clientSecret || stripeStore.clientSecret;
323
- if (!stripeStore.stripe || !clientSecret) {
324
- logError('Failed to retrieve payment intent. Stripe is not initialized');
325
- return { error: true, message: [translate('Something went wrong.')] };
326
- }
327
- const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
328
- const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
329
- const { isError, messages } = getStripeMessageBasedOnStatus(status);
330
- return { error: isError, messages };
331
- };
332
- const stripeStoreConfirmPayment = async () => {
333
- var _a, _b, _c;
334
- const stripePaymentReady = !!((_a = stripeStore.stripePaymentEventData) === null || _a === void 0 ? void 0 : _a.complete);
335
- const stripeElements = stripeStore.stripeElements;
336
- const stripe = stripeStore.stripe;
337
- const stripeClientSecret = stripeStore.clientSecret;
338
- if (stripe && stripeElements && stripePaymentReady && stripeClientSecret) {
339
- const { error } = await stripe.confirmPayment({
340
- confirmParams: {
341
- receipt_email: (_c = (_b = stripeStore.stripeLinkEventData) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.email,
342
- return_url: window.location.href,
343
- },
344
- elements: stripeElements,
345
- redirect: 'if_required',
346
- });
347
- if (error) {
348
- if (error.type === 'card_error' || error.type === 'validation_error') {
349
- throw new Error(error.message);
350
- }
351
- if (error.type === 'invalid_request_error') {
352
- if (error.code === 'payment_intent_unexpected_state') {
353
- // PaymentIntent was canceled or expired, or status is `require_capture`.
354
- // don't throw error here because we will reset the checkout session last step
355
- return;
356
- }
357
- }
358
- throw new Error('An unexpected error occurred.');
359
- }
360
- }
361
- };
362
- /**
363
- * Init checkout session
364
- * @returns {boolean} whether or not the checkout session is successfully created
365
- */
366
- const stripeStoreInitCheckoutSession = async () => {
367
- var _a;
368
- const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
369
- if (!total || !localizationStore.targetCurrency) {
370
- logError('Fail to create checkout session - invalid total or currency');
371
- return false;
372
- }
373
- stripeStore.isFetchingSession = true;
374
- const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/create-checkout-session`, {
375
- body: {
376
- currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
377
- itemsAmount: total,
378
- presentmentCountryCode: localizationStore.selectedCountryCode || null,
379
- },
380
- method: 'POST',
381
- });
382
- stripeStore.isFetchingSession = false;
383
- if (errors.length || !json) {
384
- logError('Error occurs when creating checkout session', JSON.stringify(errors, null, 2));
385
- return false;
386
- }
387
- const result = json.checkoutSessionCreate;
388
- stripeStore.clientSecret = result.clientSecret;
389
- // update cart store with updated informations
390
- cartStore.checkoutSessionId = result.id;
391
- cartStoreApplySubtotals(Object.assign(Object.assign({}, result.subtotals), { landedCostTotal: 0, shipping: 0, total: result.subtotals.items }));
392
- log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
393
- log('done-init-checkout-session');
394
- return true;
395
- };
396
- /**
397
- * Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
398
- */
399
- const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
400
- // No need to set loading state here because this function will be called under the hood to update
401
- // landed cost id for the section.
402
- const { errors, json } = await handleFetch(`${"https://v1.route.js.zonos.com"}/api/zonos-elements/update-checkout-session`, {
403
- body: {
404
- currency,
405
- id,
406
- itemsAmount,
407
- landedCostId,
408
- presentmentCountryCode,
409
- },
410
- method: 'POST',
411
- });
412
- if (errors.length || !json) {
413
- logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
414
- return { errors, json };
415
- }
416
- return { errors: [], json };
417
- };
418
- onChange$1('clientSecret', clientSecret => {
419
- // update stripe elements when client secret changes
420
- if (clientSecret && stripeStore.stripe) {
421
- sessionStorage.setItem('zonos--client-secret', clientSecret);
422
- }
423
- if (!clientSecret) {
424
- sessionStorage.removeItem('zonos--client-secret');
425
- }
426
- });
427
-
428
- const formatDate = ({ date, formatOptions = { day: 'numeric', weekday: 'long', year: 'numeric' }, }) => {
429
- // format date to Thursday 3, 2023
430
- return new Intl.DateTimeFormat('en-US', formatOptions).format(date);
431
- };
432
-
433
- const getDaysDifference = (targetDate) => {
434
- const currentDate = new Date();
435
- const timeDifference = targetDate.getTime() - currentDate.getTime();
436
- const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); // Convert milliseconds to days
437
- return daysDifference;
438
- };
439
-
440
- const { onChange, reset, state: cartStore, } = createStore(() => ({
441
- checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
442
- currency: 'USD',
443
- dutiesTaxFees: 0,
444
- error: null,
445
- exchangeRate: null,
446
- isSelectedShippingAboveDeminimis: false,
447
- isSelectedShippingGuarantee: false,
448
- items: [],
449
- landedCostData: null,
450
- selectedLandedCost: null,
451
- selectedShippingOption: null,
452
- selectedShippingOptionExpectedDate: '',
453
- selectedShippingOptionTransitTime: '',
454
- shipping: 0,
455
- shippingData: null,
456
- step: 'customer-info',
457
- subtotal: 0,
458
- total: 0,
459
- }));
460
- /**
461
- * Format shipping transit info to be displayed on UI
462
- * @returns
463
- * - expectedDate: Thursday, Aug 12
464
- * - maxTransit: 5
465
- * - minTransit: 3
466
- */
467
- const cartStoreGetShippingTransitInfo = (item) => {
468
- const minTransit = item.minTransitAt
469
- ? getDaysDifference(new Date(item.minTransitAt))
470
- : '';
471
- const maxTransit = item.maxTransitAt
472
- ? getDaysDifference(new Date(item.maxTransitAt))
473
- : '';
474
- const expectedDate = item.minTransitAt
475
- ? formatDate({
476
- date: new Date(item.minTransitAt),
477
- })
478
- : '';
479
- return {
480
- expectedDate,
481
- maxTransit,
482
- minTransit,
483
- };
484
- };
485
- const cartStoreReset = () => {
486
- sessionStorage.removeItem('zonos--checkout-session-id');
487
- // reset cart store
488
- reset();
489
- };
490
- const cartStoreUpdateToErrorState = ({ messages, title, }) => {
491
- cartStoreReset();
492
- stripeStoreReset();
493
- cartStore.step = 'error';
494
- cartStore.error = {
495
- messages,
496
- title,
497
- };
498
- };
499
- const cartStoreApplySubtotals = (subtotals) => {
500
- // update exchange rate so we can use it to display cart items
501
- cartStore.exchangeRate = subtotals.exchangeRate;
502
- cartStore.dutiesTaxFees = subtotals.landedCostTotal;
503
- cartStore.subtotal = subtotals.items;
504
- cartStore.total = subtotals.total;
505
- cartStore.currency = subtotals.presentmentCurrencyCode;
506
- };
507
- const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
508
- if (landedCostId && cartStore.selectedLandedCost) {
509
- // update cart total right away if we have landed cost id to avoid order total flickering
510
- const subtotals = cartStore.selectedLandedCost.subtotals;
511
- cartStoreApplySubtotals(subtotals);
512
- log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
513
- }
514
- // update checkout session
515
- if (!cartStore.checkoutSessionId) {
516
- logError('Could not update cart total without checkout session id');
517
- return false;
518
- }
519
- const { json } = await stripeStoreUpdateCheckoutSession({
520
- currency,
521
- id: cartStore.checkoutSessionId,
522
- itemsAmount,
523
- landedCostId,
524
- presentmentCountryCode: localizationStore.selectedCountryCode,
525
- });
526
- if (!json) {
527
- // do nothing if we can't get checkout session
528
- logError('Error occurs when updating checkout session');
529
- cartStoreUpdateToErrorState({
530
- messages: [
531
- translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
532
- ],
533
- title: translate('Error updating Checkout'),
534
- });
535
- return false;
536
- }
537
- if (!landedCostId) {
538
- // This is when first open the checkout modal and we just want to get info from the old cart session.
539
- // use subtotals from checkout session to update cart total
540
- cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
541
- log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
542
- }
543
- return true;
544
- };
545
- const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) => {
546
- var _a, _b, _c, _d, _e;
547
- cartStore.selectedShippingOption = selectedShippingOption;
548
- // update shipping transit info
549
- const { expectedDate, maxTransit, minTransit } = cartStoreGetShippingTransitInfo(cartStore.selectedShippingOption);
550
- cartStore.selectedShippingOptionExpectedDate = expectedDate;
551
- cartStore.selectedShippingOptionTransitTime =
552
- minTransit && maxTransit
553
- ? `${minTransit}-${maxTransit}`
554
- : `${minTransit || maxTransit}`;
555
- const selectedLandedCost = (_a = cartStore.landedCostData) === null || _a === void 0 ? void 0 : _a.find(checkoutSessionPresentment => {
556
- var _a, _b, _c;
557
- return ((_b = (_a = checkoutSessionPresentment.landedCost) === null || _a === void 0 ? void 0 : _a.shipmentRating) === null || _b === void 0 ? void 0 : _b.id) ===
558
- ((_c = cartStore.selectedShippingOption) === null || _c === void 0 ? void 0 : _c.id);
559
- });
560
- // save selected landed cost for later use
561
- cartStore.selectedLandedCost = selectedLandedCost || null;
562
- if (!selectedLandedCost) {
563
- // do nothing if we can't find landed cost for selected shipping option
564
- return false;
565
- }
566
- // update shipping value and dutiesTaxFees on selectedShippingOption change
567
- cartStore.shipping = selectedLandedCost.subtotals.shipping;
568
- // update deminimis status
569
- const isGuarantee = ((_b = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _b === void 0 ? void 0 : _b.landedCostGuaranteeCode) === 'ZONOS';
570
- // one item in deminimis with type of duty and tax has threshold value is "ABOVE"
571
- const isAboveDeminimis = !!((_d = (_c = selectedLandedCost === null || selectedLandedCost === void 0 ? void 0 : selectedLandedCost.landedCost) === null || _c === void 0 ? void 0 : _c.deMinimis) === null || _d === void 0 ? void 0 : _d.find(item => ['DUTY', 'TAX'].includes(item.type) && item.threshold === 'ABOVE'));
572
- cartStore.isSelectedShippingAboveDeminimis = isAboveDeminimis;
573
- cartStore.isSelectedShippingGuarantee = isGuarantee;
574
- // update session with selected landed cost
575
- const updateCalulateStatus = await cartStoreReCalculateTotal({
576
- landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
577
- });
578
- return updateCalulateStatus;
579
- };
580
- onChange('checkoutSessionId', () => {
581
- if (!cartStore.checkoutSessionId) {
582
- sessionStorage.removeItem('zonos--checkout-session-id');
583
- return;
584
- }
585
- sessionStorage.setItem('zonos--checkout-session-id', cartStore.checkoutSessionId);
586
- });
587
- const cartStoreUpdateItems = async (items) => {
588
- var _a;
589
- cartStore.items = items;
590
- const currency = (_a = items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
591
- const total = items.reduce((amt, item) => {
592
- return amt + item.amount * item.quantity;
593
- }, 0);
594
- if (!currency || !total) {
595
- // do nothing if we can't get currency or total
596
- return;
597
- }
598
- cartStore.currency = currency;
599
- // set loading state here because this is first load checkout session when we already have checkout session id stored
600
- stripeStore.isFetchingSession = true;
601
- await cartStoreReCalculateTotal({
602
- currency: currency,
603
- itemsAmount: total,
604
- });
605
- stripeStore.isFetchingSession = false;
606
- };
607
- const cartStoreResetSelectedShippingOption = () => {
608
- cartStore.selectedShippingOption = null;
609
- cartStore.isSelectedShippingAboveDeminimis = false;
610
- cartStore.isSelectedShippingGuarantee = false;
611
- cartStore.selectedShippingOptionExpectedDate = '';
612
- cartStore.selectedShippingOptionTransitTime = '';
613
- cartStore.shipping = 0;
614
- };
615
- const cartStoreNextStep = () => {
616
- if (cartStore.step === 'customer-info') {
617
- cartStore.step = 'shipping';
618
- }
619
- else if (cartStore.step === 'shipping') {
620
- cartStore.step = 'payment';
621
- }
622
- else if (cartStore.step === 'payment') {
623
- cartStore.step = 'finish';
624
- }
625
- };
626
- const cartStorePreviousStep = () => {
627
- if (cartStore.step === 'payment') {
628
- cartStore.step = 'shipping';
629
- }
630
- else if (cartStore.step === 'shipping') {
631
- cartStore.step = 'customer-info';
632
- // reset selected shipping option
633
- cartStoreResetSelectedShippingOption();
634
- }
635
- };
636
-
637
- export { cartStoreApplySubtotals as a, cartStoreGetShippingTransitInfo as b, cartStore as c, cartStoreNextStep as d, cartStorePreviousStep as e, cartStoreReCalculateTotal as f, cartStoreReset as g, cartStoreUpdateItems as h, cartStoreUpdateSelectedShippingOption as i, cartStoreUpdateToErrorState as j, initStripeElements as k, stripeStoreInitCheckoutSession as l, stripeStorePrefetchLandedCost as m, stripeStoreConfirmPayment as n, stripeStoreReset as o, stripeStoreRetrievePayment as p, stripeStore as s };
@@ -1,16 +0,0 @@
1
- import { z as zonosStore } from './zonosStore-e59617f8.js';
2
-
3
- /**
4
- * Get the border radius for the elements based on the style
5
- * @param overrideBorderStyle
6
- * @returns
7
- */
8
- const getBorderRadius = (overrideBorderStyle) => {
9
- if (overrideBorderStyle) {
10
- // If the override is set, use that, otherwise use the default radius style
11
- return overrideBorderStyle === 'SHARP' ? '0px' : '10px';
12
- }
13
- return zonosStore.appearance.style === 'SHARP' ? '0px' : '10px';
14
- };
15
-
16
- export { getBorderRadius as g };