@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{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import{setFocusOnField as l}from"../../../utils/setFocus.js";import a from"../FormFields/Field/Field.js";import u from"./IssuerButtonGroup/IssuerButtonGroup.js";import c from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as m}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 f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function C(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const x=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],w={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function F(F){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:R}=F,k=C(F,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=m(),{handleChangeFor:V,triggerValidation:L,data:N,valid:B,errors:D,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:w}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=d(),Q=null==H?void 0:H({}),U=r(null),W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:k.type,type:v.selected,target:s,issuer:r.name});k.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,k.type]),X=o(e=>{if(e){const e=new b({component:k.type,type:v.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),Y=r(y(k.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]),ee=r({setStatus:$,showValidation:()=>{L()}});n(()=>{k.setComponentRef(ee.current)},[k.setComponentRef]),n(()=>{k.onChange({data:N,valid:B,errors:D,isValid:K});const e=null==Q?void 0:Q({errors:D,isValidating:!0});(null==e?void 0:e.action)===p&&J&&l(U.current,"issuer-list")},[N,B,D,K]);const{highlightedItems:te}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(u,{selectedIssuerId:0===q?N.issuer:null,items:te,onChange:W(0)}),e(c,null)),e(a,{label:null!=R?R:T.get("issuerList.selectField.label"),errorMessage:(se=D.issuer,se&&se.errorMessage?T.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.showPayButton&&k.payButton({status:G,label:x({issuer:N.issuer,items:[...I,...te]},T)}));var se}F.defaultProps={onChange:()=>{}};export{F as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useRef as r,useCallback as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import{setFocusOnField as l}from"../../../utils/setFocus.js";import a from"../FormFields/Field/Field.js";import u from"./IssuerButtonGroup/IssuerButtonGroup.js";import c from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as m}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 f from"../DisclaimerMessage/DisclaimerMessage.js";import g from"../FormFields/Select/Select.js";import{ANALYTICS_SEARCH_DEBOUNCE_TIME as h}from"../../../core/Analytics/constants.js";import{debounce as y}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as b,UiTarget as j,InfoEventType as v}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";function O(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function C(e,t){if(null==e)return{};var s,r,o,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(s=Reflect.ownKeys(Object(e)),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}if(n=function(e,t){if(null==e)return{};var s,r,o={},n=Object.getOwnPropertyNames(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s]);return o}(e,t),Object.getOwnPropertySymbols)for(s=Object.getOwnPropertySymbols(e),o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}const x=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find(t=>t.id===e))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},S=["issuer"],F={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function w(w){let{items:I,placeholder:E,issuer:A,highlightedIds:P=[],showContextualElement:_,contextualText:M,selectFieldLabel:R}=w,k=C(w,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText","selectFieldLabel"]);const{i18n:T}=m(),{handleChangeFor:V,triggerValidation:L,data:N,valid:D,errors:B,isValid:K}=i({schema:S,defaultData:{issuer:A},rules:F}),[G,$]=s("ready"),[q,z]=s(1),{setSRMessagesFromObjects:H,shouldMoveFocusSR:J}=d(),Q=null==H?void 0:H({}),U=r(null),W=o(e=>t=>{const s=1===e?j.list:j.featuredIssuer,r=I.find(e=>e.id===t.target.value),o=new b({component:k.type,type:v.selected,target:s,issuer:r.name});k.onSubmitAnalytics(o),z(e),V("issuer")(t)},[V,k.type]),X=o(e=>{if(e){const e=new b({component:k.type,type:v.displayed,target:j.list});k.onSubmitAnalytics(e)}},[k.type,k.onSubmitAnalytics]),Y=r(y(k.onSubmitAnalytics,h)),Z=o(()=>{Y.current({type:v.input,target:j.listSearch})},[]),ee=r({setStatus:$,showValidation:()=>{L()}});n(()=>{k.setComponentRef(ee.current)},[k.setComponentRef]),n(()=>{k.onChange({data:N,valid:D,errors:B,isValid:K});const e=null==Q?void 0:Q({errors:B,isValidating:!0});(null==e?void 0:e.action)===p&&J&&l(U.current,"issuer-list")},[N,D,B,K]);const{highlightedItems:te}=I.reduce((e,t)=>(P.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),r.forEach(function(t){O(e,t,s[t])})}return e}({},t)),e),{highlightedItems:[]});return e("div",{ref:U,className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(u,{selectedIssuerId:0===q?N.issuer:null,items:te,onChange:W(0)}),e(c,null)),e(a,{label:null!=R?R:T.get("issuerList.selectField.label"),errorMessage:(se=B.issuer,se&&se.errorMessage?T.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:_,contextualText:M},e(g,{items:I,selectedValue:1===q?N.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:W(1),onListToggle:X,onInput:Z})),k.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:T.get(k.termsAndConditions.translationKey),urls:k.termsAndConditions.urls})),k.payButton({status:G,label:x({issuer:N.issuer,items:[...I,...te]},T)}));var se}w.defaultProps={onChange:()=>{}};export{w 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","_0","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","_object_spread","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":"+vDAwBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf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A,CAAkBC,QAASvG,EAAKM,IAAIc,EAAMiF,mBAAmBG,gBAAiBC,KAAMrF,EAAMiF,mBAAmBI,QAIrHrF,EAAMsF,eACHtF,EAAMuF,UAAU,CACZ5E,SACA+D,MAAOjG,EAAe,CAAEC,OAAQ0B,EAAK,OAAWzB,MAAO,IAAIA,KAAU+E,KAAqB9E,MAhHlF+F,IAAAA,EAoH5B,CAEAlF,EAAW+F,aAAe,CACtBpC,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","_0","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","_object_spread","h","div","ref","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","payButton","defaultProps"],"mappings":"+vDAwBA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAsCH,QAAzBC,EAAAA,EAAMG,KAAKC,GAAKA,EAAEC,KAAON,UAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,aAI1CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,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,EAAMiF,oBACHhB,EAACC,MAAAA,CAAIE,UAAU,mDACXH,EAACiB,EAAAA,CAAkBC,QAASvG,EAAKM,IAAIc,EAAMiF,mBAAmBG,gBAAiBC,KAAMrF,EAAMiF,mBAAmBI,QAIrHrF,EAAMsF,UAAU,CACb3E,SACA+D,MAAOjG,EAAe,CAAEC,OAAQ0B,EAAK,OAAWzB,MAAO,IAAIA,KAAU+E,KAAqB9E,MA/G9E+F,IAAAA,EAmH5B,CAEAlF,EAAW8F,aAAe,CACtBnC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useEffect as s}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import i from"../CompanyDetails/CompanyDetails.js";import a 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 u,fieldsetsSchema as p,getActiveFieldsData as b}from"./utils.js";import m from"../IbanInput/IbanInput.js";import y from"../FormFields/Field/Field.js";import f from"../FormInstruction/FormInstruction.js";import v from"./useSRPanelForOpenInvoiceErrors.js";function h(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function C(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},s=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),s.forEach(function(r){h(e,r,o[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j,D,O;const{countryCode:x,visibility:w}=h,{i18n:F}=t(),P=r(!1),R=r(null),S=u(w,h.data),[E,I]=o(S),{current:V}=r(p.reduce((e,r)=>(e[r]=e=>{V[r].current=e},e),{})),q=!!h.consentCheckboxLabel,M=!q&&Object.keys(E).every(e=>!E[e]),N="editable"===w.deliveryAddress&&"hidden"!==w.billingAddress,[_,L]=o(C({},h.data,q&&{consentCheckbox:!1})),[B,z]=o({}),[G,H]=o({}),[J,K]=o("ready"),Q=r({setStatus:K,showValidation:()=>{}});Q.current.showValidation=()=>{P.current=!0,p.forEach(e=>{V[e].current&&V[e].current.showValidation()}),z(C({},q&&{consentCheckbox:_.consentCheckbox?null:A}))},s(()=>{var e;null===(e=h.setComponentRef)||void 0===e||e.call(h,Q.current)},[h.setComponentRef]),v({errors:B,data:_,props:h,isValidating:P,containerRef:R}),s(()=>{const e=Object.keys(E).every(e=>!E[e]||!!G[e]),r=!q||!!G.consentCheckbox,o=e&&r,s=b(E,_);h.onChange({data:s,errors:B,valid:G,isValid:o})},[_,E]);const T=e=>r=>{L(o=>g(C({},o),{[e]:r.data})),H(o=>g(C({},o),{[e]:r.isValid})),z(o=>g(C({},o),{[e]:r.errors}))};return e("div",{ref:R,className:n({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===J})},e(f,null),E.companyDetails&&e(i,{data:h.data.companyDetails,label:"companyDetails",onChange:T("companyDetails"),setComponentRef:V.companyDetails,visibility:w.companyDetails}),E.personalDetails&&e(a,{data:h.data.personalDetails,requiredFields:h.personalDetailsRequiredFields,label:"personalDetails",onChange:T("personalDetails"),setComponentRef:V.personalDetails,visibility:w.personalDetails}),E.bankAccount&&e(m,{holderName:!0,label:"ach.bankAccount",data:_.bankAccount,onChange:T("bankAccount"),ref:V.bankAccount}),E.billingAddress&&e(l,{allowedCountries:null!==(k=null==h||null===(D=h.billingAddressSpecification)||void 0===D?void 0:D.allowedCountries)&&void 0!==k?k:h.allowedCountries,countryCode:x,requiredFields:h.billingAddressRequiredFields,specifications:h.billingAddressSpecification,data:_.billingAddress,label:"billingAddress",onChange:T("billingAddress"),setComponentRef:V.billingAddress,visibility:w.billingAddress}),N&&e(y,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(d,{label:F.get("separateDeliveryAddress"),checked:E.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{I(e=>g(C({},e),{deliveryAddress:!E.deliveryAddress}))}})),E.deliveryAddress&&e(l,{allowedCountries:null!==(j=null==h||null===(O=h.deliveryAddressSpecification)||void 0===O?void 0:O.allowedCountries)&&void 0!==j?j:h.allowedCountries,countryCode:x,requiredFields:h.deliveryAddressRequiredFields,specifications:h.deliveryAddressSpecification,data:_.deliveryAddress,label:"deliveryAddress",onChange:T("deliveryAddress"),setComponentRef:V.deliveryAddress,visibility:w.deliveryAddress}),q&&e(c,{data:_,errorMessage:!!B.consentCheckbox,label:h.consentCheckboxLabel,onChange:e=>{const{checked:r}=e.target;L(e=>g(C({},e),{consentCheckbox:r})),H(e=>g(C({},e),{consentCheckbox:r})),z(e=>C({},e,{consentCheckbox:r?null:A}))},i18n:F}),h.showPayButton&&h.payButton({status:J,classNameModifiers:[...M?["standalone"]:[]],label:F.get("confirmPurchase")}))}export{k as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useEffect as s}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../_virtual/index.js";import{useCoreContext as t}from"../../../core/Context/CoreProvider.js";import i from"../CompanyDetails/CompanyDetails.js";import a 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 u,fieldsetsSchema as p,getActiveFieldsData as b}from"./utils.js";import m from"../IbanInput/IbanInput.js";import y from"../FormFields/Field/Field.js";import f from"../FormInstruction/FormInstruction.js";import v from"./useSRPanelForOpenInvoiceErrors.js";function h(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function C(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},s=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),s.forEach(function(r){h(e,r,o[r])})}return e}function g(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r}(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))}),e}const A={isValid:!1,errorMessage:"consent.checkbox.invalid",error:"consent.checkbox.invalid"};function k(h){var k,j,D,O;const{countryCode:x,visibility:w}=h,{i18n:F}=t(),P=r(!1),R=r(null),S=u(w,h.data),[E,I]=o(S),{current:V}=r(p.reduce((e,r)=>(e[r]=e=>{V[r].current=e},e),{})),q=!!h.consentCheckboxLabel,M=!q&&Object.keys(E).every(e=>!E[e]),N="editable"===w.deliveryAddress&&"hidden"!==w.billingAddress,[_,L]=o(C({},h.data,q&&{consentCheckbox:!1})),[B,z]=o({}),[G,H]=o({}),[J,K]=o("ready"),Q=r({setStatus:K,showValidation:()=>{}});Q.current.showValidation=()=>{P.current=!0,p.forEach(e=>{V[e].current&&V[e].current.showValidation()}),z(C({},q&&{consentCheckbox:_.consentCheckbox?null:A}))},s(()=>{var e;null===(e=h.setComponentRef)||void 0===e||e.call(h,Q.current)},[h.setComponentRef]),v({errors:B,data:_,props:h,isValidating:P,containerRef:R}),s(()=>{const e=Object.keys(E).every(e=>!E[e]||!!G[e]),r=!q||!!G.consentCheckbox,o=e&&r,s=b(E,_);h.onChange({data:s,errors:B,valid:G,isValid:o})},[_,E]);const T=e=>r=>{L(o=>g(C({},o),{[e]:r.data})),H(o=>g(C({},o),{[e]:r.isValid})),z(o=>g(C({},o),{[e]:r.errors}))};return e("div",{ref:R,className:n({"adyen-checkout__open-invoice":!0,"adyen-checkout__open-invoice--loading":"loading"===J})},e(f,null),E.companyDetails&&e(i,{data:h.data.companyDetails,label:"companyDetails",onChange:T("companyDetails"),setComponentRef:V.companyDetails,visibility:w.companyDetails}),E.personalDetails&&e(a,{data:h.data.personalDetails,requiredFields:h.personalDetailsRequiredFields,label:"personalDetails",onChange:T("personalDetails"),setComponentRef:V.personalDetails,visibility:w.personalDetails}),E.bankAccount&&e(m,{holderName:!0,label:"ach.bankAccount",data:_.bankAccount,onChange:T("bankAccount"),ref:V.bankAccount}),E.billingAddress&&e(l,{allowedCountries:null!==(k=null==h||null===(D=h.billingAddressSpecification)||void 0===D?void 0:D.allowedCountries)&&void 0!==k?k:h.allowedCountries,countryCode:x,requiredFields:h.billingAddressRequiredFields,specifications:h.billingAddressSpecification,data:_.billingAddress,label:"billingAddress",onChange:T("billingAddress"),setComponentRef:V.billingAddress,visibility:w.billingAddress}),N&&e(y,{classNameModifiers:["separateDeliveryAddress","consentCheckbox"],name:"separateDeliveryAddress",useLabelElement:!1,showErrorElement:!1},e(d,{label:F.get("separateDeliveryAddress"),checked:E.deliveryAddress,classNameModifiers:["separateDeliveryAddress"],name:"separateDeliveryAddress",onChange:()=>{I(e=>g(C({},e),{deliveryAddress:!E.deliveryAddress}))}})),E.deliveryAddress&&e(l,{allowedCountries:null!==(j=null==h||null===(O=h.deliveryAddressSpecification)||void 0===O?void 0:O.allowedCountries)&&void 0!==j?j:h.allowedCountries,countryCode:x,requiredFields:h.deliveryAddressRequiredFields,specifications:h.deliveryAddressSpecification,data:_.deliveryAddress,label:"deliveryAddress",onChange:T("deliveryAddress"),setComponentRef:V.deliveryAddress,visibility:w.deliveryAddress}),q&&e(c,{data:_,errorMessage:!!B.consentCheckbox,label:h.consentCheckboxLabel,onChange:e=>{const{checked:r}=e.target;L(e=>g(C({},e),{consentCheckbox:r})),H(e=>g(C({},e),{consentCheckbox:r})),z(e=>C({},e,{consentCheckbox:r?null:A}))},i18n:F}),h.payButton({status:J,classNameModifiers:[...M?["standalone"]:[]],label:F.get("confirmPurchase")}))}export{k 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","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","openInvoiceRef","showValidation","forEach","useEffect","setComponentRef","useSRPanelForOpenInvoiceErrors","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","_ref","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","_ref1","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","showPayButton","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,WA4HEA,EA+BAA,EA1JlC,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+BmB,EAAA,GAChDhC,EAAMU,KACLW,GAAsB,CAAEY,iBAAiB,MAE1CC,EAAQC,GAAatB,EAAgC,CAAA,IACrDuB,EAAOC,GAAYxB,EAAgC,CAAA,IACnDyB,EAAQC,GAAa1B,EAAS,SAE/B2B,EAAiBlC,EAA4B,CAC/Ci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E,YAAaA,EACbkE,eAAgBnE,EAAMyF,8BACtBZ,eAAgB7E,EAAMwF,6BACtB9E,KAAMA,EAAKmB,gBACXmC,MAAM,kBACNd,SAAUC,EAAe,mBACzBP,gBAAiB7B,EAAcc,gBAC/B3B,WAAYA,EAAW2B,kBAI9BR,GACGoC,EAACiC,EAAAA,CACGhF,KAAMA,EACNb,eAAgBqC,EAAOD,gBACvB+B,MAAOhE,EAAMsB,qBACb4B,SAjGcyC,IAC1B,MAAMN,QAAEA,GAAYM,EAAEC,OACtB7D,EAAQsB,GAAaC,EAAAtB,EAAA,CAAA,EAAKqB,GAAAA,CAAUpB,gBAAiBoD,KACrDhD,EAASkB,GAAcD,EAAAtB,EAAA,CAAA,EAAKuB,GAAAA,CAAWtB,gBAAiBoD,KACxDlD,EAAUqB,GAAexB,EAAA,CAAA,EAAKwB,EAAe,CAAEvB,gBAAkBoD,EAA8B,KAApB1F,MA8F/DQ,KAAMA,IAIbH,EAAM6F,eACH7F,EAAM8F,UAAU,CACZxD,SACAyC,mBAAoB,IAAKxD,EAAqB,CAAC,cAAgB,IAC/DyC,MAAO7D,EAAKiF,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","_object_spread","consentCheckbox","errors","setErrors","valid","setValid","status","setStatus","openInvoiceRef","showValidation","forEach","useEffect","setComponentRef","useSRPanelForOpenInvoiceErrors","fieldsetsAreValid","consentCheckboxValid","newData","getActiveFieldsData","onChange","handleFieldset","state","prevData","_object_spread_props","prevValid","prevErrors","h","div","className","classNames","FormInstruction","companyDetails","CompanyDetails","label","personalDetails","PersonalDetails","requiredFields","personalDetailsRequiredFields","bankAccount","IbanInput","holderName","Address","allowedCountries","_ref","billingAddressSpecification","billingAddressRequiredFields","specifications","Field","classNameModifiers","name","useLabelElement","showErrorElement","Checkbox","get","checked","prevActiveFields","_ref1","deliveryAddressSpecification","deliveryAddressRequiredFields","ConsentCheckbox","e","target","payButton"],"mappings":"smDA0BA,MAAMA,EAAkC,CACpCC,SAAS,EACTC,aAAc,2BACdC,MAAO,4BAGI,SAASC,EAAYC,WA4HEA,EA+BAA,EA1JlC,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,KAA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BAAoB,CAAC,2BACrBC,KAAM,0BACN9B,SAhFkB,KAClCtC,EAAmB0E,GAAqBhC,EAAAtB,EAAA,CAAA,EACjCsD,GAAAA,CACHzD,iBAAkBlB,EAAgBkB,uBAkFjClB,EAAgBkB,iBACb4B,EAACe,EAAAA,CACGC,iBAAuE,QAAvDc,EAAEvF,SAAmC,QAAnCA,EAAAA,EAAOwF,oCAAPxF,IAAAA,SAAAA,EAAqCyE,wBAAgB,IAAAc,EAAAA,EAAIvF,EAAMyE,iBACjFxE,YAAaA,EACbkE,eAAgBnE,EAAMyF,8BACtBZ,eAAgB7E,EAAMwF,6BACtB9E,KAAMA,EAAKmB,gBACXmC,MAAM,kBACNd,SAAUC,EAAe,mBACzBP,gBAAiB7B,EAAcc,gBAC/B3B,WAAYA,EAAW2B,kBAI9BR,GACGoC,EAACiC,EAAAA,CACGhF,KAAMA,EACNb,eAAgBqC,EAAOD,gBACvB+B,MAAOhE,EAAMsB,qBACb4B,SAjGcyC,IAC1B,MAAMN,QAAEA,GAAYM,EAAEC,OACtB7D,EAAQsB,GAAaC,EAAAtB,EAAA,CAAA,EAAKqB,GAAAA,CAAUpB,gBAAiBoD,KACrDhD,EAASkB,GAAcD,EAAAtB,EAAA,CAAA,EAAKuB,GAAAA,CAAWtB,gBAAiBoD,KACxDlD,EAAUqB,GAAexB,EAAA,CAAA,EAAKwB,EAAe,CAAEvB,gBAAkBoD,EAA8B,KAApB1F,MA8F/DQ,KAAMA,IAIbH,EAAM6F,UAAU,CACbvD,SACAyC,mBAAoB,IAAKxD,EAAqB,CAAC,cAAgB,IAC/DyC,MAAO7D,EAAKiF,IAAI,qBAIhC"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as l}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as n,ERROR_ACTION_FOCUS_FIELD as i}from"../../../core/Errors/constants.js";import c 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 f}from"../../../utils/arrayUtils.js";import{mapFieldKey as p}from"./utils.js";function y(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function m(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(r){y(e,r,o[r])})}return e}function b(e,r){if(null==e)return{};var o,t,s,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(e)),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}if(l=function(e,r){if(null==e)return{};var o,t,s={},l=Object.getOwnPropertyNames(e);for(t=0;t<l.length;t++)o=l[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}(e,r),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}const j=({errors:y,data:j,props:v,isValidating:g,containerRef:O})=>{const[h,A]=e(null),F=u(h),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:w,clearSRPanel:P,shouldMoveFocusSR:k}=c(),D=null==S?void 0:S({fieldTypeMappingFn:p}),E=r(()=>new a,[]),R=r(()=>new a(v.deliveryAddressSpecification),[]);o(()=>{try{var e,r,o,c,a;const u="deliveryAddress:",p="billingAddress:",{companyDetails:h,personalDetails:S,bankAccount:C,billingAddress:x,deliveryAddress:T}=y,M=b(y,["companyDetails","personalDetails","bankAccount","billingAddress","deliveryAddress"]),$=t(x,p),L=t(T,u),I=m({},"object"==typeof h&&h,"object"==typeof S&&S,"object"==typeof C&&C,"object"==typeof $&&$,"object"==typeof L&&L,M),K=s,U=null!==(e=v.personalDetailsRequiredFields)&&void 0!==e?e:l,V=l.filter(e=>null==U?void 0:U.includes(e)),_=["holder","iban"],q=E.getAddressSchemaForCountryFlat(null===(r=j.billingAddress)||void 0===r?void 0:r.country).map(e=>`${p}${e}`),B=R.getAddressSchemaForCountryFlat(null===(o=j.deliveryAddress)||void 0===o?void 0:o.country).map(e=>`${u}${e}`),N=K.concat(V,_,q,B,["consentCheckbox"]),z=E.getAddressLabelsForCountry(null===(c=j.billingAddress)||void 0===c?void 0:c.country),G=R.getAddressLabelsForCountry(null===(a=j.deliveryAddress)||void 0===a?void 0:a.country),H=null==D?void 0:D({errors:I,isValidating:g.current,layout:N,countrySpecificLabels:m({},z,G)}),J=null==H?void 0:H.currentErrorsSortedByLayout;switch(A(J),null==H?void 0:H.action){case i:{const e=H.fieldToFocus.includes(":")?H.fieldToFocus.split(":")[1]:H.fieldToFocus;let r="";const o=H.fieldToFocus.includes(":")?H.fieldToFocus.split(":")[0]:"";o.length&&(r=`.adyen-checkout__fieldset--${o} `),k&&O.current&&d(O.current,e,r),setTimeout(()=>{g.current=!1},300);break}case n:{const e=f(J,F,"field"),r=null==e?void 0:e[0];if(r){const e="shopperEmail"===r.field&&"field.error.invalid"===r.errorCode?r.errorMessage:null;w(e)}else P();break}}}catch(e){}},[y,j])};export{j as default};
1
+ import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as n}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as i}from"../../../core/Errors/constants.js";import c 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 f}from"../../../utils/arrayUtils.js";import{mapFieldKey as p}from"./utils.js";function y(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function b(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(r){y(e,r,o[r])})}return e}function m(e,r){if(null==e)return{};var o,t,s,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(Object(e)),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t]);return n}if(n=function(e,r){if(null==e)return{};var o,t,s={},n=Object.getOwnPropertyNames(e);for(t=0;t<n.length;t++)o=n[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}(e,r),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),s=0;s<o.length;s++)t=o[s],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t]);return n}const j=({errors:y,data:j,props:v,isValidating:g,containerRef:O})=>{const[h,A]=e(null),F=u(h),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:k,clearSRPanel:w,shouldMoveFocusSR:C}=c(),P=null==S?void 0:S({fieldTypeMappingFn:p}),x=r(()=>new a,[]),D=r(()=>new a(v.deliveryAddressSpecification),[]);o(()=>{try{var e,r,o,c,a;const u="deliveryAddress:",p="billingAddress:",{companyDetails:h,personalDetails:S,bankAccount:E,billingAddress:R,deliveryAddress:T}=y,M=m(y,["companyDetails","personalDetails","bankAccount","billingAddress","deliveryAddress"]),$=t(R,p),L=t(T,u),I=b({},"object"==typeof h&&h,"object"==typeof S&&S,"object"==typeof E&&E,"object"==typeof $&&$,"object"==typeof L&&L,"object"==typeof M.consentCheckbox&&{consentCheckbox:M.consentCheckbox}),K=s,U=null!==(e=v.personalDetailsRequiredFields)&&void 0!==e?e:n,V=n.filter(e=>null==U?void 0:U.includes(e)),_=["holder","iban"],q=x.getAddressSchemaForCountryFlat(null===(r=j.billingAddress)||void 0===r?void 0:r.country).map(e=>`${p}${e}`),B=D.getAddressSchemaForCountryFlat(null===(o=j.deliveryAddress)||void 0===o?void 0:o.country).map(e=>`${u}${e}`),N=K.concat(V,_,q,B,["consentCheckbox"]),z=x.getAddressLabelsForCountry(null===(c=j.billingAddress)||void 0===c?void 0:c.country),G=D.getAddressLabelsForCountry(null===(a=j.deliveryAddress)||void 0===a?void 0:a.country),H=null==P?void 0:P({errors:I,isValidating:g.current,layout:N,countrySpecificLabels:b({},z,G)}),J=null==H?void 0:H.currentErrorsSortedByLayout;switch(A(J),null==H?void 0:H.action){case i:{const e=H.fieldToFocus.includes(":")?H.fieldToFocus.split(":")[1]:H.fieldToFocus;let r="";const o=H.fieldToFocus.includes(":")?H.fieldToFocus.split(":")[0]:"";o.length&&(r=`.adyen-checkout__fieldset--${o} `),C&&O.current&&d(O.current,e,r),setTimeout(()=>{g.current=!1},300);break}case l:{const e=f(J,F,"field"),r=null==e?void 0:e[0];if(r){const e="shopperEmail"===r.field&&"field.error.invalid"===r.errorCode?r.errorMessage:null;k(e)}else w();break}}}catch(e){}},[y,j])};export{j as default};
2
2
  //# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n containerRef: MutableRef<HTMLDivElement | null>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating, containerRef }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\n * For prefixed fields (ones that can occur twice but in different contexts i.e. billingAddress & deliveryAddress) - consider the prefix...\n */\n // ...Firstly strip it to gain a \"clean\" reference to the field...\n const fieldToFocus = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[1] : srPanelResp.fieldToFocus; // country, street etc\n\n // ...Secondly use the prefix to add context for when we try to select it\n let focusContextSelector = '';\n const focusContext = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[0] : ''; // 'billingAddress' | 'deliveryAddress'\n if (focusContext.length) {\n focusContextSelector = `.adyen-checkout__fieldset--${focusContext} `;\n }\n\n // Focus first field in error, if required\n // Use the component's own container ref (rather than a global class selector) so that, when multiple\n // OpenInvoice-based components are rendered on the same page, focus moves within the correct instance\n if (shouldMoveFocusSR && containerRef.current) setFocusOnField(containerRef.current, fieldToFocus, focusContextSelector);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n }\n\n /**\n * Relates to errors triggered by a field blurring (some pm forms have this, some don't) - check if there is an error to either set or to clear\n */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.field === 'shopperEmail' && latestErrorMsg.errorCode === 'field.error.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","containerRef","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","field","errorCode","errorMessage","_"],"mappings":"kzDAuBA,MAAMA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,eAAcC,mBAEzE,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,aAAAA,EAAAA,EAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,EAAQ,IAAM,IAAIC,EAAkB,IACnEC,EAAgCF,EAAQ,IAAM,IAAIC,EAAelB,EAAMoB,8BAA+B,IAE5GC,EAAU,KACN,IAiC+CrB,IAAAA,EAK8CD,EAIEA,EAYGA,EACEA,EAtDhG,MAAMuB,EAA0B,mBAC1BC,EAAyB,mBAK3BC,eAAgBC,EAChBC,gBAAiBC,EACjBC,YAAaC,EACbC,eAAgBC,EAChBC,gBAAiBC,GAEjBnC,EADGoC,EAAAA,EACHpC,EAAAA,uFAIEqC,EAA+BC,EAA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K,GAAKR,EAAYO,aAGnH,IAAIE,EAAuB,GAC3B,MAAMC,EAAeV,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAK,GACnGE,EAAaC,SACbF,EAAuB,8BAA8BC,MAMrD5D,GAAqBT,EAAa4D,SAASW,EAAgBvE,EAAa4D,QAASM,EAAcE,GAEnGI,WAAW,KACPzE,EAAa6D,SAAU,GACxB,KACH,KACJ,CAKA,KAAKa,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBZ,EAA6B3D,EAAsB,SAEpFwE,EAAiBF,aAAAA,EAAAA,EAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAH4C,iBAAzBD,EAAeE,OAAyD,wBAA7BF,EAAeG,UAG1CH,EAAeI,aAAe,KACvEzE,EAAyBsE,EAC7B,MAEIrE,IAGJ,KACJ,EAIR,CAAE,MAAOyE,GAET,GACD,CAACrF,EAAQC"}
1
+ {"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n containerRef: MutableRef<HTMLDivElement | null>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating, containerRef }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...(typeof remainingErrors.consentCheckbox === 'object' && { consentCheckbox: remainingErrors.consentCheckbox })\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\n * For prefixed fields (ones that can occur twice but in different contexts i.e. billingAddress & deliveryAddress) - consider the prefix...\n */\n // ...Firstly strip it to gain a \"clean\" reference to the field...\n const fieldToFocus = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[1] : srPanelResp.fieldToFocus; // country, street etc\n\n // ...Secondly use the prefix to add context for when we try to select it\n let focusContextSelector = '';\n const focusContext = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[0] : ''; // 'billingAddress' | 'deliveryAddress'\n if (focusContext.length) {\n focusContextSelector = `.adyen-checkout__fieldset--${focusContext} `;\n }\n\n // Focus first field in error, if required\n // Use the component's own container ref (rather than a global class selector) so that, when multiple\n // OpenInvoice-based components are rendered on the same page, focus moves within the correct instance\n if (shouldMoveFocusSR && containerRef.current) setFocusOnField(containerRef.current, fieldToFocus, focusContextSelector);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n }\n\n /**\n * Relates to errors triggered by a field blurring (some pm forms have this, some don't) - check if there is an error to either set or to clear\n */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.field === 'shopperEmail' && latestErrorMsg.errorCode === 'field.error.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","containerRef","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","consentCheckbox","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","field","errorCode","errorMessage","_"],"mappings":"kzDAuBA,MAAMA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,eAAcC,mBAEzE,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,aAAAA,EAAAA,EAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,EAAQ,IAAM,IAAIC,EAAkB,IACnEC,EAAgCF,EAAQ,IAAM,IAAIC,EAAelB,EAAMoB,8BAA+B,IAE5GC,EAAU,KACN,IAiC+CrB,IAAAA,EAK8CD,EAIEA,EAYGA,EACEA,EAtDhG,MAAMuB,EAA0B,mBAC1BC,EAAyB,mBAK3BC,eAAgBC,EAChBC,gBAAiBC,EACjBC,YAAaC,EACbC,eAAgBC,EAChBC,gBAAiBC,GAEjBnC,EADGoC,EAAAA,EACHpC,EAAAA,uFAIEqC,EAA+BC,EAAuBL,EAA+BR,GACrFc,EAAgCD,EAAuBH,EAAgCX,GAGvFgB,EAAiBC,EAAA,CAAA,EAC0B,iBAAlCd,GAA8CA,EACX,iBAAnCE,GAA+CA,EAChB,iBAA/BE,GAA2CA,EACV,iBAAjCM,GAA6CA,EACX,iBAAlCE,GAA8CA,EACV,iBAApCH,EAAgBM,iBAAgC,CAAEA,gBAAiBN,EAAgBM,kBAI5FC,EAAiCC,EAEjCC,EAAwE,QAAnC3C,EAAAA,EAAM4C,yCAAN5C,EAAAA,EAAuC6C,EAC5EC,EAAiCD,EAAwBE,OAAOC,GAAKL,aAAAA,EAAAA,EAA0BM,SAASD,IAExGE,EAAoB,CAAC,SAAU,QAI/BC,EAFuBnC,EAA6BoC,+BAAkD,QAAnBrD,EAAAA,EAAK+B,sBAAL/B,IAAAA,OAAAA,EAAAA,EAA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eG,UAG1CH,EAAeI,aAAe,KACvE1E,EAAyBuE,EAC7B,MAEItE,IAGJ,KACJ,EAIR,CAAE,MAAO0E,GAET,GACD,CAACtF,EAAQC"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../Button/Button.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{createButtonLabel as o,createSecondaryLabel as n}from"./utils.js";import c from"./components/SecondaryButtonLabel.js";import{useAmount as i,useSecondaryAmount as s}from"../../../core/Context/AmountProvider.js";import{isAmountValid as l}from"../../../utils/amount-util.js";function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function p(e,t){if(null==e)return{};var r,o,n,c={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(c[o]=e[o]);return c}if(c=function(e,t){if(null==e)return{};var r,o,n={},c=Object.getOwnPropertyNames(e);for(o=0;o<c.length;o++)r=c[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(c[o]=e[o]);return c}const f=f=>{let{customAmount:m,classNameModifiers:b=[],label:y,icon:O,showReview:j}=f,d=p(f,["customAmount","classNameModifiers","label","icon","showReview"]);const{amount:w,isZeroAuth:g}=i(),{secondaryAmount:P}=s(),{i18n:v}=r(),h=o(v,{customLabel:y,amount:w,isZeroAuth:g,customAmount:m,secondaryAmount:P,showReview:j}),A=O&&!j?O:void 0,x=n(v,P,l(w),g,y),S=d.disabled||"loading"===d.status;return e(t,a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){u(e,t,r[t])})}return e}({},d),{icon:A,disabled:S,classNameModifiers:[...b,"pay"],label:h}),x&&e(c,{label:x}))};export{f as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useMemo as r}from"../../../external/preact/hooks/dist/hooks.js";import o from"../Button/Button.js";import{useCoreContext as n}from"../../../core/Context/CoreProvider.js";import{createButtonLabel as s,createSecondaryLabel as i}from"./utils.js";import a from"./components/SecondaryButtonLabel.js";import{useAmount as l,useSecondaryAmount as c}from"../../../core/Context/AmountProvider.js";import{isAmountValid as u}from"../../../utils/amount-util.js";import{getUniqueId as m}from"../../../utils/idGenerator.js";import p from"../DisclaimerMessage/DisclaimerMessage.js";import{formatDisclaimerMessage as f}from"../DisclaimerMessage/utils.js";function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){b(e,t,r[t])})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function O(e,t){if(null==e)return{};var r,o,n,s={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}if(s=function(e,t){if(null==e)return{};var r,o,n={},s=Object.getOwnPropertyNames(e);for(o=0;o<s.length;o++)r=s[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r]);return n}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o]);return s}const j=b=>{let{customAmount:j,classNameModifiers:g=[],label:w,icon:P,showReview:v,disclaimerMessage:h,showPayButton:D=!0}=b,M=O(b,["customAmount","classNameModifiers","label","icon","showReview","disclaimerMessage","showPayButton"]);const{amount:x,isZeroAuth:A}=l(),{secondaryAmount:B}=c(),{i18n:S}=n(),E=s(S,{customLabel:w,amount:x,isZeroAuth:A,customAmount:j,secondaryAmount:B,showReview:v}),R=P&&!v?P:void 0,k=i(S,B,u(x),A,w),N=M.disabled||"loading"===M.status,C=h&&f(h),I=r(()=>m("pay-button-disclaimer"),[]),K=[M.ariaDescribedBy,(null==C?void 0:C.message)?I:void 0].filter(Boolean).join(" ")||void 0;return e(t,null,(null==C?void 0:C.message)&&e(p,d(y({},C),{id:I})),D&&e(o,d(y({},M),{ariaDescribedBy:K,icon:R,disabled:N,classNameModifiers:[...g,"pay"],label:E}),k&&e(a,{label:k})))};export{j as default};
2
2
  //# sourceMappingURL=PayButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { createButtonLabel, createSecondaryLabel } from './utils';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\nimport { useAmount, useSecondaryAmount } from '../../../core/Context/AmountProvider';\nimport type { PaymentAmount } from '../../../types';\nimport { isAmountValid } from '../../../utils/amount-util';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n /**\n * Custom amount that can be passed to the button.\n * This is useful when the amount is not available in the amount provider, such as Giftcard scenario where\n * we need to display the remaining amount\n */\n customAmount?: PaymentAmount;\n label?: string;\n status?: string;\n disabled?: boolean;\n icon?: string;\n showReview?: boolean;\n}\n\nconst PayButton = ({ customAmount, classNameModifiers = [], label, icon, showReview, ...props }: Readonly<PayButtonProps>) => {\n const { amount, isZeroAuth } = useAmount();\n const { secondaryAmount } = useSecondaryAmount();\n const { i18n } = useCoreContext();\n\n const buttonLabel = createButtonLabel(i18n, { customLabel: label, amount, isZeroAuth, customAmount, secondaryAmount, showReview });\n const buttonIcon = icon && !showReview ? icon : undefined;\n const secondaryAmountLabel = createSecondaryLabel(i18n, secondaryAmount, isAmountValid(amount), isZeroAuth, label);\n\n const isDisabled = props.disabled || props.status === 'loading';\n\n return (\n <Button {...props} icon={buttonIcon} disabled={isDisabled} classNameModifiers={[...classNameModifiers, 'pay']} label={buttonLabel}>\n {secondaryAmountLabel && <SecondaryButtonLabel label={secondaryAmountLabel} />}\n </Button>\n );\n};\n\nexport default PayButton;\n"],"names":["PayButton","_0","customAmount","classNameModifiers","label","icon","showReview","props","amount","isZeroAuth","useAmount","secondaryAmount","useSecondaryAmount","i18n","useCoreContext","buttonLabel","createButtonLabel","customLabel","buttonIcon","undefined","secondaryAmountLabel","createSecondaryLabel","isAmountValid","isDisabled","disabled","status","h","Button","SecondaryButtonLabel"],"mappings":"uiDA4BA,MAAMA,EAAYC,QAACC,aAAEA,EAAYC,mBAAEA,EAAqB,GAAEC,MAAEA,EAAKC,KAAEA,EAAIC,WAAEA,GAAgDL,EAAjCM,EAAAA,EAAAA,EAAAA,mEACpF,MAAMC,OAAEA,EAAMC,WAAEA,GAAeC,KACzBC,gBAAEA,GAAoBC,KACtBC,KAAEA,GAASC,IAEXC,EAAcC,EAAkBH,EAAM,CAAEI,YAAab,EAAOI,SAAQC,aAAYP,eAAcS,kBAAiBL,eAC/GY,EAAab,IAASC,EAAaD,OAAOc,EAC1CC,EAAuBC,EAAqBR,EAAMF,EAAiBW,EAAcd,GAASC,EAAYL,GAEtGmB,EAAahB,EAAMiB,UAA6B,YAAjBjB,EAAMkB,OAE3C,OACIC,EAACC,EAAAA,oUAAAA,CAAAA,CAAAA,EAAWpB,GAAAA,CAAOF,KAAMa,EAAYM,SAAUD,EAAYpB,mBAAoB,IAAIA,EAAoB,OAAQC,MAAOW,IACjHK,GAAwBM,EAACE,EAAAA,CAAqBxB,MAAOgB"}
1
+ {"version":3,"file":"PayButton.js","sources":["../../../../../src/components/internal/PayButton/PayButton.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useMemo } from 'preact/hooks';\nimport Button from '../Button';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ButtonProps } from '../Button/types';\nimport { createButtonLabel, createSecondaryLabel } from './utils';\nimport SecondaryButtonLabel from './components/SecondaryButtonLabel';\nimport { useAmount, useSecondaryAmount } from '../../../core/Context/AmountProvider';\nimport type { PaymentAmount } from '../../../types';\nimport { isAmountValid } from '../../../utils/amount-util';\nimport { getUniqueId } from '../../../utils/idGenerator';\nimport DisclaimerMessage, { formatDisclaimerMessage } from '../DisclaimerMessage';\nimport type { DisclaimerMsgObject } from '../DisclaimerMessage';\n\nexport interface PayButtonProps extends ButtonProps {\n /**\n * Class name modifiers will be used as: `adyen-checkout__image--${modifier}`\n */\n classNameModifiers?: string[];\n /**\n * Custom amount that can be passed to the button.\n * This is useful when the amount is not available in the amount provider, such as Giftcard scenario where\n * we need to display the remaining amount\n */\n customAmount?: PaymentAmount;\n label?: string;\n status?: string;\n disabled?: boolean;\n icon?: string;\n showReview?: boolean;\n /**\n * Disclaimer message displayed above the button\n */\n disclaimerMessage?: DisclaimerMsgObject;\n /**\n * Hides the button itself. The disclaimer message is still rendered, since it belongs to the\n * payment step rather than to the button, and merchants hiding the button supply their own.\n * @defaultValue `true`\n */\n showPayButton?: boolean;\n}\n\nconst PayButton = ({\n customAmount,\n classNameModifiers = [],\n label,\n icon,\n showReview,\n disclaimerMessage,\n showPayButton = true,\n ...props\n}: Readonly<PayButtonProps>) => {\n const { amount, isZeroAuth } = useAmount();\n const { secondaryAmount } = useSecondaryAmount();\n const { i18n } = useCoreContext();\n\n const buttonLabel = createButtonLabel(i18n, { customLabel: label, amount, isZeroAuth, customAmount, secondaryAmount, showReview });\n const buttonIcon = icon && !showReview ? icon : undefined;\n const secondaryAmountLabel = createSecondaryLabel(i18n, secondaryAmount, isAmountValid(amount), isZeroAuth, label);\n\n const isDisabled = props.disabled || props.status === 'loading';\n const formattedDisclaimerMessage = disclaimerMessage && formatDisclaimerMessage(disclaimerMessage);\n const disclaimerId = useMemo(() => getUniqueId('pay-button-disclaimer'), []);\n const ariaDescribedBy =\n [props.ariaDescribedBy, formattedDisclaimerMessage?.message ? disclaimerId : undefined].filter(Boolean).join(' ') || undefined;\n\n return (\n <Fragment>\n {formattedDisclaimerMessage?.message && <DisclaimerMessage {...formattedDisclaimerMessage} id={disclaimerId} />}\n {showPayButton && (\n <Button\n {...props}\n ariaDescribedBy={ariaDescribedBy}\n icon={buttonIcon}\n disabled={isDisabled}\n classNameModifiers={[...classNameModifiers, 'pay']}\n label={buttonLabel}\n >\n {secondaryAmountLabel && <SecondaryButtonLabel label={secondaryAmountLabel} />}\n </Button>\n )}\n </Fragment>\n );\n};\n\nexport default PayButton;\n"],"names":["PayButton","_0","customAmount","classNameModifiers","label","icon","showReview","disclaimerMessage","showPayButton","props","amount","isZeroAuth","useAmount","secondaryAmount","useSecondaryAmount","i18n","useCoreContext","buttonLabel","createButtonLabel","customLabel","buttonIcon","undefined","secondaryAmountLabel","createSecondaryLabel","isAmountValid","isDisabled","disabled","status","formattedDisclaimerMessage","formatDisclaimerMessage","disclaimerId","useMemo","getUniqueId","ariaDescribedBy","message","filter","Boolean","join","h","Fragment","DisclaimerMessage","id","Button","SecondaryButtonLabel"],"mappings":"6nEA0CA,MAAMA,EAAYC,IAAC,IAAAC,aACfA,EAAYC,mBACZA,EAAqB,GAAEC,MACvBA,EAAKC,KACLA,EAAIC,WACJA,EAAUC,kBACVA,EAAiBC,cACjBA,GAAgB,GAEOP,EADpBQ,EAAAA,EAAAA,EAAAA,uGAEH,MAAMC,OAAEA,EAAMC,WAAEA,GAAeC,KACzBC,gBAAEA,GAAoBC,KACtBC,KAAEA,GAASC,IAEXC,EAAcC,EAAkBH,EAAM,CAAEI,YAAaf,EAAOM,SAAQC,aAAYT,eAAcW,kBAAiBP,eAC/Gc,EAAaf,IAASC,EAAaD,OAAOgB,EAC1CC,EAAuBC,EAAqBR,EAAMF,EAAiBW,EAAcd,GAASC,EAAYP,GAEtGqB,EAAahB,EAAMiB,UAA6B,YAAjBjB,EAAMkB,OACrCC,EAA6BrB,GAAqBsB,EAAwBtB,GAC1EuB,EAAeC,EAAQ,IAAMC,EAAY,yBAA0B,IACnEC,EACF,CAACxB,EAAMwB,iBAAiBL,aAAAA,EAAAA,EAA4BM,SAAUJ,OAAeT,GAAWc,OAAOC,SAASC,KAAK,WAAQhB,EAEzH,OACIiB,EAACC,QACIX,eAAAA,EAA4BM,UAAWI,EAACE,EAAAA,EAAAA,EAAAA,CAAAA,EAAsBZ,GAAAA,CAA4Ba,GAAIX,KAC9FtB,GACG8B,EAACI,EAAAA,EAAAA,EAAAA,GACOjC,GAAAA,CACJwB,gBAAiBA,EACjB5B,KAAMe,EACNM,SAAUD,EACVtB,mBAAoB,IAAIA,EAAoB,OAC5CC,MAAOa,IAENK,GAAwBgB,EAACK,EAAAA,CAAqBvC,MAAOkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePhonePrefixes.js","sources":["../../../../../src/components/internal/PhoneInput/usePhonePrefixes.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'preact/hooks';\nimport getDataset from '../../../core/Services/get-dataset';\nimport { DataSet } from '../../../core/Services/data-set';\nimport { PhonePrefixes } from './types';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nfunction usePhonePrefixes({ allowedCountries, loadingContext, handleError }): PhonePrefixes {\n const [loadingStatus, setLoadingStatus] = useState<string>('loading');\n const [phonePrefixes, setPhonePrefixes] = useState<DataSet>([]);\n\n useLayoutEffect(() => {\n getDataset('phonenumbers', loadingContext)\n .then(response => {\n const countriesFilter = country => allowedCountries.includes(country.id);\n const filteredCountries = allowedCountries.length ? response.filter(countriesFilter) : response;\n const mappedCountries = filteredCountries.map(({ prefix, id }) => ({\n id: prefix,\n name: `${prefix} (${id})`,\n selectedOptionName: prefix\n }));\n\n setPhonePrefixes(mappedCountries || []);\n setLoadingStatus('ready');\n })\n .catch(error => {\n setPhonePrefixes([]);\n setLoadingStatus('ready');\n handleError?.(new AdyenCheckoutError('ERROR', error));\n });\n }, []);\n\n return { phonePrefixes, loadingStatus };\n}\n\nexport default usePhonePrefixes;\n"],"names":["usePhonePrefixes","allowedCountries","loadingContext","handleError","loadingStatus","setLoadingStatus","useState","phonePrefixes","setPhonePrefixes","useLayoutEffect","getDataset","then","response","mappedCountries","length","filter","country","includes","id","map","prefix","name","selectedOptionName","catch","error","AdyenCheckoutError"],"mappings":"4MAMA,SAASA,GAAiBC,iBAAEA,EAAgBC,eAAEA,EAAcC,YAAEA,IAC1D,MAAOC,EAAeC,GAAoBC,EAAiB,YACpDC,EAAeC,GAAoBF,EAAkB,IAuB5D,OArBAG,EAAgB,KACZC,EAAW,eAAgBR,GACtBS,KAAKC,IACF,MAEMC,GADoBZ,EAAiBa,OAASF,EAASG,OADrCC,GAAWf,EAAiBgB,SAASD,EAAQE,KACkBN,GAC7CO,IAAI,EAAGC,SAAQF,SAAI,CACzDA,GAAIE,EACJC,KAAM,GAAGD,MAAWF,KACpBI,mBAAoBF,KAGxBZ,EAAiBK,GAAmB,IACpCR,EAAiB,WAEpBkB,MAAMC,IACHhB,EAAiB,IACjBH,EAAiB,SACjBF,SAAAA,EAAc,IAAIsB,EAAmB,QAASD,OAEvD,IAEI,CAAEjB,gBAAeH,gBAC5B"}
1
+ {"version":3,"file":"usePhonePrefixes.js","sources":["../../../../../src/components/internal/PhoneInput/usePhonePrefixes.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'preact/hooks';\nimport getDataset from '../../../core/Services/get-dataset';\nimport { DataSet } from '../../../core/Services/data-set';\nimport { PhonePrefixDataSetItem, PhonePrefixes } from './types';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\n\nfunction usePhonePrefixes({ allowedCountries, loadingContext, handleError }): PhonePrefixes {\n const [loadingStatus, setLoadingStatus] = useState<string>('loading');\n const [phonePrefixes, setPhonePrefixes] = useState<DataSet>([]);\n\n useLayoutEffect(() => {\n getDataset<PhonePrefixDataSetItem[]>('phonenumbers', loadingContext)\n .then(response => {\n const countriesFilter = (country: PhonePrefixDataSetItem) => allowedCountries.includes(country.id);\n const filteredCountries = allowedCountries.length ? response.filter(countriesFilter) : response;\n const mappedCountries = filteredCountries.map(({ prefix, id }) => ({\n id: prefix,\n name: `${prefix} (${id})`,\n selectedOptionName: prefix\n }));\n\n setPhonePrefixes(mappedCountries || []);\n setLoadingStatus('ready');\n })\n .catch(error => {\n setPhonePrefixes([]);\n setLoadingStatus('ready');\n handleError?.(new AdyenCheckoutError('ERROR', error));\n });\n }, []);\n\n return { phonePrefixes, loadingStatus };\n}\n\nexport default usePhonePrefixes;\n"],"names":["usePhonePrefixes","allowedCountries","loadingContext","handleError","loadingStatus","setLoadingStatus","useState","phonePrefixes","setPhonePrefixes","useLayoutEffect","getDataset","then","response","mappedCountries","length","filter","country","includes","id","map","prefix","name","selectedOptionName","catch","error","AdyenCheckoutError"],"mappings":"4MAMA,SAASA,GAAiBC,iBAAEA,EAAgBC,eAAEA,EAAcC,YAAEA,IAC1D,MAAOC,EAAeC,GAAoBC,EAAiB,YACpDC,EAAeC,GAAoBF,EAAkB,IAuB5D,OArBAG,EAAgB,KACZC,EAAqC,eAAgBR,GAChDS,KAAKC,IACF,MAEMC,GADoBZ,EAAiBa,OAASF,EAASG,OADpCC,GAAoCf,EAAiBgB,SAASD,EAAQE,KACRN,GAC7CO,IAAI,EAAGC,SAAQF,SAAI,CACzDA,GAAIE,EACJC,KAAM,GAAGD,MAAWF,KACpBI,mBAAoBF,KAGxBZ,EAAiBK,GAAmB,IACpCR,EAAiB,WAEpBkB,MAAMC,IACHhB,EAAiB,IACjBH,EAAiB,SACjBF,SAAAA,EAAc,IAAIsB,EAAmB,QAASD,OAEvD,IAEI,CAAEjB,gBAAeH,gBAC5B"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{useState as n,useRef as o,useEffect as c}from"../../../external/preact/hooks/dist/hooks.js";import{useAmount as l}from"../../../core/Context/AmountProvider.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,c={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}if(c=function(e,t){if(null==e)return{};var r,n,o={},c=Object.getOwnPropertyNames(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}function s(s){let{label:p=null,icon:f=null,payButton:b,onSubmit:y,name:O,showPayButton:m,setComponentRef:j}=s,g=i(s,["label","icon","payButton","onSubmit","name","showPayButton","setComponentRef"]);const{i18n:P}=r(),[w,d]=n("ready"),{amount:h}=l(),v=o({setStatus:d});c(()=>{j(v.current)},[j]);if(m)return e(t,null,b(u(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({},g),{status:w,icon:f,classNameModifiers:["standalone"],label:p||(h&&{}.hasOwnProperty.call(h,"value")&&0===h.value?`${P.get("preauthorizeWith")} ${O}`:`${P.get("continueTo")} ${O}`),onClick:y})))}export{s as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useCoreContext as r}from"../../../core/Context/CoreProvider.js";import{useState as n,useRef as o,useEffect as c}from"../../../external/preact/hooks/dist/hooks.js";import{useAmount as l}from"../../../core/Context/AmountProvider.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function i(e,t){if(null==e)return{};var r,n,o,c={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}if(c=function(e,t){if(null==e)return{};var r,n,o={},c=Object.getOwnPropertyNames(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n]);return c}function s(s){let{label:p=null,icon:f=null,payButton:b,onSubmit:y,name:O,setComponentRef:m}=s,j=i(s,["label","icon","payButton","onSubmit","name","setComponentRef"]);const{i18n:g}=r(),[P,d]=n("ready"),{amount:w}=l(),h=o({setStatus:d});c(()=>{m(h.current)},[m]);return e(t,null,b(u(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({},j),{status:P,icon:f,classNameModifiers:["standalone"],label:p||(w&&{}.hasOwnProperty.call(w,"value")&&0===w.value?`${g.get("preauthorizeWith")} ${O}`:`${g.get("continueTo")} ${O}`),onClick:y})))}export{s as default};
2
2
  //# sourceMappingURL=RedirectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectButton.js","sources":["../../../../../src/components/internal/RedirectButton/RedirectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport interface RedirectButtonProps {\n label?: string;\n icon?: string;\n payButton: Function;\n onSubmit: Function;\n name: string;\n showPayButton: boolean;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\nfunction RedirectButton({\n label = null,\n icon = null,\n payButton,\n onSubmit,\n name,\n showPayButton,\n setComponentRef,\n ...props\n}: Readonly<RedirectButtonProps>) {\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { amount } = useAmount();\n\n const redirectButtonRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus\n });\n\n useEffect(() => {\n setComponentRef(redirectButtonRef.current);\n }, [setComponentRef]);\n\n const payButtonLabel = () => {\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n if (isZeroAuth) return `${i18n.get('preauthorizeWith')} ${name}`;\n return `${i18n.get('continueTo')} ${name}`;\n };\n\n if (!showPayButton) {\n return;\n }\n\n return (\n <Fragment>\n {payButton({\n ...props,\n status,\n icon,\n classNameModifiers: ['standalone'],\n label: label || payButtonLabel(),\n onClick: onSubmit\n })}\n </Fragment>\n );\n}\n\nexport default RedirectButton;\n"],"names":["RedirectButton","_0","label","icon","payButton","onSubmit","name","showPayButton","setComponentRef","props","i18n","useCoreContext","status","setStatus","useState","amount","useAmount","redirectButtonRef","useRef","useEffect","current","h","Fragment","_object_spread_props","_object_spread","classNameModifiers","hasOwnProperty","call","value","get","onClick"],"mappings":"k6CAgBA,SAASA,EAAeC,GAAA,IAAAC,MACpBA,EAAQ,KAAIC,KACZA,EAAO,KAAIC,UACXA,EAASC,SACTA,EAAQC,KACRA,EAAIC,cACJA,EAAaC,gBACbA,GAE4BP,EADzBQ,EAAAA,EAAAA,EAAAA,kFAEH,MAAMC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,OAAEA,GAAWC,IAEbC,EAAoBC,EAA4B,CAClDL,UAAWA,IAGfM,EAAU,KACNX,EAAgBS,EAAkBG,UACnC,CAACZ,IAQJ,GAAKD,EAIL,OACIc,EAACC,EAAAA,KACIlB,EAAUmB,oUAAAC,CAAA,GACJf,GAAAA,CACHG,SACAT,OACAsB,mBAAoB,CAAC,cACrBvB,MAAOA,IAhBIa,GAAU,CAAC,EAAEW,eAAeC,KAAKZ,EAAQ,UAA6B,IAAjBA,EAAOa,MACxD,GAAGlB,EAAKmB,IAAI,uBAAuBvB,IACnD,GAAGI,EAAKmB,IAAI,iBAAiBvB,KAe5BwB,QAASzB,KAIzB"}
1
+ {"version":3,"file":"RedirectButton.js","sources":["../../../../../src/components/internal/RedirectButton/RedirectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport interface RedirectButtonProps {\n label?: string;\n icon?: string;\n payButton: Function;\n onSubmit: Function;\n name: string;\n setComponentRef: (ref: ComponentMethodsRef) => void;\n}\n\nfunction RedirectButton({\n label = null,\n icon = null,\n payButton,\n onSubmit,\n name,\n setComponentRef,\n ...props\n}: Readonly<RedirectButtonProps>) {\n const { i18n } = useCoreContext();\n const [status, setStatus] = useState('ready');\n const { amount } = useAmount();\n\n const redirectButtonRef = useRef<ComponentMethodsRef>({\n setStatus: setStatus\n });\n\n useEffect(() => {\n setComponentRef(redirectButtonRef.current);\n }, [setComponentRef]);\n\n const payButtonLabel = () => {\n const isZeroAuth = amount && {}.hasOwnProperty.call(amount, 'value') && amount.value === 0;\n if (isZeroAuth) return `${i18n.get('preauthorizeWith')} ${name}`;\n return `${i18n.get('continueTo')} ${name}`;\n };\n\n return (\n <Fragment>\n {payButton({\n ...props,\n status,\n icon,\n classNameModifiers: ['standalone'],\n label: label || payButtonLabel(),\n onClick: onSubmit\n })}\n </Fragment>\n );\n}\n\nexport default RedirectButton;\n"],"names":["RedirectButton","_0","label","icon","payButton","onSubmit","name","setComponentRef","props","i18n","useCoreContext","status","setStatus","useState","amount","useAmount","redirectButtonRef","useRef","useEffect","current","h","Fragment","_object_spread_props","_object_spread","classNameModifiers","hasOwnProperty","call","value","get","onClick"],"mappings":"k6CAeA,SAASA,EAAeC,GAAA,IAAAC,MACpBA,EAAQ,KAAIC,KACZA,EAAO,KAAIC,UACXA,EAASC,SACTA,EAAQC,KACRA,EAAIC,gBACJA,GAE4BN,EADzBO,EAAAA,EAAAA,EAAAA,kEAEH,MAAMC,KAAEA,GAASC,KACVC,EAAQC,GAAaC,EAAS,UAC/BC,OAAEA,GAAWC,IAEbC,EAAoBC,EAA4B,CAClDL,UAAWA,IAGfM,EAAU,KACNX,EAAgBS,EAAkBG,UACnC,CAACZ,IAQJ,OACIa,EAACC,EAAAA,KACIjB,EAAUkB,oUAAAC,CAAA,GACJf,GAAAA,CACHG,SACAR,OACAqB,mBAAoB,CAAC,cACrBtB,MAAOA,IAZIY,GAAU,CAAC,EAAEW,eAAeC,KAAKZ,EAAQ,UAA6B,IAAjBA,EAAOa,MACxD,GAAGlB,EAAKmB,IAAI,uBAAuBtB,IACnD,GAAGG,EAAKmB,IAAI,iBAAiBtB,KAW5BuB,QAASxB,KAIzB"}
@@ -1,2 +1,2 @@
1
- import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as e,validFieldsReducer as s,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import a from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as d,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{resolveCVCErrorKey as m}from"../../../Card/components/CardInput/utils.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as y}from"../../../../core/Errors/constants.js";import{TxVariants as O}from"../../../tx-variants.js";function C(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function F(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),i.forEach(function(e){C(t,e,s[e])})}return t}function b(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class S extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=e(this.rootNode),i=t.reduce(s,{});this.setState({valid:i}),t.forEach(t=>{this.numCharsInField[t]=0}),this.numDateFields=t.filter(t=>t.match(/Expiry/)).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):(this.props.componentType===O.customCard&&console.debug('You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a "data-cse" attribute e.g. <div data-cse="encryptedCardNumber"></div>'),this.handleOnNoDataRequired())}componentDidUpdate(){var t,e;this.checkForKCPFields(),null===(t=(e=this.props).onStateUpdate)||void 0===t||t.call(e,this.state)}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){var e;let s=this.props.loadingContext;const i={rootNode:t,type:this.props.type,componentType:this.props.componentType,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,onSubmitAnalytics:this.props.onSubmitAnalytics,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyDown:this.handleKeyDown},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:null!==(e=this.props.placeholders)&&void 0!==e?e:{},showContextualElement:this.props.showContextualElement};this.csf=n(i),this.csfLoadFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))},this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:b(F({},t.data),{[d]:void 0}),valid:b(F({},t.valid),{[d]:!1}),errors:b(F({},t.errors),{[d]:null}),hasKoreanFields:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.removeSecuredField(d),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:b(F({},t.valid),{[d]:!1}),hasKoreanFields:!0,isSfpValid:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.addSecuredField(d),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const e=!!t.error;return e&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,e),this.csf&&this.csf.hasUnsupportedCard(h,t.error),e}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}getRootNode(){return this.rootNode}showValidation(){const{numDateFields:t,state:e}=this;Object.keys(e.valid).reduce(i(t,e),[]).forEach(t=>{const s=o(t,this.rootNode,e);this.handleOnError(s,!!e.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,s.error)})}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce((t,e)=>{const s=this.state.errors[e];return t[e]=s?F({isValid:!1,errorMessage:f(s,y),errorI18n:this.props.i18n.get(m(s,"amex"===this.state.brand)),error:s,rootNode:this.rootNode},this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}):null,t},{})}processBinLookupResponse(t,e){var s;if(this.state.detectedUnsupportedBrands&&(this.setState(t=>({errors:b(F({},t.errors),{[h]:null}),detectedUnsupportedBrands:null})),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=null==t||null===(s=t.issuingCountryCode)||void 0===s?void 0:s.toLowerCase();const i=(null==e?void 0:e.brand)&&l.includes(e.brand);i&&this.setState(e,()=>{this.props.onChange(this.state)}),this.csf&&this.csf.brandsFromBinLookup(t,i?e:null)}render(t,e){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},e)}constructor(t){super(t),C(this,"csfLoadFailTimeout",void 0),C(this,"csfLoadFailTimeoutMS",void 0),C(this,"csfConfigFailTimeout",void 0),C(this,"csfConfigFailTimeoutMS",void 0),C(this,"numCharsInField",void 0),C(this,"rootNode",void 0),C(this,"numDateFields",void 0),C(this,"csf",void 0),C(this,"handleOnLoad",void 0),C(this,"handleOnConfigSuccess",void 0),C(this,"handleOnFieldValid",void 0),C(this,"handleOnAllValid",void 0),C(this,"handleOnBrand",void 0),C(this,"handleFocus",void 0),C(this,"handleOnError",void 0),C(this,"handleOnAutoComplete",void 0),C(this,"handleOnNoDataRequired",void 0),C(this,"handleOnTouchstartIOS",void 0),C(this,"handleKeyDown",void 0),C(this,"state",void 0),C(this,"props",void 0),C(this,"issuingCountryCode",void 0),C(this,"setRootNode",t=>{this.rootNode=t});const e={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=e,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyDown=r.handleKeyDown.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}C(S,"defaultProps",a);export{S as default};
1
+ import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as e,validFieldsReducer as s,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import a from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as d,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{resolveCVCErrorKey as m}from"../../../Card/components/CardInput/utils.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as y}from"../../../../core/Errors/constants.js";import{TxVariants as O}from"../../../tx-variants.js";function C(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function F(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),i.forEach(function(e){C(t,e,s[e])})}return t}function b(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(e)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(e,s))}),t}class S extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=e(this.rootNode),i=t.reduce(s,{});this.setState({valid:i}),t.forEach(t=>{this.numCharsInField[t]=0}),this.numDateFields=t.filter(t=>t.match(/Expiry/)).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):(this.props.componentType===O.customCard&&console.debug('You are trying to create a CustomCard component but the element into which you are trying to mount the CustomCard component does not contain any elements with a "data-cse" attribute e.g. <div data-cse="encryptedCardNumber"></div>'),this.handleOnNoDataRequired())}componentDidUpdate(){var t,e;this.checkForKCPFields(),null===(t=(e=this.props).onStateUpdate)||void 0===t||t.call(e,this.state)}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){var e;let s=this.props.loadingContext;const i={rootNode:t,type:this.props.type,componentType:this.props.componentType,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,onSubmitAnalytics:this.props.onSubmitAnalytics,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyDown:this.handleKeyDown},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:null!==(e=this.props.placeholders)&&void 0!==e?e:{},showContextualElement:this.props.showContextualElement};this.csf=n(i),this.csfLoadFailTimeout=setTimeout(()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))},this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:b(F({},t.data),{[d]:void 0}),valid:b(F({},t.valid),{[d]:!1}),errors:b(F({},t.errors),{[d]:null}),hasKoreanFields:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.removeSecuredField(d),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:b(F({},t.valid),{[d]:!1}),hasKoreanFields:!0,isSfpValid:!1});this.setState(t,()=>{this.props.onChange(this.state)}),this.csf.addSecuredField(d),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const e=!!t.error;return e&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,e),this.csf&&this.csf.hasUnsupportedCard(h,t.error),e}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}getRootNode(){return this.rootNode}showValidation(){const{numDateFields:t,state:e}=this;Object.keys(e.valid).reduce(i(t,e),[]).forEach(t=>{const s=o(t,this.rootNode,e);this.handleOnError(s,!!e.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,s.error)})}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce((t,e)=>{const s=this.state.errors[e];return t[e]=s?F({isValid:!1,errorMessage:f(s,y),errorI18n:this.props.i18n.get(m(s,"amex"===this.state.brand)),error:s,rootNode:this.rootNode},this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}):null,t},{})}processBinLookupResponse(t,e){var s;if(this.state.detectedUnsupportedBrands&&(this.setState(t=>({errors:b(F({},t.errors),{[h]:null}),detectedUnsupportedBrands:null})),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=null==t||null===(s=t.issuingCountryCode)||void 0===s?void 0:s.toLowerCase();const i=(null==e?void 0:e.brand)&&l.includes(e.brand);i&&this.setState(e,()=>{this.props.onChange(this.state)}),this.csf&&this.csf.brandsFromBinLookup(t,i?e:null)}render(t,e){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},e)}constructor(t){super(t),C(this,"csfLoadFailTimeout",void 0),C(this,"csfLoadFailTimeoutMS",void 0),C(this,"csfConfigFailTimeout",void 0),C(this,"csfConfigFailTimeoutMS",void 0),C(this,"numCharsInField",void 0),C(this,"rootNode",void 0),C(this,"numDateFields",void 0),C(this,"csf",void 0),C(this,"handleOnLoad",void 0),C(this,"handleOnConfigSuccess",void 0),C(this,"handleOnFieldValid",void 0),C(this,"handleOnAllValid",void 0),C(this,"handleOnBrand",void 0),C(this,"handleFocus",void 0),C(this,"handleOnError",void 0),C(this,"handleOnAutoComplete",void 0),C(this,"handleOnNoDataRequired",void 0),C(this,"handleOnTouchstartIOS",void 0),C(this,"handleKeyDown",void 0),C(this,"issuingCountryCode",void 0),C(this,"setRootNode",t=>{this.rootNode=t});const e={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=e,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyDown=r.handleKeyDown.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}C(S,"defaultProps",a);export{S as default};
2
2
  //# sourceMappingURL=SecuredFieldsProvider.js.map