@adyen/adyen-web 6.0.0-alpha.5 → 6.0.0-alpha.7

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 (442) hide show
  1. package/dist/cjs/adyen.css +10 -9
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +41 -29
  6. package/dist/es/adyen.css +10 -9
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Address/Address.js +1 -1
  9. package/dist/es/components/Address/Address.js.map +1 -1
  10. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  11. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  12. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  13. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  15. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/defaultProps.js +1 -1
  17. package/dist/es/components/Card/components/CardInput/defaultProps.js.map +1 -1
  18. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  20. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  21. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  22. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  23. package/dist/es/components/CashAppPay/components/CashAppComponent.js +1 -1
  24. package/dist/es/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  25. package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
  26. package/dist/es/components/GooglePay/components/GooglePayButton.js +1 -1
  27. package/dist/es/components/GooglePay/components/GooglePayButton.js.map +1 -1
  28. package/dist/es/components/GooglePay/defaultProps.js +1 -1
  29. package/dist/es/components/GooglePay/defaultProps.js.map +1 -1
  30. package/dist/es/components/PersonalDetails/PersonalDetails.js +1 -1
  31. package/dist/es/components/PersonalDetails/PersonalDetails.js.map +1 -1
  32. package/dist/es/components/internal/Address/Address.js +1 -1
  33. package/dist/es/components/internal/Address/Address.js.map +1 -1
  34. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
  35. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  36. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  37. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  38. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
  39. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
  40. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  41. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  42. package/dist/es/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
  43. package/dist/es/components/internal/ClickToPay/services/sdks/MastercardSdk.js.map +1 -1
  44. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  45. package/dist/es/components/internal/ClickToPay/services/utils.js +1 -1
  46. package/dist/es/components/internal/ClickToPay/services/utils.js.map +1 -1
  47. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  48. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  49. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  50. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  51. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  52. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  53. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  54. package/dist/es/components/internal/Icon/constants.js +2 -0
  55. package/dist/es/components/internal/Icon/constants.js.map +1 -0
  56. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  57. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  58. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +2 -0
  59. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -0
  60. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  61. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  62. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  63. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  64. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  65. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  69. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  70. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  71. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  72. package/dist/es/components/internal/Voucher/Voucher.js +1 -1
  73. package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
  74. package/dist/es/core/Analytics/Analytics.js +1 -1
  75. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  76. package/dist/es/core/Analytics/constants.js +1 -1
  77. package/dist/es/core/Analytics/constants.js.map +1 -1
  78. package/dist/es/core/Analytics/utils.js.map +1 -1
  79. package/dist/es/core/Context/Resources.js +1 -1
  80. package/dist/es/core/Context/Resources.js.map +1 -1
  81. package/dist/es/core/Environment/Environment.js +1 -1
  82. package/dist/es/core/Environment/Environment.js.map +1 -1
  83. package/dist/es/core/Environment/constants.js +2 -0
  84. package/dist/es/core/Environment/constants.js.map +1 -0
  85. package/dist/es/core/Errors/SRMessages.js +1 -1
  86. package/dist/es/core/Errors/SRMessages.js.map +1 -1
  87. package/dist/es/core/Errors/SRPanel.js +1 -1
  88. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  89. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  90. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  91. package/dist/es/core/Services/analytics/log-event.js +1 -1
  92. package/dist/es/core/Services/get-translations.js +1 -1
  93. package/dist/es/core/Services/get-translations.js.map +1 -1
  94. package/dist/es/core/core.defaultProps.js +1 -1
  95. package/dist/es/core/core.defaultProps.js.map +1 -1
  96. package/dist/es/core/core.js +1 -1
  97. package/dist/es/core/core.js.map +1 -1
  98. package/dist/es/core/core.registry.js +1 -1
  99. package/dist/es/core/core.registry.js.map +1 -1
  100. package/dist/es/core/utils.js +1 -1
  101. package/dist/es/core/utils.js.map +1 -1
  102. package/dist/es/external/preact/dist/preact.js +1 -1
  103. package/dist/es/external/preact/dist/preact.js.map +1 -1
  104. package/dist/es/external/preact/hooks/dist/hooks.js +1 -1
  105. package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
  106. package/dist/es/index.d.ts +41 -29
  107. package/dist/es/utils/arrayUtils.js +1 -1
  108. package/dist/es/utils/arrayUtils.js.map +1 -1
  109. package/dist/es/utils/useForm/useForm.js +1 -1
  110. package/dist/es/utils/validator-utils.js +1 -1
  111. package/dist/es/utils/validator-utils.js.map +1 -1
  112. package/dist/es-legacy/adyen.css +10 -9
  113. package/dist/es-legacy/adyen.css.map +1 -1
  114. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  115. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  116. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  117. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  118. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js +1 -1
  119. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +1 -1
  120. package/dist/es-legacy/components/Address/Address.js +1 -1
  121. package/dist/es-legacy/components/Address/Address.js.map +1 -1
  122. package/dist/es-legacy/components/Affirm/Affirm.js +1 -1
  123. package/dist/es-legacy/components/Affirm/Affirm.js.map +1 -1
  124. package/dist/es-legacy/components/AfterPay/AfterPay.js +1 -1
  125. package/dist/es-legacy/components/AfterPay/AfterPay.js.map +1 -1
  126. package/dist/es-legacy/components/AfterPay/AfterPayB2B.js +1 -1
  127. package/dist/es-legacy/components/AfterPay/AfterPayB2B.js.map +1 -1
  128. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  129. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  130. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js +1 -1
  131. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  132. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  133. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  134. package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
  135. package/dist/es-legacy/components/AmazonPay/utils.js.map +1 -1
  136. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  137. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  138. package/dist/es-legacy/components/Atome/Atome.js +1 -1
  139. package/dist/es-legacy/components/Atome/Atome.js.map +1 -1
  140. package/dist/es-legacy/components/Atome/config.js +1 -1
  141. package/dist/es-legacy/components/Atome/config.js.map +1 -1
  142. package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
  143. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  144. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  145. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  146. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  147. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  148. package/dist/es-legacy/components/BillDesk/BillDeskOnline.js +1 -1
  149. package/dist/es-legacy/components/BillDesk/BillDeskOnline.js.map +1 -1
  150. package/dist/es-legacy/components/BillDesk/BillDeskWallet.js +1 -1
  151. package/dist/es-legacy/components/BillDesk/BillDeskWallet.js.map +1 -1
  152. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  153. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  154. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  155. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  156. package/dist/es-legacy/components/Boleto/Boleto.js +1 -1
  157. package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
  158. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  159. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  160. package/dist/es-legacy/components/Card/Bancontact.js +1 -1
  161. package/dist/es-legacy/components/Card/Bancontact.js.map +1 -1
  162. package/dist/es-legacy/components/Card/Card.js +1 -1
  163. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  164. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  165. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  166. package/dist/es-legacy/components/Card/components/CardInput/components/IframeLabelAlternative.js +1 -1
  167. package/dist/es-legacy/components/Card/components/CardInput/components/IframeLabelAlternative.js.map +1 -1
  168. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
  169. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  170. package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js +1 -1
  171. package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js.map +1 -1
  172. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  173. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  174. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  175. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  176. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  177. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js +1 -1
  178. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  179. package/dist/es-legacy/components/ClickToPay/ClickToPay.js +1 -1
  180. package/dist/es-legacy/components/ClickToPay/ClickToPay.js.map +1 -1
  181. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  182. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  183. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  184. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  185. package/dist/es-legacy/components/Doku/Doku.js +1 -1
  186. package/dist/es-legacy/components/Doku/Doku.js.map +1 -1
  187. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  188. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  189. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  190. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  191. package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
  192. package/dist/es-legacy/components/Dragonpay/Dragonpay.js.map +1 -1
  193. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  194. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  195. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  196. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  197. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  198. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  199. package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
  200. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  201. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  202. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  203. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  204. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js +1 -1
  205. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  206. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js +1 -1
  207. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js.map +1 -1
  208. package/dist/es-legacy/components/EPS/index.js +1 -1
  209. package/dist/es-legacy/components/EPS/index.js.map +1 -1
  210. package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
  211. package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
  212. package/dist/es-legacy/components/FacilyPay/FacilyPay10x.js +1 -1
  213. package/dist/es-legacy/components/FacilyPay/FacilyPay10x.js.map +1 -1
  214. package/dist/es-legacy/components/FacilyPay/FacilyPay12x.js +1 -1
  215. package/dist/es-legacy/components/FacilyPay/FacilyPay12x.js.map +1 -1
  216. package/dist/es-legacy/components/FacilyPay/FacilyPay3x.js +1 -1
  217. package/dist/es-legacy/components/FacilyPay/FacilyPay3x.js.map +1 -1
  218. package/dist/es-legacy/components/FacilyPay/FacilyPay4x.js +1 -1
  219. package/dist/es-legacy/components/FacilyPay/FacilyPay4x.js.map +1 -1
  220. package/dist/es-legacy/components/FacilyPay/FacilyPay6x.js +1 -1
  221. package/dist/es-legacy/components/FacilyPay/FacilyPay6x.js.map +1 -1
  222. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  223. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  224. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  225. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  226. package/dist/es-legacy/components/Giftcard/components/GiftcardFields.js +1 -1
  227. package/dist/es-legacy/components/Giftcard/components/GiftcardFields.js.map +1 -1
  228. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  229. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  230. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  231. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  232. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js +1 -1
  233. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js.map +1 -1
  234. package/dist/es-legacy/components/GooglePay/defaultProps.js +1 -1
  235. package/dist/es-legacy/components/GooglePay/defaultProps.js.map +1 -1
  236. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  237. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  238. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  239. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  240. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  241. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  242. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  243. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  244. package/dist/es-legacy/components/MealVoucherFR/MealVoucherFR.js +1 -1
  245. package/dist/es-legacy/components/MealVoucherFR/MealVoucherFR.js.map +1 -1
  246. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherFields.js +1 -1
  247. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherFields.js.map +1 -1
  248. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  249. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  250. package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
  251. package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
  252. package/dist/es-legacy/components/OnlineBankingIN/index.js +1 -1
  253. package/dist/es-legacy/components/OnlineBankingIN/index.js.map +1 -1
  254. package/dist/es-legacy/components/OnlineBankingPL/OnlineBankingPL.js +1 -1
  255. package/dist/es-legacy/components/OnlineBankingPL/OnlineBankingPL.js.map +1 -1
  256. package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
  257. package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
  258. package/dist/es-legacy/components/Oxxo/Oxxo.js +1 -1
  259. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  260. package/dist/es-legacy/components/PayByBank/PayByBank.js +1 -1
  261. package/dist/es-legacy/components/PayByBank/PayByBank.js.map +1 -1
  262. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  263. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  264. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  265. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  266. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  267. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  268. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +1 -1
  269. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  270. package/dist/es-legacy/components/PayU/PayuCashcard.js +1 -1
  271. package/dist/es-legacy/components/PayU/PayuCashcard.js.map +1 -1
  272. package/dist/es-legacy/components/PayU/PayuNetBanking.js +1 -1
  273. package/dist/es-legacy/components/PayU/PayuNetBanking.js.map +1 -1
  274. package/dist/es-legacy/components/PersonalDetails/PersonalDetails.js +1 -1
  275. package/dist/es-legacy/components/PersonalDetails/PersonalDetails.js.map +1 -1
  276. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  277. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  278. package/dist/es-legacy/components/RatePay/RatePay.js +1 -1
  279. package/dist/es-legacy/components/RatePay/RatePay.js.map +1 -1
  280. package/dist/es-legacy/components/RatePay/RatePayDirectDebit.js +1 -1
  281. package/dist/es-legacy/components/RatePay/RatePayDirectDebit.js.map +1 -1
  282. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  283. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  284. package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
  285. package/dist/es-legacy/components/Riverty/Riverty.js.map +1 -1
  286. package/dist/es-legacy/components/Sepa/Sepa.js +1 -1
  287. package/dist/es-legacy/components/Sepa/Sepa.js.map +1 -1
  288. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  289. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  290. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  291. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  292. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  293. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  294. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  295. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  296. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  297. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  298. package/dist/es-legacy/components/Twint/Twint.js +1 -1
  299. package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
  300. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  301. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  302. package/dist/es-legacy/components/WalletIN/index.js +1 -1
  303. package/dist/es-legacy/components/WalletIN/index.js.map +1 -1
  304. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  305. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  306. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
  307. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  308. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  309. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  310. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  311. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  312. package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
  313. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  314. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  315. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  316. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
  317. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  318. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  319. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  320. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
  321. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
  322. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  323. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  324. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  325. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  326. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
  327. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/MastercardSdk.js +1 -1
  328. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/MastercardSdk.js.map +1 -1
  329. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  330. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  331. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js +1 -1
  332. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js.map +1 -1
  333. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  334. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  335. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
  336. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
  337. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  338. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  339. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  340. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  341. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js +1 -1
  342. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  343. package/dist/es-legacy/components/internal/FormFields/InputEmail.js +1 -1
  344. package/dist/es-legacy/components/internal/FormFields/InputEmail.js.map +1 -1
  345. package/dist/es-legacy/components/internal/FormFields/InputTelephone.js +1 -1
  346. package/dist/es-legacy/components/internal/FormFields/InputTelephone.js.map +1 -1
  347. package/dist/es-legacy/components/internal/FormFields/InputText.js +1 -1
  348. package/dist/es-legacy/components/internal/FormFields/InputText.js.map +1 -1
  349. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  350. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  351. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  352. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  353. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  354. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  355. package/dist/es-legacy/components/internal/Icon/constants.js +2 -0
  356. package/dist/es-legacy/components/internal/Icon/constants.js.map +1 -0
  357. package/dist/es-legacy/components/internal/Img/Img.js +1 -1
  358. package/dist/es-legacy/components/internal/Img/Img.js.map +1 -1
  359. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  360. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  361. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  362. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  363. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +2 -0
  364. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -0
  365. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  366. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  367. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  368. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  369. package/dist/es-legacy/components/internal/PhoneInput/PhoneInput.js +1 -1
  370. package/dist/es-legacy/components/internal/PhoneInput/PhoneInput.js.map +1 -1
  371. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  372. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  373. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  374. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  375. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  376. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  377. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  378. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  379. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  380. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  381. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  382. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  383. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js +1 -1
  384. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
  385. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  386. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  387. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  388. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  389. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js +1 -1
  390. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js.map +1 -1
  391. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  392. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  393. package/dist/es-legacy/components/internal/Voucher/Voucher.js +1 -1
  394. package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
  395. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  396. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  397. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  398. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  399. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  400. package/dist/es-legacy/core/Context/Resources.js +1 -1
  401. package/dist/es-legacy/core/Context/Resources.js.map +1 -1
  402. package/dist/es-legacy/core/Environment/Environment.js +1 -1
  403. package/dist/es-legacy/core/Environment/Environment.js.map +1 -1
  404. package/dist/es-legacy/core/Environment/constants.js +2 -0
  405. package/dist/es-legacy/core/Environment/constants.js.map +1 -0
  406. package/dist/es-legacy/core/Errors/SRPanel.js +1 -1
  407. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  408. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  409. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  410. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js +1 -1
  411. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
  412. package/dist/es-legacy/core/ProcessResponse/process-response.js +1 -1
  413. package/dist/es-legacy/core/ProcessResponse/process-response.js.map +1 -1
  414. package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
  415. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  416. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  417. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  418. package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
  419. package/dist/es-legacy/core/Services/get-translations.js +1 -1
  420. package/dist/es-legacy/core/Services/get-translations.js.map +1 -1
  421. package/dist/es-legacy/core/Services/http.js +1 -1
  422. package/dist/es-legacy/core/Services/http.js.map +1 -1
  423. package/dist/es-legacy/core/core.defaultProps.js +1 -1
  424. package/dist/es-legacy/core/core.defaultProps.js.map +1 -1
  425. package/dist/es-legacy/core/core.js +1 -1
  426. package/dist/es-legacy/core/core.js.map +1 -1
  427. package/dist/es-legacy/core/core.registry.js +1 -1
  428. package/dist/es-legacy/core/core.registry.js.map +1 -1
  429. package/dist/es-legacy/core/utils.js +1 -1
  430. package/dist/es-legacy/core/utils.js.map +1 -1
  431. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  432. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  433. package/dist/es-legacy/external/preact/hooks/dist/hooks.js +1 -1
  434. package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
  435. package/dist/es-legacy/utils/arrayUtils.js +1 -1
  436. package/dist/es-legacy/utils/arrayUtils.js.map +1 -1
  437. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  438. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  439. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  440. package/dist/es-legacy/utils/validator-utils.js +1 -1
  441. package/dist/es-legacy/utils/validator-utils.js.map +1 -1
  442. package/package.json +144 -148
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerListContainer.js","sources":["../../../../../src/components/helpers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\n\nclass IssuerListContainer extends UIElement<IssuerListConfiguration> {\n protected static defaultProps = {\n showImage: true,\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: IssuerListConfiguration) {\n super(checkout, props);\n\n const getImage = props => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props) {\n const issuers = (props.details && props.details.length && (props.details.find(d => d.key === 'issuer') || {}).items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): IssuerListData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n };\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): { icon: any; name: string }[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.issuers.length > 0 ? (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <IssuerList\n ref={ref => {\n this.componentRef = ref;\n }}\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n ) : (\n this.props.showPayButton && (\n <RedirectButton\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n )\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","brands","showPaymentMethodItemImages","map","brand","icon","name","id","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","IssuerList","ref","componentRef","highlightedIds","highlightedIssuers","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","get","onSubmitAnalytics","submitAnalytics","showPayButton","RedirectButton","checkout","super","getImage","getIssuerIcon","getIssuerImageUrl","item","_define_property","defaultProps","FALLBACK_CONTEXT"],"mappings":"i3CAWA,MAAMA,UAA4BC,EAwB9BC,WAAAA,CAAYC,GACR,MAAMC,EAAWD,EAAME,SAAWF,EAAME,QAAQC,SAAWH,EAAME,QAAQE,MAAKC,GAAe,WAAVA,EAAEC,OAAqB,CAAC,GAAGC,OAAUP,EAAMC,SAAW,GACzI,OAAOO,EAAKR,EAAAA,CAAAA,EAAAA,GAAAA,CAAOC,WACvB,CAKAQ,UAAAA,OAIoBC,EAAAC,EAHhB,MAAO,CACHC,cAAe,CACXC,KAAMC,KAAKD,KACXE,OAAkB,QAAVJ,EAAAG,KAAKE,aAAL,IAAAL,GAAA,QAAAD,EAAAC,EAAYM,YAAZ,IAAAP,OAAA,EAAAA,EAAkBK,QAGtC,CAKA,WAAIG,GAIS,IAAAP,EAHT,OAAkC,IAA9BG,KAAKd,MAAMC,QAAQE,WAGJ,QAAVQ,EAAAG,KAAKE,aAAL,IAAAL,OAAA,EAAAA,EAAYO,QACzB,CAOA,UAAIC,GACA,OAAIL,KAAKd,MAAMoB,4BACJN,KAAKd,MAAMC,QAAQoB,KAAIC,IAEnB,CAAEC,KADSD,EAAMC,KACEC,KAAMF,EAAMG,OAIvC,EACX,CAEAC,MAAAA,GACI,OACIC,EAACC,EAAAA,CAAaC,KAAMf,KAAKd,MAAM6B,KAAMC,eAAgBhB,KAAKd,MAAM8B,eAAgBC,UAAWjB,KAAKiB,WAC3FjB,K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pers/IssuerListContainer/IssuerListContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport IssuerList from '../../internal/IssuerList';\nimport getIssuerImageUrl from '../../../utils/get-issuer-image';\nimport { FALLBACK_CONTEXT } from '../../../core/config';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { IssuerListConfiguration, IssuerListData } from './types';\nimport type { ICore } from '../../../core/types';\n\nclass IssuerListContainer extends UIElement<IssuerListConfiguration> {\n protected static defaultProps = {\n showImage: true,\n issuers: [],\n highlightedIssuers: [],\n loadingContext: FALLBACK_CONTEXT,\n showPaymentMethodItemImages: false\n };\n\n constructor(checkout: ICore, props?: IssuerListConfiguration) {\n super(checkout, props);\n\n const getImage = props => this.resources.getImage(props);\n\n if (this.props.showImage) {\n const getIssuerIcon = getIssuerImageUrl({ loadingContext: this.props.loadingContext }, this.constructor['type'], getImage);\n\n this.props.issuers = this.props.issuers.map(item => ({\n ...item,\n icon: getIssuerIcon(item.id)\n }));\n }\n }\n\n formatProps(props) {\n const issuers = (props.details && props.details.length && (props.details.find(d => d.key === 'issuer') || {}).items) || props.issuers || [];\n return { ...props, issuers };\n }\n\n /**\n * Formats the component data output\n */\n formatData(): IssuerListData {\n return {\n paymentMethod: {\n type: this.type,\n issuer: this.state?.data?.issuer\n }\n };\n }\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n if (this.props.issuers.length === 0) {\n return true;\n }\n return !!this.state?.isValid;\n }\n\n /**\n * Returns brands array (similar to card) depending on showPaymentMethodItemImages\n * This is used to show the brands in the PaymentMethodItem\n * Requires brands icons to be loaded in the payment method\n */\n get brands(): { icon: any; name: string }[] {\n if (this.props.showPaymentMethodItemImages) {\n return this.props.issuers.map(brand => {\n const brandIcon = brand.icon;\n return { icon: brandIcon, name: brand.id };\n });\n }\n\n return [];\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n {this.props.issuers.length > 0 ? (\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <IssuerList\n ref={ref => {\n this.componentRef = ref;\n }}\n items={this.props.issuers}\n highlightedIds={this.props.highlightedIssuers}\n {...this.props}\n {...this.state}\n showImage={this.props.showImage}\n type={this.constructor['type']}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n contextualText={this.props.i18n.get('issuerList.selectField.contextualText')}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n ) : (\n this.props.showPayButton && (\n <RedirectButton\n name={this.props.name}\n {...this.props}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n )\n )}\n </CoreProvider>\n );\n }\n}\n\nexport default IssuerListContainer;\n"],"names":["IssuerListContainer","UIElement","formatProps","props","issuers","details","length","find","d","key","items","_object_spread_props","formatData","_this_state_data","_this_state","paymentMethod","type","this","issuer","state","data","isValid","brands","showPaymentMethodItemImages","map","brand","icon","name","id","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","IssuerList","ref","componentRef","highlightedIds","highlightedIssuers","showImage","constructor","onChange","setState","onSubmit","submit","payButton","contextualText","get","onSubmitAnalytics","submitAnalytics","showPayButton","RedirectButton","checkout","super","getImage","getIssuerIcon","getIssuerImageUrl","item","_define_property","defaultProps","FALLBACK_CONTEXT"],"mappings":"0xCAWA,MAAMA,UAA4BC,EAwB9BC,WAAAA,CAAYC,GACR,MAAMC,EAAWD,EAAME,SAAWF,EAAME,QAAQC,SAAWH,EAAME,QAAQE,MAAKC,GAAe,WAAVA,EAAEC,OAAqB,CAAC,GAAGC,OAAUP,EAAMC,SAAW,GACzI,OAAOO,EAAKR,EAAAA,CAAAA,EAAAA,GAAAA,CAAOC,WACvB,CAKAQ,UAAAA,OAIoBC,EAAAC,EAHhB,MAAO,CACHC,cAA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AA,KAOhD,CA/FAK,WAAAA,CAAYY,EAAiBrD,GACzBsD,MAAMD,EAAUrD,GAEhB,MAAMuD,EAAWvD,GAASc,KAAKiB,UAAUwB,SAASvD,GAElD,GAAIc,KAAKd,MAAMwC,UAAW,CACtB,MAAMgB,EAAgBC,EAAkB,CAAE3B,eAAgBhB,KAAKd,MAAM8B,gBAAkBhB,KAAK2B,iBAAqBc,GAEjHzC,KAAKd,MAAMC,QAAUa,KAAKd,MAAMC,QAAQoB,KAAIqC,GAASlD,EAC9CkD,EAAAA,CAAAA,EAAAA,GAAAA,CACHnC,KAAMiC,EAAcE,EAAKjC,OAEjC,CACJ,EArBAkC,EADE9D,EACe+D,eAAe,CAC5BpB,WAAW,EACXvC,QAAS,GACTsC,mBAAoB,GACpBT,eAAgB+B,EAChBzC,6BAA6B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{UIElement as t}from"../../internal/UIElement/UIElement.js";import r from"../../internal/OpenInvoice/OpenInvoice.js";import{CoreProvider as n}from"../../../core/Context/CoreProvider.js";import o from"../../../core/Errors/SRPanelProvider.js";function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){i(e,t,r[t])}))}return e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class l extends t{get isValid(){return!!this.state.isValid}formatProps(e){var t,r;const n=e.countryCode||(null===(r=e.data)||void 0===r||null===(t=r.billingAddress)||void 0===t?void 0:t.countryCode);return a(s({},e),{allowedCountries:[n],visibility:s({},l.defaultProps.visibility,e.visibility),data:a(s({},e.data),{billingAddress:a(s({},e.data.billingAddress),{country:n}),deliveryAddress:a(s({},e.data.deliveryAddress),{country:n})})})}formatData(){const{data:e={}}=this.state,{companyDetails:t={},personalDetails:r={},billingAddress:n,deliveryAddress:o,bankAccount:i}=e;return s({paymentMethod:{type:this.constructor.type}},r,t,i&&{bankAccount:{iban:i.ibanNumber,ownerName:i.ownerName,countryCode:i.countryCode}},n&&{billingAddress:n},(o||n)&&{deliveryAddress:o||n})}render(){return e(n,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,{srPanel:this.props.modules.srPanel},e(r,a(s({setComponentRef:this.setComponentRef},this.props,this.state),{onChange:this.setState,onSubmit:this.submit,payButton:this.payButton}))))}}i(l,"defaultProps",{onChange:()=>{},data:{companyDetails:{},personalDetails:{},billingAddress:{},deliveryAddress:{},bankAccount:{}},visibility:{companyDetails:"hidden",personalDetails:"editable",billingAddress:"editable",deliveryAddress:"editable",bankAccount:"hidden"},showFormInstruction:!0});export{l as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{UIElement as t}from"../../internal/UIElement/UIElement.js";import r from"../../internal/OpenInvoice/OpenInvoice.js";import{CoreProvider as n}from"../../../core/Context/CoreProvider.js";import o from"../../../core/Errors/SRPanelProvider.js";function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){i(e,t,r[t])}))}return e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}class l extends t{get isValid(){return!!this.state.isValid}formatProps(e){var t,r;const n=e.countryCode||(null===(r=e.data)||void 0===r||null===(t=r.billingAddress)||void 0===t?void 0:t.countryCode);return a(s({},e),{allowedCountries:[n],visibility:s({},l.defaultProps.visibility,e.visibility),data:a(s({},e.data),{billingAddress:a(s({},e.data.billingAddress),{country:n}),deliveryAddress:a(s({},e.data.deliveryAddress),{country:n})})})}formatData(){const{data:e={}}=this.state,{companyDetails:t={},personalDetails:r={},billingAddress:n,deliveryAddress:o,bankAccount:i}=e;return s({paymentMethod:{type:this.constructor.type}},r,t,i&&{bankAccount:{iban:i.ibanNumber,ownerName:i.ownerName,countryCode:i.countryCode}},n&&{billingAddress:n},(o||n)&&{deliveryAddress:o||n})}render(){return e(n,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},e(o,{srPanel:this.props.modules.srPanel},e(r,a(s({setComponentRef:this.setComponentRef},this.props,this.state),{onChange:this.setState,onSubmit:this.submit,payButton:this.payButton}))))}}i(l,"defaultProps",{onChange:()=>{},data:{companyDetails:{},personalDetails:{},billingAddress:{},deliveryAddress:{},bankAccount:{}},visibility:{companyDetails:"hidden",personalDetails:"editable",billingAddress:"editable",deliveryAddress:"editable",bankAccount:"hidden"},showFormInstruction:!0});export{l as default};
2
2
  //# sourceMappingURL=OpenInvoiceContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenInvoiceContainer.js","sources":["../../../../../src/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport OpenInvoice from '../../internal/OpenInvoice';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { OpenInvoiceConfiguration } from './types';\n\nexport default class OpenInvoiceContainer extends UIElement<OpenInvoiceConfiguration> {\n protected static defaultProps: Partial<OpenInvoiceConfiguration> = {\n onChange: () => {},\n data: { companyDetails: {}, personalDetails: {}, billingAddress: {}, deliveryAddress: {}, bankAccount: {} },\n visibility: {\n companyDetails: 'hidden',\n personalDetails: 'editable',\n billingAddress: 'editable',\n deliveryAddress: 'editable',\n bankAccount: 'hidden'\n },\n showFormInstruction: true\n };\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n return !!this.state.isValid;\n }\n\n /**\n * Formats props on construction time\n */\n formatProps(props) {\n const country = props.countryCode || props.data?.billingAddress?.countryCode;\n\n return {\n ...props,\n allowedCountries: [country],\n visibility: {\n ...OpenInvoiceContainer.defaultProps.visibility,\n ...props.visibility\n },\n data: {\n ...props.data,\n billingAddress: {\n ...props.data.billingAddress,\n country\n },\n deliveryAddress: {\n ...props.data.deliveryAddress,\n country\n }\n }\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { data = {} } = this.state;\n const { companyDetails = {}, personalDetails = {}, billingAddress, deliveryAddress, bankAccount } = data;\n\n return {\n paymentMethod: {\n type: this.constructor['type']\n },\n ...personalDetails,\n ...companyDetails,\n ...(bankAccount && {\n bankAccount: {\n iban: bankAccount.ibanNumber,\n ownerName: bankAccount.ownerName,\n countryCode: bankAccount.countryCode\n }\n }),\n ...(billingAddress && { billingAddress }),\n ...((deliveryAddress || billingAddress) && { deliveryAddress: deliveryAddress || billingAddress })\n };\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <OpenInvoice\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n"],"names":["OpenInvoiceContainer","UIElement","isValid","this","state","formatProps","props","country","countryCode","data","billingAddress","_object_spread_props","allowedCountries","visibility","_object_spread","defaultProps","deliveryAddress","formatData","companyDetails","personalDetails","bankAccount","paymentMethod","type","constructor","iban","ibanNumber","ownerName","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","OpenInvoice","setComponentRef","onChange","setState","onSubmit","submit","payButton","_define_property","showFormInstruction"],"mappings":"usCAOe,MAAMA,UAA6BC,EAiB9C,WAAIC,GACA,QAASC,KAAKC,MAAMF,OACxB,CAKAG,WAAAA,CAAYC,OAC6BA,EAAAA,EAArC,MAAMC,EAAUD,EAAME,cAAeF,QAAAA,EAAAA,EAAMG,YAANH,IAAAA,GAAAA,QAAAA,EAAAA,EAAYI,sBAAZJ,IAAAA,OAAAA,EAAAA,EAA4BE,aAEjE,OAAOG,EACAL,EAAAA,CAAAA,EAAAA,GAAAA,CACHM,iBAAkB,CAACL,GACnBM,WAAYC,KACLd,EAAqBe,aAAaF,WAClCP,EAAMO,YAEbJ,KAAME,EAAAG,EAAA,CAAA,EACCR,EAAMG,MAAI,CACbC,eAAgBC,EACTL,EAAAA,CAAAA,EAAAA,EAAMG,KAAKC,gBAAc,CAC5BH,YAEJS,gBAAiBL,EACVL,EAAAA,CAAAA,EAAAA,EAAMG,KAAKO,iBAAe,CAC7BT,eAIhB,CAKAU,UAAAA,GACI,MAAMR,KAAEA,EAAO,CAAA,GAAON,KAAKC,OACrBc,eAAEA,EAAiB,CAAE,EAAAC,gBAAEA,EAAkB,CAAA,EAAET,eAAEA,EAAcM,gBAAEA,EAAeI,YAAEA,GAAgBX,EAEpG,OAAOK,EAAA,CACHO,cAAe,CACXC,KAAMnB,KAAKoB,YAAmB,OAE/BJ,EACAD,EACCE,GAAe,CACfA,YAAa,CACTI,KAAMJ,EAAYK,WAClBC,UAAWN,EAAYM,UACvBlB,YAAaY,EAAYZ,cAG7BE,GAAkB,CAAEA,mBACnBM,GAAmBN,IAAmB,CAAEM,gBAAiBA,GAAmBN,GAEzF,CAEAiB,MAAAA,GACI,OACIC,EAACC,EAAAA,CAAaC,KAAM3B,KAAKG,MAAMwB,KAAMC,eAAgB5B,KAAKG,MAAMyB,eAAgBC,UAAW7B,KAAK6B,WAC5FJ,EAACK,EAAAA,CAAgBC,QAAS/B,KAAKG,MAAM6B,QAAQD,SACzCN,EAACQ,EAAAA,EAAAA,EAAAA,CACGC,gBAAiBlC,KAAKkC,iBAClBlC,KAAKG,MACLH,KAAKC,OAAK,CACdkC,SAAUnC,KAAKoC,SACfC,SAAUrC,KAAKsC,OACfC,UAAWvC,KAAKuC,cAKpC,EAvFAC,EADiB3C,EACAe,eAAkD,CAC/DuB,SAAU,OACV7B,KAAM,CAAES,eAAgB,CAAC,EAAGC,gBAAiB,CAAC,EAAGT,eAAgB,CAAC,EAAGM,gBAAiB,CAAC,EAAGI,YAAa,CAAC,GACxGP,WAAY,CACRK,eAAgB,SAChBC,gBAAiB,WACjBT,eAAgB,WAChBM,gBAAiB,WACjBI,YAAa,UAEjBwB,qBAAqB"}
1
+ {"version":3,"file":"OpenInvoiceContainer.js","sources":["../../../../../src/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport OpenInvoice from '../../internal/OpenInvoice';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { OpenInvoiceConfiguration } from './types';\n\nexport default class OpenInvoiceContainer extends UIElement<OpenInvoiceConfiguration> {\n protected static defaultProps: Partial<OpenInvoiceConfiguration> = {\n onChange: () => {},\n data: { companyDetails: {}, personalDetails: {}, billingAddress: {}, deliveryAddress: {}, bankAccount: {} },\n visibility: {\n companyDetails: 'hidden',\n personalDetails: 'editable',\n billingAddress: 'editable',\n deliveryAddress: 'editable',\n bankAccount: 'hidden'\n },\n showFormInstruction: true\n };\n\n /**\n * Returns whether the component state is valid or not\n */\n get isValid() {\n return !!this.state.isValid;\n }\n\n /**\n * Formats props on construction time\n */\n formatProps(props) {\n const country = props.countryCode || props.data?.billingAddress?.countryCode;\n\n return {\n ...props,\n allowedCountries: [country],\n visibility: {\n ...OpenInvoiceContainer.defaultProps.visibility,\n ...props.visibility\n },\n data: {\n ...props.data,\n billingAddress: {\n ...props.data.billingAddress,\n country\n },\n deliveryAddress: {\n ...props.data.deliveryAddress,\n country\n }\n }\n };\n }\n\n /**\n * Formats the component data output\n */\n formatData() {\n const { data = {} } = this.state;\n const { companyDetails = {}, personalDetails = {}, billingAddress, deliveryAddress, bankAccount } = data;\n\n return {\n paymentMethod: {\n type: this.constructor['type']\n },\n ...personalDetails,\n ...companyDetails,\n ...(bankAccount && {\n bankAccount: {\n iban: bankAccount.ibanNumber,\n ownerName: bankAccount.ownerName,\n countryCode: bankAccount.countryCode\n }\n }),\n ...(billingAddress && { billingAddress }),\n ...((deliveryAddress || billingAddress) && { deliveryAddress: deliveryAddress || billingAddress })\n };\n }\n\n render() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <OpenInvoice\n setComponentRef={this.setComponentRef}\n {...this.props}\n {...this.state}\n onChange={this.setState}\n onSubmit={this.submit}\n payButton={this.payButton}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n"],"names":["OpenInvoiceContainer","UIElement","isValid","this","state","formatProps","props","country","countryCode","data","billingAddress","_object_spread_props","allowedCountries","visibility","_object_spread","defaultProps","deliveryAddress","formatData","companyDetails","personalDetails","bankAccount","paymentMethod","type","constructor","iban","ibanNumber","ownerName","render","h","CoreProvider","i18n","loadingContext","resources","SRPanelProvider","srPanel","modules","OpenInvoice","setComponentRef","onChange","setState","onSubmit","submit","payBut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AA,EAAAA,CACGC,gBAAiBlC,KAAKkC,iBAClBlC,KAAKG,MACLH,KAAKC,OAAK,CACdkC,SAAUnC,KAAKoC,SACfC,SAAUrC,KAAKsC,OACfC,UAAWvC,KAAKuC,cAKpC,EAvFAC,EADiB3C,EACAe,eAAkD,CAC/DuB,SAAU,OACV7B,KAAM,CAAES,eAAgB,CAAC,EAAGC,gBAAiB,CAAC,EAAGT,eAAgB,CAAC,EAAGM,gBAAiB,CAAC,EAAGI,YAAa,CAAC,GACxGP,WAAY,CACRK,eAAgB,SAChBC,gBAAiB,WACjBT,eAAgB,WAChBM,gBAAiB,WACjBI,YAAa,UAEjBwB,qBAAqB"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import r from"../../internal/QRLoader/QRLoader.js";import{CoreProvider as o}from"../../../core/Context/CoreProvider.js";import n from"../../internal/RedirectButton/RedirectButton.js";import s from"../../../core/Errors/SRPanelProvider.js";function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){i(t,e,r[e])}))}return t}function a(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}class c extends e{formatData(){return{paymentMethod:p({type:this.type},this.state.data)}}get isValid(){return!0}renderQRCode(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{srPanel:this.props.modules.srPanel},t(r,a(p({ref:t=>{this.componentRef=t}},this.props),{type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,delay:this.props.delay,onComplete:this.onComplete,countdownTime:this.props.countdownTime,instructions:this.props.instructions,onActionHandled:this.props.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics}))))}render(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{name:this.displayName,onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})):null}}i(c,"defaultProps",{qrCodeImage:"",amount:null,paymentData:null,onError:()=>{},onComplete:()=>{},onActionHandled:()=>{}});export{c as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import{UIElement as e}from"../../internal/UIElement/UIElement.js";import r from"../../internal/QRLoader/QRLoader.js";import{CoreProvider as o}from"../../../core/Context/CoreProvider.js";import n from"../../internal/RedirectButton/RedirectButton.js";import s from"../../../core/Errors/SRPanelProvider.js";function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){i(t,e,r[e])}))}return t}function a(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}class c extends e{formatData(){return{paymentMethod:p({type:this.type},this.state.data)}}get isValid(){return!0}renderQRCode(){return t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(s,{srPanel:this.props.modules.srPanel},t(r,a(p({ref:t=>{this.componentRef=t}},this.props),{type:this.constructor.type,brandLogo:this.props.brandLogo||this.icon,delay:this.props.delay,onComplete:this.onComplete,countdownTime:this.props.countdownTime,instructions:this.props.instructions,onActionHandled:this.props.onActionHandled,brandName:this.displayName,onSubmitAnalytics:this.submitAnalytics}))))}render(){return this.props.paymentData?this.renderQRCode():this.props.showPayButton?t(o,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(n,{name:this.displayName,onSubmit:this.submit,payButton:this.payButton,ref:t=>{this.componentRef=t}})):null}}i(c,"defaultProps",{qrCodeImage:"",amount:null,paymentData:null,onError:()=>{},onComplete:()=>{},onActionHandled:()=>{}});export{c as default};
2
2
  //# sourceMappingURL=QRLoaderContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport QRLoader from '../../internal/QRLoader';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {},\n onComplete: () => {},\n onActionHandled: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n delay={this.props.delay}\n onComplete={this.onComplete}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n onActionHandled={this.props.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n render() {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <RedirectButton\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </CoreProvider>\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","_object_spread","type","this","state","data","isValid","renderQRCode","h","CoreProvider","i18n","props","loadingContext","resources","SRPanelProvider","srPanel","modules","QRLoader","ref","componentRef","constructor","brandLogo","icon","delay","onComplete","countdownTime","instructions","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","render","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","_define_property","defaultProps","qrCodeImage","amount","onError"],"mappings":"gwCAQA,MAAMA,UAAmFC,EAWrFC,UAAAA,GACI,MAAO,CACHC,cAAeC,EAAA,CACXC,KAAMC,KAAKD,MACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAACM,EAAAA,CAAgBC,QAASZ,KAAKQ,MAAMK,QAAQD,SACzCP,EAACS,EAAAA,EAAAA,EAAAA,CACGC,IAAKA,IACDf,KAAKgB,aAAeD,CAAAA,GAEpBf,KAAKQ,OAAK,CACdT,KAAMC,KAAKiB,YAAmB,KAC9BC,UAAWlB,KAAKQ,MAAMU,WAAalB,KAAKmB,KACxCC,MAAOpB,KAAKQ,MAAMY,MAClBC,WAAYrB,KAAKqB,WACjBC,cAAetB,KAAKQ,MAAMc,cAC1BC,aAAcvB,KAAKQ,MAAMe,aACzBC,gBAAiBxB,KAAKQ,MAAMgB,gBAC5BC,UAAWzB,KAAK0B,YAChBC,kBAAmB3B,KAAK4B,oBAK5C,CAEAC,MAAAA,GACI,OAAI7B,KAAKQ,MAAMsB,YACJ9B,KAAKI,eAGZJ,KAAKQ,MAAMuB,cAEP1B,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAAC2B,EAAAA,CACGC,KAAMjC,KAAK0B,YACXQ,SAAUlC,KAAKmC,OACfC,UAAWpC,KAAKoC,UAChBrB,IAAKA,IACDf,KAAKgB,aAAeD,CAAAA,KAOjC,IACX,EApEAsB,EAFE3C,EAEe4C,eAAe,CAC5BC,YAAa,GACbC,OAAQ,KACRV,YAAa,KACbW,QAAS,OACTpB,WAAY,OACZG,gBAAiB"}
1
+ {"version":3,"file":"QRLoaderContainer.js","sources":["../../../../../src/components/helpers/QRLoaderContainer/QRLoaderContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport UIElement from '../../internal/UIElement/UIElement';\nimport QRLoader from '../../internal/QRLoader';\nimport { CoreProvider } from '../../../core/Context/CoreProvider';\nimport RedirectButton from '../../internal/RedirectButton';\nimport SRPanelProvider from '../../../core/Errors/SRPanelProvider';\nimport { QRLoaderConfiguration } from './types';\n\nclass QRLoaderContainer<T extends QRLoaderConfiguration = QRLoaderConfiguration> extends UIElement<T> {\n // Using the generic here allow to fully extend the QRLoaderContainer (including it's props)\n protected static defaultProps = {\n qrCodeImage: '',\n amount: null,\n paymentData: null,\n onError: () => {},\n onComplete: () => {},\n onActionHandled: () => {}\n };\n\n formatData() {\n return {\n paymentMethod: {\n type: this.type,\n ...this.state.data\n }\n };\n }\n\n get isValid() {\n return true;\n }\n\n // Makes possible to extend the final QR code step\n public renderQRCode() {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n type={this.constructor['type']}\n brandLogo={this.props.brandLogo || this.icon}\n delay={this.props.delay}\n onComplete={this.onComplete}\n countdownTime={this.props.countdownTime}\n instructions={this.props.instructions}\n onActionHandled={this.props.onActionHandled}\n brandName={this.displayName}\n onSubmitAnalytics={this.submitAnalytics}\n />\n </SRPanelProvider>\n </CoreProvider>\n );\n }\n\n render() {\n if (this.props.paymentData) {\n return this.renderQRCode();\n }\n\n if (this.props.showPayButton) {\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <RedirectButton\n name={this.displayName}\n onSubmit={this.submit}\n payButton={this.payButton}\n ref={ref => {\n this.componentRef = ref;\n }}\n />\n </CoreProvider>\n );\n }\n\n return null;\n }\n}\n\nexport default QRLoaderContainer;\n"],"names":["QRLoaderContainer","UIElement","formatData","paymentMethod","_object_spread","type","this","state","data","isValid","renderQRCode","h","CoreProvider","i18n","props","loadingContext","resources","SRPanelProvider","srPanel","modules","QRLoader","ref","componentRef","constructor","brandLogo","icon","delay","onComplete","countdownTime","instructions","onActionHandled","brandName","displayName","onSubmitAnalytics","submitAnalytics","render","paymentData","showPayButton","RedirectButton","name","onSubmit","submit","payButton","_define_property","defaultProps","qrCodeImage","amount","onError"],"mappings":"yqCAQA,MAAMA,UAAmFC,EAWrFC,UAAAA,GACI,MAAO,CACHC,cAAeC,EAAA,CACXC,KAAMC,KAAKD,MACRC,KAAKC,MAAMC,MAG1B,CAEA,WAAIC,GACA,OAAO,CACX,CAGOC,YAAAA,GACH,OACIC,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAACM,EAAAA,CAAgBC,QAASZ,KAAKQ,MAAMK,QAAQD,SACzCP,EAACS,EAAAA,EAAAA,EAAAA,CACGC,IAAKA,IACDf,KAAKgB,aAAeD,CAAAA,GAEpBf,KAAKQ,OAAK,CACdT,KAAMC,KAAKiB,YAAmB,KAC9BC,UAAWlB,KAAKQ,MAAMU,WAAalB,KAAKmB,KACxCC,MAAOpB,KAAKQ,MAAMY,MAClBC,WAAYrB,KAAKqB,WACjBC,cAAetB,KAAKQ,MAAMc,cAC1BC,aAAcvB,KAAKQ,MAAMe,aACzBC,gBAAiBxB,KAAKQ,MAAMgB,gBAC5BC,UAAWzB,KAAK0B,YAChBC,kBAAmB3B,KAAK4B,oBAK5C,CAEAC,MAAAA,GACI,OAAI7B,KAAKQ,MAAMsB,YACJ9B,KAAKI,eAGZJ,KAAKQ,MAAMuB,cAEP1B,EAACC,EAAAA,CAAaC,KAAMP,KAAKQ,MAAMD,KAAME,eAAgBT,KAAKQ,MAAMC,eAAgBC,UAAWV,KAAKU,WAC5FL,EAAC2B,EAAAA,CACGC,KAAMjC,KAAK0B,YACXQ,SAAUlC,KAAKmC,OACfC,UAAWpC,KAAKoC,UAChBrB,IAAKA,IACDf,KAAKgB,aAAeD,CAAAA,KAOjC,IACX,EApEAsB,EAFE3C,EAEe4C,eAAe,CAC5BC,YAAa,GACbC,OAAQ,KACRV,YAAa,KACbW,QAAS,OACTpB,WAAY,OACZG,gBAAiB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as d,countrySpecificFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import f from"../../../utils/useForm/useForm.js";import m from"./Specifications.js";import{FALLBACK_VALUE as y,ADDRESS_SCHEMA as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as O}from"../../../utils/validator-utils.js";import{useCoreContext as g}from"../../../core/Context/CoreProvider.js";import h from"./components/AddressSearch.js";function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){j(e,t,r[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function C(j){const{i18n:C}=g(),{label:A="",requiredFields:P,visibility:w,iOSFocusedField:S=null,showContextualElement:k}=j,x=r({});var D;Object.keys(x.current).length||(null===(D=j.setComponentRef)||void 0===D||D.call(j,x.current));const M=o((()=>new m(j.specifications)),[j.specifications]),E=M.getAddressSchemaForCountryFlat(j.countryCode).filter((e=>P.includes(e))),[B,N]=n(!1),[L,R]=n(!1),[V,q]=n(""),H=!!j.onAddressLookup,T=!j.onAddressLookup||(B||L),{data:_,errors:I,valid:$,isValid:z,handleChangeFor:G,triggerValidation:J,setData:K}=f({schema:E,defaultData:j.data,rules:F({},c(M),j.validationRules),formatters:d}),Q=s((e=>{b.forEach((t=>{const r=e[t];null!=r&&K(t,String(r))})),J(),N(!0)}),[N,J,K]),U=s((()=>{R(!0)}),[]);x.current.showValidation=()=>{J(),q(!H||T||z?"":C.get("address.errors.incomplete"))};const W=E.filter((e=>!S||e===S));if(a((()=>{const e=M.countryHasDataset(_.country)?"":y,t=v(F({},_),{stateOrProvince:e});P.forEach((e=>{var r;G(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")})),t.postalCode&&G("postalCode","blur")(_.postalCode)}),[_.country]),a((()=>{const e=P.includes("stateOrProvince"),t=_.country&&M.countryHasDataset(_.country),r=e&&t,o=_.stateOrProvince||(r?"":y);G("stateOrProvince","input")(o)}),[]),a((()=>{const e=M.getOptionalFieldsForCountry(_.country),t=b.reduce(((t,r)=>{const o=e.includes(r),n=P.includes(r),s=_[r],a=j.data[r],i=o&&!s||!n?n||s||!a?y:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t}),{});j.onChange({data:t,valid:$,errors:I,isValid:z})}),[_,$,I,z]),"hidden"===w)return null;if("readOnly"===w)return e(l,{data:_,label:A});const X=(t,{classNameModifiers:r=[]})=>P.includes(t)?e(p,{key:t,allowedCountries:j.allowedCountries,classNameModifiers:[...r,t],data:_,errors:I,valid:$,fieldName:t,onInput:G(t,"input"),onBlur:G(t,"blur"),onDropdownChange:G(t,"blur"),specifications:M,maxLength:O(u,t,_.country,!0),trimOnBlur:!0,disabled:!W.includes(t),onFieldFocusAnalytics:j.onFieldFocusAnalytics,onFieldBlurAnalytics:j.onFieldBlurAnalytics}):null,Y=M.getAddressSchemaForCountry(_.country);return e(t,null,e(i,{classNameModifiers:[A||"address"],label:A},H&&e(h,{onAddressLookup:j.onAddressLookup,onAddressSelected:j.onAddressSelected,onSelect:Q,onManualAddress:U,externalErrorMessage:V,hideManualButton:T,showContextualElement:k,contextualText:C.get("address.search.contextualText"),addressSearchDebounceMs:j.addressSearchDebounceMs}),T&&e(t,null,Y.map((t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map((([e,t])=>X(e,{classNameModifiers:[`col-${t}`]})))):X(t,{}))))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:b,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as d,countrySpecificFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{FALLBACK_VALUE as y,ADDRESS_SCHEMA as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as O}from"../../../utils/validator-utils.js";import{useCoreContext as h}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){j(e,t,r[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function C(j){const{i18n:C}=h(),{label:A="",requiredFields:P,visibility:w,iOSFocusedField:S=null,showContextualElement:k}=j,x=r({});var D;Object.keys(x.current).length||(null===(D=j.setComponentRef)||void 0===D||D.call(j,x.current));const M=o((()=>new f(j.specifications)),[j.specifications]),E=M.getAddressSchemaForCountryFlat(j.countryCode).filter((e=>P.includes(e))),[B,N]=n(!1),[L,R]=n(!1),[V,q]=n(""),H=!!j.onAddressLookup,T=!j.onAddressLookup||(B||L),{data:_,errors:I,valid:$,isValid:z,handleChangeFor:G,triggerValidation:J,setData:K}=m({schema:E,defaultData:j.data,rules:F({},c(M),j.validationRules),formatters:d}),Q=s((e=>{b.forEach((t=>{const r=e[t];null!=r&&K(t,String(r))})),J(),N(!0)}),[N,J,K]),U=s((()=>{R(!0)}),[]);x.current.showValidation=()=>{J(),q(!H||T||z?"":C.get("address.errors.incomplete"))};const W=E.filter((e=>!S||e===S));if(a((()=>{const e=M.countryHasDataset(_.country)?"":y,t=v(F({},_),{stateOrProvince:e});P.forEach((e=>{var r;G(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")})),t.postalCode&&G("postalCode","blur")(_.postalCode)}),[_.country]),a((()=>{const e=P.includes("stateOrProvince"),t=_.country&&M.countryHasDataset(_.country),r=e&&t,o=_.stateOrProvince||(r?"":y);G("stateOrProvince","input")(o)}),[]),a((()=>{const e=M.getOptionalFieldsForCountry(_.country),t=b.reduce(((t,r)=>{const o=e.includes(r),n=P.includes(r),s=_[r],a=j.data[r],i=o&&!s||!n?n||s||!a?y:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t}),{});j.onChange({data:t,valid:$,errors:I,isValid:z})}),[_,$,I,z]),"hidden"===w)return null;if("readOnly"===w)return e(l,{data:_,label:A});const X=(t,{classNameModifiers:r=[]})=>P.includes(t)?e(p,{key:t,allowedCountries:j.allowedCountries,classNameModifiers:[...r,t],data:_,errors:I,valid:$,fieldName:t,onInput:G(t,"input"),onBlur:G(t,"blur"),onDropdownChange:G(t,"blur"),specifications:M,maxLength:O(u,t,_.country),trimOnBlur:!0,disabled:!W.includes(t),onFieldFocusAnalytics:j.onFieldFocusAnalytics,onFieldBlurAnalytics:j.onFieldBlurAnalytics}):null,Y=M.getAddressSchemaForCountry(_.country);return e(t,null,e(i,{classNameModifiers:[A||"address"],label:A},H&&e(g,{onAddressLookup:j.onAddressLookup,onAddressSelected:j.onAddressSelected,onSelect:Q,onManualAddress:U,externalErrorMessage:V,hideManualButton:T,showContextualElement:k,contextualText:C.get("address.search.contextualText"),addressSearchDebounceMs:j.addressSearchDebounceMs}),T&&e(t,null,Y.map((t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map((([e,t])=>X(e,{classNameModifiers:[`col-${t}`]})))):X(t,{}))))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:b,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
2
2
  //# sourceMappingURL=Address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport default function Address(props: AddressProps) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n propsKeysToProcess.forEach(propKey => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue === null || providedValue === undefined) return;\n // Cast everything to string\n setData(propKey, String(providedValue));\n });\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label || 'address']} label={label}>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","showAddressFields","data","errors","valid","isValid","handleChangeFor","triggerValidation","setData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","ADDRESS_SCHEMA","forEach","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","country","FALLBACK_VALUE","newData","_object_spread_props","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","reduce","acc","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"+tDAiBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAG5FQ,EAAaC,EAA4B,CAAA,GAG3CT,IAAAA,EADCU,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBb,EAAAA,EAAMc,2BAANd,GAAAA,EAAAA,KAAAA,EAAwBQ,EAAWI,UAGvC,MAAMG,EAAiBC,GAAQ,IAAM,IAAIC,EAAejB,EAAMe,iBAAiB,CAACf,EAAMe,iBAEhFG,EAAuBH,EAAeI,+BAA+BnB,EAAMoB,aAAaC,QAAOC,GAASlB,EAAemB,SAASD,MAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsB/B,EAA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,OACIqB,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAACvF,GAAS,WAAYA,MAAOA,GACtD4B,GACGwD,EAACqB,EAAAA,CACG5E,gBAAiBhC,EAAMgC,gBACvB6E,kBAAmB7G,EAAM6G,kBACzBC,SAAU5D,EACVQ,gBAAiBA,EACjBqD,qBAAsBlF,EACtBmF,iBAAkB/E,EAClB1B,sBAAuBA,EACvB0G,eAAgBhH,EAAK2D,IAAI,iCACzBsD,wBAAyBlH,EAAMkH,0BAGtCjF,GACGsD,EAACmB,EAAAA,KAAUF,EAAcW,KAAI7F,GAAUA,aAAiB8F,MAxBpE7B,EAAC8B,MAAAA,CAAIC,UAAU,+BAwBwEhG,EAvB5E6F,KAAI,EAAE7F,EAAOiG,KAAU9B,EAAanE,EAAO,CAAEoE,mBAAoB,CAAC,OAAO6B,UAuBY9B,EAAanE,EAAO,QAK5H,CAEAvB,EAAQyH,aAAe,CACnBpG,YAAa,KACb2B,gBAAiB,KACjBb,KAAM,CAAC,EACPoD,SAAU,OACVjF,WAAY,WACZD,eAAgBiD,EAChBtC,eAAgB,CAAC,EACjBuF,sBAAuB,OACvBC,qBAAsB"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport default function Address(props: AddressProps) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n propsKeysToProcess.forEach(propKey => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue === null || providedValue === undefined) return;\n // Cast everything to string\n setData(propKey, String(providedValue));\n });\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label || 'address']} label={label}>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","showAddressFields","data","errors","valid","isValid","handleChangeFor","triggerValidation","setData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","ADDRESS_SCHEMA","forEach","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","country","FALLBACK_VALUE","newData","_object_spread_props","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","reduce","acc","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"woDAiBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAG5FQ,EAAaC,EAA4B,CAAA,GAG3CT,IAAAA,EADCU,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBb,EAAAA,EAAMc,2BAANd,GAAAA,EAAAA,KAAAA,EAAwBQ,EAAWI,UAGvC,MAAMG,EAAiBC,GAAQ,IAAM,IAAIC,EAAejB,EAAMe,iBAAiB,CAACf,EAAMe,iBAEhFG,EAAuBH,EAAeI,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C,SACpFkC,YAAY,EACZC,UAAWxC,EAActC,SAAS+C,GAClCgC,sBAAuBtG,EAAMsG,sBAC7BC,qBAAsBvG,EAAMuG,uBAnBY,KA8B9CC,EAAgBzF,EAAe0F,2BAA2BvE,EAAKgC,SAErE,OACIqB,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAACvF,GAAS,WAAYA,MAAOA,GACtD4B,GACGwD,EAACqB,EAAAA,CACG5E,gBAAiBhC,EAAMgC,gBACvB6E,kBAAmB7G,EAAM6G,kBACzBC,SAAU5D,EACVQ,gBAAiBA,EACjBqD,qBAAsBlF,EACtBmF,iBAAkB/E,EAClB1B,sBAAuBA,EACvB0G,eAAgBhH,EAAK2D,IAAI,iCACzBsD,wBAAyBlH,EAAMkH,0BAGtCjF,GACGsD,EAACmB,EAAAA,KAAUF,EAAcW,KAAI7F,GAAUA,aAAiB8F,MAxBpE7B,EAAC8B,MAAAA,CAAIC,UAAU,+BAwBwEhG,EAvB5E6F,KAAI,EAAE7F,EAAOiG,KAAU9B,EAAanE,EAAO,CAAEoE,mBAAoB,CAAC,OAAO6B,UAuBY9B,EAAanE,EAAO,QAK5H,CAEAvB,EAAQyH,aAAe,CACnBpG,YAAa,KACb2B,gBAAiB,KACjBb,KAAM,CAAC,EACPoD,SAAU,OACVjF,WAAY,WACZD,eAAgBiD,EAChBtC,eAAgB,CAAC,EACjBuF,sBAAuB,OACvBC,qBAAsB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import c from"../../../../core/Services/get-dataset.js";import s from"../../FormFields/Select/Select.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const l=(e,t)=>{const r=e=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){a(e,t,r[t])}))}return e}({},e),{name:e.name,selectedOptionName:e.name});return t.length?e.filter((e=>t.includes(e.id))).map(r):e.map(r)};function u(a){const{allowedCountries:i=[],classNameModifiers:u=[],errorMessage:p,onDropdownChange:f,value:m}=a,{i18n:O,loadingContext:d}=n(),[y,b]=t([]),[j,g]=t(!1),[h,w]=t(a.readOnly);return r((()=>{c("countries",d,O.locale).then((e=>{const t=l(e,i);b(t||[]),w(1===t.length||h),g(!0)})).catch((e=>{console.error(e),b([]),g(!0)}))}),[]),j?e(o,{name:"country",label:O.get("country"),errorMessage:p,classNameModifiers:u,isValid:!!m,showValidIcon:!1,i18n:O,readOnly:h&&!!m},e(s,{onChange:f,name:"country",selectedValue:m,items:y,readonly:h&&!!m})):null}export{u as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import c from"../../../../core/Services/get-dataset.js";import s from"../../FormFields/Select/Select.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const l=(e,t)=>{const r=e=>i(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){a(e,t,r[t])}))}return e}({},e),{name:e.name,selectedOptionName:e.name});return t.length?e.filter((e=>t.includes(e.id))).map(r):e.map(r)};function u(a){const{allowedCountries:i=[],classNameModifiers:u=[],errorMessage:p,onDropdownChange:m,value:f}=a,{i18n:d,loadingContext:y}=n(),[O,b]=t([]),[j,g]=t(!1),[h,w]=t(a.readOnly);return r((()=>{c("countries",y,d.locale).then((e=>{const t=l(e,i);b(t||[]),w(1===t.length||h),g(!0)})).catch((e=>{console.error(e),b([]),g(!0)}))}),[]),j?e(o,{name:"country",label:d.get("country"),errorMessage:p,classNameModifiers:u,isValid:!!f,showValidIcon:!1,i18n:d,readOnly:h&&!!f},e(s,{onChange:m,name:"country",selectedValue:f,items:O,readonly:h&&!!f})):null}export{u as default};
2
2
  //# sourceMappingURL=CountryField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select onChange={onDropdownChange} name={'country'} selectedValue={value} items={countries} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["formatCountries","countries","allowedCountries","applyMapper","country","_object_spread_props","name","selectedOptionName","length","filter","includes","id","map","CountryField","props","classNameModifiers","errorMessage","onDropdownChange","value","i18n","loadingContext","useCoreContext","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"68BAQA,MAAMA,EAAkB,CAACC,EAAoCC,KACzD,MACMC,EAAeC,GACVC,wUACAD,CAAAA,CAAAA,EAAAA,GAAAA,CACHE,KAAMF,EAAQE,KACdC,mBAAoBH,EAAQE,OAGpC,OAAOJ,EAAiBM,OAASP,EAAUQ,QARtBL,GAA8BF,EAAiBQ,SAASN,EAAQO,MAQtBC,IAAIT,GAAeF,EAAUW,IAAIT,EAAAA,EAGrF,SAASU,EAAaC,GACjC,MAAMZ,iBAAEA,EAAmB,GAAEa,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,GAAUJ,GAC5FK,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BpB,EAAWqB,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAAST,EAAMY,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaT,EAAgBD,EAAKW,QACxCC,MAAKC,IACF,MAAMC,EAAejC,EAAgBgC,EAAU9B,GAC/CoB,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAazB,QAAgBkB,GACzCD,GAAU,EAAA,IAEbS,OAAMC,IACHC,QAAQD,MAAMA,GACdb,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDa,EAACC,EAAAA,CACGhC,KAAM,UACNiC,MAAOpB,EAAKqB,IAAI,WAChBxB,aAAcA,EACdD,mBAAoBA,EACpB0B,UAAWvB,EACXwB,eAAe,EACfvB,KAAMA,EACNO,SAAUA,KAAcR,GAExBmB,EAACM,EAAAA,CAAOC,SAAU3B,EAAkBX,KAAM,UAAWuC,cAAe3B,EAAO4B,MAAO7C,EAAW8C,SAAUrB,KAAcR,KAbzG,IAgBxB"}
1
+ {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select onChange={onDropdownChange} name={'country'} selectedValue={value} items={countries} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["formatCountries","countries","allowedCountries","applyMapper","country","_object_spread_props","name","selectedOptionName","length","filter","includes","id","map","CountryField","props","classNameModifiers","errorMessage","onDropdownChange","value","i18n","loadingContext","useCoreContext","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"s3BAQA,MAAMA,EAAkB,CAACC,EAAoCC,KACzD,MACMC,EAAeC,GACVC,wUACAD,CAAAA,CAAAA,EAAAA,GAAAA,CACHE,KAAMF,EAAQE,KACdC,mBAAoBH,EAAQE,OAGpC,OAAOJ,EAAiBM,OAASP,EAAUQ,QARtBL,GAA8BF,EAAiBQ,SAASN,EAAQO,MAQtBC,IAAIT,GAAeF,EAAUW,IAAIT,EAAAA,EAGrF,SAASU,EAAaC,GACjC,MAAMZ,iBAAEA,EAAmB,GAAEa,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,GAAUJ,GAC5FK,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BpB,EAAWqB,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAAST,EAAMY,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaT,EAAgBD,EAAKW,QACxCC,MAAKC,IACF,MAAMC,EAAejC,EAAgBgC,EAAU9B,GAC/CoB,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAazB,QAAgBkB,GACzCD,GAAU,EAAA,IAEbS,OAAMC,IACHC,QAAQD,MAAMA,GACdb,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDa,EAACC,EAAAA,CACGhC,KAAM,UACNiC,MAAOpB,EAAKqB,IAAI,WAChBxB,aAAcA,EACdD,mBAAoBA,EACpB0B,UAAWvB,EACXwB,eAAe,EACfvB,KAAMA,EACNO,SAAUA,KAAcR,GAExBmB,EAACM,EAAAA,CAAOC,SAAU3B,EAAkBX,KAAM,UAAWuC,cAAe3B,EAAO4B,MAAO7C,EAAW8C,SAAUrB,KAAcR,KAbzG,IAgBxB"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{ANALYTICS_RENDERED_STR as n}from"../../../core/Analytics/constants.js";function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){s(t,e,r[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function p(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class a{buildElementProps(t){this.props=this.formatProps(i({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}setState(t){this.state=i({},this.state,t)}get data(){var t,r;const o=e(this.props,"modules.risk.data"),n=!!(null===(t=e(this.props,"modules.analytics.getEnabled"))||void 0===t?void 0:t())?null===(r=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===r?void 0:r():"do-not-track",s=this.state.order||this.props.order,a=this.formatData();if(a.paymentMethod&&n&&(a.paymentMethod.checkoutAttemptId=n),"riverty"!==this.props.type&&a.billingAddress){const t=p(a.billingAddress,["firstName","lastName"]);a.billingAddress=i({},t)}return c(i({},o&&{riskData:{clientData:o}},s&&{order:{orderData:s.orderData,pspReference:s.pspReference}},a),{clientStateDataIndicator:!0})}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var s;(this._node&&this.unmount(),this._node=r,this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(s=this.constructor.analyticsType)&&void 0!==s?s:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:n})})));return this}update(t){return this.props=this.formatProps(i({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){s(this,"_id",`${this.constructor.type}-${r()}`),s(this,"props",void 0),s(this,"state",{}),s(this,"_component",void 0),s(this,"_node",null),s(this,"core",void 0);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e)}}s(a,"defaultProps",{});export{a as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{ANALYTICS_RENDERED_STR as n}from"../../../core/Analytics/constants.js";function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){s(t,e,r[e])}))}return t}function c(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r.push.apply(r,o)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function p(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class a{buildElementProps(t){this.props=this.formatProps(i({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}setState(t){this.state=i({},this.state,t)}get data(){var t,r;const o=e(this.props,"modules.risk.data"),n=!!(null===(t=e(this.props,"modules.analytics.getEnabled"))||void 0===t?void 0:t())?null===(r=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===r?void 0:r():"do-not-track",s=this.state.order||this.props.order,a=this.formatData();if(a.paymentMethod&&n&&(a.paymentMethod.checkoutAttemptId=n),"riverty"!==this.props.type&&a.billingAddress){const t=p(a.billingAddress,["firstName","lastName"]);a.billingAddress=i({},t)}return c(i({},o&&{riskData:{clientData:o}},s&&{order:{orderData:s.orderData,pspReference:s.pspReference}},a),{clientStateDataIndicator:!0})}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var s;(this._node&&this.unmount(),this._node=r,this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(s=this.constructor.analyticsType)&&void 0!==s?s:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:n})})));return this}update(t){return this.props=this.formatProps(i({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){s(this,"_id",`${this.constructor.type}-${r()}`),s(this,"props",void 0),s(this,"state",{}),s(this,"_component",void 0),s(this,"_node",null),s(this,"core",void 0);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e)}}s(a,"defaultProps",{});export{a as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nclass BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n protected readonly core: ICore;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n *\n * TODO: Replace 'any' by type PaymentMethodData<T> - this change requires updating all payment methods,\n * properly adding the type of the formatData function\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const useAnalytics = !!getProp(this.props, 'modules.analytics.getEnabled')?.();\n const checkoutAttemptId = useAnalytics ? getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() : 'do-not-track';\n const order = this.state.order || this.props.order;\n\n const componentData = this.formatData();\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && (node as HTMLElement).offsetWidth,\n component: !this.props.isDropin ? this.constructor['analyticsType'] ?? this.constructor['type'] : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","setState","newState","state","data","getProp","clientData","checkoutAttemptId","order","componentData","paymentMethod","type","billingAddress","rest","firstName","lastName","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","defaultProps"],"mappings":"ohDAsBA,MAAMA,EA0BQC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,CAAA,EAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CASA,UAAAI,GACI,MAAO,EACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,OAEgBC,EACkBA,EAFzC,MAAMC,EAAaD,EAAQd,KAAKC,MAAO,qBAEjCe,KADqC,QAApBF,EAAAA,EAAQd,KAAKC,MAAO,uCAApBa,IAAAA,OAAAA,EAAAA,KACkBA,QAAAA,EAAAA,EAAQd,KAAKC,MAAO,iDAApBa,IAAAA,OAAAA,EAAAA,IAAoE,eACvGG,EAAQjB,KAAKY,MAAMK,OAASjB,KAAKC,MAAMgB,MAEvCC,EAAgBlB,KAAKK,aAQ3B,GAPIa,EAAcC,eAAiBH,IAC/BE,EAAcC,cAAcH,kBAAoBA,GAM5B,YAApBhB,KAAKC,MAAMmB,MAAsBF,EAAcG,eAAgB,CACtBH,MAATI,EAASJ,EAAAA,EAAcG,eAAdH,CAAjCK,YAAWC,aACnBN,EAAcG,eAAiBlB,EAAKmB,CAAAA,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YkD,EAAiBrD,GAX7BsD,EAAAvD,KAAgBwD,MAAM,GAAGxD,KAAKI,YAAY,QAAWqD,OAErDF,EAAAvD,KAAOC,aAAP,GACAsD,EAAAvD,KAAOY,QAAa,CAAA,GACpB2C,EAAAvD,KAAOyC,kBAAP,GAEAc,EAAAvD,KAAUsC,QAAqB,MAC/BiB,EAAAvD,KAAmBqD,YAAnB,GAKI,MAAMK,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC9D,KAAKI,YAAmB,6DAIvEJ,KAAKqD,KAAOC,EACZtD,KAAKF,kBAAkBG,EAC3B,EAdAsD,EAVE1D,EAUekE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { ANALYTICS_RENDERED_STR } from '../../../core/Analytics/constants';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nclass BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n protected readonly core: ICore;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n *\n * TODO: Replace 'any' by type PaymentMethodData<T> - this change requires updating all payment methods,\n * properly adding the type of the formatData function\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const useAnalytics = !!getProp(this.props, 'modules.analytics.getEnabled')?.();\n const checkoutAttemptId = useAnalytics ? getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() : 'do-not-track';\n const order = this.state.order || this.props.order;\n\n const componentData = this.formatData();\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && (node as HTMLElement).offsetWidth,\n component: !this.props.isDropin ? this.constructor['analyticsType'] ?? this.constructor['type'] : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","setState","newState","state","data","getProp","clientData","checkoutAttemptId","order","componentData","paymentMethod","type","billingAddress","rest","firstName","lastName","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","defaultProps"],"mappings":"67CAsBA,MAAMA,EA0BQC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,CAAA,EAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CASA,UAAAI,GACI,MAAO,EACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfX,KAAKY,MAAQT,KAAKH,KAAKY,MAAUD,EACrC,CAMA,QAAWE,OAEgBC,EACkBA,EAFzC,MAAMC,EAAaD,EAAQd,KAAKC,MAAO,qBAEjCe,KADqC,QAApBF,EAAAA,EAAQd,KAAKC,MAAO,uCAApBa,IAAAA,OAAAA,EAAAA,KACkBA,QAAAA,EAAAA,EAAQd,KAAKC,MAAO,iDAApBa,IAAAA,OAAAA,EAAAA,IAAoE,eACvGG,EAAQjB,KAAKY,MAAMK,OAASjB,KAAKC,MAAMgB,MAEvCC,EAAgBlB,KAAKK,aAQ3B,GAPIa,EAAcC,eAAiBH,IAC/BE,EAAcC,cAAcH,kBAAoBA,GAM5B,YAApBhB,KAAKC,MAAMmB,MAAsBF,EAAcG,eAAgB,CACtBH,MA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IpD,KAAKwC,UAEDxC,KAAKqD,MACLrD,KAAKqD,KAAKD,OAAOpD,KAEzB,CAtKAI,WAAAA,CAAYkD,EAAiBrD,GAX7BsD,EAAAvD,KAAgBwD,MAAM,GAAGxD,KAAKI,YAAY,QAAWqD,OAErDF,EAAAvD,KAAOC,aAAP,GACAsD,EAAAvD,KAAOY,QAAa,CAAA,GACpB2C,EAAAvD,KAAOyC,kBAAP,GAEAc,EAAAvD,KAAUsC,QAAqB,MAC/BiB,EAAAvD,KAAmBqD,YAAnB,GAKI,MAAMK,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC9D,KAAKI,YAAmB,6DAIvEJ,KAAKqD,KAAOC,EACZtD,KAAKF,kBAAkBG,EAC3B,EAdAsD,EAVE1D,EAUekE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../context/useClickToPayContext.js";import a from"./CtPSingleCard/CtPSingleCard.js";import i from"../../../PayButton/PayButton.js";import{amountLabel as l}from"../../../PayButton/utils.js";import c from"./CtPCardsList/CtPCardsList.js";import m from"../../services/sdks/SrciError.js";import u from"../CtPSection/CtPSection.js";import{CTP_IFRAME_NAME as d}from"../../services/utils.js";import p from"../../../IFrame/Iframe.js";import f from"../../../../../core/Context/useImage.js";import{useCoreContext as g}from"../../../../../core/Context/CoreProvider.js";import C from"../../../../../utils/isMobile.js";function h(t,e){if(!t)return null;const r=e.get(`ctp.errors.${t}`);return r.includes("ctp.errors")?e.get("ctp.errors.UNKNOWN_ERROR"):r}function y(t,e,r){return r?C()?null:t.get("payButton.with",{values:{value:l(t,e),maskedData:`•••• ${null==r?void 0:r.panLastFour}`}}):t.get("payButton")}const P=({onDisplayCardComponent:l})=>{const{i18n:C}=g(),P=f(),{amount:j,cards:v,checkout:k,isCtpPrimaryPaymentMethod:S,status:x,onSubmit:b,onSetStatus:E,onError:B}=n(),[M,N]=r(v.find((t=>!t.isExpired))||v[0]),[$,w]=r(null),F=v.every((t=>t.isExpired)),[R,_]=r(!1);o((()=>{(0===v.length||F)&&(null==l||l())}),[l,F,v]);const D=s((async()=>{if(M)try{_(!0),w(null),E("loading");const t=await k(M);b(t)}catch(t){t instanceof m&&(w(null==t?void 0:t.reason),console.warn(`CtP - Checkout: Reason: ${null==t?void 0:t.reason} / Source: ${null==t?void 0:t.source} / Scheme: ${null==t?void 0:t.scheme}`)),_(!1),B(t)}}),[k,M]),I=s((t=>{N(t)}),[]),L=R&&"loading"===x&&(null==M?void 0:M.isDcfPopupEmbedded),T="loading"!==x||!L;return t(e,null,t(p,{name:d,height:"380",width:"100%",classNameModifiers:[L?"":"hidden"]}),T&&t(e,null,t(u.Title,null,C.get("ctp.cards.title")),t(u.Text,null,C.get("ctp.cards.subtitle")),0===v.length&&t("div",{className:"adyen-checkout-ctp__empty-cards"},C.get("ctp.emptyProfile.message")),1===v.length&&t(a,{card:v[0],errorMessage:h($,C)}),v.length>1&&t(c,{cardSelected:M,cards:v,onChangeCard:I,errorMessage:h($,C)}),t(i,{disabled:F,amount:j,label:y(C,j,M),status:x,variant:S?"primary":"secondary",icon:0!==v.length&&P({imageFolder:"components/"})(S?"lock":"lock_black"),onClick:D})))};export{P as default};
1
+ import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as r,useEffect as o,useCallback as s}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../context/useClickToPayContext.js";import a from"./CtPSingleCard/CtPSingleCard.js";import i from"../../../PayButton/PayButton.js";import{amountLabel as l}from"../../../PayButton/utils.js";import c from"./CtPCardsList/CtPCardsList.js";import m from"../../services/sdks/SrciError.js";import u from"../CtPSection/CtPSection.js";import{CTP_IFRAME_NAME as d}from"../../services/utils.js";import p from"../../../IFrame/Iframe.js";import f from"../../../../../core/Context/useImage.js";import{useCoreContext as g}from"../../../../../core/Context/CoreProvider.js";import C from"../../../../../utils/isMobile.js";import h from"../../../../../core/Errors/AdyenCheckoutError.js";import{PREFIX as y}from"../../../Icon/constants.js";function P(t,e){if(!t)return null;const r=e.get(`ctp.errors.${t}`);return r.includes("ctp.errors")?e.get("ctp.errors.UNKNOWN_ERROR"):r}function j(t,e,r){return r?C()?null:t.get("payButton.with",{values:{value:l(t,e),maskedData:`•••• ${null==r?void 0:r.panLastFour}`}}):t.get("payButton")}const k=({onDisplayCardComponent:l})=>{const{i18n:C}=g(),k=f(),{amount:v,cards:E,checkout:S,isCtpPrimaryPaymentMethod:x,status:b,onSubmit:R,onSetStatus:$,onError:w}=n(),[B,M]=r(E.find((t=>!t.isExpired))||E[0]),[N,F]=r(null),I=E.every((t=>t.isExpired)),[T,_]=r(!1);o((()=>{(0===E.length||I)&&(null==l||l())}),[l,I,E]);const D=s((async()=>{if(B)try{_(!0),F(null),$("loading");const t=await S(B);R(t)}catch(t){t instanceof m&&(F(null==t?void 0:t.reason),console.warn(`CtP - Checkout: Reason: ${null==t?void 0:t.reason} / Source: ${null==t?void 0:t.source} / Scheme: ${null==t?void 0:t.scheme}`)),_(!1),w(t instanceof h?t:new h("ERROR","Error during ClickToPay checkout",{cause:t}))}}),[S,B]),L=s((t=>{M(t)}),[]),O=T&&"loading"===b&&(null==B?void 0:B.isDcfPopupEmbedded),A="loading"!==b||!O;return t(e,null,t(p,{name:d,height:"380",width:"100%",classNameModifiers:[O?"":"hidden"]}),A&&t(e,null,t(u.Title,null,C.get("ctp.cards.title")),t(u.Text,null,C.get("ctp.cards.subtitle")),0===E.length&&t("div",{className:"adyen-checkout-ctp__empty-cards"},C.get("ctp.emptyProfile.message")),1===E.length&&t(a,{card:E[0],errorMessage:P(N,C)}),E.length>1&&t(c,{cardSelected:B,cards:E,onChangeCard:L,errorMessage:P(N,C)}),t(i,{disabled:I,amount:v,label:j(C,v,B),status:b,variant:x?"primary":"secondary",icon:0!==E.length&&k({imageFolder:"components/"})(x?`${y}lock`:`${y}lock_black`),onClick:D})))};export{k as default};
2
2
  //# sourceMappingURL=CtPCards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { amount, cards, checkout, isCtpPrimaryPaymentMethod, status, onSubmit, onSetStatus, onError } = useClickToPayContext();\n const [checkoutCard, setCheckoutCard] = useState<ShopperCard | undefined>(cards.find(card => !card.isExpired) || cards[0]);\n const [errorCode, setErrorCode] = useState<string>(null);\n const isEveryCardExpired = cards.every(card => card.isExpired);\n const [isShopperCheckingOutWithCtp, setIsShopperCheckingOutWithCtp] = useState<boolean>(false);\n\n useEffect(() => {\n if (cards.length === 0 || isEveryCardExpired) {\n onDisplayCardComponent?.();\n }\n }, [onDisplayCardComponent, isEveryCardExpired, cards]);\n\n const doCheckout = useCallback(async () => {\n if (!checkoutCard) return;\n\n try {\n setIsShopperCheckingOutWithCtp(true);\n setErrorCode(null);\n onSetStatus('loading');\n const payload = await checkout(checkoutCard);\n onSubmit(payload);\n } catch (error) {\n if (error instanceof SrciError) {\n setErrorCode(error?.reason);\n console.warn(`CtP - Checkout: Reason: ${error?.reason} / Source: ${error?.source} / Scheme: ${error?.scheme}`);\n }\n setIsShopperCheckingOutWithCtp(false);\n onError(error);\n }\n }, [checkout, checkoutCard]);\n\n const handleOnChangeCard = useCallback((card: ShopperCard) => {\n setCheckoutCard(card);\n }, []);\n\n /**\n * If shopper submits the payment using the default Card component while CtP is rendered, the status here will be updated\n * and that can potentially display an iframe.\n *\n * Therefore, we use the flag 'isShopperCheckingOutWithCtp' to flag that the iframe should be displayed only in case the\n * Shopper is checking out with Click to Pay.\n */\n const displayNetworkDcf = isShopperCheckingOutWithCtp && status === 'loading' && checkoutCard?.isDcfPopupEmbedded;\n const displayCardCheckoutView = status !== 'loading' || !displayNetworkDcf;\n\n return (\n <Fragment>\n <Iframe name={CTP_IFRAME_NAME} height=\"380\" width=\"100%\" classNameModifiers={[displayNetworkDcf ? '' : 'hidden']} />\n\n {displayCardCheckoutView && (\n <Fragment>\n <CtPSection.Title>{i18n.get('ctp.cards.title')}</CtPSection.Title>\n <CtPSection.Text>{i18n.get('ctp.cards.subtitle')}</CtPSection.Text>\n\n {cards.length === 0 && <div className=\"adyen-checkout-ctp__empty-cards\">{i18n.get('ctp.emptyProfile.message')}</div>}\n {cards.length === 1 && <CtPSingleCard card={cards[0]} errorMessage={getErrorLabel(errorCode, i18n)} />}\n {cards.length > 1 && (\n <CtPCardsList\n cardSelected={checkoutCard}\n cards={cards}\n onChangeCard={handleOnChangeCard}\n errorMessage={getErrorLabel(errorCode, i18n)}\n />\n )}\n\n <PayButton\n disabled={isEveryCardExpired}\n amount={amount}\n label={getPayButtonLabel(i18n, amount, checkoutCard)}\n status={status}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n icon={cards.length !== 0 && getImage({ imageFolder: 'components/' })(isCtpPrimaryPaymentMethod ? 'lock' : 'lock_black')}\n onClick={doCheckout}\n />\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nexport default CtPCards;\n"],"names":["getErrorLabel","errorCode","i18n","errorLabel","get","includes","getPayButtonLabel","amount","checkoutCard","isMobile","values","value","amountLabel","maskedData","panLastFour","CtPCards","onDisplayCardComponent","useCoreContext","getImage","useImage","cards","checkout","isCtpPrimaryPaymentMethod","status","onSubmit","onSetStatus","onError","useClickToPayContext","setCheckoutCard","useState","find","card","isExpired","setErrorCode","isEveryCardExpired","every","isShopperCheckingOutWithCtp","setIsShopperCheckingOutWithCtp","useEffect","length","doCheckout","useCallback","async","payload","error","SrciError","reason","console","warn","source","scheme","handleOnChangeCard","displayNetworkDcf","isDcfPopupEmbedded","displayCardCheckoutView","h","Fragment","Iframe","name","CTP_IFRAME_NAME","height","width","classNameModifiers","CtPSection","Title","Text","div","className","CtPSingleCard","errorMessage","CtPCardsList","cardSelected","onChangeCard","PayButton","disabled","label","variant","icon","imageFolder","onClick"],"mappings":"wzBAuBA,SAASA,EAAcC,EAAmBC,GACtC,IAAKD,EAAW,OAAO,KAEvB,MAAME,EAAaD,EAAKE,IAAI,cAAcH,KAC1C,OAAIE,EAAWE,SAAS,cAAsBH,EAAKE,IAAI,4BAChDD,CACX,CAEA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EAACE,EAAAA,CAAOC,KAAMC,EAAiBC,OAAO,MAAMC,MAAM,OAAOC,mBAAoB,CAACV,EAAoB,GAAK,YAEtGE,GACGC,EAACC,OACGD,EAACQ,EAAWC,MAAO9D,KAAAA,EAAKE,IAAI,oBAC5BmD,EAACQ,EAAWE,KAAI,KAAE/D,EAAKE,IAAI,uBAET,IAAjBgB,EAAMmB,QAAgBgB,EAACW,MAAAA,CAAIC,UAAU,mCAAmCjE,EAAKE,IAAI,6BAChE,IAAjBgB,EAAMmB,QAAgBgB,EAACa,EAAAA,CAAcrC,KAAMX,EAAM,GAAIiD,aAAcrE,EAAcC,EAAWC,KAC5FkB,EAAMmB,OAAS,GACZgB,EAACe,EAAAA,CACGC,aAAc/D,EACdY,MAAOA,EACPoD,aAAcrB,EACdkB,aAAcrE,EAAcC,EAAWC,KAI/CqD,EAACkB,EAAAA,CACGC,SAAUxC,EACV3B,OAAQA,EACRoE,MAAOrE,EAAkBJ,EAAMK,EAAQC,GACvCe,OAAQA,EACRqD,QAAStD,EAA4B,UAAY,YACjDuD,KAAuB,IAAjBzD,EAAMmB,QAAgBrB,EAAS,CAAE4D,YAAa,eAAxB5D,CAAyCI,EAA4B,OAAS,cAC1GyD,QAASvC"}
1
+ {"version":3,"file":"CtPCards.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCards.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPSingleCard from './CtPSingleCard/CtPSingleCard';\nimport PayButton from '../../../PayButton';\nimport { amountLabel } from '../../../PayButton/utils';\nimport CtPCardsList from './CtPCardsList';\nimport ShopperCard from '../../models/ShopperCard';\nimport SrciError from '../../services/sdks/SrciError';\nimport CtPSection from '../CtPSection';\nimport { CTP_IFRAME_NAME } from '../../services/utils';\nimport Iframe from '../../../../internal/IFrame';\nimport useImage from '../../../../../core/Context/useImage';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport isMobile from '../../../../../utils/isMobile';\nimport Language from '../../../../../language';\nimport { PaymentAmount } from '../../../../../types/global-types';\nimport './CtPCards.scss';\nimport AdyenCheckoutError from '../../../../../core/Errors/AdyenCheckoutError';\nimport { PREFIX } from '../../../Icon/constants';\n\n\ntype CtPCardsProps = {\n onDisplayCardComponent?(): void;\n};\n\nfunction getErrorLabel(errorCode: string, i18n: Language): string {\n if (!errorCode) return null;\n\n const errorLabel = i18n.get(`ctp.errors.${errorCode}`);\n if (errorLabel.includes('ctp.errors')) return i18n.get(`ctp.errors.UNKNOWN_ERROR`);\n return errorLabel;\n}\n\nfunction getPayButtonLabel(i18n: Language, amount: PaymentAmount, checkoutCard?: ShopperCard): string | null {\n if (!checkoutCard) return i18n.get('payButton');\n if (!isMobile())\n return i18n.get('payButton.with', {\n values: { value: amountLabel(i18n, amount), maskedData: `•••• ${checkoutCard?.panLastFour}` }\n });\n return null;\n}\n\nconst CtPCards = ({ onDisplayCardComponent }: CtPCardsProps) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { amount, cards, checkout, isCtpPrimaryPaymentMethod, status, onSubmit, onSetStatus, onError } = useClickToPayContext();\n const [checkoutCard, setCheckoutCard] = useState<ShopperCard | undefined>(cards.find(card => !card.isExpired) || cards[0]);\n const [errorCode, setErrorCode] = useState<string>(null);\n const isEveryCardExpired = cards.every(card => card.isExpired);\n const [isShopperCheckingOutWithCtp, setIsShopperCheckingOutWithCtp] = useState<boolean>(false);\n\n useEffect(() => {\n if (cards.length === 0 || isEveryCardExpired) {\n onDisplayCardComponent?.();\n }\n }, [onDisplayCardComponent, isEveryCardExpired, cards]);\n\n const doCheckout = useCallback(async () => {\n if (!checkoutCard) return;\n\n try {\n setIsShopperCheckingOutWithCtp(true);\n setErrorCode(null);\n onSetStatus('loading');\n const payload = await checkout(checkoutCard);\n onSubmit(payload);\n } catch (error: unknown) {\n if (error instanceof SrciError) {\n setErrorCode(error?.reason);\n console.warn(`CtP - Checkout: Reason: ${error?.reason} / Source: ${error?.source} / Scheme: ${error?.scheme}`);\n }\n setIsShopperCheckingOutWithCtp(false);\n\n if (error instanceof AdyenCheckoutError) onError(error);\n else onError(new AdyenCheckoutError('ERROR', 'Error during ClickToPay checkout', { cause: error }));\n }\n }, [checkout, checkoutCard]);\n\n const handleOnChangeCard = useCallback((card: ShopperCard) => {\n setCheckoutCard(card);\n }, []);\n\n /**\n * If shopper submits the payment using the default Card component while CtP is rendered, the status here will be updated\n * and that can potentially display an iframe.\n *\n * Therefore, we use the flag 'isShopperCheckingOutWithCtp' to flag that the iframe should be displayed only in case the\n * Shopper is checking out with Click to Pay.\n */\n const displayNetworkDcf = isShopperCheckingOutWithCtp && status === 'loading' && checkoutCard?.isDcfPopupEmbedded;\n const displayCardCheckoutView = status !== 'loading' || !displayNetworkDcf;\n\n return (\n <Fragment>\n <Iframe name={CTP_IFRAME_NAME} height=\"380\" width=\"100%\" classNameModifiers={[displayNetworkDcf ? '' : 'hidden']} />\n\n {displayCardCheckoutView && (\n <Fragment>\n <CtPSection.Title>{i18n.get('ctp.cards.title')}</CtPSection.Title>\n <CtPSection.Text>{i18n.get('ctp.cards.subtitle')}</CtPSection.Text>\n\n {cards.length === 0 && <div className=\"adyen-checkout-ctp__empty-cards\">{i18n.get('ctp.emptyProfile.message')}</div>}\n {cards.length === 1 && <CtPSingleCard card={cards[0]} errorMessage={getErrorLabel(errorCode, i18n)} />}\n {cards.length > 1 && (\n <CtPCardsList\n cardSelected={checkoutCard}\n cards={cards}\n onChangeCard={handleOnChangeCard}\n errorMessage={getErrorLabel(errorCode, i18n)}\n />\n )}\n\n <PayButton\n disabled={isEveryCardExpired}\n amount={amount}\n label={getPayButtonLabel(i18n, amount, checkoutCard)}\n status={status}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n icon={\n cards.length !== 0 &&\n getImage({ imageFolder: 'components/' })(isCtpPrimaryPaymentMethod ? `${PREFIX}lock` : `${PREFIX}lock_black`)\n }\n onClick={doCheckout}\n />\n </Fragment>\n )}\n </Fragment>\n );\n};\n\nexport default CtPCards;\n"],"names":["getErrorLabel","errorCode","i18n","errorLabel","get","includes","getPayButtonLabel","amount","checkoutCard","isMobile","values","value","amountLabel","maskedData","panLastFour","CtPCards","onDisplayCardComponent","useCoreContext","getImage","useImage","cards","checkout","isCtpPrimaryPaymentMethod","status","onSubmit","onSetStatus","onError","useClickToPayContext","setCheckoutCard","useState","find","card","isExpired","setErrorCode","isEveryCardExpired","every","isShopperCheckingOutWithCtp","setIsShopperCheckingOutWithCtp","useEffect","length","doCheckout","useCallback","async","payload","error","SrciError","reason","console","warn","source","scheme","AdyenCheckoutError","cause","handleOnChangeCard","displayNetworkDcf","isDcfPopupEmbedded","displayCardCheckoutView","h","Fragment","Iframe","name","CTP_IFRAME_NAME","height","width","classNameModifiers","CtPSection","Title","Text","div","className","CtPSingleCard","errorMessage","CtPCardsList","cardSelected","onChangeCard","PayButton","disabled","label","variant","icon","imageFolder","PREFIX","onClick"],"mappings":"46BA0BA,SAASA,EAAcC,EAAmBC,GACtC,IAAKD,EAAW,OAAO,KAEvB,MAAME,EAAaD,EAAKE,IAAI,cAAcH,KAC1C,OAAIE,EAAWE,SAAS,cAAsBH,EAAKE,IAAI,4BAChDD,CACX,CAEA,SAASG,EAAkBJ,EAAgBK,EAAuBC,GAC9D,OAAKA,EACAC,IAIE,KAHIP,EAAKE,IAAI,iBAAkB,CAC9BM,OAAQ,CAAEC,MAAOC,EAAYV,EAAMK,GAASM,WAAY,QAAQL,eAAAA,EAAcM,iBAH5DZ,EAAKE,IAAI,YAMvC,CAEA,MAAMW,EAAW,EAAGC,6BAChB,MAAMd,KAAEA,GAASe,IACXC,EAAWC,KACXZ,OAAEA,EAAMa,MAAEA,EAAKC,SAAEA,EAAQC,0BAAEA,EAAyBC,OAAEA,EAAMC,SAAEA,EAAQC,YAAEA,EAAWC,QAAEA,GAAYC,KAChGnB,EAAcoB,GAAmBC,EAA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,KAAMX,EAAM,GAAImD,aAAcvE,EAAcC,EAAWC,KAC5FkB,EAAMmB,OAAS,GACZkB,EAACe,EAAAA,CACGC,aAAcjE,EACdY,MAAOA,EACPsD,aAAcrB,EACdkB,aAAcvE,EAAcC,EAAWC,KAI/CuD,EAACkB,EAAAA,CACGC,SAAU1C,EACV3B,OAAQA,EACRsE,MAAOvE,EAAkBJ,EAAMK,EAAQC,GACvCe,OAAQA,EACRuD,QAASxD,EAA4B,UAAY,YACjDyD,KACqB,IAAjB3D,EAAMmB,QACNrB,EAAS,CAAE8D,YAAa,eAAxB9D,CAAyCI,EAA4B,GAAG2D,QAAe,GAAGA,eAE9FC,QAAS1C"}
@@ -1,2 +1,2 @@
1
- import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import p from"../../services/sdks/SrciError.js";import{useCoreContext as m}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";const d=()=>{const{i18n:d}=m(),{isCtpPrimaryPaymentMethod:u,setIsCtpPrimaryPaymentMethod:f,verifyIfShopperIsEnrolled:g,startIdentityValidation:C}=s(),[P,h]=r(null),[y,j]=r(!1),[v,I]=r(null),[S,x]=r(!1),[E,k]=r(null),T=e((t=>{k(t)}),[]),b=e((({data:t,isValid:o})=>{var r;h(t.shopperLogin),j(o),(null==t||null===(r=t.shopperLogin)||void 0===r?void 0:r.length)>0&&f(!0)}),[]),w=e((async()=>{if(I(null),y){x(!0);try{const{isEnrolled:t}=await g({shopperEmail:P});t?await C():(I("NOT_FOUND"),x(!1))}catch(t){t instanceof p&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),I(null==t?void 0:t.reason),x(!1)}}else E.validateInput()}),[g,C,P,y,E]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:b,onSetInputHandlers:T,disabled:S,errorMessage:v&&d.get(`ctp.errors.${v}`),onPressEnter:w}),t(n,{label:d.get("continue"),variant:u?"primary":"secondary",status:S&&"loading",onClick:()=>{w()}}))};export{d as default};
1
+ import{createElement as t,Fragment as o}from"../../../../../external/preact/dist/preact.js";import{useState as r,useCallback as e}from"../../../../../external/preact/hooks/dist/hooks.js";import n from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import i from"./CtPLoginInput.js";import{CtPInfo as a}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import m from"../../services/sdks/SrciError.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import c from"../../errors/TimeoutError.js";import{isSrciError as u}from"../../services/utils.js";const d=()=>{const{i18n:d}=p(),{isCtpPrimaryPaymentMethod:f,setIsCtpPrimaryPaymentMethod:g,verifyIfShopperIsEnrolled:C,startIdentityValidation:P}=s(),[h,j]=r(null),[y,v]=r(!1),[I,S]=r(null),[x,E]=r(!1),[k,T]=r(null),b=e((t=>{T(t)}),[]),w=e((({data:t,isValid:o})=>{var r;j(t.shopperLogin),v(o),(null==t||null===(r=t.shopperLogin)||void 0===r?void 0:r.length)>0&&g(!0)}),[]),L=e((async()=>{if(S(null),y){E(!0);try{const{isEnrolled:t}=await C({shopperEmail:h});t?await P():(S("NOT_FOUND"),E(!1))}catch(t){t instanceof m&&console.warn(`CtP - Login error: ${t.toString()}`),t instanceof c&&console.warn(t.toString()),u(t)?S(null==t?void 0:t.reason):console.error(t),E(!1)}}else k.validateInput()}),[C,P,h,y,k]);return t(o,null,t(l.Title,{endAdornment:t(a,null)},d.get("ctp.login.title")),t(l.Text,null,d.get("ctp.login.subtitle")),t(i,{onChange:w,onSetInputHandlers:b,disabled:x,errorMessage:I&&d.get(`ctp.errors.${I}`),onPressEnter:L}),t(n,{label:d.get("continue"),variant:f?"primary":"secondary",status:x&&"loading",onClick:()=>{L()}}))};export{d as default};
2
2
  //# sourceMappingURL=CtPLogin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n setErrorCode(error?.reason);\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","reason","validateInput","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick"],"mappings":"+jBAYA,MAAMA,EAAW,KACb,MAAMC,KAAEA,GAASC,KACXC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,YAChBU,QAASlD,EAA4B,UAAY,YACjDmD,OAAQvC,GAAe,UACvBwC,QAAS,KACA9B,GAAAA"}
1
+ {"version":3,"file":"CtPLogin.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLogin.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPLoginInput, { CtPLoginInputHandlers } from './CtPLoginInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport SrciError from '../../services/sdks/SrciError';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPLogin.scss';\nimport TimeoutError from '../../errors/TimeoutError';\nimport { isSrciError } from '../../services/utils';\n\nconst CtPLogin = (): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { isCtpPrimaryPaymentMethod, setIsCtpPrimaryPaymentMethod, verifyIfShopperIsEnrolled, startIdentityValidation } = useClickToPayContext();\n const [shopperLogin, setShopperLogin] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [isLoggingIn, setIsLoggingIn] = useState<boolean>(false);\n const [loginInputHandlers, setLoginInputHandlers] = useState<CtPLoginInputHandlers>(null);\n\n const onSetLoginInputHandlers = useCallback((handlers: CtPLoginInputHandlers) => {\n setLoginInputHandlers(handlers);\n }, []);\n\n const handleOnLoginChange = useCallback(({ data, isValid }) => {\n setShopperLogin(data.shopperLogin);\n setIsValid(isValid);\n\n // As soon as the Shopper interacts with input, the CtP becomes the primary PM\n if (data?.shopperLogin?.length > 0) {\n setIsCtpPrimaryPaymentMethod(true);\n }\n }, []);\n\n const handleOnLoginButtonClick = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n loginInputHandlers.validateInput();\n return;\n }\n\n setIsLoggingIn(true);\n\n try {\n const { isEnrolled } = await verifyIfShopperIsEnrolled({ shopperEmail: shopperLogin });\n if (isEnrolled) {\n await startIdentityValidation();\n } else {\n setErrorCode('NOT_FOUND');\n setIsLoggingIn(false);\n }\n } catch (error: unknown) {\n if (error instanceof SrciError) console.warn(`CtP - Login error: ${error.toString()}`);\n if (error instanceof TimeoutError) console.warn(error.toString());\n if (isSrciError(error)) setErrorCode(error?.reason);\n else console.error(error);\n\n setIsLoggingIn(false);\n }\n }, [verifyIfShopperIsEnrolled, startIdentityValidation, shopperLogin, isValid, loginInputHandlers]);\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.login.title')}</CtPSection.Title>\n\n <CtPSection.Text>{i18n.get('ctp.login.subtitle')}</CtPSection.Text>\n\n <CtPLoginInput\n onChange={handleOnLoginChange}\n onSetInputHandlers={onSetLoginInputHandlers}\n disabled={isLoggingIn}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={handleOnLoginButtonClick}\n />\n\n <Button\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n status={isLoggingIn && 'loading'}\n onClick={() => {\n void handleOnLoginButtonClick();\n }}\n />\n </Fragment>\n );\n};\n\nexport default CtPLogin;\n"],"names":["CtPLogin","i18n","useCoreContext","isCtpPrimaryPaymentMethod","setIsCtpPrimaryPaymentMethod","verifyIfShopperIsEnrolled","startIdentityValidation","useClickToPayContext","shopperLogin","setShopperLogin","useState","isValid","setIsValid","errorCode","setErrorCode","isLoggingIn","setIsLoggingIn","loginInputHandlers","setLoginInputHandlers","onSetLoginInputHandlers","useCallback","handlers","handleOnLoginChange","data","length","handleOnLoginButtonClick","async","isEnrolled","shopperEmail","error","SrciError","console","warn","toString","TimeoutError","isSrciError","reason","validateInput","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","get","Text","CtPLoginInput","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","Button","label","variant","status","onClick"],"mappings":"qnBAaA,MAAMA,EAAW,K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AClDsC,aAAc1B,IAGlBa,EAACc,EAAAA,CACGC,MAAOpD,EAAK2C,IAAI,YAChBU,QAASnD,EAA4B,UAAY,YACjDoD,OAAQxC,GAAe,UACvByC,QAAS,KACA/B,GAAAA"}
@@ -1,2 +1,2 @@
1
- import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as o,useCallback as n}from"../../../../../external/preact/hooks/dist/hooks.js";import a from"../../../Button/Button.js";import s from"../../context/useClickToPayContext.js";import r from"./CtPOneTimePasswordInput/CtPOneTimePasswordInput.js";import{CtPInfo as i}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import d from"./CtPSaveCookiesCheckbox/CtPSaveCookiesCheckbox.js";const u=({onDisplayCardComponent:u})=>{const{i18n:c}=p(),{finishIdentityValidation:m,otpMaskedContact:C,otpNetwork:P,isCtpPrimaryPaymentMethod:f}=s(),[h,k]=o(null),[g,y]=o(!1),[j,x]=o(!1),[I,b]=o(null),[S,v]=o(null),[T,w]=o(!1),B=n((t=>{v(t)}),[]),E=n((({data:t,isValid:e})=>{k(t.otp),y(e)}),[]),O=n((()=>{b(null)}),[]),A=n((async()=>{if(b(null),g){x(!0);try{await m(h)}catch(t){b(null==t?void 0:t.reason),x(!1),"ACCT_INACCESSIBLE"===(null==t?void 0:t.reason)&&(w(!0),null==u||u())}}else S.validateInput()}),[h,g,S,u]),M=c.get("ctp.otp.subtitle").split("%@");return t(e,null,t(l.Title,{endAdornment:t(i,null)},c.get("ctp.otp.title")),t(l.Text,null,M[0]," ",P," ",M[1],t("span",{className:"adyen-checkout-ctp__otp-subtitle--highlighted"},C),M[2]),t(r,{hideResendOtpButton:T,onChange:E,onSetInputHandlers:B,disabled:j,errorMessage:I&&c.get(`ctp.errors.${I}`),onPressEnter:A,onResendCode:O,isValidatingOtp:j}),t(d,null),t(a,{disabled:T,label:c.get("continue"),variant:f?"primary":"secondary",onClick:A,status:j&&"loading"}))};export{u as default};
1
+ import{createElement as t,Fragment as e}from"../../../../../external/preact/dist/preact.js";import{useState as o,useCallback as n}from"../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../Button/Button.js";import r from"../../context/useClickToPayContext.js";import a from"./CtPOneTimePasswordInput/CtPOneTimePasswordInput.js";import{CtPInfo as i}from"../CtPInfo/CtPInfo.js";import l from"../CtPSection/CtPSection.js";import{useCoreContext as p}from"../../../../../core/Context/CoreProvider.js";import d from"./CtPSaveCookiesCheckbox/CtPSaveCookiesCheckbox.js";import{isSrciError as u}from"../../services/utils.js";const m=({onDisplayCardComponent:m})=>{const{i18n:c}=p(),{finishIdentityValidation:C,otpMaskedContact:f,otpNetwork:P,isCtpPrimaryPaymentMethod:h}=r(),[k,g]=o(null),[j,y]=o(!1),[v,x]=o(!1),[I,b]=o(null),[S,T]=o(null),[w,B]=o(!1),E=n((t=>{T(t)}),[]),O=n((({data:t,isValid:e})=>{g(t.otp),y(e)}),[]),A=n((()=>{b(null)}),[]),M=n((async()=>{if(b(null),j){x(!0);try{await C(k)}catch(t){if(!u(t))return void x(!1);b(null==t?void 0:t.reason),x(!1),"ACCT_INACCESSIBLE"===(null==t?void 0:t.reason)&&(B(!0),null==m||m())}}else S.validateInput()}),[k,j,S,m]),N=c.get("ctp.otp.subtitle").split("%@");return t(e,null,t(l.Title,{endAdornment:t(i,null)},c.get("ctp.otp.title")),t(l.Text,null,N[0]," ",P," ",N[1],t("span",{className:"adyen-checkout-ctp__otp-subtitle--highlighted"},f),N[2]),t(a,{hideResendOtpButton:w,onChange:O,onSetInputHandlers:E,disabled:v,errorMessage:I&&c.get(`ctp.errors.${I}`),onPressEnter:M,onResendCode:A,isValidatingOtp:v}),t(d,null),t(s,{disabled:w,label:c.get("continue"),variant:h?"primary":"secondary",onClick:M,status:v&&"loading"}))};export{m as default};
2
2
  //# sourceMappingURL=CtPOneTimePassword.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPOneTimePassword.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPOneTimePasswordInput from './CtPOneTimePasswordInput';\nimport { CtPOneTimePasswordInputHandlers } from './CtPOneTimePasswordInput/CtPOneTimePasswordInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPOneTimePassword.scss';\nimport CtPSaveCookiesCheckbox from './CtPSaveCookiesCheckbox';\n\ntype CtPOneTimePasswordProps = {\n onDisplayCardComponent?(): void;\n};\nconst CtPOneTimePassword = ({ onDisplayCardComponent }: CtPOneTimePasswordProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { finishIdentityValidation, otpMaskedContact, otpNetwork, isCtpPrimaryPaymentMethod } = useClickToPayContext();\n const [otp, setOtp] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [isValidatingOtp, setIsValidatingOtp] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [otpInputHandlers, setOtpInputHandlers] = useState<CtPOneTimePasswordInputHandlers>(null);\n const [isAccountLocked, setIsAccountLocked] = useState<boolean>(false);\n\n const onSetOtpInputHandlers = useCallback((handlers: CtPOneTimePasswordInputHandlers) => {\n setOtpInputHandlers(handlers);\n }, []);\n\n const onChangeOtpInput = useCallback(({ data, isValid }) => {\n setOtp(data.otp);\n setIsValid(isValid);\n }, []);\n\n const onResendCode = useCallback(() => {\n setErrorCode(null);\n }, []);\n\n const onSubmitPassword = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n otpInputHandlers.validateInput();\n return;\n }\n\n setIsValidatingOtp(true);\n\n try {\n await finishIdentityValidation(otp);\n } catch (error) {\n setErrorCode(error?.reason);\n setIsValidatingOtp(false);\n\n if (error?.reason === 'ACCT_INACCESSIBLE') {\n setIsAccountLocked(true);\n onDisplayCardComponent?.();\n }\n }\n }, [otp, isValid, otpInputHandlers, onDisplayCardComponent]);\n\n const subtitleParts = i18n.get('ctp.otp.subtitle').split('%@');\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.otp.title')}</CtPSection.Title>\n\n <CtPSection.Text>\n {subtitleParts[0]} {otpNetwork} {subtitleParts[1]}\n <span className=\"adyen-checkout-ctp__otp-subtitle--highlighted\">{otpMaskedContact}</span>\n {subtitleParts[2]}\n </CtPSection.Text>\n\n <CtPOneTimePasswordInput\n hideResendOtpButton={isAccountLocked}\n onChange={onChangeOtpInput}\n onSetInputHandlers={onSetOtpInputHandlers}\n disabled={isValidatingOtp}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={onSubmitPassword}\n onResendCode={onResendCode}\n isValidatingOtp={isValidatingOtp}\n />\n\n <CtPSaveCookiesCheckbox />\n\n <Button\n disabled={isAccountLocked}\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n onClick={onSubmitPassword}\n status={isValidatingOtp && 'loading'}\n />\n </Fragment>\n );\n};\n\nexport default CtPOneTimePassword;\n"],"names":["CtPOneTimePassword","onDisplayCardComponent","i18n","useCoreContext","finishIdentityValidation","otpMaskedContact","otpNetwork","isCtpPrimaryPaymentMethod","useClickToPayContext","otp","setOtp","useState","isValid","setIsValid","isValidatingOtp","setIsValidatingOtp","errorCode","setErrorCode","otpInputHandlers","setOtpInputHandlers","isAccountLocked","setIsAccountLocked","onSetOtpInputHandlers","useCallback","handlers","onChangeOtpInput","data","onResendCode","onSubmitPassword","async","error","reason","validateInput","subtitleParts","get","split","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","Text","span","className","CtPOneTimePasswordInput","hideResendOtpButton","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","CtPSaveCookiesCheckbox","Button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AclB,KAClDmC,aAAcvB,EACdD,aAAcA,EACdb,gBAAiBA,IAGrBsB,EAACgB,QAEDhB,EAACiB,EAAAA,CACGJ,SAAU7B,EACVkC,MAAOpD,EAAKgC,IAAI,YAChBqB,QAAShD,EAA4B,UAAY,YACjDiD,QAAS5B,EACT6B,OAAQ3C,GAAmB"}
1
+ {"version":3,"file":"CtPOneTimePassword.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useState } from 'preact/hooks';\nimport Button from '../../../Button';\nimport useClickToPayContext from '../../context/useClickToPayContext';\nimport CtPOneTimePasswordInput from './CtPOneTimePasswordInput';\nimport { CtPOneTimePasswordInputHandlers } from './CtPOneTimePasswordInput/CtPOneTimePasswordInput';\nimport { CtPInfo } from '../CtPInfo';\nimport CtPSection from '../CtPSection';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport './CtPOneTimePassword.scss';\nimport CtPSaveCookiesCheckbox from './CtPSaveCookiesCheckbox';\nimport { isSrciError } from '../../services/utils';\n\ntype CtPOneTimePasswordProps = {\n onDisplayCardComponent?(): void;\n};\nconst CtPOneTimePassword = ({ onDisplayCardComponent }: CtPOneTimePasswordProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const { finishIdentityValidation, otpMaskedContact, otpNetwork, isCtpPrimaryPaymentMethod } = useClickToPayContext();\n const [otp, setOtp] = useState<string>(null);\n const [isValid, setIsValid] = useState<boolean>(false);\n const [isValidatingOtp, setIsValidatingOtp] = useState<boolean>(false);\n const [errorCode, setErrorCode] = useState<string>(null);\n const [otpInputHandlers, setOtpInputHandlers] = useState<CtPOneTimePasswordInputHandlers>(null);\n const [isAccountLocked, setIsAccountLocked] = useState<boolean>(false);\n\n const onSetOtpInputHandlers = useCallback((handlers: CtPOneTimePasswordInputHandlers) => {\n setOtpInputHandlers(handlers);\n }, []);\n\n const onChangeOtpInput = useCallback(({ data, isValid }) => {\n setOtp(data.otp);\n setIsValid(isValid);\n }, []);\n\n const onResendCode = useCallback(() => {\n setErrorCode(null);\n }, []);\n\n const onSubmitPassword = useCallback(async () => {\n setErrorCode(null);\n\n if (!isValid) {\n otpInputHandlers.validateInput();\n return;\n }\n\n setIsValidatingOtp(true);\n\n try {\n await finishIdentityValidation(otp);\n } catch (error: unknown) {\n if (!isSrciError(error)) {\n setIsValidatingOtp(false);\n return;\n }\n\n setErrorCode(error?.reason);\n setIsValidatingOtp(false);\n\n if (error?.reason === 'ACCT_INACCESSIBLE') {\n setIsAccountLocked(true);\n onDisplayCardComponent?.();\n }\n }\n }, [otp, isValid, otpInputHandlers, onDisplayCardComponent]);\n\n const subtitleParts = i18n.get('ctp.otp.subtitle').split('%@');\n\n return (\n <Fragment>\n <CtPSection.Title endAdornment={<CtPInfo />}>{i18n.get('ctp.otp.title')}</CtPSection.Title>\n\n <CtPSection.Text>\n {subtitleParts[0]} {otpNetwork} {subtitleParts[1]}\n <span className=\"adyen-checkout-ctp__otp-subtitle--highlighted\">{otpMaskedContact}</span>\n {subtitleParts[2]}\n </CtPSection.Text>\n\n <CtPOneTimePasswordInput\n hideResendOtpButton={isAccountLocked}\n onChange={onChangeOtpInput}\n onSetInputHandlers={onSetOtpInputHandlers}\n disabled={isValidatingOtp}\n errorMessage={errorCode && i18n.get(`ctp.errors.${errorCode}`)}\n onPressEnter={onSubmitPassword}\n onResendCode={onResendCode}\n isValidatingOtp={isValidatingOtp}\n />\n\n <CtPSaveCookiesCheckbox />\n\n <Button\n disabled={isAccountLocked}\n label={i18n.get('continue')}\n variant={isCtpPrimaryPaymentMethod ? 'primary' : 'secondary'}\n onClick={onSubmitPassword}\n status={isValidatingOtp && 'loading'}\n />\n </Fragment>\n );\n};\n\nexport default CtPOneTimePassword;\n"],"names":["CtPOneTimePassword","onDisplayCardComponent","i18n","useCoreContext","finishIdentityValidation","otpMaskedContact","otpNetwork","isCtpPrimaryPaymentMethod","useClickToPayContext","otp","setOtp","useState","isValid","setIsValid","isValidatingOtp","setIsValidatingOtp","errorCode","setErrorCode","otpInputHandlers","setOtpInputHandlers","isAccountLocked","setIsAccountLocked","onSetOtpInputHandlers","useCallback","handlers","onChangeOtpInput","data","onResendCode","onSubmitPassword","async","error","isSrciError","reason","validateInput","subtitleParts","get","split","h","Fragment","CtPSection","Title","endAdornment","CtPInfo","Text","span","className","CtPOneTimePasswordInput","hideResendOtpButton","onChange","onSetInputHandlers","disabled","errorMessage","onPressEnter","CtPSaveCookiesCheckbox","Button","label","variant","onClick","status"],"mappings":"6nBAgBA,MAAMA,EAAqB,EAAGC,6BAC1B,MAAMC,KAAEA,GAASC,KACXC,yBAAEA,EAAwBC,iBAAEA,EAAgBC,WAAEA,EAAUC,0BAAEA,GAA8BC,KACvFC,EAAKC,GAAUC,EAAiB,OAChCC,EAASC,GAAcF,GAAkB,IACzCG,EAAiBC,GAAsBJ,GAAkB,IACzDK,EAAWC,GAAgBN,EAAiB,OAC5CO,EAAkBC,GAAuBR,EAA0C,OACnFS,EAAiBC,GAAsBV,GAAkB,GAE1DW,EAAwBC,GAAaC,IACvCL,EAAoBK,EAAAA,GACrB,IAEGC,EAAmBF,GAAY,EAAGG,OAAMd,cAC1CF,EAAOgB,EAAKjB,KACZI,EAAWD,EAAAA,GACZ,IAEGe,EAAeJ,GAAY,KAC7BN,EAAa,KAAA,GACd,IAEGW,EAAmBL,GAAYM,UAGjC,GAFAZ,EAAa,MAERL,EAAL,CAKAG,GAAmB,GAEnB,UACUX,EAAyBK,EACnC,CAAE,MAAOqB,GACL,IAAKC,EAAYD,GAEb,YADAf,GAAmB,GAIvBE,EAAaa,aAAAA,EAAAA,EAAOE,QACpBjB,GAAmB,GAEG,uBAAlBe,aAAAA,EAAAA,EAAOE,UACPX,GAAmB,GACnBpB,SAAAA,IAER,CAnBA,MAFIiB,EAAiBe,eAqBrB,GACD,CAACxB,EAAKG,EAASM,EAAkBjB,IAE9BiC,EAAgBhC,EAAKiC,IAAI,oBAAoBC,MAAM,MAEzD,OACIC,EAACC,EAAAA,KACGD,EAACE,EAAWC,MAAK,CAACC,aAAcJ,EAACK,EAAAA,OAAaxC,EAAKiC,IAAI,kBAEvDE,EAACE,EAAWI,UACPT,EAAc,GAAG,IAAE5B,EAAW,IAAE4B,EAAc,GAC/CG,EAACO,OAAAA,CAAKC,UAAU,iDAAiDxC,GAChE6B,EAAc,IAGnBG,EAACS,EAAAA,CACGC,oBAAqB3B,EACrB4B,SAAUvB,EACVwB,mBAAoB3B,EACpB4B,SAAUpC,EACVqC,aAAcnC,GAAad,EAAKiC,IAAI,cAAcnB,KAClDoC,aAAcxB,EACdD,aAAcA,EACdb,gBAAiBA,IAGrBuB,EAACgB,QAEDhB,EAACiB,EAAAA,CACGJ,SAAU9B,EACVmC,MAAOrD,EAAKiC,IAAI,YAChBqB,QAASjD,EAA4B,UAAY,YACjDkD,QAAS7B,EACT8B,OAAQ5C,GAAmB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useEffect as o,useCallback as c}from"../../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../context/useClickToPayContext.js";import a from"../../../../../../external/classnames/index.js";import{useCoreContext as r}from"../../../../../../core/Context/CoreProvider.js";import n from"../../../../Icon/Icon.js";const d=({onError:d,onResendCode:i,disabled:l})=>{const[p,m]=t(null),[u,k]=t(!1),{i18n:h}=r(),{startIdentityValidation:f}=s();o((()=>{let e=null;return p>0&&(e=setTimeout((()=>m(p-1)),1e3)),()=>clearTimeout(e)}),[p]),o((()=>{let e=null;return u&&(e=setTimeout((()=>{k(!1),m(60)}),2e3)),()=>clearTimeout(e)}),[u]);const y=c((async e=>{e.preventDefault();try{i(),k(!0),await f()}catch(e){d(e.reason),m(0),k(!1)}}),[f,d,i]);return u?e("div",{className:"adyen-checkout-ctp__otp-resend-code--confirmation"},h.get("ctp.otp.codeResent"),e(n,{type:"checkmark",height:14,width:14})):p>0?e("div",{className:"adyen-checkout-ctp__otp-resend-code--disabled"},h.get("ctp.otp.resendCode")," -"," ",e("span",{className:"adyen-checkout-ctp__otp-resend-code-counter"}," ",p>0&&`${p}s`," ")):e("div",{role:"link",tabIndex:0,className:a("adyen-checkout-ctp__otp-resend-code",{"adyen-checkout-ctp__otp-resend-code--disabled":l}),onClick:y},h.get("ctp.otp.resendCode"))};export{d as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useEffect as o,useCallback as r}from"../../../../../../external/preact/hooks/dist/hooks.js";import s from"../../../context/useClickToPayContext.js";import c from"../../../../../../external/classnames/index.js";import{useCoreContext as n}from"../../../../../../core/Context/CoreProvider.js";import a from"../../../../Icon/Icon.js";import{isSrciError as d}from"../../../services/utils.js";import{PREFIX as i}from"../../../../Icon/constants.js";const l=({onError:l,onResendCode:p,disabled:m})=>{const[u,f]=t(null),[k,h]=t(!1),{i18n:y}=n(),{startIdentityValidation:_}=s();o((()=>{let e=null;return u>0&&(e=setTimeout((()=>f(u-1)),1e3)),()=>clearTimeout(e)}),[u]),o((()=>{let e=null;return k&&(e=setTimeout((()=>{h(!1),f(60)}),2e3)),()=>clearTimeout(e)}),[k]);const x=r((async e=>{e.preventDefault();try{p(),h(!0),await _()}catch(e){if(f(0),h(!1),!d(e))return void console.error(e);l(e.reason)}}),[_,l,p]);return k?e("div",{className:"adyen-checkout-ctp__otp-resend-code--confirmation"},y.get("ctp.otp.codeResent"),e(a,{type:`${i}checkmark`,height:14,width:14})):u>0?e("div",{className:"adyen-checkout-ctp__otp-resend-code--disabled"},y.get("ctp.otp.resendCode")," -"," ",e("span",{className:"adyen-checkout-ctp__otp-resend-code-counter"}," ",u>0&&`${u}s`," ")):e("div",{role:"link",tabIndex:0,className:c("adyen-checkout-ctp__otp-resend-code",{"adyen-checkout-ctp__otp-resend-code--disabled":m}),onClick:x},y.get("ctp.otp.resendCode"))};export{l as default};
2
2
  //# sourceMappingURL=CtPResendOtpLink.js.map