@adyen/adyen-web 6.5.1 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/dist/cjs/adyen.css +5 -5
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +290 -169
  6. package/dist/es/adyen.css +5 -5
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/ANCV.js +1 -1
  9. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  10. package/dist/es/components/Ach/components/AchInput/AchInput.js.map +1 -1
  11. package/dist/es/components/Ach/components/AchInput/defaultProps.js +1 -1
  12. package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  13. package/dist/es/components/Ach/components/AchInput/defaultStyles.js.map +1 -1
  14. package/dist/es/components/AfterPay/AfterPayB2B.js.map +1 -1
  15. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  16. package/dist/es/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  17. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  18. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  19. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  20. package/dist/es/components/Boleto/Boleto.js.map +1 -1
  21. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  22. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  23. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  24. package/dist/es/components/Card/Card.js.map +1 -1
  25. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  26. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  27. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  28. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  29. package/dist/es/components/Card/components/CardInput/defaultProps.js.map +1 -1
  30. package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
  31. package/dist/es/components/Card/components/CardInput/types.js +1 -1
  32. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  33. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  34. package/dist/es/components/CashAppPay/services/types.js +1 -1
  35. package/dist/es/components/CashAppPay/services/types.js.map +1 -1
  36. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  37. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  38. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  39. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  40. package/dist/es/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
  41. package/dist/es/components/Donation/components/CampaignContent.js +1 -1
  42. package/dist/es/components/Donation/components/CampaignContent.js.map +1 -1
  43. package/dist/es/components/Donation/components/CampaignInfo.js +2 -0
  44. package/dist/es/components/Donation/components/CampaignInfo.js.map +1 -0
  45. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  46. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  47. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  48. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  49. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  50. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  51. package/dist/es/components/Dropin/components/PaymentMethod/useBrandLogoConfiguration.js.map +1 -1
  52. package/dist/es/components/Dropin/elements/filters.js.map +1 -1
  53. package/dist/es/components/Dropin/elements/getComponentConfiguration.js.map +1 -1
  54. package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  55. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  56. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  57. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  58. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  59. package/dist/es/components/GooglePay/components/GooglePayButton.js +1 -1
  60. package/dist/es/components/GooglePay/components/GooglePayButton.js.map +1 -1
  61. package/dist/es/components/GooglePay/requests.js.map +1 -1
  62. package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
  63. package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
  64. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  65. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  66. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  67. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  68. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  69. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  70. package/dist/es/components/OnlineBankingCZ/index.js +1 -1
  71. package/dist/es/components/OnlineBankingCZ/index.js.map +1 -1
  72. package/dist/es/components/OnlineBankingSK/index.js +1 -1
  73. package/dist/es/components/OnlineBankingSK/index.js.map +1 -1
  74. package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
  75. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  76. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  77. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  78. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  79. package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  80. package/dist/es/components/Pix/Pix.js.map +1 -1
  81. package/dist/es/components/Redirect/Redirect.js +1 -1
  82. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  83. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  84. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  85. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  86. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  87. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  88. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  89. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  90. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  91. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  92. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  93. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  94. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  95. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  96. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  97. package/dist/es/components/Twint/Twint.js.map +1 -1
  98. package/dist/es/components/UPI/UPI.js.map +1 -1
  99. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  100. package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  101. package/dist/es/components/internal/Address/Address.js.map +1 -1
  102. package/dist/es/components/internal/Address/components/CountryField.js +1 -1
  103. package/dist/es/components/internal/Address/components/CountryField.js.map +1 -1
  104. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  105. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  106. package/dist/es/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  107. package/dist/es/components/internal/Address/components/StateField.js +1 -1
  108. package/dist/es/components/internal/Address/components/StateField.js.map +1 -1
  109. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  110. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  111. package/dist/es/components/internal/Button/Button.js.map +1 -1
  112. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  113. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  114. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  115. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  116. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js +1 -1
  117. package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js.map +1 -1
  118. package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
  119. package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  120. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  121. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  122. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  123. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  124. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  125. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  126. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  127. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  128. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  129. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  130. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  131. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  132. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  133. package/dist/es/components/internal/OpenInvoice/utils.js.map +1 -1
  134. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  135. package/dist/es/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  136. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  137. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  138. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  139. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  140. package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  141. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  142. package/dist/es/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
  143. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  144. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  145. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
  146. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
  147. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  148. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleValidation.js.map +1 -1
  149. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleBinValue.js.map +1 -1
  150. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleFocus.js.map +1 -1
  151. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleIframeConfigFeedback.js.map +1 -1
  152. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
  153. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/postMessageToAllIframes.js.map +1 -1
  154. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
  155. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  156. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/validateForm.js.map +1 -1
  157. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  158. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/destroySecuredFields.js.map +1 -1
  159. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/processErrors.js.map +1 -1
  160. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  161. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  162. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  163. package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.js.map +1 -1
  164. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  165. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  166. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  167. package/dist/es/components/internal/Voucher/utils.js.map +1 -1
  168. package/dist/es/components/tx-variants.js +1 -1
  169. package/dist/es/components/tx-variants.js.map +1 -1
  170. package/dist/es/core/Analytics/Analytics.js +1 -1
  171. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  172. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  173. package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
  174. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
  175. package/dist/es/core/Analytics/constants.js +1 -1
  176. package/dist/es/core/Analytics/constants.js.map +1 -1
  177. package/dist/es/core/Analytics/utils.js.map +1 -1
  178. package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
  179. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  180. package/dist/es/core/Errors/SRMessages.js.map +1 -1
  181. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  182. package/dist/es/core/Errors/constants.js +1 -1
  183. package/dist/es/core/Errors/constants.js.map +1 -1
  184. package/dist/es/core/Errors/utils.js +1 -1
  185. package/dist/es/core/Errors/utils.js.map +1 -1
  186. package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
  187. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  188. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  189. package/dist/es/core/Services/http.js +1 -1
  190. package/dist/es/core/Services/http.js.map +1 -1
  191. package/dist/es/core/Services/sessions/constants.js +1 -1
  192. package/dist/es/core/Services/sessions/constants.js.map +1 -1
  193. package/dist/es/core/Services/sessions/create-order.js +1 -1
  194. package/dist/es/core/Services/sessions/create-order.js.map +1 -1
  195. package/dist/es/core/Services/sessions/make-payment.js +1 -1
  196. package/dist/es/core/Services/sessions/make-payment.js.map +1 -1
  197. package/dist/es/core/Services/sessions/setup-session.js.map +1 -1
  198. package/dist/es/core/Services/sessions/submit-details.js +1 -1
  199. package/dist/es/core/Services/sessions/submit-details.js.map +1 -1
  200. package/dist/es/core/core.js +1 -1
  201. package/dist/es/core/core.registry.js.map +1 -1
  202. package/dist/es/core/utils.js.map +1 -1
  203. package/dist/es/external/classnames/index.js.map +1 -1
  204. package/dist/es/external/preact/dist/preact.js +1 -1
  205. package/dist/es/external/preact/dist/preact.js.map +1 -1
  206. package/dist/es/index.d.ts +290 -169
  207. package/dist/es/language/Language.js.map +1 -1
  208. package/dist/es/language/utils.js.map +1 -1
  209. package/dist/es/utils/Storage.js.map +1 -1
  210. package/dist/es/utils/commonUtils.js.map +1 -1
  211. package/dist/es/utils/get-process-message-handler.js.map +1 -1
  212. package/dist/es/utils/getOrigin.js.map +1 -1
  213. package/dist/es/utils/useForm/reducer.js.map +1 -1
  214. package/dist/es/utils/useForm/useForm.js.map +1 -1
  215. package/dist/es-legacy/adyen.css +5 -5
  216. package/dist/es-legacy/adyen.css.map +1 -1
  217. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  218. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  219. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +1 -1
  220. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +1 -1
  221. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  222. package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js.map +1 -1
  223. package/dist/es-legacy/components/AfterPay/AfterPayB2B.js.map +1 -1
  224. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  225. package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
  226. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  227. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  228. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  229. package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
  230. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  231. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  232. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  233. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  234. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  235. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  236. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  237. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  238. package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js.map +1 -1
  239. package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
  240. package/dist/es-legacy/components/Card/components/CardInput/types.js +1 -1
  241. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  242. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  243. package/dist/es-legacy/components/CashAppPay/services/types.js +1 -1
  244. package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
  245. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  246. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  247. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  248. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  249. package/dist/es-legacy/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
  250. package/dist/es-legacy/components/Donation/components/CampaignContent.js +1 -1
  251. package/dist/es-legacy/components/Donation/components/CampaignContent.js.map +1 -1
  252. package/dist/es-legacy/components/Donation/components/CampaignInfo.js +2 -0
  253. package/dist/es-legacy/components/Donation/components/CampaignInfo.js.map +1 -0
  254. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  255. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  256. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  257. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  258. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  259. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  260. package/dist/es-legacy/components/Dropin/components/PaymentMethod/useBrandLogoConfiguration.js.map +1 -1
  261. package/dist/es-legacy/components/Dropin/elements/filters.js.map +1 -1
  262. package/dist/es-legacy/components/Dropin/elements/getComponentConfiguration.js.map +1 -1
  263. package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  264. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  265. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  266. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  267. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  268. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js +1 -1
  269. package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js.map +1 -1
  270. package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
  271. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  272. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  273. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  274. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  275. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  276. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  277. package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
  278. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  279. package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
  280. package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
  281. package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
  282. package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
  283. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  284. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  285. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  286. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  287. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  288. package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
  289. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  290. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  291. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  292. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  293. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  294. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  295. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  296. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  297. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  298. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  299. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  300. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  301. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  302. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  303. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  304. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  305. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  306. package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
  307. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  308. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  309. package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  310. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  311. package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
  312. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  313. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  314. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  315. package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  316. package/dist/es-legacy/components/internal/Address/components/StateField.js +1 -1
  317. package/dist/es-legacy/components/internal/Address/components/StateField.js.map +1 -1
  318. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  319. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  320. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  321. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  322. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  323. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  324. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
  325. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
  326. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js +1 -1
  327. package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js.map +1 -1
  328. package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
  329. package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  330. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  331. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  332. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  333. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  334. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  335. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  336. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  337. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  338. package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
  339. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  340. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  341. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  342. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  343. package/dist/es-legacy/components/internal/OpenInvoice/utils.js.map +1 -1
  344. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  345. package/dist/es-legacy/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  346. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  347. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  348. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  349. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  350. package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
  351. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  352. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  353. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
  354. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  355. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  356. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
  357. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
  358. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  359. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleValidation.js.map +1 -1
  360. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleBinValue.js.map +1 -1
  361. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleFocus.js.map +1 -1
  362. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleIframeConfigFeedback.js.map +1 -1
  363. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
  364. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/postMessageToAllIframes.js.map +1 -1
  365. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
  366. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  367. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/validateForm.js.map +1 -1
  368. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  369. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/destroySecuredFields.js.map +1 -1
  370. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/processErrors.js.map +1 -1
  371. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  372. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  373. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  374. package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.js.map +1 -1
  375. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  376. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  377. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  378. package/dist/es-legacy/components/internal/Voucher/utils.js.map +1 -1
  379. package/dist/es-legacy/components/tx-variants.js +1 -1
  380. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  381. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  382. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  383. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  384. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
  385. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
  386. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  387. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  388. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  389. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js +1 -1
  390. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  391. package/dist/es-legacy/core/Errors/SRMessages.js.map +1 -1
  392. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  393. package/dist/es-legacy/core/Errors/constants.js +1 -1
  394. package/dist/es-legacy/core/Errors/constants.js.map +1 -1
  395. package/dist/es-legacy/core/Errors/utils.js +1 -1
  396. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  397. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  398. package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  399. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  400. package/dist/es-legacy/core/Services/http.js +1 -1
  401. package/dist/es-legacy/core/Services/http.js.map +1 -1
  402. package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
  403. package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
  404. package/dist/es-legacy/core/Services/sessions/create-order.js +1 -1
  405. package/dist/es-legacy/core/Services/sessions/create-order.js.map +1 -1
  406. package/dist/es-legacy/core/Services/sessions/make-payment.js +1 -1
  407. package/dist/es-legacy/core/Services/sessions/make-payment.js.map +1 -1
  408. package/dist/es-legacy/core/Services/sessions/setup-session.js.map +1 -1
  409. package/dist/es-legacy/core/Services/sessions/submit-details.js +1 -1
  410. package/dist/es-legacy/core/Services/sessions/submit-details.js.map +1 -1
  411. package/dist/es-legacy/core/core.js +1 -1
  412. package/dist/es-legacy/core/core.registry.js.map +1 -1
  413. package/dist/es-legacy/core/utils.js.map +1 -1
  414. package/dist/es-legacy/external/classnames/index.js.map +1 -1
  415. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  416. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  417. package/dist/es-legacy/language/Language.js.map +1 -1
  418. package/dist/es-legacy/language/utils.js.map +1 -1
  419. package/dist/es-legacy/utils/Storage.js.map +1 -1
  420. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  421. package/dist/es-legacy/utils/get-process-message-handler.js.map +1 -1
  422. package/dist/es-legacy/utils/getOrigin.js.map +1 -1
  423. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  424. package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
  425. package/package.json +25 -25
  426. package/styles/adyen.css +5 -5
  427. package/dist/es/components/Donation/components/CampaignContainer.js +0 -2
  428. package/dist/es/components/Donation/components/CampaignContainer.js.map +0 -1
  429. package/dist/es-legacy/components/Donation/components/CampaignContainer.js +0 -2
  430. package/dist/es-legacy/components/Donation/components/CampaignContainer.js.map +0 -1
@@ -1 +1 @@
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 <FormInstruction />\n\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=\"ach.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","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","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":"kkDAyBA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,OAsHEA,EA+BAA,EApJlC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,CAAA,GAG/CN,IAAAA,EADCO,OAAOC,KAAKH,EAAeI,SAASC,SAChB,QAArBV,EAAAA,EAAMW,2BAANX,GAAAA,EAAAA,KAAAA,EAAwBK,EAAeI,UAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EAAYF,EAAMe,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EJ,QAASU,GAAkBb,EAC/Bc,EAAgBC,QAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUd,QAAUe,CAAAA,EAE/BF,IACR,CAAA,IAIDG,IAAuBzB,EAAM0B,qBAC7BC,GAAsBF,GAAsBlB,OA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,EAAAA,CACGC,iBAAuE,QAArDxE,EAAAA,SAAAA,QAAAA,EAAAA,EAAOqF,oCAAPrF,IAAAA,OAAAA,EAAAA,EAAqCwE,wBAArCxE,IAAAA,EAAAA,EAAyDA,EAAMwE,iBACjFvE,YAAaA,EACbiE,eAAgBlE,EAAMsF,8BACtBX,eAAgB3E,EAAMqF,6BACtBtE,KAAMA,EAAKgB,gBACXgC,MAAM,kBACNb,SAAUC,EAAe,mBACzBxC,gBAAiBQ,EAAcY,gBAC/B7B,WAAYA,EAAW6B,kBAI9BN,GACGgC,EAAC8B,EAAAA,CACGxE,KAAMA,EACNlB,eAAgBuC,EAAOD,gBACvB4B,MAAO/D,EAAM0B,qBACbwB,SA3FcsC,IAC1B,MAAML,QAAEA,GAAYK,EAAEC,OACtBxD,GAAQoB,GAAaC,EAAKD,EAAAA,CAAAA,EAAAA,GAAAA,CAAUlB,gBAAiBgD,MACrD5C,GAASgB,GAAcD,EAAKC,EAAAA,CAAAA,EAAAA,GAAAA,CAAWpB,gBAAiBgD,MACxD9C,GAAUmB,GAAetB,EAAA,CAAA,EAAKsB,EAAe,CAAErB,gBAAkBgD,EAA8B,KAApBxF,KAAyB,EAwFxFQ,KAAMA,IAIbH,EAAM0F,eACH1F,EAAM2F,UAAU,CACZnD,SACAqC,mBAAoB,IAAKlD,EAAqB,CAAC,cAAgB,IAC/DoC,MAAO5D,EAAK+E,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 <FormInstruction />\n\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=\"ach.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","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","showValidation","forEach","useSRPanelForOpenInvoiceErrors","useEffect","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","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":"kkDAyBA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,OAsHEA,EA+BAA,EApJlC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAGXC,EAAiBC,EAA4B,IAG/CN,IAAAA,EADCO,OAAOC,KAAKH,EAAeI,SAASC,SAChB,QAArBV,EAAAA,EAAMW,2BAANX,GAAAA,EAAAA,KAAAA,EAAwBK,EAAeI,UAG3C,MAAMG,EAAeN,GAAO,GAEtBO,EAAqDC,EAA0BZ,EA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AAA,CACGlB,MAAO5D,EAAK+E,IAAI,2BAChBC,QAASnE,EAAgBe,gBACzB8C,mBAAoB,CAAC,2BACrBC,KAAM,0BACN5B,SA1EkB,KAClCjC,GAAmBmE,GAAqB9B,EACjC8B,EAAAA,CAAAA,EAAAA,GAAAA,CACHrD,iBAAkBf,EAAgBe,wBA4EjCf,EAAgBe,iBACb0B,EAACc,EAAAA,CACGC,iBAAuE,QAArDxE,EAAAA,SAAAA,QAAAA,EAAAA,EAAOqF,oCAAPrF,IAAAA,OAAAA,EAAAA,EAAqCwE,wBAArCxE,IAAAA,EAAAA,EAAyDA,EAAMwE,iBACjFvE,YAAaA,EACbiE,eAAgBlE,EAAMsF,8BACtBX,eAAgB3E,EAAMqF,6BACtBtE,KAAMA,EAAKgB,gBACXgC,MAAM,kBACNb,SAAUC,EAAe,mBACzBxC,gBAAiBQ,EAAcY,gBAC/B7B,WAAYA,EAAW6B,kBAI9BN,GACGgC,EAAC8B,EAAAA,CACGxE,KAAMA,EACNlB,eAAgBuC,EAAOD,gBACvB4B,MAAO/D,EAAM0B,qBACbwB,SA3FcsC,IAC1B,MAAML,QAAEA,GAAYK,EAAEC,OACtBxD,GAAQoB,GAAaC,EAAKD,EAAAA,CAAAA,EAAAA,GAAAA,CAAUlB,gBAAiBgD,MACrD5C,GAASgB,GAAcD,EAAKC,EAAAA,CAAAA,EAAAA,GAAAA,CAAWpB,gBAAiBgD,MACxD9C,GAAUmB,GAAetB,EAAA,CAAA,EAAKsB,EAAe,CAAErB,gBAAkBgD,EAA8B,KAApBxF,KAAyB,EAwFxFQ,KAAMA,IAIbH,EAAM0F,eACH1F,EAAM2F,UAAU,CACZnD,SACAqC,mBAAoB,IAAKlD,EAAqB,CAAC,cAAgB,IAC/DoC,MAAO5D,EAAK+E,IAAI,qBAIpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/OpenInvoice/utils.ts"],"sourcesContent":["import { OpenInvoiceActiveFieldsets, OpenInvoiceStateData, OpenInvoiceVisibility } from './types';\nimport Language from '../../../language';\nimport { mapFieldKey as mapFieldKeyAddress } from '../Address/utils';\nimport { StringObject } from '../Address/types';\n\nexport const fieldsetsSchema: Array<keyof OpenInvoiceStateData> = [\n 'companyDetails',\n 'personalDetails',\n 'billingAddress',\n 'deliveryAddress',\n 'bankAccount'\n];\n\nconst isPrefilled = (fieldsetData: object = {}): boolean => Object.keys(fieldsetData).length > 1;\n\nexport const getActiveFieldsData = (activeFieldsets: OpenInvoiceActiveFieldsets, data: OpenInvoiceStateData): OpenInvoiceStateData =>\n Object.keys(data)\n .filter(fieldset => activeFieldsets[fieldset])\n .reduce((acc, cur) => {\n acc[cur] = data[cur];\n return acc;\n }, {});\n\nexport const getInitialActiveFieldsets = (visibility: OpenInvoiceVisibility, data: OpenInvoiceStateData = {}): OpenInvoiceActiveFieldsets =>\n fieldsetsSchema.reduce((acc, fieldset) => {\n const isVisible = visibility[fieldset] !== 'hidden';\n const isDeliveryAddress = fieldset === 'deliveryAddress';\n const billingAddressIsHidden = visibility?.billingAddress === 'hidden';\n\n // The delivery address will be active not only when set as visible\n // but also when the billing address is hidden or when it has prefilled data\n acc[fieldset] = isVisible && (!isDeliveryAddress || billingAddressIsHidden || isPrefilled(data[fieldset]));\n return acc;\n }, {} as OpenInvoiceActiveFieldsets);\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to add the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to add the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n let refKey = key;\n let label;\n\n // Differentiate between address types (billing and delivery)\n const splitKey = refKey.split(':');\n const hasSplitKey = splitKey.length > 1;\n if (hasSplitKey) {\n label = splitKey[0];\n refKey = splitKey[1];\n }\n\n const addressKey = mapFieldKeyAddress(refKey, i18n, countrySpecificLabels);\n // Also use the presence of a label to know that we are dealing with address related fields. (This matters now that addresses can contain first & last name fields.)\n if (addressKey && label) return hasSplitKey ? `${i18n.get(label)} ${addressKey}` : addressKey;\n\n switch (refKey) {\n case 'dateOfBirth':\n case 'shopperEmail':\n case 'telephoneNumber':\n return i18n.get(refKey);\n default:\n break;\n }\n\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them\n return null;\n};\n"],"names":["fieldsetsSchema","getActiveFieldsData","activeFieldsets","data","Object","keys","filter","fieldset","reduce","acc","cur","getInitialActiveFieldsets","visibility","isVisible","isDeliveryAddress","billingAddressIsHidden","billingAddress","fieldsetData","length","isPrefilled","mapFieldKey","key","i18n","countrySpecificLabels","label","refKey","splitKey","split","hasSplitKey","addressKey","mapFieldKeyAddress","get"],"mappings":"wDAKaA,EAAqD,CAC9D,iBACA,kBACA,iBACA,kBACA,eAKSC,EAAsB,CAACC,EAA6CC,IAC7EC,OAAOC,KAAKF,GACPG,QAAOC,GAAYL,EAAgBK,KACnCC,QAAO,CAACC,EAAKC,KACVD,EAAIC,GAAOP,EAAKO,GACTD,IACR,IAEEE,EAA4B,CAACC,EAAmCT,EAA6B,CAAA,IACtGH,EAAgBQ,QAAO,CAACC,EAAKF,KACzB,MAAMM,EAAqC,WAAzBD,EAAWL,GACvBO,EAAiC,oBAAbP,EACpBQ,EAAwD,YAA/BH,aAAAA,EAAAA,EAAYI,gBAK3C,OADAP,EAAIF,GAAYM,KAAeC,GAAqBC,GAlBxC,EAACE,EAAuB,KAAgBb,OAAOC,KAAKY,GAAcC,OAAS,EAkBTC,CAAYhB,EAAKI,KACxFE,CAAAA,GACR,IAOMW,EAAc,CAACC,EAAaC,EAAgBC,KACrD,IACIC,EADAC,EAASJ,EAIb,MAAMK,EAAWD,EAAOE,MAAM,KACxBC,EAAcF,EAASR,OAAS,EAClCU,IACAJ,EAAQE,EAAS,GACjBD,EAASC,EAAS,IAGtB,MAAMG,EAAaC,EAAmBL,EAAQH,EAAMC,GAEpD,GAAIM,GAAcL,EAAO,OAAOI,EAAc,GAAGN,EAAKS,IAAIP,MAAUK,IAAeA,EAEnF,OAAQJ,GACJ,IAAK,cACL,IAAK,eACL,IAAK,kBACD,OAAOH,EAAKS,IAAIN,GAMxB,OAAO,IAAA"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/OpenInvoice/utils.ts"],"sourcesContent":["import { OpenInvoiceActiveFieldsets, OpenInvoiceStateData, OpenInvoiceVisibility } from './types';\nimport Language from '../../../language';\nimport { mapFieldKey as mapFieldKeyAddress } from '../Address/utils';\nimport { StringObject } from '../Address/types';\n\nexport const fieldsetsSchema: Array<keyof OpenInvoiceStateData> = [\n 'companyDetails',\n 'personalDetails',\n 'billingAddress',\n 'deliveryAddress',\n 'bankAccount'\n];\n\nconst isPrefilled = (fieldsetData: object = {}): boolean => Object.keys(fieldsetData).length > 1;\n\nexport const getActiveFieldsData = (activeFieldsets: OpenInvoiceActiveFieldsets, data: OpenInvoiceStateData): OpenInvoiceStateData =>\n Object.keys(data)\n .filter(fieldset => activeFieldsets[fieldset])\n .reduce((acc, cur) => {\n acc[cur] = data[cur];\n return acc;\n }, {});\n\nexport const getInitialActiveFieldsets = (visibility: OpenInvoiceVisibility, data: OpenInvoiceStateData = {}): OpenInvoiceActiveFieldsets =>\n fieldsetsSchema.reduce((acc, fieldset) => {\n const isVisible = visibility[fieldset] !== 'hidden';\n const isDeliveryAddress = fieldset === 'deliveryAddress';\n const billingAddressIsHidden = visibility?.billingAddress === 'hidden';\n\n // The delivery address will be active not only when set as visible\n // but also when the billing address is hidden or when it has prefilled data\n acc[fieldset] = isVisible && (!isDeliveryAddress || billingAddressIsHidden || isPrefilled(data[fieldset]));\n return acc;\n }, {} as OpenInvoiceActiveFieldsets);\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to add the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to add the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n let refKey = key;\n let label;\n\n // Differentiate between address types (billing and delivery)\n const splitKey = refKey.split(':');\n const hasSplitKey = splitKey.length > 1;\n if (hasSplitKey) {\n label = splitKey[0];\n refKey = splitKey[1];\n }\n\n const addressKey = mapFieldKeyAddress(refKey, i18n, countrySpecificLabels);\n // Also use the presence of a label to know that we are dealing with address related fields. (This matters now that addresses can contain first & last name fields.)\n if (addressKey && label) return hasSplitKey ? `${i18n.get(label)} ${addressKey}` : addressKey;\n\n switch (refKey) {\n case 'dateOfBirth':\n case 'shopperEmail':\n case 'telephoneNumber':\n return i18n.get(refKey);\n default:\n break;\n }\n\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them\n return null;\n};\n"],"names":["fieldsetsSchema","getActiveFieldsData","activeFieldsets","data","Object","keys","filter","fieldset","reduce","acc","cur","getInitialActiveFieldsets","visibility","isVisible","isDeliveryAddress","billingAddressIsHidden","billingAddress","fieldsetData","length","isPrefilled","mapFieldKey","key","i18n","countrySpecificLabels","label","refKey","splitKey","split","hasSplitKey","addressKey","mapFieldKeyAddress","get"],"mappings":"wDAKaA,EAAqD,CAC9D,iBACA,kBACA,iBACA,kBACA,eAKSC,EAAsB,CAACC,EAA6CC,IAC7EC,OAAOC,KAAKF,GACPG,QAAOC,GAAYL,EAAgBK,KACnCC,QAAO,CAACC,EAAKC,KACVD,EAAIC,GAAOP,EAAKO,GACTD,IACR,CAAI,GAEFE,EAA4B,CAACC,EAAmCT,EAA6B,CAAA,IACtGH,EAAgBQ,QAAO,CAACC,EAAKF,KACzB,MAAMM,EAAqC,WAAzBD,EAAWL,GACvBO,EAAiC,oBAAbP,EACpBQ,EAAwD,YAA/BH,aAAAA,EAAAA,EAAYI,gBAK3C,OADAP,EAAIF,GAAYM,KAAeC,GAAqBC,GAlBxC,EAACE,EAAuB,KAAgBb,OAAOC,KAAKY,GAAcC,OAAS,EAkBTC,CAAYhB,EAAKI,KACxFE,CAAAA,GACR,CAAkC,GAO5BW,EAAc,CAACC,EAAaC,EAAgBC,KACrD,IACIC,EADAC,EAASJ,EAIb,MAAMK,EAAWD,EAAOE,MAAM,KACxBC,EAAcF,EAASR,OAAS,EAClCU,IACAJ,EAAQE,EAAS,GACjBD,EAASC,EAAS,IAGtB,MAAMG,EAAaC,EAAmBL,EAAQH,EAAMC,GAEpD,GAAIM,GAAcL,EAAO,OAAOI,EAAc,GAAGN,EAAKS,IAAIP,MAAUK,IAAeA,EAEnF,OAAQJ,GACJ,IAAK,cACL,IAAK,eACL,IAAK,kBACD,OAAOH,EAAKS,IAAIN,GAMxB,OAAO,IAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport './PersonalDetails.scss';\nimport InputText from '../FormFields/InputText';\nimport RadioGroup from '../FormFields/RadioGroup';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'gender', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: PersonalDetailsProps) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const personalDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(personalDetailsRef.current).length) {\n props.setComponentRef?.(personalDetailsRef.current);\n }\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n // Expose method expected by (parent) PersonalDetails.tsx\n personalDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const eventHandler =\n (mode: string): h.JSX.GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('gender') && (\n <Field\n errorMessage={getErrorMessage(i18n, errors.gender)}\n classNameModifiers={['gender']}\n name={'gender'}\n useLabelElement={false}\n >\n <RadioGroup\n name={generateFieldName('gender')}\n value={data.gender}\n items={[\n { id: 'MALE', name: 'male' },\n { id: 'FEMALE', name: 'female' }\n ]}\n classNameModifiers={['gender']}\n onInput={eventHandler('input')}\n onChange={eventHandler('blur')}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","personalDetailsRef","useRef","Object","keys","current","length","setComponentRef","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","showValidation","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fragment","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellCheck","required","lastName","gender","useLabelElement","RadioGroup","items","id","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"utDAqBaA,EAA0B,CAAC,YAAa,WAAY,SAAU,cAAe,eAAgB,mBAE3F,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAGXC,EAAqBC,EAA4B,CAAA,GAGnDT,IAAAA,EADCU,OAAOC,KAAKH,EAAmBI,SA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AAe8C,SAAS,iBACrBL,EAACM,EAAAA,CACGlD,MAAOK,EAAK8C,IAAI,gBAChBH,mBAAoB,CAAC,gBACrBI,aAAcC,EAAgBhD,EAAMgB,EAAOkD,aAAclE,EAAK8C,IAAI,iBAClEqB,IAAK,MACLtC,KAAM,eACN7B,KAAMA,GAENuC,EAAC6B,EAAAA,CACGvC,KAAMK,EAAkB,gBACxBiB,MAAOrC,EAAKoD,aACZvB,mBAAoB,CAAC,gBACrBS,QAAS1B,EAAa,SACtB2B,OAAQ3B,EAAa,QACrB4B,YAAazD,EAAaqE,aAC1BV,UAAU,KAKrB1D,EAAe8C,SAAS,oBACrBL,EAACM,EAAAA,CACGlD,MAAOK,EAAK8C,IAAI,mBAChBH,mBAAoB,CAAC,mBACrBI,aAAcC,EAAgBhD,EAAMgB,EAAOqD,gBAAiBrE,EAAK8C,IAAI,oBACrEqB,IAAK,MACLtC,KAAM,kBACN7B,KAAMA,GAENuC,EAAC+B,EAAAA,CACGzC,KAAMK,EAAkB,mBACxBiB,MAAOrC,EAAKuD,gBACZ1B,mBAAoB,CAAC,mBACrBS,QAAS1B,EAAa,SACtB2B,OAAQ3B,EAAa,QACrB4B,YAAazD,EAAawE,gBAC1Bb,UAAU,MAOtC,CAEA/D,EAAgB8E,aAAe,CAC3BzD,KAAM,CAAC,EACPwB,SAAU,OACVzC,aAAc,CAAC,EACfC,eAAgBN,EAChB+B,gBAAiBD,EACjBvB,WAAY"}
1
+ {"version":3,"file":"PersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/PersonalDetails.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useEffect, useMemo, useRef } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport Field from '../FormFields/Field';\nimport ReadOnlyPersonalDetails from './ReadOnlyPersonalDetails';\nimport { personalDetailsValidationRules } from './validate';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { PersonalDetailsProps } from './types';\nimport { checkDateInputSupport } from '../FormFields/InputDate/utils';\nimport { PersonalDetailsSchema } from '../../../types';\nimport { getFormattedData } from './utils';\nimport useForm from '../../../utils/useForm';\nimport './PersonalDetails.scss';\nimport InputText from '../FormFields/InputText';\nimport RadioGroup from '../FormFields/RadioGroup';\nimport InputDate from '../FormFields/InputDate';\nimport InputEmail from '../FormFields/InputEmail';\nimport InputTelephone from '../FormFields/InputTelephone';\nimport { getErrorMessage } from '../../../utils/getErrorMessage';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport const PERSONAL_DETAILS_SCHEMA = ['firstName', 'lastName', 'gender', 'dateOfBirth', 'shopperEmail', 'telephoneNumber'];\n\nexport default function PersonalDetails(props: PersonalDetailsProps) {\n const { label = '', namePrefix, placeholders, requiredFields, visibility } = props;\n\n const { i18n } = useCoreContext();\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const personalDetailsRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(personalDetailsRef.current).length) {\n props.setComponentRef?.(personalDetailsRef.current);\n }\n\n const isDateInputSupported = useMemo(checkDateInputSupport, []);\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm<PersonalDetailsSchema>({\n schema: requiredFields,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...personalDetailsValidationRules, ...props.validationRules },\n defaultData: props.data\n });\n\n // Expose method expected by (parent) PersonalDetails.tsx\n personalDetailsRef.current.showValidation = () => {\n triggerValidation();\n };\n\n const eventHandler =\n (mode: string): h.JSX.GenericEventHandler<EventTarget> =>\n (e: Event): void => {\n const { name } = e.target as HTMLInputElement;\n const key = name.split(`${namePrefix}.`).pop();\n\n handleChangeFor(key, mode)(e);\n };\n\n const generateFieldName = (name: string): string => `${namePrefix ? `${namePrefix}.` : ''}${name}`;\n\n useEffect(() => {\n const formattedData = getFormattedData(data);\n props.onChange({ data: formattedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyPersonalDetails {...props} data={data} />;\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={['personalDetails']} label={label}>\n {requiredFields.includes('firstName') && (\n <Field\n label={i18n.get('firstName')}\n classNameModifiers={['col-50', 'firstName']}\n errorMessage={getErrorMessage(i18n, errors.firstName, i18n.get('firstName'))}\n name={'firstName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('firstName')}\n value={data.firstName}\n classNameModifiers={['firstName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.firstName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('lastName') && (\n <Field\n label={i18n.get('lastName')}\n classNameModifiers={['col-50', 'lastName']}\n errorMessage={getErrorMessage(i18n, errors.lastName, i18n.get('lastName'))}\n name={'lastName'}\n i18n={i18n}\n >\n <InputText\n name={generateFieldName('lastName')}\n value={data.lastName}\n classNameModifiers={['lastName']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.lastName}\n spellCheck={false}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('gender') && (\n <Field\n errorMessage={getErrorMessage(i18n, errors.gender)}\n classNameModifiers={['gender']}\n name={'gender'}\n useLabelElement={false}\n >\n <RadioGroup\n name={generateFieldName('gender')}\n value={data.gender}\n items={[\n { id: 'MALE', name: 'male' },\n { id: 'FEMALE', name: 'female' }\n ]}\n classNameModifiers={['gender']}\n onInput={eventHandler('input')}\n onChange={eventHandler('blur')}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('dateOfBirth') && (\n <Field\n label={i18n.get('dateOfBirth')}\n classNameModifiers={['col-50', 'dateOfBirth']}\n errorMessage={getErrorMessage(i18n, errors.dateOfBirth, i18n.get('dateOfBirth'))}\n helper={isDateInputSupported ? null : i18n.get('dateOfBirth.format')}\n name={'dateOfBirth'}\n i18n={i18n}\n >\n <InputDate\n name={generateFieldName('dateOfBirth')}\n value={data.dateOfBirth}\n classNameModifiers={['dateOfBirth']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.dateOfBirth}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('shopperEmail') && (\n <Field\n label={i18n.get('shopperEmail')}\n classNameModifiers={['shopperEmail']}\n errorMessage={getErrorMessage(i18n, errors.shopperEmail, i18n.get('shopperEmail'))}\n dir={'ltr'}\n name={'emailAddress'}\n i18n={i18n}\n >\n <InputEmail\n name={generateFieldName('shopperEmail')}\n value={data.shopperEmail}\n classNameModifiers={['shopperEmail']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.shopperEmail}\n required={true}\n />\n </Field>\n )}\n\n {requiredFields.includes('telephoneNumber') && (\n <Field\n label={i18n.get('telephoneNumber')}\n classNameModifiers={['telephoneNumber']}\n errorMessage={getErrorMessage(i18n, errors.telephoneNumber, i18n.get('telephoneNumber'))}\n dir={'ltr'}\n name={'telephoneNumber'}\n i18n={i18n}\n >\n <InputTelephone\n name={generateFieldName('telephoneNumber')}\n value={data.telephoneNumber}\n classNameModifiers={['telephoneNumber']}\n onInput={eventHandler('input')}\n onBlur={eventHandler('blur')}\n placeholder={placeholders.telephoneNumber}\n required={true}\n />\n </Field>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nPersonalDetails.defaultProps = {\n data: {},\n onChange: () => {},\n placeholders: {},\n requiredFields: PERSONAL_DETAILS_SCHEMA,\n validationRules: personalDetailsValidationRules,\n visibility: 'editable'\n};\n"],"names":["PERSONAL_DETAILS_SCHEMA","PersonalDetails","props","label","namePrefix","placeholders","requiredFields","visibility","i18n","useCoreContext","personalDetailsRef","useRef","Object","keys","current","length","setComponentRef","isDateInputSupported","useMemo","checkDateInputSupport","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","schema","rules","_object_spread","personalDetailsValidationRules","validationRules","defaultData","showValidation","eventHandler","mode","e","name","target","key","split","pop","generateFieldName","useEffect","formattedData","getFormattedData","onChange","h","ReadOnlyPersonalDetails","Fragment","Fieldset","classNameModifiers","includes","Field","get","errorMessage","getErrorMessage","firstName","InputText","value","onInput","onBlur","placeholder","spellCheck","required","lastName","gender","useLabelElement","RadioGroup","items","id","dateOfBirth","helper","InputDate","shopperEmail","dir","InputEmail","telephoneNumber","InputTelephone","defaultProps"],"mappings":"utDAqBaA,EAA0B,CAAC,YAAa,WAAY,SAAU,cAAe,eAAgB,mBAE3F,SAASC,EAAgBC,GACpC,MAAMC,MAAEA,EAAQ,GAAEC,WAAEA,EAAUC,aAAEA,EAAYC,eAAEA,EAAcC,WAAEA,GAAeL,GAEvEM,KAAEA,GAASC,IAGXC,EAAqBC,EAA4B,IAGnDT,IAAAA,EADCU,OAAOC,KAAKH,EAAmBI,SAASC,SACpB,QAArBb,EAAAA,EAAMc,2BAANd,GAAAA,EAAAA,KAAAA,EAAwBQ,EAAmBI,UAG/C,MAAMG,EAAuBC,EAAQC,EAAuB,KACtDC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAA+B,CACxGC,OAAQrB,EAERsB,MAAOC,EAAA,CAAA,EAAKC,EAAmC5B,EAAM6B,iBACrDC,YAAa9B,EAAMoB,OAIvBZ,EAAmBI,QAAQmB,eAAiB,KACxCZ,GAAAA,EAGJ,MAAMa,EACDC,GACAC,IACG,MAAMC,KAAEA,GAASD,EAAEE,OACbC,EAAMF,EAAKG,MAAM,GAAGpC,MAAeqC,MAEzCrB,EAAgBmB,EAAKJ,EAArBf,CAA2BgB,EAAAA,EAG7BM,EAAqBL,GAAyB,GAAGjC,EAAa,GAAGA,KAAgB,KAAKiC,IAO5F,OALAM,GAAU,KACN,MAAMC,EAAgBC,EAAiBvB,GACvCpB,EAAM4C,SAAS,CAAExB,KAAMsB,EAAerB,QAAOC,SAAQC,WAAQ,GAC9D,CAACH,EAAMC,EAAOC,EAAQC,IAEN,WAAflB,EAAgC,KACjB,aAAfA,EAAkCw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CAEA/D,EAAgB8E,aAAe,CAC3BzD,KAAM,CAAC,EACPwB,SAAU,OACVzC,aAAc,CAAC,EACfC,eAAgBN,EAChB+B,gBAAiBD,EACjBvB,WAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyPersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/ReadOnlyPersonalDetails.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Fieldset from '../FormFields/Fieldset';\nimport { ReadOnlyPersonalDetailsProps } from './types';\n\nconst ReadOnlyPersonalDetails = ({ data }) => {\n const { firstName, lastName, shopperEmail, telephoneNumber }: ReadOnlyPersonalDetailsProps = data;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label=\"personalDetails\" readonly>\n {firstName && `${firstName} `}\n {lastName && `${lastName} `}\n {shopperEmail && (\n <Fragment>\n <br />\n {shopperEmail}\n </Fragment>\n )}\n {telephoneNumber && (\n <Fragment>\n <br />\n {telephoneNumber}\n </Fragment>\n )}\n </Fieldset>\n );\n};\n\nexport default ReadOnlyPersonalDetails;\n"],"names":["ReadOnlyPersonalDetails","data","firstName","lastName","shopperEmail","telephoneNumber","h","Fieldset","classNameModifiers","label","readonly","Fragment","br"],"mappings":"wIAIA,MAAMA,EAA0B,EAAGC,WAC/B,MAAMC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,EAAYC,gBAAEA,GAAkDJ,EAE7F,OACIK,EAACC,EAAAA,CAASC,mBAAoB,CAAC,mBAAoBC,MAAM,kBAAkBC,UAAAA,GACtER,GAAa,GAAGA,KAChBC,GAAY,GAAGA,KACfC,GACGE,EAACK,EAAAA,KACGL,EAACM,KAAAA,MACAR,GAGRC,GACGC,EAACK,EACG,KAAAL,EAACM,KACAP,MAAAA,GAAAA"}
1
+ {"version":3,"file":"ReadOnlyPersonalDetails.js","sources":["../../../../../src/components/internal/PersonalDetails/ReadOnlyPersonalDetails.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport Fieldset from '../FormFields/Fieldset';\nimport { ReadOnlyPersonalDetailsProps } from './types';\n\nconst ReadOnlyPersonalDetails = ({ data }) => {\n const { firstName, lastName, shopperEmail, telephoneNumber }: ReadOnlyPersonalDetailsProps = data;\n\n return (\n <Fieldset classNameModifiers={['personalDetails']} label=\"personalDetails\" readonly>\n {firstName && `${firstName} `}\n {lastName && `${lastName} `}\n {shopperEmail && (\n <Fragment>\n <br />\n {shopperEmail}\n </Fragment>\n )}\n {telephoneNumber && (\n <Fragment>\n <br />\n {telephoneNumber}\n </Fragment>\n )}\n </Fieldset>\n );\n};\n\nexport default ReadOnlyPersonalDetails;\n"],"names":["ReadOnlyPersonalDetails","data","firstName","lastName","shopperEmail","telephoneNumber","h","Fieldset","classNameModifiers","label","readonly","Fragment","br"],"mappings":"wIAIA,MAAMA,EAA0B,EAAGC,WAC/B,MAAMC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,EAAYC,gBAAEA,GAAkDJ,EAE7F,OACIK,EAACC,EAAAA,CAASC,mBAAoB,CAAC,mBAAoBC,MAAM,kBAAkBC,UAAAA,GACtER,GAAa,GAAGA,KAChBC,GAAY,GAAGA,KACfC,GACGE,EAACK,OACGL,EAACM,KAAAA,MACAR,GAGRC,GACGC,EAACK,EACG,KAAAL,EAACM,KACAP,MAAAA,GAAAA"}
@@ -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 i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}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";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}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)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}barcode.shtml?barcodeType=qrCode&fileType=png&data=${this.props.qrCodeData}`:this.props.qrCodeImage,E=(t,o)=>{const r=I.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:S({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(v)return E("error","error.subtitle.payment");if(q)return E("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=I.get(this.props.timeToPay).split("%@"),D=u(),A=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${f} ${A.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},I.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"},I.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:I.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?I.get(this.props.introduction):null===(C=(N=this.props).introduction)||void 0===C?void 0:C.call(N)),e("img",{src:x,alt:I.get("wechatpay.scanqrcode"),onLoad:()=>{null==k||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"},P[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?I.get(this.props.instructions):null===(w=(T=this.props).instructions)||void 0===w?void 0:w.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData),this.props.onSubmitAnalytics({type:h,target:_}),e()},icon:S({imageFolder:"components/"})(`${y}copy`),label:I.get("button.copy")})))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",(t=>{window.location.assign(t)})),g(this,"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)})),g(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),g(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),g(this,"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)})),g(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)})),g(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).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}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(f,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{f 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 i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}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";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}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)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,E=(t,o)=>{const r=I.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:S({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(v)return E("error","error.subtitle.payment");if(q)return E("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=I.get(this.props.timeToPay).split("%@"),D=u(),A=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${f} ${A.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},I.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"},I.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:I.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?I.get(this.props.introduction):null===(C=(N=this.props).introduction)||void 0===C?void 0:C.call(N)),e("img",{src:x,alt:I.get("wechatpay.scanqrcode"),onLoad:()=>{null==k||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"},P[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?I.get(this.props.instructions):null===(w=(T=this.props).instructions)||void 0===w?void 0:w.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData),this.props.onSubmitAnalytics({type:h,target:_}),e()},icon:S({imageFolder:"components/"})(`${y}copy`),label:I.get("button.copy")})))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",(t=>{window.location.assign(t)})),g(this,"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)})),g(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),g(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),g(this,"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)})),g(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)})),g(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).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}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(f,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{f 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';\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\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\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\">{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 && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\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 {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\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 {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\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","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","clientKey","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mgCAsBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH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AEAP,EAjBE3G,EAiBYsI,eAAe,CACzB7H,MAAO,IACPe,cAAe,GACf+F,QAAS,OACTE,WAAY,OACZL,aAAc,IACdtD,mBAAoB,GACpBuD,kBAAmB,IACnBxC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
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 = 'utility/v1/barcode.png?type=qrCode&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\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\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\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\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\">{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 && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\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 {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\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 {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\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","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mgCAsBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH,YAAYC,MACxBX,KAAKC,eAAea,KAAKC,MAAMF,EAAMJ,GAAAA,GACtCH,EACP,CAiEAU,MAAAA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAIC,gBAAEA,IAAkCC,QAAEA,EAAOC,UAAEA,EAASC,QAAEA,IAyEtB,IAAAC,EAAAC,EA0BI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Fields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,m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,MACjDA,KAAKoB,uBAAyBwI,EAASxI,uBAAuByI,KAAK7J,MACnEA,KAAK6D,qBAAuB+F,EAAS/F,qBAAqBgG,KAAK7J,MAC/DA,KAAKiE,sBAAwB2F,EAAS3F,sBAAsB4F,KAAK7J,MACjEA,KAAKmE,iBAAmByF,EAASzF,iBAAiB0F,KAAK7J,MAEvDA,KAAKwI,yBAA2BxI,KAAKwI,yBAAyBqB,KAAK7J,MAGnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
1
+ {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eAiDd,IAAAC,EArClB,MAAMC,EAA8B,CAChC7B,SAAU0B,EACVI,KAAMhC,KAAKC,MAAM+B,KACjBC,UAAWjC,KAAKC,MAAMgC,UACtBC,eAAgBlC,KAAKC,MAAMkC,OAC3BC,UAAWpC,KAAKC,MAAMmC,UACtBC,sBAAuBrC,KAAKC,MAAMoC,sBAClCR,iBACAS,UAAWtC,KAAKC,MAAMqC,UACtBC,aAAcvC,KAAKC,MAAMsC,aACzBC,eAAgB,CACZC,SAAUzC,KAAKC,MAAMyC,QAEzBC,KAAM3C,KAAKC,MAAM0C,KACjBC,UAAW,CACPC,OAAQ7C,KAAK8C,aACbC,gBAAiB/C,KAAKgD,sBACtBC,aAAcjD,KAAKkD,mBACnBC,WAAYnD,KAAKoD,iBACjBC,QAASrD,KAAKsD,cACdC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KqE,MAAQkF,EAEbvJ,KAAK0B,mBAAqB,KAC1B1B,KAAKqF,qBAAuB,IAE5BrF,KAAK2B,qBAAuB,KAC5B3B,KAAKqJ,uBAAyB,KAE9BrJ,KAAKY,gBAAkB,CAAC,EAGxBZ,KAAK8C,aAAe8G,EAAS9G,aAAa+G,KAAK7J,MAC/CA,KAAKgD,sBAAwB4G,EAAS5G,sBAAsB6G,KAAK7J,MACjEA,KAAKkD,mBAAqB0G,EAAS1G,mBAAmB2G,KAAK7J,MAC3DA,KAAKoD,iBAAmBwG,EAASxG,iBAAiByG,KAAK7J,MACvDA,KAAKsD,cAAgBsG,EAAStG,cAAcuG,KAAK7J,MACjDA,KAAK0D,YAAckG,EAASlG,YAAYmG,KAAK7J,MAC7CA,KAAKwD,cAAgBoG,EAASpG,cAAcqG,KAAK7J,MACjDA,KAAKoB,uBAAyBwI,EAASxI,uBAAuByI,KAAK7J,MACnEA,KAAK6D,qBAAuB+F,EAAS/F,qBAAqBgG,KAAK7J,MAC/DA,KAAKiE,sBAAwB2F,EAAS3F,sBAAsB4F,KAAK7J,MACjEA,KAAKmE,iBAAmByF,EAASzF,iBAAiB0F,KAAK7J,MAEvDA,KAAKwI,yBAA2BxI,KAAKwI,yBAAyBqB,KAAK7J,MAGnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CbObjOnLoad): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CbObjOnConfigSuccess): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CbObjOnAllValid): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CbObjOnFieldValid): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? false }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CbObjOnBrand): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CbObjOnError, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || false },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CbObjOnFocus): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CbObjOnAutoComplete): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyPressed(obj: SFKeyPressObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keypress', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyPress?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyPressed\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","_object_spread_props","_object_spread","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","_this_props_brandsConfiguration_cardInfo_brand","_this_props_brandsConfiguration_cardInfo_brand_icon","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS","_this_props_disableIOSArrowKeys","_this_props","disableIOSArrowKeys","call","handleKeyPressed","obj","action","_this_props_handleKeyPress","kb","KeyboardEvent","bubbles","cancelable","key","code","handleKeyPress"],"mappings":"4sCA0HA,SAASA,EAAeC,EAAmBC,EAAgBC,EAAqBC,GAC5E,OAAQF,IAAWG,GAAYH,IAAWI,GAAsC,IAA3BH,EAAYF,KAA2BG,EAAUH,EAC1G,CAwHA,IAAeM,EAAA,CACXC,YAzCJ,SAAqBC,GACjBC,KAA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IC,cAAc,WAAY,CACrCC,SAAS,EACTC,YAAY,EACZC,IAAK,QACLC,KAAM,UAEe,QAAzBN,GAAAN,EAAA5E,KAAKG,OAAMsF,sBAAX,IAAAP,GAAAA,EAAAJ,KAAAF,EAA4BO,EAChC,CACJ"}
1
+ {"version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CardLoadData): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CardConfigSuccessData): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CardAllValidData): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CardFieldValidData): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? false }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CardBrandData): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CardErrorData, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || false },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CardFocusData): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CardAutoCompleteData): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyPressed(obj: SFKeyPressObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keypress', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyPress?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyPressed\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","_object_spread_props","_object_spread","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","_this_props_brandsConfiguration_cardInfo_brand","_this_props_brandsConfiguration_cardInfo_brand_icon","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS","_this_props_disableIOSArrowKeys","_this_props","disableIOSArrowKeys","call","handleKeyPressed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AAY,KAC/E,EAYIgE,sBA5CJ,SAA+B3E,OAE3B4E,EAAAC,EAA8B,QAA9BD,GAAAC,EAAA5E,KAAKG,OAAM0E,2BAAX,IAAAF,GAAAA,EAAAG,KAAAF,EAAiC7E,EACrC,EA0CIgF,iBA/BJ,SAA0BC,GACtB,GAAmB,oBAAfA,EAAIC,OAA8B,KAOlCC,EAAAN,EANA,MAAMO,EAAK,IAAIC,cAAc,WAAY,CACrCC,SAAS,EACTC,YAAY,EACZC,IAAK,QACLC,KAAM,UAEe,QAAzBN,GAAAN,EAAA5E,KAAKG,OAAMsF,sBAAX,IAAAP,GAAAA,EAAAJ,KAAAF,EAA4BO,EAChC,CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyPress: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyPress","styles"],"mappings":"AAAA,IAAeA,EAAA,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,eAAgB,OAGhBC,OAAQ,CAAC"}
1
+ {"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyPress: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyPress","styles"],"mappings":"AAAA,IAAeA,EAAA,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,eAAgB,OAGhBC,OAAQ,CAAA"}