@adyen/adyen-web 6.0.0-alpha.4 → 6.0.0-alpha.6

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 (449) hide show
  1. package/dist/cjs/adyen.css +12 -10
  2. package/dist/cjs/adyen.css.map +1 -0
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +33 -29
  6. package/dist/es/adyen.css +12 -10
  7. package/dist/es/adyen.css.map +1 -0
  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/CashAppPay/CashAppPay.js +1 -1
  17. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  18. package/dist/es/components/CashAppPay/components/CashAppComponent.js +1 -1
  19. package/dist/es/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  20. package/dist/es/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
  21. package/dist/es/components/GooglePay/components/GooglePayButton.js +1 -1
  22. package/dist/es/components/GooglePay/components/GooglePayButton.js.map +1 -1
  23. package/dist/es/components/GooglePay/defaultProps.js +1 -1
  24. package/dist/es/components/GooglePay/defaultProps.js.map +1 -1
  25. package/dist/es/components/PersonalDetails/PersonalDetails.js +1 -1
  26. package/dist/es/components/PersonalDetails/PersonalDetails.js.map +1 -1
  27. package/dist/es/components/internal/Address/Address.js +1 -1
  28. package/dist/es/components/internal/Address/Address.js.map +1 -1
  29. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
  30. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  31. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  32. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  33. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
  34. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
  35. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  36. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  37. package/dist/es/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
  38. package/dist/es/components/internal/ClickToPay/services/sdks/MastercardSdk.js.map +1 -1
  39. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  40. package/dist/es/components/internal/ClickToPay/services/utils.js +1 -1
  41. package/dist/es/components/internal/ClickToPay/services/utils.js.map +1 -1
  42. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  43. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  44. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  45. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  46. package/dist/es/components/internal/FormFields/InputBase.js.map +1 -1
  47. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  48. package/dist/es/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  49. package/dist/es/components/internal/Icon/constants.js +2 -0
  50. package/dist/es/components/internal/Icon/constants.js.map +1 -0
  51. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  52. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  53. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +2 -0
  54. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -0
  55. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  56. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  57. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  58. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  59. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  60. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  61. package/dist/es/components/internal/Voucher/Voucher.js +1 -1
  62. package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
  63. package/dist/es/core/Analytics/Analytics.js +1 -1
  64. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  65. package/dist/es/core/Analytics/constants.js +1 -1
  66. package/dist/es/core/Analytics/constants.js.map +1 -1
  67. package/dist/es/core/Analytics/utils.js.map +1 -1
  68. package/dist/es/core/Context/Resources.js +1 -1
  69. package/dist/es/core/Context/Resources.js.map +1 -1
  70. package/dist/es/core/Environment/Environment.js +1 -1
  71. package/dist/es/core/Environment/Environment.js.map +1 -1
  72. package/dist/es/core/Environment/constants.js +2 -0
  73. package/dist/es/core/Environment/constants.js.map +1 -0
  74. package/dist/es/core/Errors/SRMessages.js +1 -1
  75. package/dist/es/core/Errors/SRMessages.js.map +1 -1
  76. package/dist/es/core/Errors/SRPanel.js +1 -1
  77. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  78. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  79. package/dist/es/core/Services/analytics/collect-id.js.map +1 -1
  80. package/dist/es/core/Services/analytics/log-event.js +1 -1
  81. package/dist/es/core/Services/get-translations.js +1 -1
  82. package/dist/es/core/Services/get-translations.js.map +1 -1
  83. package/dist/es/core/core.defaultProps.js +1 -1
  84. package/dist/es/core/core.defaultProps.js.map +1 -1
  85. package/dist/es/core/core.js +1 -1
  86. package/dist/es/core/core.js.map +1 -1
  87. package/dist/es/core/utils.js +1 -1
  88. package/dist/es/core/utils.js.map +1 -1
  89. package/dist/es/external/preact/dist/preact.js +1 -1
  90. package/dist/es/external/preact/dist/preact.js.map +1 -1
  91. package/dist/es/external/preact/hooks/dist/hooks.js +1 -1
  92. package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
  93. package/dist/es/index.d.ts +33 -29
  94. package/dist/es/utils/arrayUtils.js +1 -1
  95. package/dist/es/utils/arrayUtils.js.map +1 -1
  96. package/dist/es/utils/useForm/useForm.js +1 -1
  97. package/dist/es/utils/validator-utils.js +1 -1
  98. package/dist/es/utils/validator-utils.js.map +1 -1
  99. package/dist/es-legacy/adyen.css +12 -10
  100. package/dist/es-legacy/adyen.css.map +1 -0
  101. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  102. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  103. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  104. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  105. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js +1 -1
  106. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +1 -1
  107. package/dist/es-legacy/components/Address/Address.js +1 -1
  108. package/dist/es-legacy/components/Address/Address.js.map +1 -1
  109. package/dist/es-legacy/components/Affirm/Affirm.js +1 -1
  110. package/dist/es-legacy/components/Affirm/Affirm.js.map +1 -1
  111. package/dist/es-legacy/components/AfterPay/AfterPay.js +1 -1
  112. package/dist/es-legacy/components/AfterPay/AfterPay.js.map +1 -1
  113. package/dist/es-legacy/components/AfterPay/AfterPayB2B.js +1 -1
  114. package/dist/es-legacy/components/AfterPay/AfterPayB2B.js.map +1 -1
  115. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  116. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  117. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js +1 -1
  118. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  119. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
  120. package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
  121. package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
  122. package/dist/es-legacy/components/AmazonPay/utils.js.map +1 -1
  123. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  124. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  125. package/dist/es-legacy/components/Atome/Atome.js +1 -1
  126. package/dist/es-legacy/components/Atome/Atome.js.map +1 -1
  127. package/dist/es-legacy/components/Atome/config.js +1 -1
  128. package/dist/es-legacy/components/Atome/config.js.map +1 -1
  129. package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
  130. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  131. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  132. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  133. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  134. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  135. package/dist/es-legacy/components/BillDesk/BillDeskOnline.js +1 -1
  136. package/dist/es-legacy/components/BillDesk/BillDeskOnline.js.map +1 -1
  137. package/dist/es-legacy/components/BillDesk/BillDeskWallet.js +1 -1
  138. package/dist/es-legacy/components/BillDesk/BillDeskWallet.js.map +1 -1
  139. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  140. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  141. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  142. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  143. package/dist/es-legacy/components/Boleto/Boleto.js +1 -1
  144. package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
  145. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  146. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  147. package/dist/es-legacy/components/Card/Bancontact.js +1 -1
  148. package/dist/es-legacy/components/Card/Bancontact.js.map +1 -1
  149. package/dist/es-legacy/components/Card/Card.js +1 -1
  150. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  151. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  152. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  153. package/dist/es-legacy/components/Card/components/CardInput/components/IframeLabelAlternative.js +1 -1
  154. package/dist/es-legacy/components/Card/components/CardInput/components/IframeLabelAlternative.js.map +1 -1
  155. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js +1 -1
  156. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFields.js.map +1 -1
  157. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  158. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  159. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js +1 -1
  160. package/dist/es-legacy/components/CashAppPay/components/CashAppComponent.js.map +1 -1
  161. package/dist/es-legacy/components/ClickToPay/ClickToPay.js +1 -1
  162. package/dist/es-legacy/components/ClickToPay/ClickToPay.js.map +1 -1
  163. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  164. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  165. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  166. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  167. package/dist/es-legacy/components/Doku/Doku.js +1 -1
  168. package/dist/es-legacy/components/Doku/Doku.js.map +1 -1
  169. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  170. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  171. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  172. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  173. package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
  174. package/dist/es-legacy/components/Dragonpay/Dragonpay.js.map +1 -1
  175. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  176. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  177. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  178. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  179. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  180. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  181. package/dist/es-legacy/components/Dropin/components/PaymentMethod/InstantPaymentMethods.js.map +1 -1
  182. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  183. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  184. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  185. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  186. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js +1 -1
  187. package/dist/es-legacy/components/Dropin/elements/createInstantPaymentElements.js.map +1 -1
  188. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js +1 -1
  189. package/dist/es-legacy/components/Dropin/elements/createStoredElements.js.map +1 -1
  190. package/dist/es-legacy/components/EPS/index.js +1 -1
  191. package/dist/es-legacy/components/EPS/index.js.map +1 -1
  192. package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
  193. package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
  194. package/dist/es-legacy/components/FacilyPay/FacilyPay10x.js +1 -1
  195. package/dist/es-legacy/components/FacilyPay/FacilyPay10x.js.map +1 -1
  196. package/dist/es-legacy/components/FacilyPay/FacilyPay12x.js +1 -1
  197. package/dist/es-legacy/components/FacilyPay/FacilyPay12x.js.map +1 -1
  198. package/dist/es-legacy/components/FacilyPay/FacilyPay3x.js +1 -1
  199. package/dist/es-legacy/components/FacilyPay/FacilyPay3x.js.map +1 -1
  200. package/dist/es-legacy/components/FacilyPay/FacilyPay4x.js +1 -1
  201. package/dist/es-legacy/components/FacilyPay/FacilyPay4x.js.map +1 -1
  202. package/dist/es-legacy/components/FacilyPay/FacilyPay6x.js +1 -1
  203. package/dist/es-legacy/components/FacilyPay/FacilyPay6x.js.map +1 -1
  204. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  205. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  206. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  207. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  208. package/dist/es-legacy/components/Giftcard/components/GiftcardFields.js +1 -1
  209. package/dist/es-legacy/components/Giftcard/components/GiftcardFields.js.map +1 -1
  210. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  211. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  212. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  213. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  214. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js +1 -1
  215. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js.map +1 -1
  216. package/dist/es-legacy/components/GooglePay/defaultProps.js +1 -1
  217. package/dist/es-legacy/components/GooglePay/defaultProps.js.map +1 -1
  218. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  219. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  220. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  221. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  222. package/dist/es-legacy/components/MBWay/MBWay.js +1 -1
  223. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  224. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  225. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  226. package/dist/es-legacy/components/MealVoucherFR/MealVoucherFR.js +1 -1
  227. package/dist/es-legacy/components/MealVoucherFR/MealVoucherFR.js.map +1 -1
  228. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherFields.js +1 -1
  229. package/dist/es-legacy/components/MealVoucherFR/components/MealVoucherFields.js.map +1 -1
  230. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  231. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  232. package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
  233. package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
  234. package/dist/es-legacy/components/OnlineBankingIN/index.js +1 -1
  235. package/dist/es-legacy/components/OnlineBankingIN/index.js.map +1 -1
  236. package/dist/es-legacy/components/OnlineBankingPL/OnlineBankingPL.js +1 -1
  237. package/dist/es-legacy/components/OnlineBankingPL/OnlineBankingPL.js.map +1 -1
  238. package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
  239. package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
  240. package/dist/es-legacy/components/Oxxo/Oxxo.js +1 -1
  241. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  242. package/dist/es-legacy/components/PayByBank/PayByBank.js +1 -1
  243. package/dist/es-legacy/components/PayByBank/PayByBank.js.map +1 -1
  244. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  245. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  246. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  247. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  248. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  249. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  250. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js +1 -1
  251. package/dist/es-legacy/components/PayPal/utils/get-paypal-settings.js.map +1 -1
  252. package/dist/es-legacy/components/PayU/PayuCashcard.js +1 -1
  253. package/dist/es-legacy/components/PayU/PayuCashcard.js.map +1 -1
  254. package/dist/es-legacy/components/PayU/PayuNetBanking.js +1 -1
  255. package/dist/es-legacy/components/PayU/PayuNetBanking.js.map +1 -1
  256. package/dist/es-legacy/components/PersonalDetails/PersonalDetails.js +1 -1
  257. package/dist/es-legacy/components/PersonalDetails/PersonalDetails.js.map +1 -1
  258. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  259. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  260. package/dist/es-legacy/components/RatePay/RatePay.js +1 -1
  261. package/dist/es-legacy/components/RatePay/RatePay.js.map +1 -1
  262. package/dist/es-legacy/components/RatePay/RatePayDirectDebit.js +1 -1
  263. package/dist/es-legacy/components/RatePay/RatePayDirectDebit.js.map +1 -1
  264. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  265. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  266. package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
  267. package/dist/es-legacy/components/Riverty/Riverty.js.map +1 -1
  268. package/dist/es-legacy/components/Sepa/Sepa.js +1 -1
  269. package/dist/es-legacy/components/Sepa/Sepa.js.map +1 -1
  270. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  271. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  272. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  273. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  274. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  275. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  276. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  277. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  278. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  279. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  280. package/dist/es-legacy/components/Twint/Twint.js +1 -1
  281. package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
  282. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  283. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  284. package/dist/es-legacy/components/WalletIN/index.js +1 -1
  285. package/dist/es-legacy/components/WalletIN/index.js.map +1 -1
  286. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  287. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  288. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
  289. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  290. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  291. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  292. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  293. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  294. package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
  295. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  296. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  297. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  298. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js +1 -1
  299. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  300. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js +1 -1
  301. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLogin.js.map +1 -1
  302. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js +1 -1
  303. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePassword.js.map +1 -1
  304. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  305. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  306. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  307. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  308. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
  309. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/MastercardSdk.js +1 -1
  310. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/MastercardSdk.js.map +1 -1
  311. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  312. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  313. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js +1 -1
  314. package/dist/es-legacy/components/internal/ClickToPay/services/utils.js.map +1 -1
  315. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  316. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  317. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
  318. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
  319. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  320. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  321. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  322. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  323. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js +1 -1
  324. package/dist/es-legacy/components/internal/FormFields/InputDate/InputDate.js.map +1 -1
  325. package/dist/es-legacy/components/internal/FormFields/InputEmail.js +1 -1
  326. package/dist/es-legacy/components/internal/FormFields/InputEmail.js.map +1 -1
  327. package/dist/es-legacy/components/internal/FormFields/InputTelephone.js +1 -1
  328. package/dist/es-legacy/components/internal/FormFields/InputTelephone.js.map +1 -1
  329. package/dist/es-legacy/components/internal/FormFields/InputText.js +1 -1
  330. package/dist/es-legacy/components/internal/FormFields/InputText.js.map +1 -1
  331. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  332. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  333. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  334. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  335. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  336. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  337. package/dist/es-legacy/components/internal/Icon/constants.js +2 -0
  338. package/dist/es-legacy/components/internal/Icon/constants.js.map +1 -0
  339. package/dist/es-legacy/components/internal/Img/Img.js +1 -1
  340. package/dist/es-legacy/components/internal/Img/Img.js.map +1 -1
  341. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  342. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  343. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  344. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  345. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +2 -0
  346. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -0
  347. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  348. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  349. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  350. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  351. package/dist/es-legacy/components/internal/PhoneInput/PhoneInput.js +1 -1
  352. package/dist/es-legacy/components/internal/PhoneInput/PhoneInput.js.map +1 -1
  353. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  354. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  355. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  356. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  357. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  358. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  359. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  360. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  361. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  362. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  363. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  364. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  365. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  366. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  367. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js +1 -1
  368. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js.map +1 -1
  369. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  370. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  371. package/dist/es-legacy/components/internal/Voucher/Voucher.js +1 -1
  372. package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
  373. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  374. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  375. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  376. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  377. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  378. package/dist/es-legacy/core/Context/Resources.js +1 -1
  379. package/dist/es-legacy/core/Context/Resources.js.map +1 -1
  380. package/dist/es-legacy/core/Environment/Environment.js +1 -1
  381. package/dist/es-legacy/core/Environment/Environment.js.map +1 -1
  382. package/dist/es-legacy/core/Environment/constants.js +2 -0
  383. package/dist/es-legacy/core/Environment/constants.js.map +1 -0
  384. package/dist/es-legacy/core/Errors/SRPanel.js +1 -1
  385. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  386. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
  387. package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
  388. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js +1 -1
  389. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
  390. package/dist/es-legacy/core/ProcessResponse/process-response.js +1 -1
  391. package/dist/es-legacy/core/ProcessResponse/process-response.js.map +1 -1
  392. package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
  393. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  394. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  395. package/dist/es-legacy/core/Services/analytics/collect-id.js.map +1 -1
  396. package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
  397. package/dist/es-legacy/core/Services/get-translations.js +1 -1
  398. package/dist/es-legacy/core/Services/get-translations.js.map +1 -1
  399. package/dist/es-legacy/core/Services/http.js +1 -1
  400. package/dist/es-legacy/core/Services/http.js.map +1 -1
  401. package/dist/es-legacy/core/core.defaultProps.js +1 -1
  402. package/dist/es-legacy/core/core.defaultProps.js.map +1 -1
  403. package/dist/es-legacy/core/core.js +1 -1
  404. package/dist/es-legacy/core/core.js.map +1 -1
  405. package/dist/es-legacy/core/core.registry.js +1 -1
  406. package/dist/es-legacy/core/core.registry.js.map +1 -1
  407. package/dist/es-legacy/core/utils.js +1 -1
  408. package/dist/es-legacy/core/utils.js.map +1 -1
  409. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  410. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  411. package/dist/es-legacy/external/preact/hooks/dist/hooks.js +1 -1
  412. package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
  413. package/dist/es-legacy/utils/arrayUtils.js +1 -1
  414. package/dist/es-legacy/utils/arrayUtils.js.map +1 -1
  415. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  416. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  417. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  418. package/dist/es-legacy/utils/validator-utils.js +1 -1
  419. package/dist/es-legacy/utils/validator-utils.js.map +1 -1
  420. package/package.json +146 -147
  421. package/dist/umd/adyen.css +0 -78
  422. package/dist/umd/adyen.js +0 -7
  423. package/dist/umd/adyen.js.map +0 -1
  424. package/translations/ar.json +0 -306
  425. package/translations/cs-CZ.json +0 -302
  426. package/translations/da-DK.json +0 -303
  427. package/translations/de-DE.json +0 -302
  428. package/translations/el-GR.json +0 -305
  429. package/translations/en-US.json +0 -307
  430. package/translations/es-ES.json +0 -300
  431. package/translations/fi-FI.json +0 -302
  432. package/translations/fr-FR.json +0 -305
  433. package/translations/hr-HR.json +0 -305
  434. package/translations/hu-HU.json +0 -305
  435. package/translations/it-IT.json +0 -305
  436. package/translations/ja-JP.json +0 -305
  437. package/translations/ko-KR.json +0 -305
  438. package/translations/nl-NL.json +0 -302
  439. package/translations/no-NO.json +0 -302
  440. package/translations/pl-PL.json +0 -305
  441. package/translations/pt-BR.json +0 -306
  442. package/translations/pt-PT.json +0 -307
  443. package/translations/ro-RO.json +0 -305
  444. package/translations/ru-RU.json +0 -303
  445. package/translations/sk-SK.json +0 -305
  446. package/translations/sl-SI.json +0 -305
  447. package/translations/sv-SE.json +0 -303
  448. package/translations/zh-CN.json +0 -305
  449. package/translations/zh-TW.json +0 -305
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\n\nconst Field: FunctionalComponent<FieldProps> = props => {\n //\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText?.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n >\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const childProps = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n return cloneElement(child as VNode, childProps);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type=\"checkmark\" alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type=\"field_error\" alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if contextVisibleToSR is true then we are NOT dealing with the label for a securedField... so give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && { htmlFor: name && uniqueId })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","toChildArray","child","childProps","isInvalid","cloneElement","Spinner","size","Icon","type","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","onClick","htmlFor","defaultProps"],"mappings":"wgBAUA,MAAMA,EAAyCC,IAE3C,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBAChBA,EAAqBC,eACrBA,EAEAC,OAAQC,EACRC,QAASC,EAAYC,KACrBA,EAAIC,6BACJA,EAA4BC,yBAC5BA,GACA9B,EAIE+B,EAAqBF,IAAgC,EACrDG,EAAYX,GAA4C,iBAAjBd,GAA6BA,EAAa0B,OAAS,EAC1FC,EAAcZ,IAA0BU,GAAaT,GAAgBU,OAAS,EAE9EE,EAAWC,EAAOC,EAAY,kBAAkBvB,OAC/CY,EAASY,GAAcC,GAAS,IAChCf,EAAQgB,GAAaD,GAAS,GAGjB,MAAhBZ,GAAsBW,IAAaX,GACpB,MAAfF,GAAqBe,IAAYf,GAGrC,MAAMgB,EAAiBC,GAClBC,IACGL,GAAW,GACXrB,IAAU0B,EAAAA,GAEd,CAAC1B,IAGC2B,EAAgBF,GACjBC,IACGL,GAAW,GACXvB,IAAS4B,GAET3B,IAAc2B,EAAAA,GAElB,CAAC5B,EAAQC,IAGP6B,EAAmCH,GAAY,IAE7CI,EAACC,EAAAA,KACqB,iBAAVnC,GACJkC,EAACE,OAAAA,CACG9C,UAAW+C,EAAW,CAClB,+BAA+B,EAC/B,qCAAsC1C,IAE1C2C,UAASpC,GAERF,GAMS,mBAAVA,GAAwBA,IAE/BC,GAAqBiC,EAACE,OAAAA,CAAK9C,UAAU,wCAAwCW,GAE7EL,GAAUsC,EAACE,OAAAA,CAAK9C,UAAW,+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6B,+BACnG,MAAM6C,EAAsB,CACxBC,QAAS1D,EACThB,UAAW+C,EAAW,CAClB,yBAAyB,EACzB,iCAAkCvB,EAClC,gCAAiCF,EACjC,kCAAmCnB,KAI3C,OAAOe,EAEH0B,EAAClC,QAAAA,IAAU+D,MAA2BD,GAAkB,CAAEG,QAAS/D,GAAQqB,IACtElC,GAGL6B,EAAyB6C,EAAqB1E,EAAUkC,KAahE,IAMJ,OACIW,EAACa,MAAAA,CACGzD,UAAW+C,EACP,wBACA/C,EACAC,EAAmByD,KAAIC,GAAK,0BAA0BA,MACtD,CACI,+BAAgCtD,EAChC,+BAAgCI,EAChC,kCAAmCL,GAAYD,KAIvDyC,EAAC2B,GAAAA,CACGvD,aAAcA,EACdJ,KAAMA,EACNT,SAAUA,EACVmB,OAAQA,EACRE,QAASA,EACTN,gBAAiBA,EACjBe,SAAUA,EAASmB,QACnBoB,gBAAiB3C,EACjBD,yBAA0BA,GAEzBe,KAEJM,IAAAA,EAKbpD,EAAM+E,aAAe,CACjB5E,UAAW,GACXC,mBAAoB,GACpBM,sBAAuB,GACvBW,iBAAiB,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBQ,yBAA0B,IAAM"}
1
+ {"version":3,"file":"Field.js","sources":["../../../../../../src/components/internal/FormFields/Field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { cloneElement, ComponentChild, Fragment, FunctionalComponent, h, toChildArray, VNode } from 'preact';\nimport Spinner from '../../Spinner';\nimport Icon from '../../Icon';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\nimport { useCallback, useRef, useState } from 'preact/hooks';\nimport { getUniqueId } from '../../../../utils/idGenerator';\nimport { FieldProps } from './types';\nimport './Field.scss';\nimport { PREFIX } from '../../Icon/constants';\n\nconst Field: FunctionalComponent<FieldProps> = props => {\n //\n const {\n children,\n className,\n classNameModifiers,\n dir,\n disabled,\n readOnly,\n errorMessage,\n helper,\n inputWrapperModifiers,\n isLoading,\n isValid,\n label,\n labelEndAdornment,\n name,\n onBlur,\n onFieldBlur,\n onFocus,\n // onFocusField is a securedField related function that allows a label click to set focus on a securedField (equates to CardInput setFocusOn)\n // TODO should rename it to make its purpose clear => setFocusOnSecuredField\n onFocusField,\n showValidIcon,\n useLabelElement,\n showErrorElement,\n showContextualElement,\n contextualText,\n // Redeclare prop names to avoid internal clashes\n filled: propsFilled,\n focused: propsFocused,\n i18n,\n contextVisibleToScreenReader,\n renderAlternativeToLabel\n } = props;\n\n // Controls whether any error element has an aria-hidden=\"true\" attr (which means it is the error for a securedField)\n // or whether it has an id attr that can be pointed to by an aria-describedby attr on an input element\n const contextVisibleToSR = contextVisibleToScreenReader ?? true;\n const showError = showErrorElement && typeof errorMessage === 'string' && errorMessage.length > 0;\n const showContext = showContextualElement && !showError && contextualText?.length > 0;\n\n const uniqueId = useRef(getUniqueId(`adyen-checkout-${name}`));\n const [focused, setFocused] = useState(false);\n const [filled, setFilled] = useState(false);\n\n // The means by which focussed/filled is set for securedFields\n if (propsFocused != null) setFocused(!!propsFocused);\n if (propsFilled != null) setFilled(!!propsFilled);\n\n // The means by which focussed/filled is set for other fields - this function is passed down to them and triggered\n const onFocusHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(true);\n onFocus?.(event);\n },\n [onFocus]\n );\n\n const onBlurHandler = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n setFocused(false);\n onBlur?.(event);\n // When we also need to fire a specific function when a field blurs // TODO - what is the use case?\n onFieldBlur?.(event);\n },\n [onBlur, onFieldBlur]\n );\n\n const renderLabelOrAlternativeContents = useCallback(() => {\n return (\n <Fragment>\n {typeof label === 'string' && (\n <span\n className={classNames({\n 'adyen-checkout__label__text': true,\n 'adyen-checkout__label__text--error': errorMessage\n })}\n data-id={name}\n >\n {label}\n </span>\n )}\n\n {/*TODO - in what scenario is label a function? */}\n {/*@ts-ignore - function is callable*/}\n {typeof label === 'function' && label()}\n\n {labelEndAdornment && <span className=\"adyen-checkout__label-adornment--end\">{labelEndAdornment}</span>}\n\n {helper && <span className={'adyen-checkout__helper-text'}>{helper}</span>}\n </Fragment>\n );\n }, [label, errorMessage, labelEndAdornment, helper]);\n\n const renderInputRelatedElements = useCallback(() => {\n const errorElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text--error': true, 'adyen-checkout-contextual-text--hidden': !showError })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_ERROR_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {errorMessage}\n </span>\n );\n const contextualElem = (\n <span\n className={classNames({ 'adyen-checkout-contextual-text': true, 'adyen-checkout-contextual-text--hidden': !showContext })}\n {...(contextVisibleToSR && { id: `${uniqueId.current}${ARIA_CONTEXT_SUFFIX}` })}\n aria-hidden={contextVisibleToSR ? null : 'true'}\n >\n {contextualText}\n </span>\n );\n\n return (\n <Fragment>\n <div\n className={classNames([\n 'adyen-checkout__input-wrapper',\n ...inputWrapperModifiers.map(m => `adyen-checkout__input-wrapper--${m}`)\n ])}\n dir={dir}\n >\n {toChildArray(children).map((child: ComponentChild): ComponentChild => {\n const childProps = {\n isValid,\n onFocusHandler,\n onBlurHandler,\n isInvalid: !!errorMessage,\n ...(name && { uniqueId: uniqueId.current }),\n showErrorElement: showErrorElement\n };\n return cloneElement(child as VNode, childProps);\n })}\n\n {isLoading && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--loading\">\n <Spinner size=\"small\" />\n </span>\n )}\n\n {isValid && showValidIcon !== false && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--valid\">\n <Icon type={`${PREFIX}checkmark`} alt={i18n?.get('field.valid')} />\n </span>\n )}\n\n {errorMessage && (\n <span className=\"adyen-checkout-input__inline-validation adyen-checkout-input__inline-validation--invalid\">\n <Icon type={`${PREFIX}field_error`} alt={i18n?.get('error.title')} />\n </span>\n )}\n </div>\n {errorElem}\n {contextualElem}\n </Fragment>\n );\n }, [children, errorMessage, contextualText, isLoading, isValid, onFocusHandler, onBlurHandler]);\n\n const LabelOrAlternative = useCallback(\n ({ onFocusField, focused, filled, disabled, name, uniqueId, useLabelElement, isSecuredField, children, renderAlternativeToLabel }) => {\n const defaultWrapperProps = {\n onClick: onFocusField,\n className: classNames({\n 'adyen-checkout__label': true,\n 'adyen-checkout__label--focused': focused,\n 'adyen-checkout__label--filled': filled,\n 'adyen-checkout__label--disabled': disabled\n })\n };\n\n return useLabelElement ? (\n // if contextVisibleToSR is true then we are NOT dealing with the label for a securedField... so give it a `for` attribute\n <label {...defaultWrapperProps} {...(!isSecuredField && { htmlFor: name && uniqueId })}>\n {children}\n </label>\n ) : (\n renderAlternativeToLabel(defaultWrapperProps, children, uniqueId) // defaults to null\n\n // Example usage:\n // const alternativeLabelContent = (defaultWrapperProps, children, uniqueId) => {\n // return (\n // <div {...defaultWrapperProps} role={'label'} htmlFor={uniqueId}>\n // {children}\n // </div>\n // );\n // };\n // <Field name={'myField'} useLabelElement={false} renderAlternativeToLabel={alternativeLabelContent}>\n );\n },\n []\n );\n\n /**\n * RENDER\n */\n return (\n <div\n className={classNames(\n 'adyen-checkout__field',\n className,\n classNameModifiers.map(m => `adyen-checkout__field--${m}`),\n {\n 'adyen-checkout__field--error': errorMessage,\n 'adyen-checkout__field--valid': isValid,\n 'adyen-checkout__field--inactive': readOnly || disabled\n }\n )}\n >\n <LabelOrAlternative\n onFocusField={onFocusField}\n name={name}\n disabled={disabled}\n filled={filled}\n focused={focused}\n useLabelElement={useLabelElement}\n uniqueId={uniqueId.current}\n isSecuredField={!contextVisibleToSR}\n renderAlternativeToLabel={renderAlternativeToLabel}\n >\n {renderLabelOrAlternativeContents()}\n </LabelOrAlternative>\n {renderInputRelatedElements()}\n </div>\n );\n};\n\nField.defaultProps = {\n className: '',\n classNameModifiers: [],\n inputWrapperModifiers: [],\n useLabelElement: true,\n showErrorElement: true,\n showContextualElement: true,\n renderAlternativeToLabel: () => null\n};\n\nexport default Field;\n"],"names":["Field","props","children","className","classNameModifiers","dir","disabled","readOnly","errorMessage","helper","inputWrapperModifiers","isLoading","isValid","label","labelEndAdornment","name","onBlur","onFieldBlur","onFocus","onFocusField","showValidIcon","useLabelElement","showErrorElement","showContextualElement","contextualText","filled","propsFilled","focused","propsFocused","i18n","contextVisibleToScreenReader","renderAlternativeToLabel","contextVisibleToSR","showError","length","showContext","uniqueId","useRef","getUniqueId","setFocused","useState","setFilled","onFocusHandler","useCallback","event","onBlurHandler","renderLabelOrAlternativeContents","h","Fragment","span","classNames","data-id","renderInputRelatedElements","errorElem","id","current","ARIA_ERROR_SUFFIX","aria-hidden","contextualElem","ARIA_CONTEXT_SUFFIX","div","map","m","toChildArray","child","childProps","isInvalid","cloneElement","Spinner","size","Icon","type","PREFIX","alt","get","LabelOrAlternative","isSecuredField","defaultWrapperProps","onClick","htmlFor","defaultProps"],"mappings":"yjBAWA,MAAMA,EAAyCC,IAE3C,MAAMC,SACFA,EAAQC,UACRA,EAASC,mBACTA,EAAkBC,IAClBA,EAAGC,SACHA,EAAQC,SACRA,EAAQC,aACRA,EAAYC,OACZA,EAAMC,sBACNA,EAAqBC,UACrBA,EAASC,QACTA,EAAOC,MACPA,EAAKC,kBACLA,EAAiBC,KACjBA,EAAIC,OACJA,EAAMC,YACNA,EAAWC,QACXA,EAAOC,aAGPA,EAAYC,cACZA,EAAaC,gBACbA,EAAeC,iBACfA,EAAgBC,sBAChBA,EAAqBC,eACrBA,EAEAC,OAAQC,EACRC,QAASC,EAAYC,KACrBA,EAAIC,6BACJA,EAA4BC,yBAC5BA,GACA9B,EAIE+B,EAAqBF,IAAgC,EACrDG,EAAYX,GAA4C,iBAAjBd,GAA6BA,EAAa0B,OAAS,EAC1FC,EAAcZ,IAA0BU,GAAaT,GAAgBU,OAAS,EAE9EE,EAAWC,EAAOC,EAAY,kBAAkBvB,OAC/CY,EAASY,GAAcC,GAAS,IAChCf,EAAQgB,GA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B,EACjBC,kBAAkB,EAClBC,uBAAuB,EACvBQ,yBAA0B,IAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className as string;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","newProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"uSA6Be,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,GACfC,IACGnB,EAAMoB,QAAQD,EAAAA,GAElB,CAACnB,EAAMoB,UAGLC,EAAiBH,GAClBC,IACOnB,GAAOsB,YAAYtB,EAAMsB,WAAWH,EAAAA,GAE5C,CAACnB,GAAOsB,aAGNC,EAAcL,GACfC,IACOnB,GAAOwB,SAASxB,EAAMwB,QAAQL,EAAAA,GAEtC,CAACnB,GAAOwB,UAGNC,EAAaP,GACdC,IACGnB,GAAO0B,gBAAgBP,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,GAAO+B,SAASZ,EAAAA,GAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,GACfC,IACGnB,GAAOiC,iBAAiBd,KAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B5B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBkC,KAAIC,GAAK,0BAA0BA,QAIlDnC,mBAAoBoC,EAAK9B,SAAU+B,EAAKpC,UAAWqC,EAAKpC,QAASqC,EAAIC,qBAAsBC,KAAQC,GAAa5C,EAExH,OACI6C,EAACC,QAAAA,CACGC,GAAIvC,KACAoC,EACJI,gBAAeJ,EAASK,SACxB1C,KAAMA,EACNG,UAAWwB,EACXgB,SAAU7C,EACVC,WAAYA,EACZL,YAAaA,EACbkD,mBAAkB,GAAG3C,IAAWL,EAAYiD,EAAoBC,IAChEC,eAAcnD,EACdiB,QAASH,EACTc,OAAQN,EACR8B,QAASvB,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACV+C,IAAKzD,GAGjB,CAEAD,EAAU2D,aAAe,CACrBlD,KAAM,OACNL,mBAAoB"}
1
+ {"version":3,"file":"InputBase.js","sources":["../../../../../src/components/internal/FormFields/InputBase.tsx"],"sourcesContent":["import { h, RefCallback } from 'preact';\nimport { useCallback } from 'preact/hooks';\nimport classNames from 'classnames';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../core/Errors/constants';\nimport Language from '../../../language';\nimport './FormFields.scss';\n\nexport interface InputBaseProps extends h.JSX.HTMLAttributes {\n classNameModifiers?: string[];\n isInvalid?: boolean;\n isValid?: boolean;\n readonly?: boolean;\n uniqueId?: string;\n disabled?: boolean;\n className?: string;\n placeholder?: string;\n value?: string;\n name?: string;\n checked?: boolean;\n setRef?: RefCallback<HTMLInputElement>;\n trimOnBlur?: boolean;\n i18n?: Language;\n label?: string;\n onBlurHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n onFocusHandler?: h.JSX.GenericEventHandler<HTMLInputElement>;\n maxlength?: number | null;\n addContextualElement?: boolean;\n}\n\nexport default function InputBase({ setRef, ...props }: InputBaseProps) {\n const { autoCorrect, classNameModifiers, isInvalid, isValid, readonly = null, spellCheck, type, uniqueId, disabled } = props;\n const className = props.className as string;\n\n /**\n * To avoid confusion with misplaced/misdirected onChange handlers - InputBase only accepts onInput, onBlur & onFocus handlers.\n * The first 2 being the means by which we expect useForm--handleChangeFor validation functionality to be applied.\n */\n if (Object.prototype.hasOwnProperty.call(props, 'onChange')) {\n console.error('Error: Form fields that rely on InputBase may not have an onChange property');\n }\n\n const handleInput = useCallback(\n (event: h.JSX.TargetedInputEvent<HTMLInputElement>) => {\n props.onInput(event);\n },\n [props.onInput]\n );\n\n const handleKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyPress) props.onKeyPress(event);\n },\n [props?.onKeyPress]\n );\n\n const handleKeyUp = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (props?.onKeyUp) props.onKeyUp(event);\n },\n [props?.onKeyUp]\n );\n\n const handleBlur = useCallback(\n (event: h.JSX.TargetedFocusEvent<HTMLInputElement>) => {\n props?.onBlurHandler?.(event); // From Field component\n\n if (props.trimOnBlur) {\n (event.target as HTMLInputElement).value = (event.target as HTMLInputElement).value.trim(); // needed to trim trailing spaces in field (leading spaces can be done via formatting)\n }\n\n props?.onBlur?.(event);\n },\n [props.onBlur, props.onBlurHandler]\n );\n\n const handleFocus = useCallback(\n (event: h.JSX.TargetedEvent<HTMLInputElement>) => {\n props?.onFocusHandler?.(event); // From Field component\n },\n [props.onFocusHandler]\n );\n\n const inputClassNames = classNames(\n 'adyen-checkout__input',\n [`adyen-checkout__input--${type}`],\n className,\n {\n 'adyen-checkout__input--invalid': isInvalid,\n 'adyen-checkout__input--valid': isValid\n },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n );\n\n // Don't spread classNameModifiers etc to input element (it ends up as an attribute on the element itself)\n const { classNameModifiers: cnm, uniqueId: uid, isInvalid: iiv, isValid: iv, addContextualElement: ace, ...newProps } = props;\n\n return (\n <input\n id={uniqueId}\n {...newProps}\n aria-required={newProps.required}\n type={type}\n className={inputClassNames}\n readOnly={readonly}\n spellCheck={spellCheck}\n autoCorrect={autoCorrect}\n aria-describedby={`${uniqueId}${isInvalid ? ARIA_ERROR_SUFFIX : ARIA_CONTEXT_SUFFIX}`}\n aria-invalid={isInvalid}\n onInput={handleInput}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyPress={handleKeyPress}\n disabled={disabled}\n ref={setRef}\n />\n );\n}\n\nInputBase.defaultProps = {\n type: 'text',\n classNameModifiers: []\n};\n"],"names":["InputBase","setRef","props","autoCorrect","classNameModifiers","isInvalid","isValid","readonly","spellCheck","type","uniqueId","disabled","className","Object","prototype","hasOwnProperty","call","console","error","handleInput","useCallback","event","onInput","handleKeyPress","onKeyPress","handleKeyUp","onKeyUp","handleBlur","onBlurHandler","trimOnBlur","target","value","trim","onBlur","handleFocus","onFocusHandler","inputClassNames","classNames","map","m","cnm","uid","iiv","iv","addContextualElement","ace","newProps","h","input","id","aria-required","required","readOnly","aria-describedby","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","aria-invalid","onFocus","ref","defaultProps"],"mappings":"uSA6Be,SAASA,GAAUC,OAAEA,KAAWC,IAC3C,MAAMC,YAAEA,EAAWC,mBAAEA,EAAkBC,UAAEA,EAASC,QAAEA,EAAOC,SAAEA,EAAW,KAAIC,WAAEA,EAAUC,KAAEA,EAAIC,SAAEA,EAAQC,SAAEA,GAAaT,EACjHU,EAAYV,EAAMU,UAMpBC,OAAOC,UAAUC,eAAeC,KAAKd,EAAO,aAC5Ce,QAAQC,MAAM,+EAGlB,MAAMC,EAAcC,GACfC,IACGnB,EAAMoB,QAAQD,EAAAA,GAElB,CAACnB,EAAMoB,UAGLC,EAAiBH,GAClBC,IACOnB,GAAOsB,YAAYtB,EAAMsB,WAAWH,EAAAA,GAE5C,CAACnB,GAAOsB,aAGNC,EAAcL,GACfC,IACOnB,GAAOwB,SAASxB,EAAMwB,QAAQL,EAAAA,GAEtC,CAACnB,GAAOwB,UAGNC,EAAaP,GACdC,IACGnB,GAAO0B,gBAAgBP,GAEnBnB,EAAM2B,aACLR,EAAMS,OAA4BC,MAAQV,EAAOS,OAA4BC,MAAMC,QAGxF9B,GAAO+B,SAASZ,EAAAA,GAEpB,CAACnB,EAAM+B,OAAQ/B,EAAM0B,gBAGnBM,EAAcd,GACfC,IACGnB,GAAOiC,iBAAiBd,KAE5B,CAACnB,EAAMiC,iBAGLC,EAAkBC,EACpB,wBACA,CAAC,0BAA0B5B,KAC3BG,EACA,CACI,iCAAkCP,EAClC,+BAAgCC,GAEpCF,EAAmBkC,KAAIC,GAAK,0BAA0BA,QAIlDnC,mBAAoBoC,EAAK9B,SAAU+B,EAAKpC,UAAWqC,EAAKpC,QAASqC,EAAIC,qBAAsBC,KAAQC,GAAa5C,EAExH,OACI6C,EAACC,QAAAA,CACGC,GAAIvC,KACAoC,EACJI,gBAAeJ,EAASK,SACxB1C,KAAMA,EACNG,UAAWwB,EACXgB,SAAU7C,EACVC,WAAYA,EACZL,YAAaA,EACbkD,mBAAkB,GAAG3C,IAAWL,EAAYiD,EAAoBC,IAChEC,eAAcnD,EACdiB,QAASH,EACTc,OAAQN,EACR8B,QAASvB,EACTR,QAASD,EACTD,WAAYD,EACZZ,SAAUA,EACV+C,IAAKzD,GAGjB,CAEAD,EAAU2D,aAAe,CACrBlD,KAAM,OACNL,mBAAoB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import a from"../../../../../external/classnames/index.js";import t from"../../../Img/Img.js";import o from"../../../Icon/Icon.js";const d=({item:d,active:n,selected:c,...s})=>e("li",{"aria-disabled":!!d.disabled,"aria-selected":c,className:a(["adyen-checkout__dropdown__element",{"adyen-checkout__dropdown__element--active":n,"adyen-checkout__dropdown__element--disabled":!!d.disabled}]),"data-disabled":!0===d.disabled||null,"data-value":d.id,onClick:s.onSelect,onMouseEnter:s.onHover,role:"option",id:`listItem-${d.id}`},d.icon&&e(t,{className:"adyen-checkout__dropdown__element__icon",alt:d.name,src:d.icon}),e("span",{className:"adyen-checkout__dropdown__element__text"},d.name),d.secondaryText&&e("span",{className:"adyen-checkout__dropdown__element__secondary-text"},d.secondaryText),c&&e(o,{type:"checkmark",height:14,width:14}));export{d as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import a from"../../../../../external/classnames/index.js";import t from"../../../Img/Img.js";import o from"../../../Icon/Icon.js";import{PREFIX as n}from"../../../Icon/constants.js";const d=({item:d,active:c,selected:s,...l})=>e("li",{"aria-disabled":!!d.disabled,"aria-selected":s,className:a(["adyen-checkout__dropdown__element",{"adyen-checkout__dropdown__element--active":c,"adyen-checkout__dropdown__element--disabled":!!d.disabled}]),"data-disabled":!0===d.disabled||null,"data-value":d.id,onClick:l.onSelect,onMouseEnter:l.onHover,role:"option",id:`listItem-${d.id}`},d.icon&&e(t,{className:"adyen-checkout__dropdown__element__icon",alt:d.name,src:d.icon}),e("span",{className:"adyen-checkout__dropdown__element__text"},d.name),d.secondaryText&&e("span",{className:"adyen-checkout__dropdown__element__secondary-text"},d.secondaryText),s&&e(o,{type:`${n}checkmark`,height:14,width:14}));export{d as default};
2
2
  //# sourceMappingURL=SelectListItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\n\nconst SelectListItem = ({ item, active, selected, ...props }: SelectItemProps) => {\n return (\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n {selected && <Icon type=\"checkmark\" height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","item","active","selected","props","h","li","aria-disabled","disabled","aria-selected","className","cx","data-disabled","data-value","id","onClick","onSelect","onMouseEnter","onHover","role","icon","Img","alt","name","src","span","secondaryText","Icon","type","height","width"],"mappings":"iNAMMA,MAAAA,EAAiB,EAAGC,OAAMC,SAAQC,cAAaC,KAE7CC,EAACC,KAAAA,CACGC,kBAAiBN,EAAKO,SACtBC,gBAAeN,EACfO,UAAWC,EAAG,CACV,oCACA,CACI,4CAA6CT,EAC7C,gDAAiDD,EAAKO,YAM9DI,iBAAiC,IAAlBX,EAAKO,UAA2B,KAC/CK,aAAYZ,EAAKa,GACjBC,QAASX,EAAMY,SACfC,aAAcb,EAAMc,QACpBC,KAAK,SAELL,GAAI,YAAYb,EAAKa,MAEpBb,EAAKmB,MAAQf,EAACgB,EAAAA,CAAIX,UAAU,0CAA0CY,IAAKrB,EAAKsB,KAAMC,IAAKvB,EAAKmB,OACjGf,EAACoB,OAAAA,CAAKf,UAAU,2CAA2CT,EAAKsB,MAC/DtB,EAAKyB,eAAiBrB,EAACoB,OAAAA,CAAKf,UAAU,qDAAqDT,EAAKyB,eAChGvB,GAAYE,EAACsB,EAAAA,CAAKC,KAAK,YAAYC,OAAQ,GAAIC,MAAO"}
1
+ {"version":3,"file":"SelectListItem.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectListItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { SelectItemProps } from '../types';\nimport Img from '../../../Img';\nimport Icon from '../../../Icon';\nimport { PREFIX } from '../../../Icon/constants';\n\nconst SelectListItem = ({ item, active, selected, ...props }: SelectItemProps) => {\n return (\n <li\n aria-disabled={!!item.disabled}\n aria-selected={selected}\n className={cx([\n 'adyen-checkout__dropdown__element',\n {\n 'adyen-checkout__dropdown__element--active': active,\n 'adyen-checkout__dropdown__element--disabled': !!item.disabled\n }\n ])}\n // A change in Preact v10.11.1 means that all falsy values are assessed and set on data attributes.\n // In the case of data-disabled we only ever want it set if item.disabled is actually true, since the presence of the data-disabled attr,\n // regardless of its value, will disable the select list item\n data-disabled={item.disabled === true ? true : null}\n data-value={item.id}\n onClick={props.onSelect}\n onMouseEnter={props.onHover}\n role=\"option\"\n //tabIndex={-1}\n id={`listItem-${item.id}`}\n >\n {item.icon && <Img className=\"adyen-checkout__dropdown__element__icon\" alt={item.name} src={item.icon} />}\n <span className=\"adyen-checkout__dropdown__element__text\">{item.name}</span>\n {item.secondaryText && <span className=\"adyen-checkout__dropdown__element__secondary-text\">{item.secondaryText}</span>}\n {selected && <Icon type={`${PREFIX}checkmark`} height={14} width={14} />}\n </li>\n );\n};\n\nexport default SelectListItem;\n"],"names":["SelectListItem","item","active","selected","props","h","li","aria-disabled","disabled","aria-selected","className","cx","data-disabled","data-value","id","onClick","onSelect","onMouseEnter","onHover","role","icon","Img","alt","name","src","span","secondaryText","Icon","type","PREFIX","height","width"],"mappings":"qQAOMA,MAAAA,EAAiB,EAAGC,OAAMC,SAAQC,cAAaC,KAE7CC,EAACC,KAAAA,CACGC,kBAAiBN,EAAKO,SACtBC,gBAAeN,EACfO,UAAWC,EAAG,CACV,oCACA,CACI,4CAA6CT,EAC7C,gDAAiDD,EAAKO,YAM9DI,iBAAiC,IAAlBX,EAAKO,UAA2B,KAC/CK,aAAYZ,EAAKa,GACjBC,QAASX,EAAMY,SACfC,aAAcb,EAAMc,QACpBC,KAAK,SAELL,GAAI,YAAYb,EAAKa,MAEpBb,EAAKmB,MAAQf,EAACgB,EAAAA,CAAIX,UAAU,0CAA0CY,IAAKrB,EAAKsB,KAAMC,IAAKvB,EAAKmB,OACjGf,EAACoB,OAAAA,CAAKf,UAAU,2CAA2CT,EAAKsB,MAC/DtB,EAAKyB,eAAiBrB,EAACoB,OAAAA,CAAKf,UAAU,qDAAqDT,EAAKyB,eAChGvB,GAAYE,EAACsB,EAAAA,CAAKC,KAAM,GAAGC,aAAmBC,OAAQ,GAAIC,MAAO"}
@@ -0,0 +1,2 @@
1
+ const o="bento_";export{o as PREFIX};
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/components/internal/Icon/constants.ts"],"sourcesContent":["export const PREFIX = 'bento_';\n"],"names":["PREFIX"],"mappings":"AAAO,MAAMA,EAAS"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useMemo as r,useState as o,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import n,{COMPANY_DETAILS_SCHEMA as a}from"../CompanyDetails/CompanyDetails.js";import l,{PERSONAL_DETAILS_SCHEMA as d}from"../PersonalDetails/PersonalDetails.js";import c from"../Address/Address.js";import u from"../FormFields/Checkbox/Checkbox.js";import m from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{mapFieldKey as p,getInitialActiveFieldsets as b,fieldsetsSchema as y,getActiveFieldsData as f}from"./utils.js";import A from"../IbanInput/IbanInput.js";import{enhanceErrorObjectKeys as C}from"../../../core/Errors/utils.js";import h from"../../../core/Errors/useSRPanelContext.js";import v from"../Address/Specifications.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import{ERROR_ACTION_BLUR_SCENARIO as k,ERROR_ACTION_FOCUS_FIELD as F}from"../../../core/Errors/constants.js";import{usePrevious as j}from"../../../utils/hookUtils.js";import{getArrayDifferences as D}from"../../../utils/arrayUtils.js";import x from"../FormFields/Field/Field.js";import S from"../FormInstruction/FormInstruction.js";const R={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function w(w){const{countryCode:E,visibility:M}=w,{i18n:q}=i(),I=s({});Object.keys(I.current).length||w.setComponentRef?.(I.current);const L=s(!1),{setSRMessagesFromObjects:P,setSRMessagesFromStrings:V,clearSRPanel:N,shouldMoveFocusSR:O}=h(),$=P?.({fieldTypeMappingFn:p}),_=r((()=>new v),[]),B=r((()=>new v(w.deliveryAddressSpecification)),[]),T=b(M,w.data),[U,z]=o(T),{current:G}=s(y.reduce(((e,s)=>(e[s]=e=>{G[s].current=e},e)),{})),H=!!w.consentCheckboxLabel,J=!H&&Object.keys(U).every((e=>!U[e])),K="editable"===M.deliveryAddress&&"hidden"!==M.billingAddress,[Q,W]=o({...w.data,...H&&{consentCheckbox:!1}}),[X,Y]=o({}),[Z,ee]=o({}),[se,re]=o("ready"),[oe,te]=o(null);I.current.showValidation=()=>{L.current=!0,y.forEach((e=>{G[e].current&&G[e].current.showValidation()})),Y({...H&&{consentCheckbox:Q.consentCheckbox?null:R}})},I.current.setStatus=re;const ie=j(oe);t((()=>{const e=Object.keys(U).every((e=>!U[e]||!!Z[e])),s=!H||!!Z.consentCheckbox,r=e&&s,o=f(U,Q),t="deliveryAddress:",i="billingAddress:",{companyDetails:n,personalDetails:l,bankAccount:c,billingAddress:u,deliveryAddress:m,...p}=X,b=C(u,i),y=C(m,t),A={..."object"==typeof n&&n,..."object"==typeof l&&l,..."object"==typeof c&&c,..."object"==typeof b&&b,..."object"==typeof y&&y,...p},h=a,v=w.personalDetailsRequiredFields??d,j=d.filter((e=>v?.includes(e))),x=_.getAddressSchemaForCountryFlat(Q.billingAddress?.country).map((e=>`${i}${e}`)),S=B.getAddressSchemaForCountryFlat(Q.deliveryAddress?.country).map((e=>`${t}${e}`)),R=h.concat(j,["holder","iban"],x,S,["consentCheckbox"]),E=_.getAddressLabelsForCountry(Q.billingAddress?.country),M=B.getAddressLabelsForCountry(Q.deliveryAddress?.country),q=$?.({errors:A,isValidating:L.current,layout:R,countrySpecificLabels:{...E,...M}}),I=q?.currentErrorsSortedByLayout;switch(te(I),q?.action){case F:O&&g(".adyen-checkout__open-invoice",q.fieldToFocus),setTimeout((()=>{L.current=!1}),300);break;case k:{const e=D(I,ie,"field"),s=e?.[0];if(s){const e="shopperEmail.invalid"===s.errorCode?s.errorMessage:null;V(e)}else N();break}}w.onChange({data:o,errors:X,valid:Z,isValid:r})}),[Q,U]);const ne=e=>s=>{W((r=>({...r,[e]:s.data}))),ee((r=>({...r,[e]:s.isValid}))),Y((r=>({...r,[e]:s.errors})))};return e("div",{className:"adyen-checkout__open-invoice"},w.showFormInstruction&&e(S,null),U.companyDetails&&e(n,{data:w.data.companyDetails,label:"companyDetails",onChange:ne("companyDetails"),setComponentRef:G.companyDetails,visibility:M.companyDetails}),U.personalDetails&&e(l,{data:w.data.personalDetails,requiredFields:w.personalDetailsRequiredFields,label:"personalDetails",onChange:ne("personalDetails"),setComponentRef:G.personalDetails,visibility:M.personalDetails}),U.bankAccount&&e(A,{holderName:!0,label:"bankAccount",data:Q.bankAccount,onChange:ne("bankAccount"),ref:G.bankAccount}),U.billingAddress&&e(c,{allowedCountries:w?.billingAddressSpecification?.allowedCountries??w.allowedCountries,countryCode:E,requiredFields:w.billingAddressRequiredFields,specifications:w.billingAddressSpecification,data:Q.billingAddress,label:"billingAddress",onChange:ne("billingAddress"),setComponentRef:G.billingAddress,visibility:M.billingAddress}),K&&e(x,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(u,{label:q.get("separateDeliveryAddress"),checked:U.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{z((e=>({...e,deliveryAddress:!U.deliveryAddress})))}})),U.deliveryAddress&&e(c,{allowedCountries:w?.deliveryAddressSpecification?.allowedCountries??w.allowedCountries,countryCode:E,requiredFields:w.deliveryAddressRequiredFields,specifications:w.deliveryAddressSpecification,data:Q.deliveryAddress,label:"deliveryAddress",onChange:ne("deliveryAddress"),setComponentRef:G.deliveryAddress,visibility:M.deliveryAddress}),H&&e(m,{data:Q,errorMessage:!!X.consentCheckbox,label:w.consentCheckboxLabel,onChange:e=>{const{checked:s}=e.target;W((e=>({...e,consentCheckbox:s}))),ee((e=>({...e,consentCheckbox:s}))),Y((e=>({...e,consentCheckbox:!s})))},i18n:q}),w.showPayButton&&w.payButton({status:se,classNameModifiers:[...J?["standalone"]:[]],label:q.get("confirmPurchase")}))}export{w as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useState as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import n from"../CompanyDetails/CompanyDetails.js";import t from"../PersonalDetails/PersonalDetails.js";import a from"../Address/Address.js";import l from"../FormFields/Checkbox/Checkbox.js";import d from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as c,fieldsetsSchema as m,getActiveFieldsData as p}from"./utils.js";import b from"../IbanInput/IbanInput.js";import u from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import C from"./useSRPanelForOpenInvoiceErrors.js";const h={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function f(f){const{countryCode:A,visibility:v}=f,{i18n:k}=i(),g=s({});Object.keys(g.current).length||f.setComponentRef?.(g.current);const D=s(!1),x=c(v,f.data),[F,j]=r(x),{current:w}=s(m.reduce(((e,s)=>(e[s]=e=>{w[s].current=e},e)),{})),R=!!f.consentCheckboxLabel,I=!R&&Object.keys(F).every((e=>!F[e])),E="editable"===v.deliveryAddress&&"hidden"!==v.billingAddress,[S,q]=r({...f.data,...R&&{consentCheckbox:!1}}),[P,V]=r({}),[M,N]=r({}),[O,L]=r("ready");g.current.showValidation=()=>{D.current=!0,m.forEach((e=>{w[e].current&&w[e].current.showValidation()})),V({...R&&{consentCheckbox:S.consentCheckbox?null:h}})},g.current.setStatus=L,C({errors:P,data:S,props:f,isValidating:D}),o((()=>{const e=Object.keys(F).every((e=>!F[e]||!!M[e])),s=!R||!!M.consentCheckbox,r=e&&s,o=p(F,S);f.onChange({data:o,errors:P,valid:M,isValid:r})}),[S,F]);const B=e=>s=>{q((r=>({...r,[e]:s.data}))),N((r=>({...r,[e]:s.isValid}))),V((r=>({...r,[e]:s.errors})))};return e("div",{className:"adyen-checkout__open-invoice"},f.showFormInstruction&&e(y,null),F.companyDetails&&e(n,{data:f.data.companyDetails,label:"companyDetails",onChange:B("companyDetails"),setComponentRef:w.companyDetails,visibility:v.companyDetails}),F.personalDetails&&e(t,{data:f.data.personalDetails,requiredFields:f.personalDetailsRequiredFields,label:"personalDetails",onChange:B("personalDetails"),setComponentRef:w.personalDetails,visibility:v.personalDetails}),F.bankAccount&&e(b,{holderName:!0,label:"bankAccount",data:S.bankAccount,onChange:B("bankAccount"),ref:w.bankAccount}),F.billingAddress&&e(a,{allowedCountries:f?.billingAddressSpecification?.allowedCountries??f.allowedCountries,countryCode:A,requiredFields:f.billingAddressRequiredFields,specifications:f.billingAddressSpecification,data:S.billingAddress,label:"billingAddress",onChange:B("billingAddress"),setComponentRef:w.billingAddress,visibility:v.billingAddress}),E&&e(u,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(l,{label:k.get("separateDeliveryAddress"),checked:F.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{j((e=>({...e,deliveryAddress:!F.deliveryAddress})))}})),F.deliveryAddress&&e(a,{allowedCountries:f?.deliveryAddressSpecification?.allowedCountries??f.allowedCountries,countryCode:A,requiredFields:f.deliveryAddressRequiredFields,specifications:f.deliveryAddressSpecification,data:S.deliveryAddress,label:"deliveryAddress",onChange:B("deliveryAddress"),setComponentRef:w.deliveryAddress,visibility:v.deliveryAddress}),R&&e(d,{data:S,errorMessage:!!P.consentCheckbox,label:f.consentCheckboxLabel,onChange:e=>{const{checked:s}=e.target;q((e=>({...e,consentCheckbox:s}))),N((e=>({...e,consentCheckbox:s}))),V((e=>({...e,consentCheckbox:s?null:h})))},i18n:k}),f.showPayButton&&f.payButton({status:O,classNameModifiers:[...I?["standalone"]:[]],label:k.get("confirmPurchase")}))}export{f as default};
2
2
  //# sourceMappingURL=OpenInvoice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState, useMemo } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema, mapFieldKey } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { GenericError, SetSRMessagesReturnObject, SortedErrorObject } from '../../../core/Errors/types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: OpenInvoiceProps) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n\n /** SR stuff */\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n /** end SR stuff */\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState<SortedErrorObject[]>(null);\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', srPanelResp.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.errorCode === 'shopperEmail.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, consentCheckbox: !checked }));\n };\n return (\n <div className=\"adyen-checkout__open-invoice\">\n {props.showFormInstruction && <FormInstruction />}\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","sortedErrorList","setSortedErrorList","showValidation","forEach","previousSortedErrors","usePrevious","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","extractedBillingAddressErrors","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorCode","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","showFormInstruction","FormInstruction","CompanyDetails","label","PersonalDetails","requiredFields","IbanInput","holderName","Address","allowedCountries","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"4wCAkCA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,CAAA,GAE9CC,OAAOC,KAAKH,EAAeI,SAASC,QACrCV,EAAMW,kBAAkBN,EAAeI,SAG3C,MAAMG,EAAeN,GAAO,IAGtBO,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAG1FC,EAAuCL,IAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,GAAQ,IAAM,IAAIC,GAAkB,IACnEC,EAAgCF,GAAQ,IAAM,IAAIC,EAAevB,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,CACGf,MAAO5H,EAAK4I,IAAI,2BAChBC,QAASnH,EAAgBe,gBACzB8F,mBAAoB,CAAC,2BACrBC,KAAM,0BACNxB,SAzEkB,KAClCrF,GAAmBmH,IAAqB,IACjCA,EACHrG,iBAAkBf,EAAgBe,mBACtC,KA0EKf,EAAgBe,iBACb6E,EAACW,EAAAA,CACGC,iBAAkBrI,GAAOyB,8BAA8B4G,kBAAoBrI,EAAMqI,iBACjFpI,YAAaA,EACbgI,eAAgBjI,EAAMkJ,8BACtBV,eAAgBxI,EAAMyB,6BACtBG,KAAMA,EAAKgB,gBACXmF,MAAM,kBACNZ,SAAUC,GAAe,mBACzBzG,gBAAiBqB,EAAcY,gBAC/B1C,WAAYA,EAAW0C,kBAI9BN,GACGmF,EAAC0B,EAAAA,CACGvH,KAAMA,EACN/B,eAAgBmD,EAAOD,gBACvBgF,MAAO/H,EAAMuC,qBACb4E,SA1FciC,IAC1B,MAAMJ,QAAEA,GAAYI,EAAEC,OACtBvG,GAAQwE,IAAa,IAAKA,EAAUvE,gBAAiBiG,MACrD7F,IAASoE,IAAc,IAAKA,EAAWxE,gBAAiBiG,MACxD/F,GAAUuE,IAAe,IAAKA,EAAYzE,iBAAkBiG,KAAQ,EAuFxD7I,KAAMA,IAIbH,EAAMsJ,eACHtJ,EAAMuJ,UAAU,CACZnG,UACAsF,mBAAoB,IAAKlG,EAAqB,CAAC,cAAgB,IAC/DuF,MAAO5H,EAAK4I,IAAI,qBAIpC"}
1
+ {"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport CompanyDetails from '../CompanyDetails';\nimport PersonalDetails from '../PersonalDetails';\nimport Address from '../Address';\nimport Checkbox from '../FormFields/Checkbox';\nimport ConsentCheckbox from '../FormFields/ConsentCheckbox';\nimport { getActiveFieldsData, getInitialActiveFieldsets, fieldsetsSchema } from './utils';\nimport {\n OpenInvoiceActiveFieldsets,\n OpenInvoiceFieldsetsRefs,\n OpenInvoiceProps,\n OpenInvoiceStateData,\n OpenInvoiceStateError,\n OpenInvoiceStateValid\n} from './types';\nimport './OpenInvoice.scss';\nimport IbanInput from '../IbanInput';\nimport { GenericError } from '../../../core/Errors/types';\nimport Field from '../FormFields/Field';\nimport FormInstruction from '../FormInstruction';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport useSRPanelForOpenInvoiceErrors from './useSRPanelForOpenInvoiceErrors';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: OpenInvoiceProps) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const openInvoiceRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(openInvoiceRef.current).length) {\n props.setComponentRef?.(openInvoiceRef.current);\n }\n\n const isValidating = useRef(false);\n\n const initialActiveFieldsets: OpenInvoiceActiveFieldsets = getInitialActiveFieldsets(visibility, props.data);\n const [activeFieldsets, setActiveFieldsets] = useState<OpenInvoiceActiveFieldsets>(initialActiveFieldsets);\n\n const { current: fieldsetsRefs } = useRef<OpenInvoiceFieldsetsRefs>(\n fieldsetsSchema.reduce((acc, fieldset) => {\n acc[fieldset] = ref => {\n fieldsetsRefs[fieldset].current = ref;\n };\n return acc;\n }, {})\n );\n\n const checkFieldsets = () => Object.keys(activeFieldsets).every(fieldset => !activeFieldsets[fieldset] || !!valid[fieldset]);\n const hasConsentCheckbox = !!props.consentCheckboxLabel;\n const isStandAloneButton = !hasConsentCheckbox && Object.keys(activeFieldsets).every(key => !activeFieldsets[key]);\n const showSeparateDeliveryAddressCheckbox = visibility.deliveryAddress === 'editable' && visibility.billingAddress !== 'hidden';\n\n const [data, setData] = useState<OpenInvoiceStateData>({\n ...props.data,\n ...(hasConsentCheckbox && { consentCheckbox: false })\n });\n const [errors, setErrors] = useState<OpenInvoiceStateError>({});\n const [valid, setValid] = useState<OpenInvoiceStateValid>({});\n const [status, setStatus] = useState('ready');\n\n // Expose methods expected by parent\n openInvoiceRef.current.showValidation = () => {\n isValidating.current = true;\n fieldsetsSchema.forEach(fieldset => {\n if (fieldsetsRefs[fieldset].current) fieldsetsRefs[fieldset].current.showValidation();\n });\n\n setErrors({\n ...(hasConsentCheckbox && { consentCheckbox: data.consentCheckbox ? null : consentCBErrorObj })\n });\n };\n\n openInvoiceRef.current.setStatus = setStatus;\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating });\n\n useEffect(() => {\n const fieldsetsAreValid: boolean = checkFieldsets();\n const consentCheckboxValid: boolean = !hasConsentCheckbox || !!valid.consentCheckbox;\n const isValid: boolean = fieldsetsAreValid && consentCheckboxValid;\n const newData: OpenInvoiceStateData = getActiveFieldsData(activeFieldsets, data);\n props.onChange({ data: newData, errors, valid, isValid });\n }, [data, activeFieldsets]);\n\n const handleFieldset = key => state => {\n setData(prevData => ({ ...prevData, [key]: state.data }));\n setValid(prevValid => ({ ...prevValid, [key]: state.isValid }));\n setErrors(prevErrors => ({ ...prevErrors, [key]: state.errors }));\n };\n\n const handleSeparateDeliveryAddress = () => {\n setActiveFieldsets(prevActiveFields => ({\n ...prevActiveFields,\n deliveryAddress: !activeFieldsets.deliveryAddress\n }));\n };\n\n const handleConsentCheckbox = e => {\n const { checked } = e.target;\n setData(prevData => ({ ...prevData, consentCheckbox: checked }));\n setValid(prevValid => ({ ...prevValid, consentCheckbox: checked }));\n setErrors(prevErrors => ({ ...prevErrors, ...{ consentCheckbox: !checked ? consentCBErrorObj : null } }));\n };\n return (\n <div className=\"adyen-checkout__open-invoice\">\n {props.showFormInstruction && <FormInstruction />}\n {activeFieldsets.companyDetails && (\n <CompanyDetails\n data={props.data.companyDetails}\n label=\"companyDetails\"\n onChange={handleFieldset('companyDetails')}\n setComponentRef={fieldsetsRefs.companyDetails}\n visibility={visibility.companyDetails}\n />\n )}\n\n {activeFieldsets.personalDetails && (\n <PersonalDetails\n data={props.data.personalDetails}\n requiredFields={props.personalDetailsRequiredFields}\n label=\"personalDetails\"\n onChange={handleFieldset('personalDetails')}\n setComponentRef={fieldsetsRefs.personalDetails}\n visibility={visibility.personalDetails}\n />\n )}\n\n {activeFieldsets.bankAccount && (\n <IbanInput\n holderName={true}\n label=\"bankAccount\"\n data={data.bankAccount}\n onChange={handleFieldset('bankAccount')}\n ref={fieldsetsRefs.bankAccount}\n />\n )}\n\n {activeFieldsets.billingAddress && (\n <Address\n allowedCountries={props?.billingAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.billingAddressRequiredFields}\n specifications={props.billingAddressSpecification}\n data={data.billingAddress}\n label=\"billingAddress\"\n onChange={handleFieldset('billingAddress')}\n setComponentRef={fieldsetsRefs.billingAddress}\n visibility={visibility.billingAddress}\n />\n )}\n\n {showSeparateDeliveryAddressCheckbox && (\n <Field\n classNameModifiers={['separateDeliveryAddress', 'consentCheckbox']}\n name={'separateDeliveryAddress'}\n useLabelElement={false}\n showErrorElement={false}\n >\n <Checkbox\n label={i18n.get('separateDeliveryAddress')}\n checked={activeFieldsets.deliveryAddress}\n classNameModifiers={['separateDeliveryAddress']}\n name={'separateDeliveryAddress'}\n onChange={handleSeparateDeliveryAddress}\n />\n </Field>\n )}\n\n {activeFieldsets.deliveryAddress && (\n <Address\n allowedCountries={props?.deliveryAddressSpecification?.allowedCountries ?? props.allowedCountries}\n countryCode={countryCode}\n requiredFields={props.deliveryAddressRequiredFields}\n specifications={props.deliveryAddressSpecification}\n data={data.deliveryAddress}\n label=\"deliveryAddress\"\n onChange={handleFieldset('deliveryAddress')}\n setComponentRef={fieldsetsRefs.deliveryAddress}\n visibility={visibility.deliveryAddress}\n />\n )}\n\n {hasConsentCheckbox && (\n <ConsentCheckbox\n data={data}\n errorMessage={!!errors.consentCheckbox}\n label={props.consentCheckboxLabel}\n onChange={handleConsentCheckbox}\n i18n={i18n}\n />\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n classNameModifiers: [...(isStandAloneButton ? ['standalone'] : [])],\n label: i18n.get('confirmPurchase')\n })}\n </div>\n );\n}\n"],"names":["consentCBErrorObj","isValid","errorMessage","error","OpenInvoice","props","countryCode","visibility","i18n","useCoreContext","openInvoiceRef","useRef","Object","keys","current","length","setComponentRef","isValidating","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","showFormInstruction","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"mxBAyBA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,CAAA,GAE9CC,OAAOC,KAAKH,EAAeI,SAASC,QACrCV,EAAMW,kBAAkBN,EAAeI,SAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EAAYF,EAAMe,OAChGC,EAAiBC,GAAsBC,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vE,GAAOoF,8BAA8Bb,kBAAoBvE,EAAMuE,iBACjFtE,YAAaA,EACbgE,eAAgBjE,EAAMqF,8BACtBX,eAAgB1E,EAAMoF,6BACtBrE,KAAMA,EAAKgB,gBACX+B,MAAM,kBACNb,SAAUC,EAAe,mBACzBvC,gBAAiBQ,EAAcY,gBAC/B7B,WAAYA,EAAW6B,kBAI9BN,GACG8B,EAAC+B,EAAAA,CACGvE,KAAMA,EACNlB,eAAgBsC,EAAOD,gBACvB4B,MAAO9D,EAAM0B,qBACbuB,SA1FcsC,IAC1B,MAAML,QAAEA,GAAYK,EAAEC,OACtBvD,GAAQmB,IAAa,IAAKA,EAAUlB,gBAAiBgD,MACrD5C,GAASe,IAAc,IAAKA,EAAWnB,gBAAiBgD,MACxD9C,GAAUkB,IAAe,IAAKA,EAAiBpB,gBAAkBgD,EAA8B,KAApBvF,KAA2B,EAuF1FQ,KAAMA,IAIbH,EAAMyF,eACHzF,EAAM0F,UAAU,CACZnD,SACAqC,mBAAoB,IAAKjD,EAAqB,CAAC,cAAgB,IAC/DmC,MAAO3D,EAAK8E,IAAI,qBAIpC"}
@@ -0,0 +1,2 @@
1
+ import{useState as e,useMemo as s,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as o}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as a,ERROR_ACTION_FOCUS_FIELD as l}from"../../../core/Errors/constants.js";import n from"../../../core/Errors/useSRPanelContext.js";import c from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as p}from"../../../utils/hookUtils.js";import{getArrayDifferences as u}from"../../../utils/arrayUtils.js";import{mapFieldKey as m}from"./utils.js";const y=({errors:y,data:f,props:b,isValidating:j})=>{const[g,A]=e(null),F=p(g),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:h,clearSRPanel:C,shouldMoveFocusSR:k}=n(),v=S?.({fieldTypeMappingFn:m}),D=s((()=>new c),[]),E=s((()=>new c(b.deliveryAddressSpecification)),[]);r((()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:r,personalDetails:n,bankAccount:c,billingAddress:p,deliveryAddress:m,...g}=y,S=o(p,s),M=o(m,e),R={..."object"==typeof r&&r,..."object"==typeof n&&n,..."object"==typeof c&&c,..."object"==typeof S&&S,..."object"==typeof M&&M,...g},x=t,L=b.personalDetailsRequiredFields??i,P=i.filter((e=>L?.includes(e))),$=["holder","iban"],w=D.getAddressSchemaForCountryFlat(f.billingAddress?.country).map((e=>`${s}${e}`)),T=E.getAddressSchemaForCountryFlat(f.deliveryAddress?.country).map((s=>`${e}${s}`)),U=x.concat(P,$,w,T,["consentCheckbox"]),V=D.getAddressLabelsForCountry(f.billingAddress?.country),_=E.getAddressLabelsForCountry(f.deliveryAddress?.country),q=v?.({errors:R,isValidating:j.current,layout:U,countrySpecificLabels:{...V,..._}}),B=q?.currentErrorsSortedByLayout;switch(A(B),q?.action){case l:k&&d(".adyen-checkout__open-invoice",q.fieldToFocus),setTimeout((()=>{j.current=!1}),300);break;case a:{const e=u(B,F,"field"),s=e?.[0];if(s){const e="shopperEmail.invalid"===s.errorCode?s.errorMessage:null;h(e)}else C();break}}}catch(e){}}),[y,f])};export{y as default};
2
+ //# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', srPanelResp.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.errorCode === 'shopperEmail.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorCode","errorMessage","_"],"mappings":"6vBAsBMA,MAAAA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBA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,EAAgB,gCAAiCP,EAAYQ,cAEpFC,YAAW,KACPnE,EAAa2D,SAAU,CAAA,GACxB,KACH,MAGJ,KAAKS,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBR,EAA6B1D,EAAsB,SAEpFmE,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAHgD,yBAA7BD,EAAeE,UAGCF,EAAeG,aAAe,KACvEnE,EAAyBiE,QAGzBhE,IAGJ,KACJ,EAIR,CAAE,MAAOmE,GAET,IACD,CAAC9E,EAAQC,GAAK"}
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as n}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as i}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_DOWNLOAD_STR as h,ANALYTICS_QR_CODE_DOWNLOAD as _}from"../../../core/Analytics/constants.js";class y extends t{timeoutId;constructor(t){super(t),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}static defaultProps={delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"};componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}redirectToApp=t=>{window.location.assign(t)};statusInterval=(t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)};pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}onTick=t=>{this.setState({percentage:t.percentage})};onTimeUp=()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))};onComplete=t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)};onError=t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)};checkStatus=()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(n).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))};render({amount:t,url:a,brandLogo:n,brandName:c,countdownTime:y,type:g,onActionHandled:k},{expired:f,completed:q,loading:b}){const{i18n:C,loadingContext:v}=p(),T=l(),N=this.props.qrCodeData?`${v}barcode.shtml?barcodeType=qrCode&fileType=png&data=${this.props.qrCodeData}`:this.props.qrCodeImage,w=(t,o)=>{const r=C.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:T({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle adyen-checkout__qr-loader__subtitle--result"},r))};if(f)return w("error","error.subtitle.payment");if(q)return w("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},n&&e("img",{alt:c,src:n,className:"adyen-checkout__qr-loader__brand-logo"}),e(s,null));const I=C.get(this.props.timeToPay).split("%@"),S=u();return e("div",{className:`\n adyen-checkout__qr-loader\n adyen-checkout__qr-loader--${g}\n ${this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`))}\n `},n&&e("img",{src:n,alt:c,className:"adyen-checkout__qr-loader__brand-logo"}),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},C.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},C.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:C.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:S,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},C.get(this.props.introduction)),e("img",{src:N,alt:C.get("wechatpay.scanqrcode"),onLoad:()=>{k?.({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},I[0]," ",e(o,{minutesFromNow:y,onTick:this.onTick,onCompleted:this.onTimeUp})," ",I[1]),"string"==typeof this.props.instructions?e("div",{className:"adyen-checkout__qr-loader__instructions"},C.get(this.props.instructions)):this.props.instructions?.(),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{i(this.props.qrCodeData),this.props.onSubmitAnalytics({type:h,target:_}),e()},icon:T({imageFolder:"components/"})("copy"),label:C.get("button.copy")})))}}export{y as default};
1
+ import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as n}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as i}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_DOWNLOAD_STR as h,ANALYTICS_QR_CODE_DOWNLOAD as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";class g extends t{timeoutId;constructor(t){super(t),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}static defaultProps={delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"};componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}redirectToApp=t=>{window.location.assign(t)};statusInterval=(t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)};pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}onTick=t=>{this.setState({percentage:t.percentage})};onTimeUp=()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))};onComplete=t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)};onError=t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)};checkStatus=()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(n).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))};render({amount:t,url:a,brandLogo:n,brandName:c,countdownTime:g,type:k,onActionHandled:f},{expired:q,completed:b,loading:C}){const{i18n:v,loadingContext:T}=p(),N=l(),w=this.props.qrCodeData?`${T}barcode.shtml?barcodeType=qrCode&fileType=png&data=${this.props.qrCodeData}`:this.props.qrCodeImage,I=(t,o)=>{const r=v.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:N({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle adyen-checkout__qr-loader__subtitle--result"},r))};if(q)return I("error","error.subtitle.payment");if(b)return I("success","creditCard.success");if(C)return e("div",{className:"adyen-checkout__qr-loader"},n&&e("img",{alt:c,src:n,className:"adyen-checkout__qr-loader__brand-logo"}),e(s,null));const S=v.get(this.props.timeToPay).split("%@"),j=u();return e("div",{className:`\n adyen-checkout__qr-loader\n adyen-checkout__qr-loader--${k}\n ${this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`))}\n `},n&&e("img",{src:n,alt:c,className:"adyen-checkout__qr-loader__brand-logo"}),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},v.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},v.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:v.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:j,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},v.get(this.props.introduction)),e("img",{src:w,alt:v.get("wechatpay.scanqrcode"),onLoad:()=>{f?.({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},S[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",S[1]),"string"==typeof this.props.instructions?e("div",{className:"adyen-checkout__qr-loader__instructions"},v.get(this.props.instructions)):this.props.instructions?.(),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{i(this.props.qrCodeData),this.props.onSubmitAnalytics({type:h,target:_}),e()},icon:N({imageFolder:"components/"})(`${y}copy`),label:v.get("button.copy")})))}}export{g as default};
2
2
  //# sourceMappingURL=QRLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\n\nconst QRCODE_URL = 'barcode.shtml?barcodeType=qrCode&fileType=png&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const qrCodeImage = this.props.qrCodeData ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}` : this.props.qrCodeImage;\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle adyen-checkout__qr-loader__subtitle--result\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n\n return (\n <div\n className={`\n adyen-checkout__qr-loader\n adyen-checkout__qr-loader--${type}\n ${this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`)}\n `}\n >\n {brandLogo && <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {i18n.get(this.props.introduction)}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({ componentType: this.props.type, actionDescription: 'qr-code-loaded' });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {typeof this.props.instructions === 'string' ? (\n <div className=\"adyen-checkout__qr-loader__instructions\">{i18n.get(this.props.instructions)}</div>\n ) : (\n this.props.instructions?.()\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })('copy')}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","timeoutId","constructor","props","super","this","state","buttonStatus","completed","delay","expired","loading","percentage","timePassed","static","countdownTime","onError","onComplete","throttleTime","classNameModifiers","throttledInterval","introduction","timeToPay","buttonLabel","componentDidMount","statusInterval","componentWillUnmount","clearTimeout","redirectToApp","url","window","location","assign","responseTime","setState","previous","newDelay","pollStatus","setTimeout","async","start","performance","now","checkStatus","end","Math","round","onTick","time","onTimeUp","AdyenCheckoutError","status","data","details","payload","paymentData","error","clientKey","loadingContext","checkPaymentStatus","then","processResponse","catch","response","type","render","amount","brandLogo","brandName","onActionHandled","i18n","useCoreContext","getImage","useImage","qrCodeImage","qrCodeData","finalState","image","message","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","split","qrSubtitleRef","useAutoFocus","map","m","value","currency","redirectIntroduction","Button","onClick","label","ContentSeparator","ref","tabIndex","onLoad","componentType","actionDescription","span","style","width","Countdown","minutesFromNow","onCompleted","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon"],"mappings":"61BAqBA,MAAMA,UAAiBC,EACXC,UAERC,WAAAA,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQ,CACTC,aAAc,UACdC,WAAW,EACXC,MAAON,EAAMM,MACbC,SAAS,EACTC,SAAS,EACTC,WAAY,IACZC,WAAY,EAEpB,CAEAC,oBAA6B,CACzBL,MAAO,IACPM,cAAe,GACfC,QAAS,OACTC,WAAY,OACZC,aAAc,IACdC,mBAAoB,GACpBC,kBAAmB,IACnBC,aAAc,uBACdC,UAAW,sBACXC,YAAa,WAGjBC,iBAAAA,GACInB,KAAKoB,gBACT,CAEAC,oBAAAA,GACIC,aAAatB,KAAKJ,UACtB,CAEO2B,cAA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CAAIC,UAAU,wCACVM,EAAgB,GAAG,IACpBR,EAAC6B,EAAAA,CAAUC,eAAgBhG,EAAegC,OAAQ1C,KAAK0C,OAAQiE,YAAa3G,KAAK4C,WAAY,IACtFwC,EAAgB,IAGS,iBAA5BpF,KAAKF,MAAM8G,aACfhC,EAACC,MAAAA,CAAIC,UAAU,2CAA2Cb,EAAKS,IAAI1E,KAAKF,MAAM8G,eAE9E5G,KAAKF,MAAM8G,iBAGd5G,KAAKF,MAAM+G,SACRjC,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACiB,EAAAA,CACGiB,QAAAA,EACAC,QAAQ,SACRjB,QAAS,CAACkB,GAAKC,eACXC,EAAgBlH,KAAKF,MAAMwE,YAC3BtE,KAAKF,MAAMqH,kBAAkB,CACzBxD,KAAMyD,EACNC,OAAQC,IAEZL,GAAAA,EAEJM,KAAMpD,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,QAC/C4B,MAAO9B,EAAKS,IAAI,kBAMxC"}
1
+ {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'barcode.shtml?barcodeType=qrCode&fileType=png&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const qrCodeImage = this.props.qrCodeData ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}` : this.props.qrCodeImage;\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle adyen-checkout__qr-loader__subtitle--result\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n\n return (\n <div\n className={`\n adyen-checkout__qr-loader\n adyen-checkout__qr-loader--${type}\n ${this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`)}\n `}\n >\n {brandLogo && <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {i18n.get(this.props.introduction)}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({ componentType: this.props.type, actionDescription: 'qr-code-loaded' });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {typeof this.props.instructions === 'string' ? (\n <div className=\"adyen-checkout__qr-loader__instructions\">{i18n.get(this.props.instructions)}</div>\n ) : (\n this.props.instructions?.()\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","timeoutId","constructor","props","super","this","state","buttonStatus","completed","delay","expired","loading","percentage","timePassed","static","countdownTime","onError","onComplete","throttleTime","classNameModifiers","throttledInterval","introduction","timeToPay","buttonLabel","componentDidMount","statusInterval","componentWillUnmount","clearTimeout","redirectToApp","url","window","location","assign","responseTime","setState","previous","newDelay","pollStatus","setTimeout","async","start","performance","now","checkStatus","end","Math","round","onTick","time","onTimeUp","AdyenCheckoutError","status","data","details","payload","paymentData","error","clientKey","loadingContext","checkPaymentStatus","then","processResponse","catch","response","type","render","amount","brandLogo","brandName","onActionHandled","i18n","useCoreContext","getImage","useImage","qrCodeImage","qrCodeData","finalState","image","message","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","split","qrSubtitleRef","useAutoFocus","map","m","value","currency","redirectIntroduction","Button","onClick","label","ContentSeparator","ref","tabIndex","onLoad","componentType","actionDescription","span","style","width","Countdown","minutesFromNow","onCompleted","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX"],"mappings":"24BAsBA,MAAMA,UAAiBC,EACXC,UAERC,WAAAA,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQ,CACTC,aAAc,UACdC,WAAW,EACXC,MAAON,EAAMM,MACbC,SAAS,EACTC,SAAS,EACTC,WAAY,IACZC,WAAY,EAEpB,CAEAC,oBAA6B,CACzBL,MAAO,IACPM,cAAe,GACfC,QAAS,OACTC,WAAY,OACZC,aAAc,IACdC,mBAAoB,GACpBC,kBAAmB,IACnBC,aAAc,u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AU,uCACXF,EAAC0B,OAAAA,CAAKxB,UAAU,wCAAwCyB,MAAO,CAAEC,MAAO,GAAGxG,KAAKC,MAAMM,kBAG1FqE,EAACC,MAAAA,CAAIC,UAAU,wCACVM,EAAgB,GAAG,IACpBR,EAAC6B,EAAAA,CAAUC,eAAgBhG,EAAegC,OAAQ1C,KAAK0C,OAAQiE,YAAa3G,KAAK4C,WAAY,IACtFwC,EAAgB,IAGS,iBAA5BpF,KAAKF,MAAM8G,aACfhC,EAACC,MAAAA,CAAIC,UAAU,2CAA2Cb,EAAKS,IAAI1E,KAAKF,MAAM8G,eAE9E5G,KAAKF,MAAM8G,iBAGd5G,KAAKF,MAAM+G,SACRjC,EAACC,MAAAA,CAAIC,UAAU,sCACXF,EAACiB,EAAAA,CACGiB,QAAAA,EACAC,QAAQ,SACRjB,QAAS,CAACkB,GAAKC,eACXC,EAAgBlH,KAAKF,MAAMwE,YAC3BtE,KAAKF,MAAMqH,kBAAkB,CACzBxD,KAAMyD,EACNC,OAAQC,IAEZL,GAAAA,EAEJM,KAAMpD,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,GAAGqD,SAClDzB,MAAO9B,EAAKS,IAAI,kBAMxC"}
@@ -1,2 +1,2 @@
1
- const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.0.3",m=["amex","mc","visa"],C=["ach",p],b=[r,c,t,a,d,i],x=[n,o],h=b.concat(x),D=["bcmc"],g="required",k="optional",B="hidden",l=g,v=k,A=B,E=g,M=k,N=B,S="data-cse",f="data-info",j="data-uid",I=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},L={[r]:"cardNumber",[c]:"expiryDate",[d]:"securityCode",[t]:"expiryMonth",[a]:"expiryYear",[i]:"password",[n]:"bankAccountNumber",[o]:"bankLocationId",[s]:"securityCodeThreeDigits",[y]:"securityCodeFourDigits"},P=6e3;export{h as ALL_SECURED_FIELDS,I as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,b as CREDIT_CARD_SF_FIELDS,A as CVC_POLICY_HIDDEN,v as CVC_POLICY_OPTIONAL,l as CVC_POLICY_REQUIRED,S as DATA_ENCRYPTED_FIELD_ATTR,f as DATA_INFO,j as DATA_UID,N as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,D as DEDICATED_CARD_COMPONENTS,m as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,n as ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,o as ENCRYPTED_BANK_LOCATION_FIELD,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,t as ENCRYPTED_EXPIRY_MONTH,a as ENCRYPTED_EXPIRY_YEAR,i as ENCRYPTED_PWD_FIELD,d as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,y as ENCRYPTED_SECURITY_CODE_4_DIGITS,p as GIFT_CARD,B as HIDDEN,C as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,k as OPTIONAL,x as OTHER_SF_FIELDS,g as REQUIRED,P as SF_CONFIG_TIMEOUT,L as SF_FIELDS_MAP,u as SF_VERSION};
1
+ const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.0.4",m=["amex","mc","visa"],C=["ach",p],b=[r,c,t,a,d,i],x=[n,o],h=b.concat(x),D=["bcmc"],g="required",k="optional",B="hidden",l=g,v=k,A=B,E=g,M=k,N=B,S="data-cse",f="data-info",j="data-uid",I=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},L={[r]:"cardNumber",[c]:"expiryDate",[d]:"securityCode",[t]:"expiryMonth",[a]:"expiryYear",[i]:"password",[n]:"bankAccountNumber",[o]:"bankLocationId",[s]:"securityCodeThreeDigits",[y]:"securityCodeFourDigits"},P=6e3;export{h as ALL_SECURED_FIELDS,I as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,b as CREDIT_CARD_SF_FIELDS,A as CVC_POLICY_HIDDEN,v as CVC_POLICY_OPTIONAL,l as CVC_POLICY_REQUIRED,S as DATA_ENCRYPTED_FIELD_ATTR,f as DATA_INFO,j as DATA_UID,N as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,D as DEDICATED_CARD_COMPONENTS,m as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,n as ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,o as ENCRYPTED_BANK_LOCATION_FIELD,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,t as ENCRYPTED_EXPIRY_MONTH,a as ENCRYPTED_EXPIRY_YEAR,i as ENCRYPTED_PWD_FIELD,d as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,y as ENCRYPTED_SECURITY_CODE_4_DIGITS,p as GIFT_CARD,B as HIDDEN,C as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,k as OPTIONAL,x as OTHER_SF_FIELDS,g as REQUIRED,P as SF_CONFIG_TIMEOUT,L as SF_FIELDS_MAP,u as SF_VERSION};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.0.3';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = ['ach', GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n // ENCRYPTED_PIN_FIELD,// probably redundant - it was an alt. name for KCP's encryptedPassword. But maybe has a role to play if we ever encrypt ibans.\n];\n\nexport const OTHER_SF_FIELDS = [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD, ENCRYPTED_BANK_LOCATION_FIELD]; // ACH fields\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard or ach) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS.concat(OTHER_SF_FIELDS);\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD]: 'bankAccountNumber',\n [ENCRYPTED_BANK_LOCATION_FIELD]: 'bankLocationId',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","OTHER_SF_FIELDS","ALL_SECURED_FIELDS","concat","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAEtBC,EAAoC,6BACpCC,EAAgC,0BAEhCC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAAC,MAAOH,GAG9CI,EAAwB,CACjCd,EACAC,EACAC,EACAC,EACAC,EACAC,GAISU,EAAkB,CAACT,EAAmCC,GAGtDS,EAAqBF,EAAsBG,OAAOF,GAIlDG,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzB3C,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WACvBC,CAACA,GAAoC,oBACrCC,CAACA,GAAgC,iBAEjCC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BmC,EAAoB"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.0.4';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = ['ach', GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n // ENCRYPTED_PIN_FIELD,// probably redundant - it was an alt. name for KCP's encryptedPassword. But maybe has a role to play if we ever encrypt ibans.\n];\n\nexport const OTHER_SF_FIELDS = [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD, ENCRYPTED_BANK_LOCATION_FIELD]; // ACH fields\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard or ach) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS.concat(OTHER_SF_FIELDS);\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD]: 'bankAccountNumber',\n [ENCRYPTED_BANK_LOCATION_FIELD]: 'bankLocationId',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","OTHER_SF_FIELDS","ALL_SECURED_FIELDS","concat","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAEtBC,EAAoC,6BACpCC,EAAgC,0BAEhCC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAAC,MAAOH,GAG9CI,EAAwB,CACjCd,EACAC,EACAC,EACAC,EACAC,EACAC,GAISU,EAAkB,CAACT,EAAmCC,GAGtDS,EAAqBF,EAAsBG,OAAOF,GAIlDG,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzB3C,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WACvBC,CAACA,GAAoC,oBACrCC,CAACA,GAAgC,iBAEjCC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BmC,EAAoB"}
@@ -1,2 +1,2 @@
1
- import{createElement as t}from"../../../external/preact/dist/preact.js";import e from"../BaseElement/BaseElement.js";import s from"../PayButton/PayButton.js";import{assertIsDropin as i,getRegulatoryDefaults as n,sanitizeResponse as o,verifyPaymentDidNotFail as r,cleanupFinalResult as a}from"./utils.js";import h from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as l}from"../../../utils/hasOwnProperty.js";import{ANALYTICS_SUBMIT_STR as d}from"../../../core/Analytics/constants.js";class p extends e{componentRef;resources;elementRef;static type=void 0;static txVariants=[];constructor(t,e){super(t,e),this.constructor.type&&this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.elementRef=e&&e.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props)}buildElementProps(t){const e={showPayButton:!0,...this.core.getCorePropsForComponent(),...!!t?.isStoredPaymentMethod?{}:this.core.paymentMethodsResponse.find(t?.type||this.constructor.type),...t},s=i(this);this.props=this.formatProps({...this.constructor.defaultProps,...n(this.core.options.countryCode,s),...e})}storeElementRefOnCore(t){t?.isDropin||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(t){this.state={...this.state,...t},this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(t,e){return this.elementRef?.setStatus(t,e),this}setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this}onChange(){const t=this.isValid,e={data:this.data,errors:this.state.errors,valid:this.state.valid,isValid:t};return this.props.onChange?.(e,this.elementRef),e}setUpAnalytics(t){const e=this.props.session?.id;return this.props.modules.analytics.setUp({...t,...e&&{sessionId:e}})}submitAnalytics(t,e){try{let s=this.constructor.analyticsType;s||(s="scheme"===this.constructor.type||"bcmc"===this.constructor.type?this.constructor.type:this.props.type),this.props.modules.analytics.sendAnalytics(s,t,e)}catch(t){console.warn("Failed to submit the analytics event. Error:",t)}}submit(){this.isValid?this.makePaymentsCall().then(o).then(r).then(this.handleResponse).catch(this.handleFailedResult):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise(((t,e)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:t,reject:e}))):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new h("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){return new Promise(((t,e)=>{this.submitAnalytics({type:d}),this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:t,reject:e})}))}async submitUsingSessionsFlow(t){this.submitAnalytics({type:d});try{return await this.core.session.submitPayment(t)}catch(t){return this.handleError(t),Promise.reject(t)}}onComplete(t){this.props.onComplete&&this.props.onComplete(t,this.elementRef)}handleError=t=>{this.setElementStatus("ready"),this.props.onError&&this.props.onError(t,this.elementRef)};handleAdditionalDetails(t){this.makeAdditionalDetailsCall(t).then(o).then(r).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(t){return this.setElementStatus("loading"),this.props.onAdditionalDetails?new Promise(((e,s)=>{this.props.onAdditionalDetails(t,this.elementRef,{resolve:e,reject:s})})):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(t.data):void this.handleError(new h("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(t){try{return await this.core.session.submitDetails(t)}catch(t){return this.handleError(t),Promise.reject(t)}}handleAction(t,e={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(t,{...this.elementRef.props,...e,onAdditionalDetails:this.handleAdditionalDetails});return s?(this.unmount(),s.mount(this._node)):null}handleOrder=t=>{const{order:e}=t;(this.core.session?this.core.update({order:e}):this.handleAdvanceFlowPaymentMethodsUpdate(e)).then((()=>{this.props.onOrderUpdated?.({order:e})}))};handleFailedResult=t=>{i(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),a(t),this.props.onPaymentFailed?.(t,this.elementRef)};handleSuccessResult=t=>{i(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),a(t),this.props.onPaymentCompleted?.(t,this.elementRef)};handleResponse(t){const e=o(t);e.action?this.elementRef.handleAction(e.action):e.order?.remainingAmount?.value>0?this.handleOrder(e):this.handleSuccessResult(e)}updateParent(t={}){return this.elementRef.core.update(t)}setComponentRef=t=>{this.componentRef=t};get isValid(){return!1}get icon(){const t=this.props.paymentMethodType||this.type;return this.props.icon??this.resources.getImage()(t)}get displayName(){const t=this.core.paymentMethodsResponse?.paymentMethods?.find((t=>t.type===this.type));return this.props.name||t?.name||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}payButton=e=>t(s,{...e,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,onClick:this.submit});async handleAdvanceFlowPaymentMethodsUpdate(t,e){return new Promise(((e,s)=>{if(!this.props.onPaymentMethodsRequest)return s(new Error("onPaymentMethodsRequest is not implemented"));this.props.onPaymentMethodsRequest({...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},locale:this.core.options.locale},{resolve:e,reject:s})})).catch((t=>{this.handleError(new h("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:t}))})).then((s=>this.core.update({...s&&{paymentMethodsResponse:s},order:t,amount:t?t.remainingAmount:e})))}}export{p as UIElement,p as default};
1
+ import{createElement as t}from"../../../external/preact/dist/preact.js";import e from"../BaseElement/BaseElement.js";import s from"../PayButton/PayButton.js";import{assertIsDropin as i,getRegulatoryDefaults as n,sanitizeResponse as o,verifyPaymentDidNotFail as r,cleanupFinalResult as a}from"./utils.js";import h from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as l}from"../../../utils/hasOwnProperty.js";import{ANALYTICS_SUBMIT_STR as d}from"../../../core/Analytics/constants.js";class p extends e{componentRef;resources;elementRef;static type=void 0;static txVariants=[];constructor(t,e){super(t,e),this.constructor.type&&this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.elementRef=e&&e.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props)}buildElementProps(t){const e={showPayButton:!0,...this.core.getCorePropsForComponent(),...!!t?.isStoredPaymentMethod?{}:this.core.paymentMethodsResponse.find(t?.type||this.constructor.type),...t},s=i(this);this.props=this.formatProps({...this.constructor.defaultProps,...n(this.core.options.countryCode,s),...e})}storeElementRefOnCore(t){t?.isDropin||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(t){this.state={...this.state,...t},this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(t,e){return this.elementRef?.setStatus(t,e),this}setStatus(t,e){return this.componentRef?.setStatus&&this.componentRef.setStatus(t,e),this}onChange(){const t=this.isValid,e={data:this.data,errors:this.state.errors,valid:this.state.valid,isValid:t};return this.props.onChange?.(e,this.elementRef),e}setUpAnalytics(t){const e=this.props.session?.id;return this.props.modules.analytics.setUp({...t,...e&&{sessionId:e}})}submitAnalytics(t,e){try{let s=this.constructor.analyticsType;s||(s="scheme"===this.constructor.type||"bcmc"===this.constructor.type?this.constructor.type:this.props.type),this.props.modules.analytics.sendAnalytics(s,t,e)}catch(t){console.warn("Failed to submit the analytics event. Error:",t)}}submit(){this.isValid?this.makePaymentsCall().then(o).then(r).then(this.handleResponse).catch(this.handleFailedResult):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise(((t,e)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:t,reject:e}))):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new h("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){return new Promise(((t,e)=>{this.submitAnalytics({type:d}),this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:t,reject:e})}))}async submitUsingSessionsFlow(t){this.submitAnalytics({type:d});try{return await this.core.session.submitPayment(t)}catch(t){return t instanceof h?this.handleError(t):this.handleError(new h("ERROR","Error when making /payments call",{cause:t})),Promise.reject(t)}}onComplete(t){this.props.onComplete&&this.props.onComplete(t,this.elementRef)}handleError=t=>{this.setElementStatus("ready"),this.props.onError&&this.props.onError(t,this.elementRef)};handleAdditionalDetails(t){this.makeAdditionalDetailsCall(t).then(o).then(r).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(t){return this.props.onAdditionalDetails?new Promise(((e,s)=>{this.props.onAdditionalDetails(t,this.elementRef,{resolve:e,reject:s})})):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(t.data):void this.handleError(new h("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(t){try{return await this.core.session.submitDetails(t)}catch(t){return t instanceof h?this.handleError(t):this.handleError(new h("ERROR","Error when making /details call",{cause:t})),Promise.reject(t)}}handleAction(t,e={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(t,{...this.elementRef.props,...e,onAdditionalDetails:this.handleAdditionalDetails});return s?(this.unmount(),s.mount(this._node)):null}handleOrder=t=>{const{order:e}=t;(this.core.session?this.core.update({order:e}):this.handleAdvanceFlowPaymentMethodsUpdate(e)).then((()=>{this.props.onOrderUpdated?.({order:e})}))};handleFailedResult=t=>{i(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),a(t),this.props.onPaymentFailed?.(t,this.elementRef)};handleSuccessResult=t=>{i(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),a(t),this.props.onPaymentCompleted?.(t,this.elementRef)};handleResponse(t){const e=o(t);e.action?this.elementRef.handleAction(e.action):e.order?.remainingAmount?.value>0?this.handleOrder(e):this.handleSuccessResult(e)}updateParent(t={}){return this.elementRef.core.update(t)}setComponentRef=t=>{this.componentRef=t};get isValid(){return!1}get icon(){const t=this.props.paymentMethodType||this.type;return this.props.icon??this.resources.getImage()(t)}get displayName(){const t=this.core.paymentMethodsResponse?.paymentMethods?.find((t=>t.type===this.type));return this.props.name||t?.name||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}payButton=e=>t(s,{...e,amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,onClick:this.submit});async handleAdvanceFlowPaymentMethodsUpdate(t,e){return new Promise(((e,s)=>{if(!this.props.onPaymentMethodsRequest)return s(new Error("onPaymentMethodsRequest is not implemented"));this.props.onPaymentMethodsRequest({...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},locale:this.core.options.locale},{resolve:e,reject:s})})).catch((t=>{this.handleError(new h("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:t}))})).then((s=>this.core.update({...s&&{paymentMethodsResponse:s},order:t,amount:t?t.remainingAmount:e})))}}export{p as UIElement,p as default};
2
2
  //# sourceMappingURL=UIElement.js.map