@adyen/adyen-web 6.45.1 → 6.46.0-alpha.7c7199d

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 (344) hide show
  1. package/dist/cjs/adyen.css +7 -7
  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 +136 -71
  6. package/dist/es/adyen.css +7 -7
  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/ANCV/components/ANCVInput.js +1 -1
  11. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  12. package/dist/es/components/Ach/Ach.js +1 -1
  13. package/dist/es/components/Ach/Ach.js.map +1 -1
  14. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  15. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  16. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  17. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  18. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  19. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  20. package/dist/es/components/BacsDD/BacsDD.js +1 -1
  21. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  22. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  23. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  24. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  25. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  26. package/dist/es/components/Blik/Blik.js +1 -1
  27. package/dist/es/components/Blik/Blik.js.map +1 -1
  28. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  29. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  30. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  31. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  32. package/dist/es/components/Card/Card.js +1 -1
  33. package/dist/es/components/Card/Card.js.map +1 -1
  34. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  35. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  36. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  37. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  38. package/dist/es/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js +1 -1
  39. package/dist/es/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js.map +1 -1
  40. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  41. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  42. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  43. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  44. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  45. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  46. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  47. package/dist/es/components/Doku/components/DokuInput/DokuInput.js +1 -1
  48. package/dist/es/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
  49. package/dist/es/components/Dragonpay/Dragonpay.js +1 -1
  50. package/dist/es/components/Dragonpay/Dragonpay.js.map +1 -1
  51. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  52. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  53. package/dist/es/components/Dropin/Dropin.js +1 -1
  54. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  55. package/dist/es/components/Econtext/Econtext.js +1 -1
  56. package/dist/es/components/Econtext/Econtext.js.map +1 -1
  57. package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
  58. package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  59. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  60. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  61. package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
  62. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  63. package/dist/es/components/Giftcard/components/GiftcardResult.js +1 -1
  64. package/dist/es/components/Giftcard/components/GiftcardResult.js.map +1 -1
  65. package/dist/es/components/Giropay/Giropay.js +1 -1
  66. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  67. package/dist/es/components/Iris/Iris.js +1 -1
  68. package/dist/es/components/Iris/Iris.js.map +1 -1
  69. package/dist/es/components/Iris/components/IrisComponent.js +1 -1
  70. package/dist/es/components/Iris/components/IrisComponent.js.map +1 -1
  71. package/dist/es/components/Iris/components/IrisGenerateQRCode.js +1 -1
  72. package/dist/es/components/Iris/components/IrisGenerateQRCode.js.map +1 -1
  73. package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
  74. package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
  75. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  76. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  77. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  78. package/dist/es/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  79. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  80. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  81. package/dist/es/components/Oxxo/Oxxo.js +1 -1
  82. package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
  83. package/dist/es/components/PayByBankPix/PayByBankPix.js +1 -1
  84. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -1
  85. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  86. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  87. package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
  88. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  89. package/dist/es/components/PayPal/Paypal.js +1 -1
  90. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  91. package/dist/es/components/PayPalFastlane/Fastlane.js +1 -1
  92. package/dist/es/components/PayPalFastlane/Fastlane.js.map +1 -1
  93. package/dist/es/components/PayPalFastlane/components/FastlaneComponent.js +1 -1
  94. package/dist/es/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -1
  95. package/dist/es/components/PayTo/PayTo.js +1 -1
  96. package/dist/es/components/PayTo/PayTo.js.map +1 -1
  97. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  98. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  99. package/dist/es/components/Pix/Pix.js +1 -1
  100. package/dist/es/components/Pix/Pix.js.map +1 -1
  101. package/dist/es/components/Pix/components/PixInput/PixInput.js +1 -1
  102. package/dist/es/components/Pix/components/PixInput/PixInput.js.map +1 -1
  103. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  104. package/dist/es/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  105. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  106. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  107. package/dist/es/components/Redirect/Redirect.js +1 -1
  108. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  109. package/dist/es/components/Trustly/Trustly.js +1 -1
  110. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  111. package/dist/es/components/UPI/UPI.js +1 -1
  112. package/dist/es/components/UPI/UPI.js.map +1 -1
  113. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  114. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  115. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  116. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  117. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  118. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  119. package/dist/es/components/internal/Address/components/CountryField.js.map +1 -1
  120. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  121. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  122. package/dist/es/components/internal/Address/components/StateField.js.map +1 -1
  123. package/dist/es/components/internal/Address/constants.js +1 -1
  124. package/dist/es/components/internal/Address/constants.js.map +1 -1
  125. package/dist/es/components/internal/Address/validate.formats.js +1 -1
  126. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  127. package/dist/es/components/internal/Address/validate.js +1 -1
  128. package/dist/es/components/internal/Address/validate.js.map +1 -1
  129. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  130. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  131. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  132. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  133. package/dist/es/components/internal/DisclaimerMessage/utils.js +2 -0
  134. package/dist/es/components/internal/DisclaimerMessage/utils.js.map +1 -0
  135. package/dist/es/components/internal/FormFields/utils.js +1 -1
  136. package/dist/es/components/internal/FormFields/utils.js.map +1 -1
  137. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  138. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  139. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  140. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  141. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  142. package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  143. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  144. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  145. package/dist/es/components/internal/PayButton/PayButton.js +1 -1
  146. package/dist/es/components/internal/PayButton/PayButton.js.map +1 -1
  147. package/dist/es/components/internal/PhoneInput/usePhonePrefixes.js.map +1 -1
  148. package/dist/es/components/internal/RedirectButton/RedirectButton.js +1 -1
  149. package/dist/es/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  150. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  151. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  152. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  153. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  154. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  155. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  156. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  157. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  158. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  159. package/dist/es/core/Errors/SRPanelProvider.js.map +1 -1
  160. package/dist/es/core/RiskModule/RiskModule.js +1 -1
  161. package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
  162. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  163. package/dist/es/core/Services/get-dataset.js.map +1 -1
  164. package/dist/es/core/Services/http.js +1 -1
  165. package/dist/es/core/Services/http.js.map +1 -1
  166. package/dist/es/core/config.js +1 -1
  167. package/dist/es/core/config.js.map +1 -1
  168. package/dist/es/core/core.js.map +1 -1
  169. package/dist/es/core/core.registry.js +1 -1
  170. package/dist/es/core/core.registry.js.map +1 -1
  171. package/dist/es/core/utils.js +1 -1
  172. package/dist/es/core/utils.js.map +1 -1
  173. package/dist/es/index.d.ts +136 -71
  174. package/dist/es/packages/server/translations/en-US.json.js +1 -1
  175. package/dist/es-legacy/adyen.css +7 -7
  176. package/dist/es-legacy/adyen.css.map +1 -1
  177. package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
  178. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  179. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  180. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  181. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  182. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  183. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  184. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  185. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
  186. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  187. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  188. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  189. package/dist/es-legacy/components/BacsDD/BacsDD.js +1 -1
  190. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  191. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  192. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  193. package/dist/es-legacy/components/BankTransfer/BankTransfer.js +1 -1
  194. package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
  195. package/dist/es-legacy/components/Blik/Blik.js +1 -1
  196. package/dist/es-legacy/components/Blik/Blik.js.map +1 -1
  197. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  198. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  199. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  200. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  201. package/dist/es-legacy/components/Card/Card.js +1 -1
  202. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  203. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  204. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  205. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  206. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  207. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js +1 -1
  208. package/dist/es-legacy/components/Card/components/CardInput/components/StoredCardFieldsWrapper.js.map +1 -1
  209. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  210. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  211. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  212. package/dist/es-legacy/components/CashAppPay/CashAppPay.js +1 -1
  213. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  214. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  215. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  216. package/dist/es-legacy/components/Doku/components/DokuInput/DokuInput.js +1 -1
  217. package/dist/es-legacy/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
  218. package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
  219. package/dist/es-legacy/components/Dragonpay/Dragonpay.js.map +1 -1
  220. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  221. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  222. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  223. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  224. package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
  225. package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
  226. package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
  227. package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  228. package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
  229. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  230. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  231. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  232. package/dist/es-legacy/components/Giftcard/components/GiftcardResult.js +1 -1
  233. package/dist/es-legacy/components/Giftcard/components/GiftcardResult.js.map +1 -1
  234. package/dist/es-legacy/components/Giropay/Giropay.js +1 -1
  235. package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
  236. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  237. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  238. package/dist/es-legacy/components/Iris/components/IrisComponent.js +1 -1
  239. package/dist/es-legacy/components/Iris/components/IrisComponent.js.map +1 -1
  240. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js +1 -1
  241. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js.map +1 -1
  242. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  243. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  244. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  245. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  246. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js +1 -1
  247. package/dist/es-legacy/components/MBWay/components/MBWayInput/MBWayInput.js.map +1 -1
  248. package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
  249. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  250. package/dist/es-legacy/components/Oxxo/Oxxo.js +1 -1
  251. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  252. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  253. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  254. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  255. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  256. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js +1 -1
  257. package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
  258. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  259. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  260. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js +1 -1
  261. package/dist/es-legacy/components/PayPalFastlane/Fastlane.js.map +1 -1
  262. package/dist/es-legacy/components/PayPalFastlane/components/FastlaneComponent.js +1 -1
  263. package/dist/es-legacy/components/PayPalFastlane/components/FastlaneComponent.js.map +1 -1
  264. package/dist/es-legacy/components/PayTo/PayTo.js +1 -1
  265. package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
  266. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  267. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  268. package/dist/es-legacy/components/Pix/Pix.js +1 -1
  269. package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
  270. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js +1 -1
  271. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js.map +1 -1
  272. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  273. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  274. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  275. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  276. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  277. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  278. package/dist/es-legacy/components/Trustly/Trustly.js +1 -1
  279. package/dist/es-legacy/components/Trustly/Trustly.js.map +1 -1
  280. package/dist/es-legacy/components/UPI/UPI.js +1 -1
  281. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  282. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  283. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  284. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  285. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  286. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  287. package/dist/es-legacy/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  288. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  289. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  290. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  291. package/dist/es-legacy/components/internal/Address/components/StateField.js.map +1 -1
  292. package/dist/es-legacy/components/internal/Address/constants.js +1 -1
  293. package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
  294. package/dist/es-legacy/components/internal/Address/validate.formats.js +1 -1
  295. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  296. package/dist/es-legacy/components/internal/Address/validate.js +1 -1
  297. package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
  298. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  299. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  300. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  301. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  302. package/dist/es-legacy/components/internal/DisclaimerMessage/utils.js +2 -0
  303. package/dist/es-legacy/components/internal/DisclaimerMessage/utils.js.map +1 -0
  304. package/dist/es-legacy/components/internal/FormFields/utils.js +1 -1
  305. package/dist/es-legacy/components/internal/FormFields/utils.js.map +1 -1
  306. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js +1 -1
  307. package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
  308. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  309. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  310. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  311. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  312. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  313. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  314. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  315. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  316. package/dist/es-legacy/components/internal/PhoneInput/usePhonePrefixes.js.map +1 -1
  317. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  318. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  319. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  320. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  321. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  322. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  323. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  324. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  325. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  326. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  327. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  328. package/dist/es-legacy/core/Errors/SRPanelProvider.js.map +1 -1
  329. package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
  330. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  331. package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  332. package/dist/es-legacy/core/Services/get-dataset.js.map +1 -1
  333. package/dist/es-legacy/core/Services/http.js +1 -1
  334. package/dist/es-legacy/core/Services/http.js.map +1 -1
  335. package/dist/es-legacy/core/config.js +1 -1
  336. package/dist/es-legacy/core/config.js.map +1 -1
  337. package/dist/es-legacy/core/core.js.map +1 -1
  338. package/dist/es-legacy/core/core.registry.js +1 -1
  339. package/dist/es-legacy/core/core.registry.js.map +1 -1
  340. package/dist/es-legacy/core/utils.js +1 -1
  341. package/dist/es-legacy/core/utils.js.map +1 -1
  342. package/dist/es-legacy/packages/server/translations/en-US.json.js +1 -1
  343. package/package.json +11 -11
  344. package/styles/adyen.css +7 -7
@@ -1,2 +1,2 @@
1
- import{countrySpecificFormatters as t}from"./validate.formats.js";import{ERROR_FIELD_REQUIRED as r,ERROR_INVALID_CHARACTERS as e,ERROR_INVALID_FORMAT_EXPECTS as a}from"../../../core/Errors/constants.js";import{isEmpty as n,validateForSpecialChars as s}from"../../../utils/validator-utils.js";const o=t=>({pattern:new RegExp(`\\d{${t}}`)}),d=(r,e,s)=>{if(e){if(n(r))return null;s.postalCode.errorMessage={translationKey:a,translationObject:{values:{format:t[e]?.postalCode.format||null}}};const o=l[e]?.pattern;return o?o.test(r):!!r}return!n(r)||null},l={AT:o(4),AU:o(4),BE:{pattern:/(?:(?:[1-9])(?:\d{3}))/},BG:o(4),BR:{pattern:/^\d{5}-?\d{3}$/},CA:{pattern:/(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/},CH:{pattern:/[1-9]\d{3}/},CY:o(4),CZ:{pattern:/\d{3}\s?\d{2}/},DE:o(5),DK:o(4),EE:o(5),ES:{pattern:/(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/},FI:o(5),FR:o(5),GB:{pattern:/^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/},GE:o(4),GR:{pattern:/^\d{3}\s{0,1}\d{2}$/},HR:{pattern:/^([1-5])[0-9]{4}$/},HU:o(4),IE:{pattern:/(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/},IS:o(3),IT:o(5),LI:o(4),LT:{pattern:/^(LT-\d{5}|\d{4,5})$/},LU:o(4),LV:{pattern:/^(LV-)[0-9]{4}$/},MC:{pattern:/^980\d{2}$/},MT:{pattern:/^[A-Za-z]{3}\d{4}$/},MY:o(5),NL:{pattern:/(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/},NO:o(4),PL:{pattern:/^\d{2}[-]{0,1}\d{3}$/},PT:{pattern:/^([1-9]\d{3})([- ]?(\d{3})? *)$/},RO:o(6),SI:o(4),SE:o(5),SG:o(6),SK:o(5),US:{pattern:/^\d{5}(?:-\d{4})?$/}},p=t=>{const e={postalCode:{modes:["blur"],validate:r=>d(r,t,e),errorMessage:r}};return e},u={modes:["blur"],validate:t=>!n(t)||null,errorMessage:r},i={modes:["blur"],validate:t=>s(t),errorMessage:e},m=t=>{const e={postalCode:{modes:["blur"],validate:(t,r)=>{const a=r.state.data.country;return d(t,a,e)},errorMessage:r},street:[u,i],houseNumberOrName:[{validate:(r,e)=>{const a=e.state?.data?.country;return a&&t.countryHasOptionalField(a,"houseNumberOrName")||!n(r)||null},modes:["blur"],errorMessage:r},i],city:[u,i],default:u};return e};export{m as getAddressValidationRules,p as getPartialAddressValidationRules,d as validatePostalCode};
1
+ import{countrySpecificFormatters as t}from"./validate.formats.js";import{ERROR_FIELD_REQUIRED as r,ERROR_INVALID_CHARACTERS as e,ERROR_INVALID_FORMAT_EXPECTS as a}from"../../../core/Errors/constants.js";import{isEmpty as n,validateForSpecialChars as s}from"../../../utils/validator-utils.js";const d=t=>({pattern:new RegExp(`\\d{${t}}`)}),o=(r,e,s)=>{if(e){if(n(r))return null;s.postalCode.errorMessage={translationKey:a,translationObject:{values:{format:t[e]?.postalCode.format||null}}};const d=l[e]?.pattern;return d?d.test(r):!!r}return!n(r)||null},l={AT:d(4),AU:d(4),BE:{pattern:/(?:(?:[1-9])(?:\d{3}))/},BG:d(4),BR:{pattern:/^\d{5}-?\d{3}$/},CA:{pattern:/(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/},CH:{pattern:/[1-9]\d{3}/},CY:d(4),CZ:{pattern:/\d{3}\s?\d{2}/},DE:d(5),DK:d(4),EE:d(5),ES:{pattern:/(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/},FI:d(5),FR:d(5),GB:{pattern:/^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/},GE:d(4),GR:{pattern:/^\d{3}\s{0,1}\d{2}$/},HR:{pattern:/^([1-5])[0-9]{4}$/},HU:d(4),IE:{pattern:/(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/},IS:d(3),IT:d(5),JP:{pattern:/^\d{3}-?\d{4}$/},LI:d(4),LT:{pattern:/^(LT-\d{5}|\d{4,5})$/},LU:d(4),LV:{pattern:/^(LV-)[0-9]{4}$/},MC:{pattern:/^980\d{2}$/},MT:{pattern:/^[A-Za-z]{3}\d{4}$/},MY:d(5),NL:{pattern:/(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/},NO:d(4),PL:{pattern:/^\d{2}[-]{0,1}\d{3}$/},PT:{pattern:/^([1-9]\d{3})([- ]?(\d{3})? *)$/},RO:d(6),SI:d(4),SE:d(5),SG:d(6),SK:d(5),US:{pattern:/^\d{5}(?:-\d{4})?$/}},p=t=>{const e={postalCode:{modes:["blur"],validate:r=>o(r,t,e),errorMessage:r}};return e},u={modes:["blur"],validate:t=>!n(t)||null,errorMessage:r},i={modes:["blur"],validate:t=>s(t),errorMessage:e},m=t=>{const e={postalCode:{modes:["blur"],validate:(t,r)=>{const a=r.state.data.country;return o(t,a,e)},errorMessage:r},street:[u,i],houseNumberOrName:[{validate:(r,e)=>{const a=e.state?.data?.country;return a&&t.countryHasOptionalField(a,"houseNumberOrName")||!n(r)||null},modes:["blur"],errorMessage:r},i],city:[u,i],default:u};return e};export{m as getAddressValidationRules,p as getPartialAddressValidationRules,o as validatePostalCode};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS, ERROR_INVALID_CHARACTERS } from '../../../core/Errors/constants';\nimport { isEmpty, validateForSpecialChars } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string | null, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string | null): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nconst ruleIsEmpty: ValidatorRule = {\n modes: ['blur'],\n validate: value => (isEmpty(value) ? null : true),\n errorMessage: ERROR_FIELD_REQUIRED\n};\n\nconst ruleValidateForSpecialChars: ValidatorRule = {\n modes: ['blur'],\n validate: value => validateForSpecialChars(value),\n errorMessage: ERROR_INVALID_CHARACTERS\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n street: [\n ruleIsEmpty,\n ruleValidateForSpecialChars\n ],\n houseNumberOrName: [\n {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n ruleValidateForSpecialChars\n ],\n city: [\n ruleIsEmpty,\n ruleValidateForSpecialChars\n ],\n default: ruleIsEmpty\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","ruleIsEmpty","value","ruleValidateForSpecialChars","validateForSpecialChars","ERROR_INVALID_CHARACTERS","getAddressValidationRules","specifications","addressValidationRules","context","state","data","street","houseNumberOrName","selectedCountry","countryHasOptionalField","city","default"],"mappings":"oSAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,EAA4BC,KACxE,GAAID,EAAa,CAEb,GAAIE,EAAQH,GAAM,OAAO,KAGxBE,EAAeE,WAA6BC,aAAe,CACxDC,eAAgBC,EAChBC,kBAAmB,CACfC,OAAQ,CACJC,OAAQC,EAA0BV,IAAcG,WAAWM,QAAU,QAKjF,MAAMb,EAAUe,EAAmBX,IAAcJ,QACjD,OAAOA,EAAUA,EAAQgB,KAAKb,KAASA,CAC3C,CAEA,OAAOG,EAAQH,IAAO,MAGpBY,EAAqB,CACvBE,GAAInB,EAAsB,GAC1BoB,GAAIpB,EAAsB,GAC1BqB,GAAI,CAAEnB,QAAS,0BACfoB,GAAItB,EAAsB,GAC1BuB,GAAI,CAAErB,QAAS,kBACfsB,GAAI,CAAEtB,QAAS,+CACfuB,GAAI,CAAEvB,QAAS,cACfwB,GAAI1B,EAAsB,GAC1B2B,GAAI,CAAEzB,QAAS,iBACf0B,GAAI5B,EAAsB,GAC1B6B,GAAI7B,EAAsB,GAC1B8B,GAAI9B,EAAsB,GAC1B+B,GAAI,CAAE7B,QAAS,kCACf8B,GAAIhC,EAAsB,GAC1BiC,GAAIjC,EAAsB,GAC1BkC,GAAI,CAAEhC,QAAS,yFACfiC,GAAInC,EAAsB,GAC1BoC,GAAI,CAAElC,QAAS,uBACfmC,GAAI,CAAE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BD,EAAiB,uBACxEtE,EAAQ0D,IAAS,MAE3CJ,MAAO,CAAC,QACRpD,aAAcsD,GAElBG,GAEJa,KAAM,CACFf,EACAE,GAEJc,QAAShB,GAEb,OAAOO"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../src/components/internal/Address/validate.ts"],"sourcesContent":["import { ValidatorRules, ValidatorRule } from '../../../utils/Validator/types';\nimport { countrySpecificFormatters } from './validate.formats';\nimport { ERROR_FIELD_REQUIRED, ERROR_INVALID_FORMAT_EXPECTS, ERROR_INVALID_CHARACTERS } from '../../../core/Errors/constants';\nimport { isEmpty, validateForSpecialChars } from '../../../utils/validator-utils';\n\nconst createPatternByDigits = (digits: number) => {\n return {\n pattern: new RegExp(`\\\\d{${digits}}`)\n };\n};\n\nexport const validatePostalCode = (val: string, countryCode: string | null, validatorRules: ValidatorRules) => {\n if (countryCode) {\n // If there is no value, we display the 'required' error message\n if (isEmpty(val)) return null;\n\n // Dynamically create errorMessage\n (validatorRules.postalCode as ValidatorRule).errorMessage = {\n translationKey: ERROR_INVALID_FORMAT_EXPECTS,\n translationObject: {\n values: {\n format: countrySpecificFormatters[countryCode]?.postalCode.format || null\n }\n }\n };\n\n const pattern = postalCodePatterns[countryCode]?.pattern;\n return pattern ? pattern.test(val) : !!val; // No pattern? Accept any, filled, value.\n }\n // Default rule\n return isEmpty(val) ? null : true;\n};\n\nconst postalCodePatterns = {\n AT: createPatternByDigits(4),\n AU: createPatternByDigits(4),\n BE: { pattern: /(?:(?:[1-9])(?:\\d{3}))/ },\n BG: createPatternByDigits(4),\n BR: { pattern: /^\\d{5}-?\\d{3}$/ },\n CA: { pattern: /(?:[ABCEGHJ-NPRSTVXY]\\d[A-Z][ -]?\\d[A-Z]\\d)/ },\n CH: { pattern: /[1-9]\\d{3}/ },\n CY: createPatternByDigits(4),\n CZ: { pattern: /\\d{3}\\s?\\d{2}/ },\n DE: createPatternByDigits(5),\n DK: createPatternByDigits(4),\n EE: createPatternByDigits(5),\n ES: { pattern: /(?:0[1-9]|[1-4]\\d|5[0-2])\\d{3}/ },\n FI: createPatternByDigits(5),\n FR: createPatternByDigits(5),\n GB: { pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/ },\n GE: createPatternByDigits(4),\n GR: { pattern: /^\\d{3}\\s{0,1}\\d{2}$/ },\n HR: { pattern: /^([1-5])[0-9]{4}$/ },\n HU: createPatternByDigits(4),\n IE: { pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/ },\n IS: createPatternByDigits(3),\n IT: createPatternByDigits(5),\n JP: { pattern: /^\\d{3}-?\\d{4}$/ },\n LI: createPatternByDigits(4),\n LT: { pattern: /^(LT-\\d{5}|\\d{4,5})$/ },\n LU: createPatternByDigits(4),\n LV: { pattern: /^(LV-)[0-9]{4}$/ },\n MC: { pattern: /^980\\d{2}$/ },\n MT: { pattern: /^[A-Za-z]{3}\\d{4}$/ },\n MY: createPatternByDigits(5),\n NL: { pattern: /(?:NL-)?(?:[1-9]\\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/ },\n NO: createPatternByDigits(4),\n PL: { pattern: /^\\d{2}[-]{0,1}\\d{3}$/ },\n PT: { pattern: /^([1-9]\\d{3})([- ]?(\\d{3})? *)$/ },\n RO: createPatternByDigits(6),\n SI: createPatternByDigits(4),\n SE: createPatternByDigits(5),\n SG: createPatternByDigits(6),\n SK: createPatternByDigits(5),\n US: { pattern: /^\\d{5}(?:-\\d{4})?$/ }\n};\n\n/**\n * Validates only postalCode property. As the partial address form does not have the country selector, the country value\n * must be informed beforehand and can't be picked up from the form context\n *\n * @param country - Country that will be used to validate postal code\n */\nexport const getPartialAddressValidationRules = (country: string | null): ValidatorRules => {\n const validationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: val => {\n return validatePostalCode(val, country, validationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n }\n };\n return validationRules;\n};\n\nconst ruleIsEmpty: ValidatorRule = {\n modes: ['blur'],\n validate: value => (isEmpty(value) ? null : true),\n errorMessage: ERROR_FIELD_REQUIRED\n};\n\nconst ruleValidateForSpecialChars: ValidatorRule = {\n modes: ['blur'],\n validate: value => validateForSpecialChars(value),\n errorMessage: ERROR_INVALID_CHARACTERS\n};\n\nexport const getAddressValidationRules = (specifications): ValidatorRules => {\n const addressValidationRules: ValidatorRules = {\n postalCode: {\n modes: ['blur'],\n validate: (val, context) => {\n const country = context.state.data.country;\n return validatePostalCode(val, country, addressValidationRules);\n },\n errorMessage: ERROR_FIELD_REQUIRED\n },\n street: [ruleIsEmpty, ruleValidateForSpecialChars],\n houseNumberOrName: [\n {\n validate: (value, context) => {\n const selectedCountry = context.state?.data?.country;\n const isOptional = selectedCountry && specifications.countryHasOptionalField(selectedCountry, 'houseNumberOrName');\n return isOptional || (isEmpty(value) ? null : true);\n },\n modes: ['blur'],\n errorMessage: ERROR_FIELD_REQUIRED\n },\n ruleValidateForSpecialChars\n ],\n city: [ruleIsEmpty, ruleValidateForSpecialChars],\n default: ruleIsEmpty\n };\n return addressValidationRules;\n};\n"],"names":["createPatternByDigits","digits","pattern","RegExp","validatePostalCode","val","countryCode","validatorRules","isEmpty","postalCode","errorMessage","translationKey","ERROR_INVALID_FORMAT_EXPECTS","translationObject","values","format","countrySpecificFormatters","postalCodePatterns","test","AT","AU","BE","BG","BR","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GE","GR","HR","HU","IE","IS","IT","JP","LI","LT","LU","LV","MC","MT","MY","NL","NO","PL","PT","RO","SI","SE","SG","SK","US","getPartialAddressValidationRules","country","validationRules","modes","validate","ERROR_FIELD_REQUIRED","ruleIsEmpty","value","ruleValidateForSpecialChars","validateForSpecialChars","ERROR_INVALID_CHARACTERS","getAddressValidationRules","specifications","addressValidationRules","context","state","data","street","houseNumberOrName","selectedCountry","countryHasOptionalField","city","default"],"mappings":"oSAKA,MAAMA,EAAyBC,IACpB,CACHC,QAAS,IAAIC,OAAO,OAAOF,QAItBG,EAAqB,CAACC,EAAaC,EAA4BC,KACxE,GAAID,EAAa,CAEb,GAAIE,EAAQH,GAAM,OAAO,KAGxBE,EAAeE,WAA6BC,aAAe,CACxDC,eAAgBC,EAChBC,kBAAmB,CACfC,OAAQ,CACJC,OAAQC,EAA0BV,IAAcG,WAAWM,QAAU,QAKjF,MAAMb,EAAUe,EAAmBX,IAAcJ,QACjD,OAAOA,EAAUA,EAAQgB,KAAKb,KAASA,CAC3C,CAEA,OAAOG,EAAQH,IAAO,MAGpBY,EAAqB,CACvBE,GAAInB,EAAsB,GAC1BoB,GAAIpB,EAAsB,GAC1BqB,GAAI,CAAEnB,QAAS,0BACfoB,GAAItB,EAAsB,GAC1BuB,GAAI,CAAErB,QAAS,kBACfsB,GAAI,CAAEtB,QAAS,+CACfuB,GAAI,CAAEvB,QAAS,cACfwB,GAAI1B,EAAsB,GAC1B2B,GAAI,CAAEzB,QAAS,iBACf0B,GAAI5B,EAAsB,GAC1B6B,GAAI7B,EAAsB,GAC1B8B,GAAI9B,EAAsB,GAC1B+B,GAAI,CAAE7B,QAAS,kCACf8B,GAAIhC,EAAsB,GAC1BiC,GAAIjC,EAAsB,GAC1BkC,GAAI,CAAEhC,QAAS,yFACfiC,GAAInC,EAAsB,GAC1BoC,GAAI,CAAElC,QAAS,uBACfmC,GAAI,CAAEnC,QAAS,qBACfoC,GAAItC,EAAsB,GAC1BuC,GAAI,CAAErC,QAAS,8DACfsC,GAAIxC,EAAsB,GAC1ByC,GAAIzC,EAAsB,GAC1B0C,GAAI,CAAExC,QAAS,kBACfyC,GAAI3C,EAAsB,GAC1B4C,GAAI,CAAE1C,QAAS,wBACf2C,GAAI7C,EAAsB,GAC1B8C,GAAI,CAAE5C,QAAS,mBACf6C,GAAI,CAAE7C,QAAS,cACf8C,GAAI,CAAE9C,QAAS,sBACf+C,GAAIjD,EAAsB,GAC1BkD,GAAI,CAAEhD,QAAS,sFACfiD,GAAInD,EAAsB,GAC1BoD,GAAI,CAAElD,QAAS,wBACfmD,GAAI,CAAEnD,QAAS,mCACfoD,GAAItD,EAAsB,GAC1BuD,GAAIvD,EAAsB,GAC1BwD,GAAIxD,EAAsB,GAC1ByD,GAAIzD,EAAsB,GAC1B0D,GAAI1D,EAAsB,GAC1B2D,GAAI,CAAEzD,QAAS,uBASN0D,EAAoCC,IAC7C,MAAMC,EAAkC,CACpCrD,WAAY,CACRsD,MAAO,CAAC,QACRC,SAAU3D,GACCD,EAAmBC,EAAKwD,EAASC,GAE5CpD,aAAcuD,IAGtB,OAAOH,GAGLI,EAA6B,CAC/BH,MAAO,CAAC,QACRC,SAAUG,IAAU3D,EAAQ2D,IAAS,KACrCzD,aAAcuD,GAGZG,EAA6C,CAC/CL,MAAO,CAAC,QACRC,SAAUG,GAASE,EAAwBF,GAC3CzD,aAAc4D,GAGLC,EAA6BC,IACtC,MAAMC,EAAyC,CAC3ChE,WAAY,CACRsD,MAAO,CAAC,QACRC,SAAU,CAAC3D,EAAKqE,KACZ,MAAMb,EAAUa,EAAQC,MAAMC,KAAKf,QACnC,OAAOzD,EAAmBC,EAAKwD,EAASY,IAE5C/D,aAAcuD,GAElBY,OAAQ,CAACX,EAAaE,GACtBU,kBAAmB,CACf,CACId,SAAU,CAACG,EAAOO,KACd,MAAMK,EAAkBL,EAAQC,OAAOC,MAAMf,QAE7C,OADmBkB,GAAmBP,EAAeQ,wBAAwBD,EAAiB,uBACxEvE,EAAQ2D,IAAS,MAE3CJ,MAAO,CAAC,QACRrD,aAAcuD,GAElBG,GAEJa,KAAM,CAACf,EAAaE,GACpBc,QAAShB,GAEb,OAAOO"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function c(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),n=this.core.modules.risk.data,s=this.core.modules.analytics.checkoutAttemptId??r,c=o?h.NATIVE:h.GENERIC,d=i(s,n,c);return e.paymentMethod&&s&&(e.paymentMethod.checkoutAttemptId=s),e.paymentMethod&&d&&(e.paymentMethod.sdkData=d),{...n&&{riskData:{clientData:n}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){c(this,"_id",`${this.constructor.type}-${e()}`),c(this,"core",void 0),c(this,"props",void 0),c(this,"state",{}),c(this,"_component",void 0),c(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}c(d,"defaultProps",{});export{d as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as r}from"../../../core/Analytics/constants.js";import{on as n,off as s}from"../../../utils/listenerUtils.js";import{createSdkData as i}from"../../../utils/createSdkData.js";import a from"../../components-name-map.js";import{PAYMENT_METHOD_BEHAVIOR as h}from"../../../core/config.js";function c(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class d{buildElementProps(t){this.props=this.formatProps({...this.constructor.defaultProps,...t})}formatProps(t){return t}formatData(){return{}}submitAnalytics(t){return null}handleKeyDown(t){return null}setState(t){this.state={...this.state,...t}}get data(){const t=this.state.order||this.props.order,e=this.formatData(),o=Boolean(a(e.paymentMethod?.type)),n=this.core.modules.risk.riskData,s=this.core.modules.analytics.checkoutAttemptId??r,c=o?h.NATIVE:h.GENERIC,d=i(s,n,c);return e.paymentMethod&&s&&(e.paymentMethod.checkoutAttemptId=s),e.paymentMethod&&d&&(e.paymentMethod.sdkData=d),{...n&&{riskData:{clientData:n}},...t&&{order:{orderData:t.orderData,pspReference:t.pspReference}},...e,clientStateDataIndicator:!0}}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const o="string"==typeof e?document.querySelector(e):e;if(!o)throw new Error("Component could not mount. Root node was not found.");return this._node&&this.unmount(),this._node=o,n(this._node,"keydown",this.handleKeyDown,!1),this._component=this.render(),t(this._component,o),this}update(t){return this.props=this.formatProps({...this.props,...t}),this.state={},this.unmount().mount(this._node)}unmount(){return s(this._node,"keydown",this.handleKeyDown),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,r){c(this,"_id",`${this.constructor.type}-${e()}`),c(this,"core",void 0),c(this,"props",void 0),c(this,"state",{}),c(this,"_component",void 0),c(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(r),this.handleKeyDown=this.handleKeyDown.bind(this)}}c(d,"defaultProps",{});export{d as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, BaseElementState, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps, S extends BaseElementState = BaseElementState> implements IBaseElement<P> {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: S = {} as S;\n public _component: ComponentChild | undefined;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): PaymentData {\n return {} as PaymentData;\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: S): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.data;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key down events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {} as S;\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","setState","newState","state","data","order","componentData","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"mlBAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,gBAAoBJ,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAG,GACI,MAAO,CAAA,CACX,CAEUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAEUC,aAAAA,CAAcC,GACpB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfV,KAAKW,MAAQ,IAAKX,KAAKW,SAAUD,EACrC,CAMA,QAAWE,GACP,MAAMC,EAAQb,KAAKW,MAAME,OAASb,KAAKC,MAAMY,MACvCC,EAAgBd,KAAKI,aACrBW,EAAuCC,QAAQC,EAA8BH,EAAcI,eAAeC,OAC1GC,EAAapB,KAAKqB,KAAKC,QAAQC,KAAKX,KACpCY,EAAoBxB,KAAKqB,KAAKC,QAAQG,UAAUD,mBAAqBE,EACrEC,EAAwBZ,EAAuCa,EAAwBC,OAASD,EAAwBE,QAExHC,EAAUC,EAAcR,EAAmBJ,EAAYO,GAS7D,OARIb,EAAcI,eAAiBM,IAC/BV,EAAcI,cAAcM,kBAAoBA,GAGhDV,EAAcI,eAAiBa,IAC/BjB,EAAcI,cAAca,QAAUA,GAGnC,IACCX,GAAc,CAAEa,SAAU,CAAEb,kBAC5BP,GAAS,CAAEA,MAAO,CAAEqB,UAAWrB,EAAMqB,UAAWC,aAActB,EAAMsB,kBACrErB,EACHsB,0BAA0B,EAElC,CAMA,QAAAC,GAEA,CAEOC,MAAAA,GAEH,MAAM,IAAIC,MAAM,qCACpB,CAOOC,KAAAA,CAAMC,GACT,MAAMC,EAA0B,i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al/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render, TargetedKeyboardEvent } from 'preact';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, BaseElementState, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AbstractAnalyticsEvent } from '../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { createSdkData } from '../../../utils/createSdkData';\nimport getComponentNameOfPaymentType from '../../components-name-map';\nimport { PAYMENT_METHOD_BEHAVIOR } from '../../../core/config';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps, S extends BaseElementState = BaseElementState> implements IBaseElement<P> {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: S = {} as S;\n public _component: ComponentChild | undefined;\n\n protected _node: HTMLElement = null;\n\n protected static readonly defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): PaymentData {\n return {} as PaymentData;\n }\n\n protected submitAnalytics(_analyticsObj?: AbstractAnalyticsEvent) {\n return null;\n }\n\n protected handleKeyDown(_e: TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: S): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n const doesPaymentMethodHaveNativeComponent = Boolean(getComponentNameOfPaymentType(componentData.paymentMethod?.type));\n const clientData = this.core.modules.risk.riskData;\n const checkoutAttemptId = this.core.modules.analytics.checkoutAttemptId ?? NO_CHECKOUT_ATTEMPT_ID;\n const paymentMethodBehavior = doesPaymentMethodHaveNativeComponent ? PAYMENT_METHOD_BEHAVIOR.NATIVE : PAYMENT_METHOD_BEHAVIOR.GENERIC;\n\n const sdkData = createSdkData(checkoutAttemptId, clientData, paymentMethodBehavior);\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n if (componentData.paymentMethod && sdkData) {\n componentData.paymentMethod.sdkData = sdkData;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key down events, notably 'Enter' key presses\n on(this._node, 'keydown', this.handleKeyDown, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {} as S;\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keydown', this.handleKeyDown);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","constructor","formatData","submitAnalytics","_analyticsObj","handleKeyDown","_e","setState","newState","state","data","order","componentData","doesPaymentMethodHaveNativeComponent","Boolean","getComponentNameOfPaymentType","paymentMethod","type","clientData","core","modules","risk","riskData","checkoutAttemptId","analytics","NO_CHECKOUT_ATTEMPT_ID","paymentMethodBehavior","PAYMENT_METHOD_BEHAVIOR","NATIVE","GENERIC","sdkData","createSdkData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","_node","unmount","on","_component","update","off","remove","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"mlBAwBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKG,YAAY,g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IV,OAHAD,KAAKC,MAAQD,KAAKE,YAAY,IAAKF,KAAKC,SAAUA,IAClDD,KAAKW,MAAQ,CAAA,EAENX,KAAK8C,UAAUN,MAAMxC,KAAK6C,MACrC,CAKA,OAAAC,GAQI,OANAI,EAAIlD,KAAK6C,MAAO,UAAW7C,KAAKO,eAE5BP,KAAK6C,OACLP,EAAO,KAAMtC,KAAK6C,OAGf7C,IACX,CAMA,MAAAmD,GACInD,KAAK8C,UAED9C,KAAKqB,MACLrB,KAAKqB,KAAK8B,OAAOnD,KAEzB,CA3JA,WAAAG,CAAYiD,EAAiBnD,GAX7BoD,EAAArD,KAAgBsD,MAAM,GAAGtD,KAAKG,YAAY,QAAWoD,OACrDF,EAAArD,KAAgBqB,eAEhBgC,EAAArD,KAAOC,gBACPoD,EAAArD,KAAOW,QAAW,IAClB0C,EAAArD,KAAOgD,qBAEPK,EAAArD,KAAU6C,QAAqB,MAK3B,MAAMW,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuC5D,KAAKG,YAAY,6DAIhEH,KAAKqB,KAAO+B,EACZpD,KAAKF,kBAAkBG,GAEvBD,KAAKO,cAAgBP,KAAKO,cAAcsD,KAAK7D,KACjD,EAhBAqD,EAVWxD,EAUeiE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import n from"../Link/Link.js";function a({message:t,urls:r=[]}){return e("span",{className:"adyen-checkout-disclaimer__label"},e(l,{message:t,urls:r}))}function l({message:a,urls:l}){const i="string"==typeof a,o=l.every(e=>"string"==typeof e&&r(e));if(!i||!o)return null;let u;try{u=s(a,l.map(t=>function(r){return e(n,{to:t},r)}))}catch(e){u=a,console.warn(e)}return e(t,null,u)}export{l as LabelOnlyDisclaimerMessage,a as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import n from"../Link/Link.js";function a({id:t,message:r,urls:s=[]}){return e("span",{id:t,className:"adyen-checkout-disclaimer__label"},e(i,{message:r,urls:s}))}function i({message:a,urls:i=[]}){const l="string"==typeof a,o=i.every(e=>"string"==typeof e&&r(e));if(!l||!o)return null;let u;try{u=s(a,i.map(t=>function(r){return e(n,{to:t},r)}))}catch(e){u=a,console.warn(e)}return e(t,null,u)}export{i as LabelOnlyDisclaimerMessage,a as default};
2
2
  //# sourceMappingURL=DisclaimerMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText: string;\n link: string;\n}\n\ninterface InternalDisclaimerMsgObject {\n message: string;\n urls?: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n */\n\nexport default function DisclaimerMessage({ message, urls = [] }: Readonly<InternalDisclaimerMsgObject>) {\n return (\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls }: Readonly<InternalDisclaimerMsgObject>) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n let content;\n try {\n content = interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n );\n } catch (e) {\n // Fall back to raw message (i.e. the translation key) if interpolation fails\n content = message;\n // Report interpolation error to console\n console.warn(e);\n }\n\n return <Fragment>{content}</Fragment>;\n}\n"],"names":["DisclaimerMessage","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","content","interpolateElement","map","translation","Link","to","e","console","warn","Fragment"],"mappings":"mPAyBe,SAASA,GAAkBC,QAAEA,EAAOC,KAAEA,EAAO,KACxD,OACIC,EAACC,OAAAA,CAAKC,UAAU,oCACZF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,IAClD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,MAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,IAC9E,IAAKH,IAAiBC,EAAW,OAAO,KAExC,IAAII,EACJ,IACIA,EAAUC,EACNZ,EACAC,EAAKY,IAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,GAGhB,CAAE,MAAOG,GAELN,EAAUX,EAEVkB,QAAQC,KAAKF,EACjB,CAEA,OAAOf,EAACkB,EAAAA,KAAUT,EACtB"}
1
+ {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText?: string | Array<string>;\n link?: string | Array<string>;\n}\n\nexport interface DisclaimerMessageProps {\n id?: string;\n message: string;\n urls?: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n *\n * Merchant configured disclaimers use the `%{placeholder}` format instead, and must be passed\n * through `formatDisclaimerMessage` to obtain these props.\n */\n\nexport default function DisclaimerMessage({ id, message, urls = [] }: Readonly<DisclaimerMessageProps>) {\n return (\n <span id={id} className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls = [] }: Readonly<DisclaimerMessageProps>) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n let content;\n try {\n content = interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n );\n } catch (e) {\n // Fall back to raw message (i.e. the translation key) if interpolation fails\n content = message;\n // Report interpolation error to console\n console.warn(e);\n }\n\n return <Fragment>{content}</Fragment>;\n}\n"],"names":["DisclaimerMessage","id","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","content","interpolateElement","map","translation","Link","to","e","console","warn","Fragment"],"mappings":"mPA6Be,SAASA,GAAkBC,GAAEA,EAAEC,QAAEA,EAAOC,KAAEA,EAAO,KAC5D,OACIC,EAACC,OAAAA,CAAKJ,GAAIA,EAAIK,UAAU,oCACpBF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,EAAO,KACzD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,MAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,IAC9E,IAAKH,IAAiBC,EAAW,OAAO,KAExC,IAAII,EACJ,IACIA,EAAUC,EACNZ,EACAC,EAAKY,IAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,GAGhB,CAAE,MAAOG,GAELN,EAAUX,EAEVkB,QAAQC,KAAKF,EACjB,CAEA,OAAOf,EAACkB,EAAAA,KAAUT,EACtB"}
@@ -0,0 +1,2 @@
1
+ const e=/%\{[^}]*\}/g,r=e=>Array.isArray(e)?e:[e];function s({message:s,linkText:t,link:n}){if("string"!=typeof s)return{message:"",urls:[]};const i=r(t),o=r(n),g=[];let u=0;return{message:s.replace(e,()=>{const e=i[u],r=o[u];return u++,"string"!=typeof e?"":"string"!=typeof r?e:(g.push(r),`%#${e}%#`)}),urls:g}}export{s as formatDisclaimerMessage};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/DisclaimerMessage/utils.ts"],"sourcesContent":["import type { DisclaimerMessageProps, DisclaimerMsgObject } from './DisclaimerMessage';\n\n/**\n * Matches a `%{placeholder}` link slot. Placeholder names are irrelevant, only their order matters.\n */\nconst LINK_SLOT_REGEX = /%\\{[^}]*\\}/g;\n\nconst toArray = <T>(value: T | Array<T>): Array<T> => (Array.isArray(value) ? value : [value]);\n\n/**\n * Converts the merchant facing disclaimer message config into the props of the DisclaimerMessage component.\n *\n * Each `%{placeholder}` in the message is replaced, in order of appearance, by the corresponding entry of\n * `linkText` wrapped in the `%#` token pair that DisclaimerMessage renders as an anchor element. A linkText\n * without a link degrades to plain text, while a slot without linkText is removed.\n *\n * @param disclaimerMessage - merchant provided disclaimer message\n * @returns the message with interpolation tokens and the urls matching the order of the tokens\n */\nexport function formatDisclaimerMessage({ message, linkText, link }: DisclaimerMsgObject): DisclaimerMessageProps {\n if (typeof message !== 'string') return { message: '', urls: [] };\n\n const linkTexts = toArray(linkText);\n const links = toArray(link);\n const urls: Array<string> = [];\n let index = 0;\n\n const formattedMessage = message.replace(LINK_SLOT_REGEX, () => {\n const text = linkTexts[index];\n const url = links[index];\n index++;\n if (typeof text !== 'string') return '';\n if (typeof url !== 'string') return text;\n urls.push(url);\n return `%#${text}%#`;\n });\n\n return { message: formattedMessage, urls };\n}\n"],"names":["LINK_SLOT_REGEX","toArray","value","Array","isArray","formatDisclaimerMessage","message","linkText","link","urls","linkTexts","links","index","replace","text","url","push"],"mappings":"AAKA,MAAMA,EAAkB,cAElBC,EAAcC,GAAmCC,MAAMC,QAAQF,GAASA,EAAQ,CAACA,GAYhF,SAASG,GAAwBC,QAAEA,EAAOC,SAAEA,EAAQC,KAAEA,IACzD,GAAuB,iBAAZF,EAAsB,MAAO,CAAEA,QAAS,GAAIG,KAAM,IAE7D,MAAMC,EAAYT,EAAQM,GACpBI,EAAQV,EAAQO,GAChBC,EAAsB,GAC5B,IAAIG,EAAQ,EAYZ,MAAO,CAAEN,QAVgBA,EAAQO,QAAQb,EAAiB,KACtD,MAAMc,EAAOJ,EAAUE,GACjBG,EAAMJ,EAAMC,GAElB,OADAA,IACoB,iBAATE,EAA0B,GAClB,iBAARC,EAAyBD,GACpCL,EAAKO,KAAKD,GACH,KAAKD,SAGoBL,OACxC"}
@@ -1,2 +1,2 @@
1
- const o=o=>{const t=o.parentNode,e=window.getComputedStyle(t,null),p=parseInt(e.getPropertyValue("border-top-width")),l=o.offsetTop-t.offsetTop<t.scrollTop,f=o.offsetTop-t.offsetTop+o.clientHeight-p>t.scrollTop+t.clientHeight;(l||f)&&(t.scrollTop=o.offsetTop-t.offsetTop-t.clientHeight/2-p+o.clientHeight/2)};export{o as simulateFocusScroll};
1
+ const o=o=>o.replace(/[!-~]/g,o=>String.fromCharCode(o.charCodeAt(0)-65248)),e=o=>{const e=o.parentNode,t=window.getComputedStyle(e,null),p=parseInt(t.getPropertyValue("border-top-width")),l=o.offsetTop-e.offsetTop<e.scrollTop,r=o.offsetTop-e.offsetTop+o.clientHeight-p>e.scrollTop+e.clientHeight;(l||r)&&(e.scrollTop=o.offsetTop-e.offsetTop-e.clientHeight/2-p+o.clientHeight/2)};export{o as convertFullToHalf,e as simulateFocusScroll};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/FormFields/utils.ts"],"sourcesContent":["const convertFullToHalf = str => str.replace(/[!-~]/g, r => String.fromCharCode(r.charCodeAt(0) - 0xfee0));\n\n/**\n * This function scrolls and element to view and simulates the default behaviour of .focus() by a given browser\n * This function is inspired, yet simplified of the code found here https://gist.github.com/hsablonniere/2581101\n * @param element - element to focus\n */\nconst simulateFocusScroll = (element: HTMLElement) => {\n const parent = element.parentNode as HTMLElement;\n const parentComputedStyle = window.getComputedStyle(parent, null);\n const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'));\n const overTop = element.offsetTop - parent.offsetTop < parent.scrollTop;\n const overBottom = element.offsetTop - parent.offsetTop + element.clientHeight - parentBorderTopWidth > parent.scrollTop + parent.clientHeight;\n\n if (overTop || overBottom) {\n parent.scrollTop = element.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + element.clientHeight / 2;\n }\n};\n\nexport { convertFullToHalf, simulateFocusScroll };\n"],"names":["simulateFocusScroll","element","parent","parentNode","parentComputedStyle","window","getComputedStyle","parentBorderTopWidth","parseInt","getPropertyValue","overTop","offsetTop","scrollTop","overBottom","clientHeight"],"mappings":"AAOA,MAAMA,EAAuBC,IACzB,MAAMC,EAASD,EAAQE,WACjBC,EAAsBC,OAAOC,iBAAiBJ,EAAQ,MACtDK,EAAuBC,SAASJ,EAAoBK,iBAAiB,qBACrEC,EAAUT,EAAQU,UAAYT,EAAOS,UAAYT,EAAOU,UACxDC,EAAaZ,EAAQU,UAAYT,EAAOS,UAAYV,EAAQa,aAAeP,EAAuBL,EAAOU,UAAYV,EAAOY,cAE9HJ,GAAWG,KACXX,EAAOU,UAAYX,EAAQU,UAAYT,EAAOS,UAAYT,EAAOY,aAAe,EAAIP,EAAuBN,EAAQa,aAAe"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/FormFields/utils.ts"],"sourcesContent":["const convertFullToHalf = str => str.replace(/[!-~]/g, r => String.fromCharCode(r.charCodeAt(0) - 0xfee0));\n\n/**\n * This function scrolls and element to view and simulates the default behaviour of .focus() by a given browser\n * This function is inspired, yet simplified of the code found here https://gist.github.com/hsablonniere/2581101\n * @param element - element to focus\n */\nconst simulateFocusScroll = (element: HTMLElement) => {\n const parent = element.parentNode as HTMLElement;\n const parentComputedStyle = window.getComputedStyle(parent, null);\n const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'));\n const overTop = element.offsetTop - parent.offsetTop < parent.scrollTop;\n const overBottom = element.offsetTop - parent.offsetTop + element.clientHeight - parentBorderTopWidth > parent.scrollTop + parent.clientHeight;\n\n if (overTop || overBottom) {\n parent.scrollTop = element.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + element.clientHeight / 2;\n }\n};\n\nexport { convertFullToHalf, simulateFocusScroll };\n"],"names":["convertFullToHalf","str","replace","r","String","fromCharCode","charCodeAt","simulateFocusScroll","element","parent","parentNode","parentComputedStyle","window","getComputedStyle","parentBorderTopWidth","parseInt","getPropertyValue","overTop","offsetTop","scrollTop","overBottom","clientHeight"],"mappings":"AAAA,MAAMA,EAAoBC,GAAOA,EAAIC,QAAQ,SAAUC,GAAKC,OAAOC,aAAaF,EAAEG,WAAW,GAAK,QAO5FC,EAAuBC,IACzB,MAAMC,EAASD,EAAQE,WACjBC,EAAsBC,OAAOC,iBAAiBJ,EAAQ,MACtDK,EAAuBC,SAASJ,EAAoBK,iBAAiB,qBACrEC,EAAUT,EAAQU,UAAYT,EAAOS,UAAYT,EAAOU,UACxDC,EAAaZ,EAAQU,UAAYT,EAAOS,UAAYV,EAAQa,aAAeP,EAAuBL,EAAOU,UAAYV,EAAOY,cAE9HJ,GAAWG,KACXX,EAAOU,UAAYX,EAAQU,UAAYT,EAAOS,UAAYT,EAAOY,aAAe,EAAIP,EAAuBN,EAAQa,aAAe"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as a}from"../../../external/preact/dist/preact.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import r from"../FormFields/Field/Field.js";import{isValidHolder as s,checkIbanStatus as i}from"./validate.js";import{electronicFormat as n,formatIban as o,getCountryCode as l,getNextCursorPosition as d}from"./utils.js";import h from"../FormFields/Fieldset/Fieldset.js";import u from"../FormFields/InputText.js";function m(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}const b={isValid:!1,errorMessage:"ach.accountHolderNameField.invalid",error:"ach.accountHolderNameField.invalid"},c={isValid:!1,errorMessage:"sepaDirectDebit.ibanField.invalid",error:"sepaDirectDebit.ibanField.invalid"};class p extends e{setStatus(e){this.setState({status:e})}onChange(){const e=!this.props.holderName||s(this.state.data.ownerName),a="valid"===i(this.state.data.ibanNumber).status&&e,t={data:this.state.data,isValid:a,errors:this.state.errors};this.props.onChange(t)}showValidation(){const e=i(this.state.data.ibanNumber).status,a=s(this.state.data.ownerName);this.setError("iban","valid"===e?null:c);const t=a?null:b;this.setError("holder",t,this.onChange)}render({placeholders:e},{data:s,errors:i,valid:n}){const{i18n:o}=t();return a(h,{classNameModifiers:["iban-input"],label:this.props.label},this.props.holderName&&a(r,{className:"adyen-checkout__field--owner-name",label:o.get("sepa.ownerName"),filled:s.ownerName&&s.ownerName.length,errorMessage:!!i.holder&&o.get(i.holder.error),dir:"ltr",i18n:o,name:"ownerName"},a(u,{name:"ownerName",className:"adyen-checkout__iban-input__owner-name",placeholder:e?.ownerName,value:s.ownerName,"aria-invalid":!!this.state.errors.holder,"aria-label":o.get("sepa.ownerName"),onInput:e=>this.handleHolderInput(e.target.value),onBlur:e=>this.handleHolderInput(e.target.value),autocomplete:"name"})),a(r,{className:"adyen-checkout__field--iban-number",label:o.get("sepa.ibanNumber"),errorMessage:!!i.iban&&o.get(i.iban.error),filled:s.ibanNumber&&s.ibanNumber.length,isValid:n.iban,onBlur:this.handleIbanBlur,dir:"ltr",i18n:o,name:"ibanNumber"},a(u,{name:"ibanNumber",className:"adyen-checkout__iban-input__iban-number",classNameModifiers:["large"],placeholder:e?.ibanNumber,value:s.ibanNumber,onInput:this.handleIbanInput,"aria-invalid":!!this.state.errors.iban,"aria-label":o.get("sepa.ibanNumber"),autocorrect:"off",spellcheck:!1,autocomplete:void 0})),this.props.showPayButton&&this.props.payButton({status:this.state.status}))}constructor(e){if(super(e),m(this,"setError",(e,a,t)=>{this.setState(t=>({errors:{...t.errors,[e]:a}}),t)}),m(this,"handleHolderInput",e=>{this.setState(a=>({data:{...a.data,ownerName:e}}),()=>{const e=s(this.state.data.ownerName),a=e&&!e?b:null;this.setError("holder",a,this.onChange)})}),m(this,"handleIbanInput",e=>{const a=e.target.value,t=n(a),r=o(t),s=i(r).status,h=l(t),u=e.target.selectionStart,m=this.state.data.ibanNumber,b=d(u,r,m);this.setState(e=>({data:{...e.data,ibanNumber:r,countryCode:h},errors:{...e.errors,iban:"invalid"===s?c:null},valid:{...e.valid,iban:"valid"===s}}),()=>{e.target.setSelectionRange(b,b),this.onChange()})}),m(this,"handleIbanBlur",e=>{const a=e.target.value;if(a.length>0){const e=i(a).status;this.setError("iban","valid"===e?null:c,this.onChange)}else this.setError("iban",null,this.onChange)}),this.state={status:"ready",data:{ownerName:e?.data?.ownerName||"",ibanNumber:e?.data?.ibanNumber||"",countryCode:e?.data?.countryCode||""},isValid:!1,cursor:0,errors:{},valid:{}},this.state.data.ibanNumber){const e=n(this.state.data.ibanNumber);this.state.data.ibanNumber=o(e)}if(this.state.data.ibanNumber||this.state.data.ownerName){const e=!this.props.holderName||s(this.state.data.ownerName),a=!!this.state.data.ibanNumber&&"valid"===i(this.state.data.ibanNumber).status&&e,t={data:this.state.data,isValid:a};this.props.onChange(t)}}}m(p,"defaultProps",{onChange:()=>{},countryCode:null,holderName:!0,placeholders:{},label:null});export{p as default};
1
+ import{Component as e,createElement as a}from"../../../external/preact/dist/preact.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import r from"../FormFields/Field/Field.js";import{isValidHolder as s,checkIbanStatus as i}from"./validate.js";import{electronicFormat as n,formatIban as o,getCountryCode as l,getNextCursorPosition as d}from"./utils.js";import h from"../FormFields/Fieldset/Fieldset.js";import u from"../FormFields/InputText.js";function m(e,a,t){return a in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e}const b={isValid:!1,errorMessage:"ach.accountHolderNameField.invalid",error:"ach.accountHolderNameField.invalid"},c={isValid:!1,errorMessage:"sepaDirectDebit.ibanField.invalid",error:"sepaDirectDebit.ibanField.invalid"};class p extends e{setStatus(e){this.setState({status:e})}onChange(){const e=!this.props.holderName||s(this.state.data.ownerName),a="valid"===i(this.state.data.ibanNumber).status&&e,t={data:this.state.data,isValid:a,errors:this.state.errors};this.props.onChange(t)}showValidation(){const e=i(this.state.data.ibanNumber).status,a=s(this.state.data.ownerName);this.setError("iban","valid"===e?null:c);const t=a?null:b;this.setError("holder",t,this.onChange)}render({placeholders:e},{data:s,errors:i,valid:n}){const{i18n:o}=t();return a(h,{classNameModifiers:["iban-input"],label:this.props.label},this.props.holderName&&a(r,{className:"adyen-checkout__field--owner-name",label:o.get("sepa.ownerName"),filled:s.ownerName&&s.ownerName.length,errorMessage:!!i.holder&&o.get(i.holder.error),dir:"ltr",i18n:o,name:"ownerName"},a(u,{name:"ownerName",className:"adyen-checkout__iban-input__owner-name",placeholder:e?.ownerName,value:s.ownerName,"aria-invalid":!!this.state.errors.holder,"aria-label":o.get("sepa.ownerName"),onInput:e=>this.handleHolderInput(e.target.value),onBlur:e=>this.handleHolderInput(e.target.value),autocomplete:"name"})),a(r,{className:"adyen-checkout__field--iban-number",label:o.get("sepa.ibanNumber"),errorMessage:!!i.iban&&o.get(i.iban.error),filled:s.ibanNumber&&s.ibanNumber.length,isValid:n.iban,onBlur:this.handleIbanBlur,dir:"ltr",i18n:o,name:"ibanNumber"},a(u,{name:"ibanNumber",className:"adyen-checkout__iban-input__iban-number",classNameModifiers:["large"],placeholder:e?.ibanNumber,value:s.ibanNumber,onInput:this.handleIbanInput,"aria-invalid":!!this.state.errors.iban,"aria-label":o.get("sepa.ibanNumber"),autocorrect:"off",spellcheck:!1,autocomplete:void 0})),this.props.payButton?.({status:this.state.status}))}constructor(e){if(super(e),m(this,"setError",(e,a,t)=>{this.setState(t=>({errors:{...t.errors,[e]:a}}),t)}),m(this,"handleHolderInput",e=>{this.setState(a=>({data:{...a.data,ownerName:e}}),()=>{const e=s(this.state.data.ownerName),a=e&&!e?b:null;this.setError("holder",a,this.onChange)})}),m(this,"handleIbanInput",e=>{const a=e.target.value,t=n(a),r=o(t),s=i(r).status,h=l(t),u=e.target.selectionStart,m=this.state.data.ibanNumber,b=d(u,r,m);this.setState(e=>({data:{...e.data,ibanNumber:r,countryCode:h},errors:{...e.errors,iban:"invalid"===s?c:null},valid:{...e.valid,iban:"valid"===s}}),()=>{e.target.setSelectionRange(b,b),this.onChange()})}),m(this,"handleIbanBlur",e=>{const a=e.target.value;if(a.length>0){const e=i(a).status;this.setError("iban","valid"===e?null:c,this.onChange)}else this.setError("iban",null,this.onChange)}),this.state={status:"ready",data:{ownerName:e?.data?.ownerName||"",ibanNumber:e?.data?.ibanNumber||"",countryCode:e?.data?.countryCode||""},isValid:!1,cursor:0,errors:{},valid:{}},this.state.data.ibanNumber){const e=n(this.state.data.ibanNumber);this.state.data.ibanNumber=o(e)}if(this.state.data.ibanNumber||this.state.data.ownerName){const e=!this.props.holderName||s(this.state.data.ownerName),a=!!this.state.data.ibanNumber&&"valid"===i(this.state.data.ibanNumber).status&&e,t={data:this.state.data,isValid:a};this.props.onChange(t)}}}m(p,"defaultProps",{onChange:()=>{},countryCode:null,holderName:!0,placeholders:{},label:null});export{p as default};
2
2
  //# sourceMappingURL=IbanInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IbanInput.js","sources":["../../../../../src/components/internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\nimport { UIElementStatus } from '../UIElement/types';\nimport { PayButtonProps } from '../PayButton/PayButton';\n\nexport interface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputOnChangeData {\n data: IbanData;\n isValid: boolean;\n errors?: Record<string, GenericError | null>;\n}\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: (props: PayButtonProps) => h.JSX.Element;\n onChange: (data: IbanInputOnChangeData) => void;\n label: string;\n data?: IbanData;\n}\n\ninterface IbanInputState {\n data: IbanData;\n errors: Record<string, GenericError | null>;\n valid: Record<string, boolean>;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<Readonly<IbanInputProps>, IbanInputState> {\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : false;\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static readonly defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status: UIElementStatus) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr = holderStatus && !holderStatus ? ibanHolderNameErrorObj : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj);\n\n const holderErr = holderStatus ? null : ibanHolderNameErrorObj;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n autocomplete={'name'}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n autocomplete={undefined}\n />\n </Field>\n\n {this.props.showPayButton && this.props.payButton({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","autocomplete","iban","handleIbanBlur","ibanNumber","handleIbanInput","autocorrect","spellcheck","undefined","showPayButton","payButton","constructor","super","_define_property","key","cb","prevState","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"8kBA2CA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EAwCpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA1DiB,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,QACpCI,EACvBK,EAAO,CAAEA,KAAMR,KAAK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}
1
+ {"version":3,"file":"IbanInput.js","sources":["../../../../../src/components/internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\nimport { UIElementStatus } from '../UIElement/types';\nimport { PayButtonProps } from '../PayButton/PayButton';\n\nexport interface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputOnChangeData {\n data: IbanData;\n isValid: boolean;\n errors?: Record<string, GenericError | null>;\n}\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: (props: PayButtonProps) => h.JSX.Element;\n onChange: (data: IbanInputOnChangeData) => void;\n label: string;\n data?: IbanData;\n}\n\ninterface IbanInputState {\n data: IbanData;\n errors: Record<string, GenericError | null>;\n valid: Record<string, boolean>;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<Readonly<IbanInputProps>, IbanInputState> {\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : false;\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static readonly defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status: UIElementStatus) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr = holderStatus && !holderStatus ? ibanHolderNameErrorObj : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus === 'valid' ? null : ibanErrorObj);\n\n const holderErr = holderStatus ? null : ibanHolderNameErrorObj;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n autocomplete={'name'}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n autocomplete={undefined}\n />\n </Field>\n\n {/* IbanInput is also embedded in OpenInvoice, which owns the pay button and passes none down */}\n {this.props.payButton?.({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","autocomplete","iban","handleIbanBlur","ibanNumber","handleIbanInput","autocorrect","spellcheck","undefined","payButton","constructor","super","_define_property","key","cb","prevState","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"8kBA2CA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EAwCpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA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OACV6D,YAAa,KACb1D,YAAY,EACZY,aAAc,CAAA,EACdO,MAAO"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import{setFocusOnField as a}from"../../../utils/setFocus.js";import l from"../FormFields/Field/Field.js";import u from"./IssuerButtonGroup/IssuerButtonGroup.js";import m from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import d from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as p}from"../../../core/Errors/constants.js";import g from"../DisclaimerMessage/DisclaimerMessage.js";import h from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as f}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as C,UiTarget as j,InfoEventType as F}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";const S=({issuer:e,items:s},t)=>{const r=s.find(s=>s.id===e)?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},x=["issuer"],b={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function v({items:v,placeholder:A,issuer:I,highlightedIds:_=[],showContextualElement:M,contextualText:w,selectFieldLabel:E,...k}){const{i18n:R}=c(),{handleChangeFor:V,triggerValidation:T,data:B,valid:L,errors:N,isValid:P}=n({schema:x,defaultData:{issuer:I},rules:b}),[D,G]=t("ready"),[$,K]=t(1),{setSRMessagesFromObjects:O,shouldMoveFocusSR:q}=d(),z=O?.({}),H=r(null),J=o(e=>s=>{const t=1===e?j.list:j.featuredIssuer,r=v.find(e=>e.id===s.target.value),o=new C({component:k.type,type:F.selected,target:t,issuer:r.name});k.onSubmitAnalytics(o),K(e),V("issuer")(s)},[V,k.type]),Q=o(e=>{if(e){const e=new C({component:k.type,type:F.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),U=r(y(k.onSubmitAnalytics,f)),W=o(()=>{U.current({type:F.input,target:j.listSearch})},[]),X=r({setStatus:G,showValidation:()=>{T()}});i(()=>{k.setComponentRef(X.current)},[k.setComponentRef]),i(()=>{k.onChange({data:B,valid:L,errors:N,isValid:P});const e=z?.({errors:N,isValidating:!0});e?.action===p&&q&&a(H.current,"issuer-list")},[B,L,N,P]);const{highlightedItems:Y}=v.reduce((e,s)=>(_.includes(s.id)&&e.highlightedItems.push({...s}),e),{highlightedItems:[]});return e("div",{ref:H,className:"adyen-checkout__issuer-list"},!!Y.length&&e(s,null,e(u,{selectedIssuerId:0===$?B.issuer:null,items:Y,onChange:J(0)}),e(m,null)),e(l,{label:E??R.get("issuerList.selectField.label"),errorMessage:(Z=N.issuer,Z&&Z.errorMessage?R.get(Z.errorMessage):!!Z),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:M,contextualText:w},e(h,{items:v,selectedValue:1===$?B.issuer:null,placeholder:A,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:J(1),onListToggle:Q,onInput:W})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(g,{message:R.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.showPayButton&&k.payButton({status:D,label:S({issuer:B.issuer,items:[...v,...Y]},R)}));var Z}v.defaultProps={onChange:()=>{}};export{v as default};
1
+ import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import{setFocusOnField as a}from"../../../utils/setFocus.js";import l from"../FormFields/Field/Field.js";import u from"./IssuerButtonGroup/IssuerButtonGroup.js";import m from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import d from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as p}from"../../../core/Errors/constants.js";import g from"../DisclaimerMessage/DisclaimerMessage.js";import h from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as f}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as C,UiTarget as j,InfoEventType as F}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";const S=({issuer:e,items:s},t)=>{const r=s.find(s=>s.id===e)?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},x=["issuer"],b={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function v({items:v,placeholder:A,issuer:I,highlightedIds:_=[],showContextualElement:M,contextualText:E,selectFieldLabel:k,...w}){const{i18n:R}=c(),{handleChangeFor:V,triggerValidation:T,data:L,valid:N,errors:B,isValid:D}=n({schema:x,defaultData:{issuer:I},rules:b}),[P,G]=t("ready"),[$,K]=t(1),{setSRMessagesFromObjects:O,shouldMoveFocusSR:q}=d(),z=O?.({}),H=r(null),J=o(e=>s=>{const t=1===e?j.list:j.featuredIssuer,r=v.find(e=>e.id===s.target.value),o=new C({component:w.type,type:F.selected,target:t,issuer:r.name});w.onSubmitAnalytics(o),K(e),V("issuer")(s)},[V,w.type]),Q=o(e=>{if(e){const e=new C({component:w.type,type:F.displayed,target:j.list});w.onSubmitAnalytics(e)}},[w.type,w.onSubmitAnalytics]),U=r(y(w.onSubmitAnalytics,f)),W=o(()=>{U.current({type:F.input,target:j.listSearch})},[]),X=r({setStatus:G,showValidation:()=>{T()}});i(()=>{w.setComponentRef(X.current)},[w.setComponentRef]),i(()=>{w.onChange({data:L,valid:N,errors:B,isValid:D});const e=z?.({errors:B,isValidating:!0});e?.action===p&&q&&a(H.current,"issuer-list")},[L,N,B,D]);const{highlightedItems:Y}=v.reduce((e,s)=>(_.includes(s.id)&&e.highlightedItems.push({...s}),e),{highlightedItems:[]});return e("div",{ref:H,className:"adyen-checkout__issuer-list"},!!Y.length&&e(s,null,e(u,{selectedIssuerId:0===$?L.issuer:null,items:Y,onChange:J(0)}),e(m,null)),e(l,{label:k??R.get("issuerList.selectField.label"),errorMessage:(Z=B.issuer,Z&&Z.errorMessage?R.get(Z.errorMessage):!!Z),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:M,contextualText:E},e(h,{items:v,selectedValue:1===$?L.issuer:null,placeholder:A,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:J(1),onListToggle:Q,onInput:W})),w.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(g,{message:R.get(w.termsAndConditions.translationKey),urls:w.termsAndConditions.urls})),w.payButton({status:P,label:S({issuer:L.issuer,items:[...v,...Y]},R)}));var Z}v.defaultProps={onChange:()=>{}};export{v as default};
2
2
  //# sourceMappingURL=IssuerList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\n\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './IssuerList.scss';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: Readonly<IssuerListProps>) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n const issuerListRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(issuerListRef.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","issuerListRef","showValidation","useEffect","setComponentRef","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","highlightedItems","reduce","memo","item","includes","push","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"8gCAwBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC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AA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbT,KAAM,SACNiF,UAAW,wCACXf,SAAU9B,EAAAA,GACVwD,aAAcxC,EACdyC,QAASnC,KAIhB5C,EAAMgF,oBACHhB,EAACC,MAAAA,CAAIE,UAAU,mDACXH,EAACiB,EAAAA,CAAkBC,QAASrG,EAAKM,IAAIa,EAAMgF,mBAAmBG,gBAAiBC,KAAMpF,EAAMgF,mBAAmBI,QAIrHpF,EAAMqF,eACHrF,EAAMsF,UAAU,CACZ3E,SACA8D,MAAO/F,EAAe,CAAEC,OAAQyB,EAAK,OAAWxB,MAAO,IAAIA,KAAU8E,IAAqB7E,MAhHlF6F,IAAAA,CAoH5B,CAEAhF,EAAW6F,aAAe,CACtBnC,SAAU"}
1
+ {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\n\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport { ANALYTICS_SEARCH_DEBOUNCE_TIME } from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent, InfoEventType, UiTarget } from '../../../core/Analytics/events/AnalyticsInfoEvent';\nimport { ComponentMethodsRef } from '../UIElement/types';\nimport './IssuerList.scss';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({\n items,\n placeholder,\n issuer,\n highlightedIds = [],\n showContextualElement,\n contextualText,\n selectFieldLabel,\n ...props\n}: Readonly<IssuerListProps>) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? UiTarget.list : UiTarget.featuredIssuer;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.selected,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor, props.type]\n );\n\n const handleListToggle = useCallback(\n (isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n component: props.type,\n type: InfoEventType.displayed,\n target: UiTarget.list\n });\n props.onSubmitAnalytics(event);\n }\n },\n [props.type, props.onSubmitAnalytics]\n );\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: InfoEventType.input, target: UiTarget.listSearch });\n }, []);\n\n const issuerListRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus,\n showValidation: () => {\n triggerValidation();\n }\n });\n\n useEffect(() => {\n props.setComponentRef(issuerListRef.current);\n }, [props.setComponentRef]);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField(containerRef.current, 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div ref={containerRef} className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={selectFieldLabel ?? i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","selectFieldLabel","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","containerRef","useRef","handleInputChange","useCallback","type","event","target","UiTarget","list","featuredIssuer","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","component","InfoEventType","selected","onSubmitAnalytics","handleListToggle","isOpen","displayed","debounceSearchAnalytics","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","input","listSearch","issuerListRef","showValidation","useEffect","setComponentRef","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","highlightedItems","reduce","memo","item","includes","push","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","payButton","defaultProps"],"mappings":"8gCAwBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACvC,MAAMC,EAAaF,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,IAASO,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL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hB5C,EAAMgF,oBACHhB,EAACC,MAAAA,CAAIE,UAAU,mDACXH,EAACiB,EAAAA,CAAkBC,QAASrG,EAAKM,IAAIa,EAAMgF,mBAAmBG,gBAAiBC,KAAMpF,EAAMgF,mBAAmBI,QAIrHpF,EAAMqF,UAAU,CACb1E,SACA8D,MAAO/F,EAAe,CAAEC,OAAQyB,EAAK,OAAWxB,MAAO,IAAIA,KAAU8E,IAAqB7E,MA/G9E6F,IAAAA,CAmH5B,CAEAhF,EAAW4F,aAAe,CACtBlC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useState as o,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../_virtual/index.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import a from"../CompanyDetails/CompanyDetails.js";import t from"../PersonalDetails/PersonalDetails.js";import l from"../Address/Address.js";import d from"../FormFields/Checkbox/Checkbox.js";import c from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as m,fieldsetsSchema as p,getActiveFieldsData as b}from"./utils.js";import u from"../IbanInput/IbanInput.js";import C from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import h from"./useSRPanelForOpenInvoiceErrors.js";const f={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function A(A){const{countryCode:v,visibility:k}=A,{i18n:g}=n(),x=s(!1),D=s(null),F=m(k,A.data),[j,R]=o(F),{current:w}=s(p.reduce((e,s)=>(e[s]=e=>{w[s].current=e},e),{})),E=!!A.consentCheckboxLabel,I=!E&&Object.keys(j).every(e=>!j[e]),S="editable"===k.deliveryAddress&&"hidden"!==k.billingAddress,[V,q]=o({...A.data,...E&&{consentCheckbox:!1}}),[P,M]=o({}),[N,_]=o({}),[L,O]=o("ready"),B=s({setStatus:O,showValidation:()=>{}});B.current.showValidation=()=>{x.current=!0,p.forEach(e=>{w[e].current&&w[e].current.showValidation()}),M({...E&&{consentCheckbox:V.consentCheckbox?null:f}})},r(()=>{A.setComponentRef?.(B.current)},[A.setComponentRef]),h({errors:P,data:V,props:A,isValidating:x,containerRef:D}),r(()=>{const e=Object.keys(j).every(e=>!j[e]||!!N[e]),s=!E||!!N.consentCheckbox,o=e&&s,r=b(j,V);A.onChange({data:r,errors:P,valid:N,isValid:o})},[V,j]);const z=e=>s=>{q(o=>({...o,[e]:s.data})),_(o=>({...o,[e]:s.isValid})),M(o=>({...o,[e]:s.errors}))};return e("div",{ref:D,className:i({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===L})},e(y,null),j.companyDetails&&e(a,{data:A.data.companyDetails,label:"companyDetails",onChange:z("companyDetails"),setComponentRef:w.companyDetails,visibility:k.companyDetails}),j.personalDetails&&e(t,{data:A.data.personalDetails,requiredFields:A.personalDetailsRequiredFields,label:"personalDetails",onChange:z("personalDetails"),setComponentRef:w.personalDetails,visibility:k.personalDetails}),j.bankAccount&&e(u,{holderName:!0,label:"ach.bankAccount",data:V.bankAccount,onChange:z("bankAccount"),ref:w.bankAccount}),j.billingAddress&&e(l,{allowedCountries:A?.billingAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.billingAddressRequiredFields,specifications:A.billingAddressSpecification,data:V.billingAddress,label:"billingAddress",onChange:z("billingAddress"),setComponentRef:w.billingAddress,visibility:k.billingAddress}),S&&e(C,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(d,{label:g.get("separateDeliveryAddress"),checked:j.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{R(e=>({...e,deliveryAddress:!j.deliveryAddress}))}})),j.deliveryAddress&&e(l,{allowedCountries:A?.deliveryAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.deliveryAddressRequiredFields,specifications:A.deliveryAddressSpecification,data:V.deliveryAddress,label:"deliveryAddress",onChange:z("deliveryAddress"),setComponentRef:w.deliveryAddress,visibility:k.deliveryAddress}),E&&e(c,{data:V,errorMessage:!!P.consentCheckbox,label:A.consentCheckboxLabel,onChange:e=>{const{checked:s}=e.target;q(e=>({...e,consentCheckbox:s})),_(e=>({...e,consentCheckbox:s})),M(e=>({...e,consentCheckbox:s?null:f}))},i18n:g}),A.showPayButton&&A.payButton({status:L,classNameModifiers:[...I?["standalone"]:[]],label:g.get("confirmPurchase")}))}export{A as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as s,useState as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../_virtual/index.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import a from"../CompanyDetails/CompanyDetails.js";import t from"../PersonalDetails/PersonalDetails.js";import l from"../Address/Address.js";import d from"../FormFields/Checkbox/Checkbox.js";import c from"../FormFields/ConsentCheckbox/ConsentCheckbox.js";import{getInitialActiveFieldsets as m,fieldsetsSchema as p,getActiveFieldsData as b}from"./utils.js";import u from"../IbanInput/IbanInput.js";import C from"../FormFields/Field/Field.js";import y from"../FormInstruction/FormInstruction.js";import h from"./useSRPanelForOpenInvoiceErrors.js";const f={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function A(A){const{countryCode:v,visibility:k}=A,{i18n:g}=n(),x=s(!1),D=s(null),F=m(k,A.data),[j,R]=r(F),{current:w}=s(p.reduce((e,s)=>(e[s]=e=>{w[s].current=e},e),{})),E=!!A.consentCheckboxLabel,I=!E&&Object.keys(j).every(e=>!j[e]),S="editable"===k.deliveryAddress&&"hidden"!==k.billingAddress,[V,q]=r({...A.data,...E&&{consentCheckbox:!1}}),[M,N]=r({}),[P,_]=r({}),[L,O]=r("ready"),B=s({setStatus:O,showValidation:()=>{}});B.current.showValidation=()=>{x.current=!0,p.forEach(e=>{w[e].current&&w[e].current.showValidation()}),N({...E&&{consentCheckbox:V.consentCheckbox?null:f}})},o(()=>{A.setComponentRef?.(B.current)},[A.setComponentRef]),h({errors:M,data:V,props:A,isValidating:x,containerRef:D}),o(()=>{const e=Object.keys(j).every(e=>!j[e]||!!P[e]),s=!E||!!P.consentCheckbox,r=e&&s,o=b(j,V);A.onChange({data:o,errors:M,valid:P,isValid:r})},[V,j]);const z=e=>s=>{q(r=>({...r,[e]:s.data})),_(r=>({...r,[e]:s.isValid})),N(r=>({...r,[e]:s.errors}))};return e("div",{ref:D,className:i({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===L})},e(y,null),j.companyDetails&&e(a,{data:A.data.companyDetails,label:"companyDetails",onChange:z("companyDetails"),setComponentRef:w.companyDetails,visibility:k.companyDetails}),j.personalDetails&&e(t,{data:A.data.personalDetails,requiredFields:A.personalDetailsRequiredFields,label:"personalDetails",onChange:z("personalDetails"),setComponentRef:w.personalDetails,visibility:k.personalDetails}),j.bankAccount&&e(u,{holderName:!0,label:"ach.bankAccount",data:V.bankAccount,onChange:z("bankAccount"),ref:w.bankAccount}),j.billingAddress&&e(l,{allowedCountries:A?.billingAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.billingAddressRequiredFields,specifications:A.billingAddressSpecification,data:V.billingAddress,label:"billingAddress",onChange:z("billingAddress"),setComponentRef:w.billingAddress,visibility:k.billingAddress}),S&&e(C,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(d,{label:g.get("separateDeliveryAddress"),checked:j.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{R(e=>({...e,deliveryAddress:!j.deliveryAddress}))}})),j.deliveryAddress&&e(l,{allowedCountries:A?.deliveryAddressSpecification?.allowedCountries??A.allowedCountries,countryCode:v,requiredFields:A.deliveryAddressRequiredFields,specifications:A.deliveryAddressSpecification,data:V.deliveryAddress,label:"deliveryAddress",onChange:z("deliveryAddress"),setComponentRef:w.deliveryAddress,visibility:k.deliveryAddress}),E&&e(c,{data:V,errorMessage:!!M.consentCheckbox,label:A.consentCheckboxLabel,onChange:e=>{const{checked:s}=e.target;q(e=>({...e,consentCheckbox:s})),_(e=>({...e,consentCheckbox:s})),N(e=>({...e,consentCheckbox:s?null:f}))},i18n:g}),A.payButton({status:L,classNameModifiers:[...I?["standalone"]:[]],label:g.get("confirmPurchase")}))}export{A as default};
2
2
  //# sourceMappingURL=OpenInvoice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenInvoice.js","sources":["../../../../../src/components/internal/OpenInvoice/OpenInvoice.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport classNames from 'classnames';\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 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';\nimport './OpenInvoice.scss';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n const isValidating = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\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 const openInvoiceRef = useRef<ComponentMethodsRef>({\n setStatus,\n showValidation: () => {}\n });\n\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 useEffect(() => {\n props.setComponentRef?.(openInvoiceRef.current);\n }, [props.setComponentRef]);\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating, containerRef });\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\n ref={containerRef}\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\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","isValidating","useRef","containerRef","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","current","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","Object","keys","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","openInvoiceRef","showValidation","forEach","useEffect","setComponentRef","useSRPanelForOpenInvoiceErrors","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","classNames","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":"6zBA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAEXC,EAAeC,GAAO,GACtBC,EAAeD,EAAuB,MAEtCE,EAAqDC,EAA0BP,EAAYF,EAAMU,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EM,QAASC,GAAkBT,EAC/BU,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUL,QAAUM,GAE/BF,GACR,CAAA,IAIDG,IAAuBrB,EAAMsB,qBAC7BC,GAAsBF,GAAsBG,OAAOC,KAAKd,GAAiBe,MAAMC,IAAQhB,EAAgBgB,IACvGC,EAAqE,aAA/B1B,EAAW2B,iBAAgE,WAA9B3B,EAAW4B,gBAE7FpB,EAAMqB,GAAWlB,EAA+B,IAChDb,EAAMU,QACLW,GAAsB,CAAEW,iBAAiB,MAE1CC,EAAQC,GAAarB,EAAgC,CAAA,IACrDsB,EAAOC,GAAYvB,EAAgC,CAAA,IACnDwB,EAAQC,GAAazB,EAAS,SAE/B0B,EAAiBjC,EAA4B,CAC/CgC,YACAE,eAAgB,SAGpBD,EAAezB,QAAQ0B,eAAiB,KACpCnC,EAAaS,SAAU,EACvBE,EAAgByB,QAAQtB,IAChBJ,EAAcI,GAAUL,SAASC,EAAcI,GAAUL,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HzF,EAAM0F,UAAU,CACZrD,SACAuC,mBAAoB,IAAKrD,EAAqB,CAAC,cAAgB,IAC/DuC,MAAO3D,EAAK8E,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 classNames from 'classnames';\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 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';\nimport './OpenInvoice.scss';\n\nconst consentCBErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'consent.checkbox.invalid',\n error: 'consent.checkbox.invalid'\n};\n\nexport default function OpenInvoice(props: Readonly<OpenInvoiceProps>) {\n const { countryCode, visibility } = props;\n const { i18n } = useCoreContext();\n\n const isValidating = useRef(false);\n const containerRef = useRef<HTMLDivElement>(null);\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 const openInvoiceRef = useRef<ComponentMethodsRef>({\n setStatus,\n showValidation: () => {}\n });\n\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 useEffect(() => {\n props.setComponentRef?.(openInvoiceRef.current);\n }, [props.setComponentRef]);\n\n useSRPanelForOpenInvoiceErrors({ errors, data, props, isValidating, containerRef });\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\n ref={containerRef}\n className={classNames({\n 'adyen-checkout__open-invoice': true,\n 'adyen-checkout__open-invoice--loading': status === 'loading'\n })}\n >\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.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","isValidating","useRef","containerRef","initialActiveFieldsets","getInitialActiveFieldsets","data","activeFieldsets","setActiveFieldsets","useState","current","fieldsetsRefs","fieldsetsSchema","reduce","acc","fieldset","ref","hasConsentCheckbox","consentCheckboxLabel","isStandAloneButton","Object","keys","every","key","showSeparateDeliveryAddressCheckbox","deliveryAddress","billingAddress","setData","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","openInvoiceRef","showValidation","forEach","useEffect","setComponentRef","useSRPanelForOpenInvoiceErrors","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","prevValid","prevErrors","h","div","className","classNames","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","payButton"],"mappings":"6zBA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,GAChC,MAAMC,YAAEA,EAAWC,WAAEA,GAAeF,GAC9BG,KAAEA,GAASC,IAEXC,EAAeC,GAAO,GACtBC,EAAeD,EAAuB,MAEtCE,EAAqDC,EAA0BP,EAAYF,EAAMU,OAChGC,EAAiBC,GAAsBC,EAAqCL,IAE3EM,QAASC,GAAkBT,EAC/BU,EAAgBC,OAAO,CAACC,EAAKC,KACzBD,EAAIC,GAAYC,IACZL,EAAcI,GAAUL,QAAUM,GAE/BF,GACR,CAAA,IAIDG,IAAuBrB,EAAMsB,qBAC7BC,GAAsBF,GAAsBG,OAAOC,KAAKd,GAAiBe,MAAMC,IAAQhB,EAAgBgB,IACvGC,EAAqE,aAA/B1B,EAAW2B,iBAAgE,WAA9B3B,EAAW4B,gBAE7FpB,EAAMqB,GAAWlB,EAA+B,IAChDb,EAAMU,QACLW,GAAsB,CAAEW,iBAAiB,MAE1CC,EAAQC,GAAarB,EAAgC,CAAA,IACrDsB,EAAOC,GAAYvB,EAAgC,CAAA,IACnDwB,EAAQC,GAAazB,EAAS,SAE/B0B,EAAiBjC,EAA4B,CAC/CgC,YACAE,eAAgB,SAGpBD,EAAezB,QAAQ0B,eAAiB,KACpCnC,EAAaS,SAAU,EACvBE,EAAgByB,QAAQtB,IAChBJ,EAAcI,GAAUL,SAASC,EAAcI,GAAUL,QAAQ0B,mBAGzEN,EAAU,IACFb,GAAsB,CAAEW,gBAAiBtB,EAAKsB,gBAAkB,KAAOrC,MAInF+C,EAAU,KACN1C,EAAM2C,kBAAkBJ,EAAezB,UACxC,CAACd,EAAM2C,kBAEVC,EAA+B,CAAEX,SAAQvB,OAAMV,QAAOK,eAAcE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AgB1E,EAAMwE,4BACtB9D,KAAMA,EAAKoB,eACXgC,MAAM,iBACNb,SAAUC,EAAe,kBACzBP,gBAAiB5B,EAAce,eAC/B5B,WAAYA,EAAW4B,iBAI9BF,GACG2B,EAACoB,EAAAA,CACGC,mBAAoB,CAAC,0BAA2B,mBAChDC,KAAM,0BACNC,iBAAiB,EACjBC,kBAAkB,GAElBxB,EAACyB,EAAAA,CACGlB,MAAO3D,EAAK8E,IAAI,2BAChBC,QAASvE,EAAgBkB,gBACzB+C,mBAAoB,CAAC,2BACrBC,KAAM,0BACN5B,SAhFkB,KAClCrC,EAAmBuE,QACZA,EACHtD,iBAAkBlB,EAAgBkB,uBAkFjClB,EAAgBkB,iBACb0B,EAACe,EAAAA,CACGC,iBAAkBvE,GAAOoF,8BAA8Bb,kBAAoBvE,EAAMuE,iBACjFtE,YAAaA,EACbgE,eAAgBjE,EAAMqF,8BACtBX,eAAgB1E,EAAMoF,6BACtB1E,KAAMA,EAAKmB,gBACXiC,MAAM,kBACNb,SAAUC,EAAe,mBACzBP,gBAAiB5B,EAAcc,gBAC/B3B,WAAYA,EAAW2B,kBAI9BR,GACGkC,EAAC+B,EAAAA,CACG5E,KAAMA,EACNb,eAAgBoC,EAAOD,gBACvB8B,MAAO9D,EAAMsB,qBACb2B,SAjGcsC,IAC1B,MAAML,QAAEA,GAAYK,EAAEC,OACtBzD,EAAQqB,QAAkBA,EAAUpB,gBAAiBkD,KACrD9C,EAASiB,QAAmBA,EAAWrB,gBAAiBkD,KACxDhD,EAAUoB,QAAoBA,EAAiBtB,gBAAkBkD,EAA8B,KAApBvF,MA8F/DQ,KAAMA,IAIbH,EAAMyF,UAAU,CACbpD,SACAuC,mBAAoB,IAAKrD,EAAqB,CAAC,cAAgB,IAC/DuC,MAAO3D,EAAK8E,IAAI,qBAIhC"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useMemo as s,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as o}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as a}from"../../../core/Errors/constants.js";import c from"../../../core/Errors/useSRPanelContext.js";import n from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as p}from"../../../utils/arrayUtils.js";import{mapFieldKey as f}from"./utils.js";const m=({errors:m,data:y,props:b,isValidating:j,containerRef:F})=>{const[g,A]=e(null),h=u(g),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:C,clearSRPanel:k,shouldMoveFocusSR:v}=c(),D=S?.({fieldTypeMappingFn:f}),R=s(()=>new n,[]),T=s(()=>new n(b.deliveryAddressSpecification),[]);r(()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:r,personalDetails:c,bankAccount:n,billingAddress:u,deliveryAddress:f,...g}=m,S=o(u,s),E=o(f,e),M={..."object"==typeof r&&r,..."object"==typeof c&&c,..."object"==typeof n&&n,..."object"==typeof S&&S,..."object"==typeof E&&E,...g},$=t,x=b.personalDetailsRequiredFields??i,L=i.filter(e=>x?.includes(e)),P=["holder","iban"],w=R.getAddressSchemaForCountryFlat(y.billingAddress?.country).map(e=>`${s}${e}`),U=T.getAddressSchemaForCountryFlat(y.deliveryAddress?.country).map(s=>`${e}${s}`),V=$.concat(L,P,w,U,["consentCheckbox"]),_=R.getAddressLabelsForCountry(y.billingAddress?.country),q=T.getAddressLabelsForCountry(y.deliveryAddress?.country),B=D?.({errors:M,isValidating:j.current,layout:V,countrySpecificLabels:{..._,...q}}),O=B?.currentErrorsSortedByLayout;switch(A(O),B?.action){case a:{const e=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[1]:B.fieldToFocus;let s="";const r=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[0]:"";r.length&&(s=`.adyen-checkout__fieldset--${r} `),v&&F.current&&d(F.current,e,s),setTimeout(()=>{j.current=!1},300);break}case l:{const e=p(O,h,"field"),s=e?.[0];if(s){const e="shopperEmail"===s.field&&"field.error.invalid"===s.errorCode?s.errorMessage:null;C(e)}else k();break}}}catch(e){}},[m,y])};export{m as default};
1
+ import{useState as e,useMemo as s,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as r}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as c}from"../../../core/Errors/constants.js";import n from"../../../core/Errors/useSRPanelContext.js";import a from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as p}from"../../../utils/arrayUtils.js";import{mapFieldKey as f}from"./utils.js";const m=({errors:m,data:y,props:b,isValidating:j,containerRef:F})=>{const[g,h]=e(null),A=u(g),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:C,clearSRPanel:k,shouldMoveFocusSR:v}=n(),x=S?.({fieldTypeMappingFn:f}),D=s(()=>new a,[]),R=s(()=>new a(b.deliveryAddressSpecification),[]);o(()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:o,personalDetails:n,bankAccount:a,billingAddress:u,deliveryAddress:f,...g}=m,S=r(u,s),T=r(f,e),E={..."object"==typeof o&&o,..."object"==typeof n&&n,..."object"==typeof a&&a,..."object"==typeof S&&S,..."object"==typeof T&&T,..."object"==typeof g.consentCheckbox&&{consentCheckbox:g.consentCheckbox}},M=t,$=b.personalDetailsRequiredFields??i,L=i.filter(e=>$?.includes(e)),P=["holder","iban"],w=D.getAddressSchemaForCountryFlat(y.billingAddress?.country).map(e=>`${s}${e}`),U=R.getAddressSchemaForCountryFlat(y.deliveryAddress?.country).map(s=>`${e}${s}`),V=M.concat(L,P,w,U,["consentCheckbox"]),_=D.getAddressLabelsForCountry(y.billingAddress?.country),q=R.getAddressLabelsForCountry(y.deliveryAddress?.country),B=x?.({errors:E,isValidating:j.current,layout:V,countrySpecificLabels:{..._,...q}}),O=B?.currentErrorsSortedByLayout;switch(h(O),B?.action){case c:{const e=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[1]:B.fieldToFocus;let s="";const o=B.fieldToFocus.includes(":")?B.fieldToFocus.split(":")[0]:"";o.length&&(s=`.adyen-checkout__fieldset--${o} `),v&&F.current&&d(F.current,e,s),setTimeout(()=>{j.current=!1},300);break}case l:{const e=p(O,A,"field"),s=e?.[0];if(s){const e="shopperEmail"===s.field&&"field.error.invalid"===s.errorCode?s.errorMessage:null;C(e)}else k();break}}}catch(e){}},[m,y])};export{m as default};
2
2
  //# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map