@adyen/adyen-web 6.11.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/dist/cjs/adyen.css +3 -3
  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 +88 -98
  6. package/dist/es/adyen.css +3 -3
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/components/ANCVAwait/config.js +1 -1
  9. package/dist/es/components/ANCV/components/ANCVAwait/config.js.map +1 -1
  10. package/dist/es/components/Ach/Ach.js +1 -1
  11. package/dist/es/components/Ach/Ach.js.map +1 -1
  12. package/dist/es/components/Ach/components/AccountTypeSelector.js +2 -0
  13. package/dist/es/components/Ach/components/AccountTypeSelector.js.map +1 -0
  14. package/dist/es/components/Ach/components/AchComponent.js +2 -0
  15. package/dist/es/components/Ach/components/AchComponent.js.map +1 -0
  16. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js +2 -0
  17. package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
  18. package/dist/es/components/Ach/components/validate.js +2 -0
  19. package/dist/es/components/Ach/components/validate.js.map +1 -0
  20. package/dist/es/components/Ach/defaultProps.js +2 -0
  21. package/dist/es/components/Ach/defaultProps.js.map +1 -0
  22. package/dist/es/components/AmazonPay/utils.js +1 -1
  23. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  24. package/dist/es/components/Atome/Atome.js +1 -1
  25. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  26. package/dist/es/components/BcmcMobile/BcmcMobile.js +1 -1
  27. package/dist/es/components/Boleto/components/BoletoInput/validate.js +1 -1
  28. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  29. package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
  30. package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
  31. package/dist/es/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
  32. package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  33. package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  34. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  35. package/dist/es/components/Card/components/CardInput/validate.js +1 -1
  36. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  37. package/dist/es/components/DuitNow/DuitNow.js +1 -1
  38. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  39. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  40. package/dist/es/components/PayNow/PayNow.js +1 -1
  41. package/dist/es/components/PayPal/constants.js +1 -1
  42. package/dist/es/components/PayPal/constants.js.map +1 -1
  43. package/dist/es/components/PayTo/PayTo.js.map +1 -1
  44. package/dist/es/components/Pix/PixInput/PixInput.js.map +1 -1
  45. package/dist/es/components/PromptPay/PromptPay.js +1 -1
  46. package/dist/es/components/Redirect/Redirect.js +1 -1
  47. package/dist/es/components/Riverty/Riverty.js +1 -1
  48. package/dist/es/components/Riverty/config.js +1 -1
  49. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  50. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  51. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  52. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  53. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  54. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  55. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
  56. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  57. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  58. package/dist/es/components/WeChat/WeChat.js +1 -1
  59. package/dist/es/components/internal/Address/Address.js +1 -1
  60. package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
  61. package/dist/es/components/internal/Countdown/utils.js.map +1 -1
  62. package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
  63. package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
  64. package/dist/es/components/internal/FormFields/InputDate/utils.js.map +1 -1
  65. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  66. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  67. package/dist/es/components/internal/IbanInput/validate.js +1 -1
  68. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  69. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  70. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  71. package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  72. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  73. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  74. package/dist/es/components/internal/PhoneInput/validate.js +1 -1
  75. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  76. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  77. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  78. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  79. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
  80. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
  81. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
  82. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
  83. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
  84. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
  85. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
  86. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
  87. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
  88. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  89. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  90. package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js +1 -1
  91. package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
  92. package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
  93. package/dist/es/components/internal/StoreDetails/StoreDetails.js +1 -1
  94. package/dist/es/components/internal/StoreDetails/StoreDetails.js.map +1 -1
  95. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  96. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  97. package/dist/es/core/Analytics/Analytics.js +1 -1
  98. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  99. package/dist/es/core/Analytics/constants.js +1 -1
  100. package/dist/es/core/Analytics/constants.js.map +1 -1
  101. package/dist/es/core/Analytics/utils.js +1 -1
  102. package/dist/es/core/Errors/constants.js +1 -1
  103. package/dist/es/core/Errors/constants.js.map +1 -1
  104. package/dist/es/core/Errors/utils.js +1 -1
  105. package/dist/es/core/Errors/utils.js.map +1 -1
  106. package/dist/es/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
  107. package/dist/es/core/RiskModule/constants.js +1 -1
  108. package/dist/es/core/RiskModule/constants.js.map +1 -1
  109. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  110. package/dist/es/core/Services/http.js +1 -1
  111. package/dist/es/core/core.js +1 -1
  112. package/dist/es/external/preact/dist/preact.js +1 -1
  113. package/dist/es/external/preact/dist/preact.js.map +1 -1
  114. package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
  115. package/dist/es/index.d.ts +88 -98
  116. package/dist/es/index.js +1 -1
  117. package/dist/es/utils/Validator/defaultRules.js +1 -1
  118. package/dist/es/utils/base64.js.map +1 -1
  119. package/dist/es/utils/browserInfo.js +1 -1
  120. package/dist/es/utils/browserInfo.js.map +1 -1
  121. package/dist/es/utils/setFocus.js +1 -1
  122. package/dist/es/utils/setFocus.js.map +1 -1
  123. package/dist/es/utils/textUtils.js +1 -1
  124. package/dist/es/utils/textUtils.js.map +1 -1
  125. package/dist/es/utils/useForm/useForm.js +1 -1
  126. package/dist/es-legacy/adyen.css +3 -3
  127. package/dist/es-legacy/adyen.css.map +1 -1
  128. package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js +1 -1
  129. package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js.map +1 -1
  130. package/dist/es-legacy/components/Ach/Ach.js +1 -1
  131. package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
  132. package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js +2 -0
  133. package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js.map +1 -0
  134. package/dist/es-legacy/components/Ach/components/AchComponent.js +2 -0
  135. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -0
  136. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js +2 -0
  137. package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
  138. package/dist/es-legacy/components/Ach/components/validate.js +2 -0
  139. package/dist/es-legacy/components/Ach/components/validate.js.map +1 -0
  140. package/dist/es-legacy/components/Ach/defaultProps.js +2 -0
  141. package/dist/es-legacy/components/Ach/defaultProps.js.map +1 -0
  142. package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
  143. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  144. package/dist/es-legacy/components/Atome/Atome.js +1 -1
  145. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  146. package/dist/es-legacy/components/BcmcMobile/BcmcMobile.js +1 -1
  147. package/dist/es-legacy/components/Boleto/components/BoletoInput/validate.js +1 -1
  148. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  149. package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
  150. package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
  151. package/dist/es-legacy/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
  152. package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
  153. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  154. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  155. package/dist/es-legacy/components/Card/components/CardInput/validate.js +1 -1
  156. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  157. package/dist/es-legacy/components/DuitNow/DuitNow.js +1 -1
  158. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  159. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  160. package/dist/es-legacy/components/PayNow/PayNow.js +1 -1
  161. package/dist/es-legacy/components/PayPal/constants.js +1 -1
  162. package/dist/es-legacy/components/PayPal/constants.js.map +1 -1
  163. package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
  164. package/dist/es-legacy/components/Pix/PixInput/PixInput.js.map +1 -1
  165. package/dist/es-legacy/components/PromptPay/PromptPay.js +1 -1
  166. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  167. package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
  168. package/dist/es-legacy/components/Riverty/config.js +1 -1
  169. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  170. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  171. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  172. package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  173. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  174. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  175. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
  176. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  177. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  178. package/dist/es-legacy/components/WeChat/WeChat.js +1 -1
  179. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  180. package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
  181. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  182. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  183. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  184. package/dist/es-legacy/components/internal/Countdown/utils.js.map +1 -1
  185. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
  186. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
  187. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  188. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  189. package/dist/es-legacy/components/internal/FormFields/InputDate/utils.js.map +1 -1
  190. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  191. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  192. package/dist/es-legacy/components/internal/IbanInput/validate.js +1 -1
  193. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  194. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  195. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  196. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  197. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  198. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  199. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  200. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  201. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  202. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  203. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
  204. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
  205. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
  206. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
  207. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
  208. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
  209. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
  210. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
  211. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
  212. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  213. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  214. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js +1 -1
  215. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
  216. package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
  217. package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
  218. package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js.map +1 -1
  219. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  220. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  221. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  222. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  223. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  224. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  225. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  226. package/dist/es-legacy/core/Errors/constants.js +1 -1
  227. package/dist/es-legacy/core/Errors/constants.js.map +1 -1
  228. package/dist/es-legacy/core/Errors/utils.js +1 -1
  229. package/dist/es-legacy/core/Errors/utils.js.map +1 -1
  230. package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
  231. package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
  232. package/dist/es-legacy/core/RiskModule/constants.js +1 -1
  233. package/dist/es-legacy/core/RiskModule/constants.js.map +1 -1
  234. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  235. package/dist/es-legacy/core/core.js +1 -1
  236. package/dist/es-legacy/external/preact/dist/preact.js +1 -1
  237. package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
  238. package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
  239. package/dist/es-legacy/index.js +1 -1
  240. package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
  241. package/dist/es-legacy/utils/base64.js.map +1 -1
  242. package/dist/es-legacy/utils/browserInfo.js +1 -1
  243. package/dist/es-legacy/utils/browserInfo.js.map +1 -1
  244. package/dist/es-legacy/utils/setFocus.js +1 -1
  245. package/dist/es-legacy/utils/setFocus.js.map +1 -1
  246. package/dist/es-legacy/utils/textUtils.js +1 -1
  247. package/dist/es-legacy/utils/textUtils.js.map +1 -1
  248. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  249. package/package.json +21 -21
  250. package/styles/adyen.css +3 -3
  251. package/dist/es/components/Ach/components/AchInput/AchInput.js +0 -2
  252. package/dist/es/components/Ach/components/AchInput/AchInput.js.map +0 -1
  253. package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
  254. package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
  255. package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
  256. package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
  257. package/dist/es/components/Ach/components/AchInput/defaultProps.js +0 -2
  258. package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +0 -1
  259. package/dist/es/components/Ach/components/AchInput/defaultStyles.js +0 -2
  260. package/dist/es/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
  261. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
  262. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
  263. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js +0 -2
  264. package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +0 -1
  265. package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
  266. package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
  267. package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
  268. package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
  269. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +0 -2
  270. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +0 -1
  271. package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js +0 -2
  272. package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
  273. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
  274. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"0wBAmBA,MAAMA,UAA+BC,EAuCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBU,6BAC/BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORtB,KAAK4B,SAAS,CAAEC,OAAQ,8BAErB,CAGH,MAAMC,EAAmB9B,KAAMC,MAAMC,gBAAgC6B,MAE/Df,EACFc,EAASE,QAAQC,IAAgC,EAC3ChB,EAAoBiB,wBACpBjB,EAAoBkB,+BAE9BnC,KAAKc,kBACD,CA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c,kBAAkBuD,EAAYZ,OAAQc,IAE/CN,YAAaA,KACT/D,EACJuE,gBAAiBzE,KAAKI,MAAMqE,gBAC5BC,aAAc1E,KAAK0E,eAKxB,IACX,CAtOAC,WAAAA,CAAYvE,GACRwE,MAAMxE,GAmBVyE,EAAOH,KAAAA,gBAAgBI,IACnB9E,KAAKI,MAAMoD,kBAAkB,CACzBF,KAAMI,EACNvC,QAAS2D,EACTlB,QAASC,EAAoBkB,uBACjC,IAtBA,MAAMC,MAAEA,EAAKC,gBAAEA,GAAoBjF,KAAKI,MAExC,GAAI4E,EAAO,CACP,MAAM9E,EAAiDgF,EAAuB,CAAEF,QAAOC,oBAEvFjF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEiF,SAAS,EAAOpD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA4C,EADEjF,EACY0D,OAAO,UAErBuB,EAHEjF,EAGYwF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT1C,YAAa,GACbsB,aAAa,EACb1B,UAAU"}
1
+ {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"0wBAmBA,MAAMA,UAA+BC,EAuCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAA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HEjF,EAGYwF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT1C,YAAa,GACbsB,aAAa,EACb1B,UAAU"}
@@ -1,2 +1,2 @@
1
- import e from"../helpers/QRLoaderContainer/QRLoaderContainer.js";import{delay as r,countdownTime as a}from"./config.js";import{TxVariants as t}from"../tx-variants.js";function o(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}class n extends e{formatProps(e){return{delay:r,countdownTime:a,...super.formatProps(e)}}}o(n,"type",t.wechatpayQR),o(n,"txVariants",[t.wechatpay]),o(n,"analyticsType","wechatpayQR");export{n as default};
1
+ import e from"../helpers/QRLoaderContainer/QRLoaderContainer.js";import{countdownTime as r,delay as a}from"./config.js";import{TxVariants as t}from"../tx-variants.js";function o(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}class n extends e{formatProps(e){return{delay:a,countdownTime:r,...super.formatProps(e)}}}o(n,"type",t.wechatpayQR),o(n,"txVariants",[t.wechatpay]),o(n,"analyticsType","wechatpayQR");export{n as default};
2
2
  //# sourceMappingURL=WeChat.js.map
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as s,useMemo as o,useState as r,useCallback as a,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as d}from"./validate.js";import{addressFormatters as c,countrySpecificFormatters as u}from"./validate.formats.js";import m from"./components/FieldContainer.js";import p from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{FALLBACK_VALUE as y,ADDRESS_SCHEMA as F}from"./constants.js";import{getMaxLengthByFieldAndCountry as h}from"../../../utils/validator-utils.js";import{useCoreContext as C}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function A(A){const{i18n:v}=C(),{label:b="",requiredFields:j,visibility:x,iOSFocusedField:S=null,showContextualElement:k}=A,M=s({});Object.keys(M.current).length||A.setComponentRef?.(M.current);const O=o((()=>new f(A.specifications)),[A.specifications]),D=O.getAddressSchemaForCountryFlat(A.countryCode).filter((e=>j.includes(e))),[w,B]=r(!1),[E,N]=r(!1),[P,L]=r(""),R=!!A.onAddressLookup,[V,q]=r(!1),H=!A.onAddressLookup||(w||E),{data:T,errors:_,valid:I,isValid:$,handleChangeFor:z,triggerValidation:G,setData:J,mergeData:K}=p({schema:D,defaultData:A.data,rules:{...d(O),...A.validationRules},formatters:c}),Q=a((e=>{const t=F.reduce(((t,s)=>{const o=e[s];return null!=o&&(t[s]=String(o)),t}),{});K(t),q(!0),G(),B(!0)}),[B,G,J]),U=a((()=>{N(!0)}),[]);M.current.showValidation=()=>{G(),L(!R||H||$?"":v.get("address.errors.incomplete"))};const W=D.filter((e=>!S||e===S));if(n((()=>{if(V)return void q(!1);const e=O.countryHasDataset(T.country)?"":y,t={...T,stateOrProvince:e};j.forEach((e=>{z(e,"input")(t[e]??"")})),t.postalCode&&z("postalCode","blur")(T.postalCode)}),[T.country]),n((()=>{const e=j.includes("stateOrProvince"),t=T.country&&O.countryHasDataset(T.country),s=e&&t,o=T.stateOrProvince||(s?"":y);z("stateOrProvince","input")(o)}),[]),n((()=>{const e=O.getOptionalFieldsForCountry(T.country),t=F.reduce(((t,s)=>{const o=e.includes(s),r=j.includes(s),a=T[s],n=A.data[s],i=o&&!a||!r?r||a||!n?y:n:a;return i?.length&&(t[s]=i),t}),{});A.onChange({data:t,valid:I,errors:_,isValid:$})}),[T,I,_,$]),"hidden"===x)return null;if("readOnly"===x)return e(l,{data:T,label:b});const X=(t,{classNameModifiers:s=[]})=>j.includes(t)?e(m,{key:t,allowedCountries:A.allowedCountries,classNameModifiers:[...s,t],data:T,errors:_,valid:I,fieldName:t,onInput:z(t,"input"),onBlur:z(t,"blur"),onDropdownChange:z(t,"blur"),specifications:O,maxLength:h(u,t,T.country),trimOnBlur:!0,disabled:!W.includes(t),onFieldFocusAnalytics:A.onFieldFocusAnalytics,onFieldBlurAnalytics:A.onFieldBlurAnalytics}):null,Y=O.getAddressSchemaForCountry(T.country);return e(t,null,e(i,{classNameModifiers:[b||"address"],label:b},R&&e(g,{onAddressLookup:A.onAddressLookup,onAddressSelected:A.onAddressSelected,onSelect:Q,onManualAddress:U,externalErrorMessage:P,hideManualButton:H,showContextualElement:k,contextualText:v.get("address.search.contextualText"),addressSearchDebounceMs:A.addressSearchDebounceMs}),H&&e(t,null,Y.map((t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map((([e,t])=>X(e,{classNameModifiers:[`col-${t}`]})))):X(t,{}))))))}A.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:F,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{A as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as s,useMemo as o,useState as r,useCallback as a,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as d}from"./validate.js";import{countrySpecificFormatters as c,addressFormatters as u}from"./validate.formats.js";import m from"./components/FieldContainer.js";import p from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as F}from"./constants.js";import{getMaxLengthByFieldAndCountry as h}from"../../../utils/validator-utils.js";import{useCoreContext as C}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function A(A){const{i18n:v}=C(),{label:b="",requiredFields:j,visibility:x,iOSFocusedField:S=null,showContextualElement:k}=A,M=s({});Object.keys(M.current).length||A.setComponentRef?.(M.current);const O=o((()=>new f(A.specifications)),[A.specifications]),D=O.getAddressSchemaForCountryFlat(A.countryCode).filter((e=>j.includes(e))),[w,B]=r(!1),[E,N]=r(!1),[P,L]=r(""),R=!!A.onAddressLookup,[V,q]=r(!1),H=!A.onAddressLookup||(w||E),{data:T,errors:_,valid:I,isValid:$,handleChangeFor:z,triggerValidation:G,setData:J,mergeData:K}=p({schema:D,defaultData:A.data,rules:{...d(O),...A.validationRules},formatters:u}),Q=a((e=>{const t=y.reduce(((t,s)=>{const o=e[s];return null!=o&&(t[s]=String(o)),t}),{});K(t),q(!0),G(),B(!0)}),[B,G,J]),U=a((()=>{N(!0)}),[]);M.current.showValidation=()=>{G(),L(!R||H||$?"":v.get("address.errors.incomplete"))};const W=D.filter((e=>!S||e===S));if(n((()=>{if(V)return void q(!1);const e=O.countryHasDataset(T.country)?"":F,t={...T,stateOrProvince:e};j.forEach((e=>{z(e,"input")(t[e]??"")})),t.postalCode&&z("postalCode","blur")(T.postalCode)}),[T.country]),n((()=>{const e=j.includes("stateOrProvince"),t=T.country&&O.countryHasDataset(T.country),s=e&&t,o=T.stateOrProvince||(s?"":F);z("stateOrProvince","input")(o)}),[]),n((()=>{const e=O.getOptionalFieldsForCountry(T.country),t=y.reduce(((t,s)=>{const o=e.includes(s),r=j.includes(s),a=T[s],n=A.data[s],i=o&&!a||!r?r||a||!n?F:n:a;return i?.length&&(t[s]=i),t}),{});A.onChange({data:t,valid:I,errors:_,isValid:$})}),[T,I,_,$]),"hidden"===x)return null;if("readOnly"===x)return e(l,{data:T,label:b});const X=(t,{classNameModifiers:s=[]})=>j.includes(t)?e(m,{key:t,allowedCountries:A.allowedCountries,classNameModifiers:[...s,t],data:T,errors:_,valid:I,fieldName:t,onInput:z(t,"input"),onBlur:z(t,"blur"),onDropdownChange:z(t,"blur"),specifications:O,maxLength:h(c,t,T.country),trimOnBlur:!0,disabled:!W.includes(t),onFieldFocusAnalytics:A.onFieldFocusAnalytics,onFieldBlurAnalytics:A.onFieldBlurAnalytics}):null,Y=O.getAddressSchemaForCountry(T.country);return e(t,null,e(i,{classNameModifiers:[b||"address"],label:b},R&&e(g,{onAddressLookup:A.onAddressLookup,onAddressSelected:A.onAddressSelected,onSelect:Q,onManualAddress:U,externalErrorMessage:P,hideManualButton:H,showContextualElement:k,contextualText:v.get("address.search.contextualText"),addressSearchDebounceMs:A.addressSearchDebounceMs}),H&&e(t,null,Y.map((t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map((([e,t])=>X(e,{classNameModifiers:[`col-${t}`]})))):X(t,{}))))))}A.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{A as default};
2
2
  //# sourceMappingURL=Address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters: CountryFormatRules = {\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n};\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","indexOf","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAAMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ,GAAKC,QAAQQ,EAAmB,IAEnEI,EAAiC,CAC1CC,WAAY,CACRf,YAAa,CAACC,EAAKe,KACf,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWf,YACpE,OAAIoB,EACOA,EAAanB,GAIjBA,CAAAA,GAGfqB,OAAQ,CACJtB,YAAaY,GAEjBW,kBAAmB,CACfvB,YAAaY,GAEjBY,KAAM,CACFxB,YAAaY,IAORS,EAAgD,CACzDI,GAAI,CACAV,WAAYjB,EAAqB,IAErC4B,GAAI,CACAX,WAAYjB,EAAqB,IAErC6B,GAAI,CACAZ,WAAYjB,EAAqB,IAErC8B,GAAI,CACAb,WAAYjB,EAAqB,IAErC+B,GAAI,CACAd,WAAY,CAERf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAQ,EAAI,EAAI,EAChD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ,wBACRI,UAAW,IAGnBuB,GAAI,CACAjB,WAAY,CACRV,OAAQ,oBAC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AAqB,IAErC6D,GAAI,CACA5C,WAAY,CAERf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAQ,EAAI,EAAI,EAChD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ,kBACRI,UAAW,IAGnBmD,GAAI,CACA7C,WAAY,CACRf,YAAaC,GACKA,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IAC/CC,UAAU,EAAG,GAE9BC,OAAQ,WACRI,UAAW,IAGnBoD,GAAI,CACA9C,WAAYjB,EAAqB,IAErCgE,GAAI,CACA/C,WAAY,CACRV,OAAQ,kBACRI,UAAW,IAGnBsD,GAAI,CACAhD,WAAYjB,EAAqB,IAErCkE,GAAI,CACAjD,WAAYjB,EAAqB,IAErCmE,GAAI,CACAlD,WAAY,CACRV,OAAQ,oBACRI,UAAW,IAGnByD,GAAI,CACAnD,WAAY,CACRV,OAAQ,WACRI,UAAW,IAGnB0D,GAAI,CACApD,WAAY,CACRf,YAAaC,IACT,MAAM6B,EAAQ7B,EAAIC,QAAQC,EAAmB,QAAS,KAAM,IACtDM,EAAYqB,EAAMC,QAAQ,MAAQ,EAAI,GAAK,EACjD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ"}
1
+ {"version":3,"file":"validate.formats.js","sources":["../../../../../src/components/internal/Address/validate.formats.ts"],"sourcesContent":["import { CountryFormatRules, FormatRules } from '../../../utils/Validator/types';\nimport { Formatter } from '../../../utils/useForm/types';\nimport { getFormattingRegEx, SPECIAL_CHARS, trimValWithOneSpace } from '../../../utils/validator-utils';\n\nconst createFormatByDigits = (digits: number): Formatter => {\n const format = new Array(digits).fill('9').join('');\n return {\n // Formatter - excludes non digits and limits to maxlength\n formatterFn: val => val.replace(getFormattingRegEx('^\\\\d', 'g'), '').substring(0, digits),\n format,\n maxlength: digits\n };\n};\n\nconst specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS);\nconst formattingFn = val => trimValWithOneSpace(val).replace(specialCharsRegEx, '');\n\nexport const addressFormatters: FormatRules = {\n postalCode: {\n formatterFn: (val, context) => {\n const country = context.state.data.country;\n\n // Country specific formatting rule\n const specificRule = countrySpecificFormatters[country]?.postalCode.formatterFn;\n if (specificRule) {\n return specificRule(val);\n }\n\n // Default formatting rule: allow anything\n return val;\n }\n },\n street: {\n formatterFn: formattingFn\n },\n houseNumberOrName: {\n formatterFn: formattingFn\n },\n city: {\n formatterFn: formattingFn\n }\n};\n\n// TODO make proper formatter fns for those entries that don't just have a straightforward, x number of digits, no spaces, format\n// check against our internal documentation on address postal code\n// which, for example, says BR isn't just 8 digits (it can be spilt by a hyphen) & CZ can also be 5 digits, no spaces\nexport const countrySpecificFormatters: CountryFormatRules = {\n AT: {\n postalCode: createFormatByDigits(4)\n },\n AU: {\n postalCode: createFormatByDigits(4)\n },\n BE: {\n postalCode: createFormatByDigits(4)\n },\n BG: {\n postalCode: createFormatByDigits(4)\n },\n BR: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 9 : 8;\n return nuVal.substring(0, maxlength);\n },\n format: '12345678 or 12345-678',\n maxlength: 9\n }\n },\n CA: {\n postalCode: {\n format: 'A9A 9A9 or A9A9A9',\n maxlength: 7\n }\n },\n CH: {\n postalCode: createFormatByDigits(4)\n },\n CY: {\n postalCode: createFormatByDigits(4)\n },\n CZ: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n DE: {\n postalCode: createFormatByDigits(5)\n },\n DK: {\n postalCode: {\n format: '9999',\n maxlength: 7\n }\n },\n EE: {\n postalCode: createFormatByDigits(5)\n },\n ES: {\n postalCode: createFormatByDigits(5)\n },\n FI: {\n postalCode: createFormatByDigits(5)\n },\n FR: {\n postalCode: createFormatByDigits(5)\n },\n GB: {\n postalCode: {\n // Disallow special chars & set to maxlength\n formatterFn: val => val.replace(getFormattingRegEx(SPECIAL_CHARS), '').substring(0, 8),\n format: 'AA99 9AA or A99 9AA or A9 9AA',\n maxlength: 8\n }\n },\n GR: {\n postalCode: {\n format: '999 99',\n maxlength: 6\n }\n },\n HR: {\n postalCode: {\n format: '[1-5]9999',\n maxlength: 5\n }\n },\n HU: {\n postalCode: createFormatByDigits(4)\n },\n IE: {\n postalCode: {\n format: 'A99 A999',\n maxlength: 8\n }\n },\n IS: {\n postalCode: createFormatByDigits(3)\n },\n IT: {\n postalCode: createFormatByDigits(5)\n },\n LI: {\n postalCode: createFormatByDigits(4)\n },\n LT: {\n postalCode: {\n format: '9999 or 99999 or LT-99999',\n maxlength: 8\n }\n },\n LU: {\n postalCode: createFormatByDigits(4)\n },\n LV: {\n postalCode: {\n format: '9999 or LV-9999',\n maxlength: 7\n }\n },\n MC: {\n postalCode: {\n format: '980NN',\n maxlength: 5\n }\n },\n MT: {\n postalCode: {\n format: 'AA99 or AAA99 or AA9999 or AAA9999',\n maxlength: 8\n }\n },\n MY: {\n postalCode: createFormatByDigits(5)\n },\n NL: {\n postalCode: {\n format: '9999AA',\n maxlength: 7\n }\n },\n NZ: {\n postalCode: createFormatByDigits(4)\n },\n NO: {\n postalCode: createFormatByDigits(4)\n },\n PL: {\n postalCode: {\n // Formatter - excludes non digits, but allows hyphens, and limits to a maxlength that varies depending on whether a hyphen is present or not\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 6 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99-999',\n maxlength: 6\n }\n },\n PT: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n return nuVal.substring(0, 8);\n },\n format: '9999-999',\n maxlength: 8\n }\n },\n RO: {\n postalCode: createFormatByDigits(6)\n },\n SI: {\n postalCode: {\n format: '9999 or SI-9999',\n maxlength: 7\n }\n },\n SE: {\n postalCode: createFormatByDigits(5)\n },\n SG: {\n postalCode: createFormatByDigits(6)\n },\n SK: {\n postalCode: {\n format: '99999 or SK-99999',\n maxlength: 8\n }\n },\n JP: {\n postalCode: {\n format: '999-9999',\n maxlength: 8\n }\n },\n US: {\n postalCode: {\n formatterFn: val => {\n const nuVal = val.replace(getFormattingRegEx('^\\\\d-', 'g'), '');\n const maxlength = nuVal.indexOf('-') > -1 ? 10 : 5;\n return nuVal.substring(0, maxlength);\n },\n format: '99999 or 99999-9999'\n }\n }\n};\n"],"names":["createFormatByDigits","digits","formatterFn","val","replace","getFormattingRegEx","substring","format","Array","fill","join","maxlength","specialCharsRegEx","SPECIAL_CHARS","formattingFn","trimValWithOneSpace","addressFormatters","postalCode","context","country","state","data","specificRule","countrySpecificFormatters","street","houseNumberOrName","city","AT","AU","BE","BG","BR","nuVal","indexOf","CA","CH","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HR","HU","IE","IS","IT","LI","LT","LU","LV","MC","MT","MY","NL","NZ","NO","PL","PT","RO","SI","SE","SG","SK","JP","US"],"mappings":"mHAIA,MAAMA,EAAwBC,IAEnB,CAEHC,YAAaC,GAAOA,EAAIC,QAAQC,EAAmB,OAAQ,KAAM,IAAIC,UAAU,EAAGL,GAClFM,OAJW,IAAIC,MAAMP,GAAQQ,KAAK,KAAKC,KAAK,IAK5CC,UAAWV,IAIbW,EAAoBP,EAAmBQ,GACvCC,EAAeX,GAAOY,EAAoBZ,GAAKC,QAAQQ,EAAmB,IAEnEI,EAAiC,CAC1CC,WAAY,CACRf,YAAa,CAACC,EAAKe,KACf,MAAMC,EAAUD,EAAQE,MAAMC,KAAKF,QAG7BG,EAAeC,EAA0BJ,IAAUF,WAAWf,YACpE,OAAIoB,EACOA,EAAanB,GAIjBA,CAAAA,GAGfqB,OAAQ,CACJtB,YAAaY,GAEjBW,kBAAmB,C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AAK,EACjD,OAAOD,EAAM1B,UAAU,EAAGK,EAAAA,EAE9BJ,OAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Countdown/utils.ts"],"sourcesContent":["/**\n * Pads a given string or number with zeros.\n *\n * @param value - Value to zero-pad.\n * @param length - Amount of characters to pad.\n * @returns Left-padded number/string.\n */\nexport const zeroPad = (value, length = 2) => {\n if (length === 0) return value;\n const strValue = String(value);\n return strValue.length >= length ? strValue : ('0'.repeat(length) + strValue).slice(length * -1);\n};\n\n/**\n * Calculates the remaining time as a percentage\n *\n * @param start - Start date\n * @param now - Current date\n * @param end - End date\n * @returns Percentage of the remaining time\n */\nexport const getProgressPercentage = (start, now, end) => {\n const difference = end.getTime() - start.getTime();\n return 100 - Math.round(((now.getTime() - start.getTime()) * 100) / difference);\n};\n\n/**\n * Calculates the difference in minutes and seconds from now to endDate\n *\n * @param startTime -\n * @param endTime -\n * @returns Time difference\n */\nexport const getTimeDifference = (startTime, endTime) => {\n const now = new Date();\n const diff = endTime.getTime() - now.getTime();\n const seconds = diff / 1000;\n const percentage = getProgressPercentage(startTime, now, endTime);\n\n return {\n total: diff,\n minutes: zeroPad(Math.floor((seconds / 60) % 60)),\n seconds: zeroPad(Math.floor(seconds % 60)),\n completed: diff <= 0,\n percentage\n };\n};\n"],"names":["zeroPad","value","length","strValue","String","repeat","slice","getProgressPercentage","start","now","end","difference","getTime","Math","round","getTimeDifference","startTime","endTime","Date","diff","seconds","percentage","total","minutes","floor","completed"],"mappings":"AAOaA,MAAAA,EAAU,CAACC,EAAOC,EAAS,KACpC,GAAe,IAAXA,EAAc,OAAOD,EACzB,MAAME,EAAWC,OAAOH,GACxB,OAAOE,EAASD,QAAUA,EAASC,GAAY,IAAIE,OAAOH,GAAUC,GAAUG,OAAgB,EAAVJ,EAAU,EAWrFK,EAAwB,CAACC,EAAOC,EAAKC,KAC9C,MAAMC,EAAaD,EAAIE,UAAYJ,EAAMI,UACzC,OAAO,IAAMC,KAAKC,MAA2C,KAAnCL,EAAIG,UAAYJ,EAAMI,WAAoBD,EAAAA,EAU3DI,EAAoB,CAACC,EAAWC,KACzC,MAAMR,EAAM,IAAIS,KACVC,EAAOF,EAAQL,UAAYH,EAAIG,UAC/BQ,EAAUD,EAAO,IACjBE,EAAad,EAAsBS,EAAWP,EAAKQ,GAEzD,MAAO,CACHK,MAAOH,EACPI,QAASvB,EAAQa,KAAKW,MAAOJ,EAAU,GAAM,KAC7CA,QAASpB,EAAQa,KAAKW,MAAMJ,EAAU,KACtCK,UAAWN,GAAQ,EACnBE,aACJ"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/Countdown/utils.ts"],"sourcesContent":["/**\n * Pads a given string or number with zeros.\n *\n * @param value - Value to zero-pad.\n * @param length - Amount of characters to pad.\n * @returns Left-padded number/string.\n */\nexport const zeroPad = (value, length = 2) => {\n if (length === 0) return value;\n const strValue = String(value);\n return strValue.length >= length ? strValue : ('0'.repeat(length) + strValue).slice(length * -1);\n};\n\n/**\n * Calculates the remaining time as a percentage\n *\n * @param start - Start date\n * @param now - Current date\n * @param end - End date\n * @returns Percentage of the remaining time\n */\nexport const getProgressPercentage = (start, now, end) => {\n const difference = end.getTime() - start.getTime();\n return 100 - Math.round(((now.getTime() - start.getTime()) * 100) / difference);\n};\n\n/**\n * Calculates the difference in minutes and seconds from now to endDate\n *\n * @param startTime -\n * @param endTime -\n * @returns Time difference\n */\nexport const getTimeDifference = (startTime, endTime) => {\n const now = new Date();\n const diff = endTime.getTime() - now.getTime();\n const seconds = diff / 1000;\n const percentage = getProgressPercentage(startTime, now, endTime);\n\n return {\n total: diff,\n minutes: zeroPad(Math.floor((seconds / 60) % 60)),\n seconds: zeroPad(Math.floor(seconds % 60)),\n completed: diff <= 0,\n percentage\n };\n};\n"],"names":["zeroPad","value","length","strValue","String","repeat","slice","getProgressPercentage","start","now","end","difference","getTime","Math","round","getTimeDifference","startTime","endTime","Date","diff","seconds","percentage","total","minutes","floor","completed"],"mappings":"AAOaA,MAAAA,EAAU,CAACC,EAAOC,EAAS,KACpC,GAAe,IAAXA,EAAc,OAAOD,EACzB,MAAME,EAAWC,OAAOH,GACxB,OAAOE,EAASD,QAAUA,EAASC,GAAY,IAAIE,OAAOH,GAAUC,GAAUG,OAAe,EAATJ,EAAU,EAWrFK,EAAwB,CAACC,EAAOC,EAAKC,KAC9C,MAAMC,EAAaD,EAAIE,UAAYJ,EAAMI,UACzC,OAAO,IAAMC,KAAKC,MAA2C,KAAnCL,EAAIG,UAAYJ,EAAMI,WAAoBD,EAAAA,EAU3DI,EAAoB,CAACC,EAAWC,KACzC,MAAMR,EAAM,IAAIS,KACVC,EAAOF,EAAQL,UAAYH,EAAIG,UAC/BQ,EAAUD,EAAO,IACjBE,EAAad,EAAsBS,EAAWP,EAAKQ,GAEzD,MAAO,CACHK,MAAOH,EACPI,QAASvB,EAAQa,KAAKW,MAAOJ,EAAU,GAAM,KAC7CA,QAASpB,EAAQa,KAAKW,MAAMJ,EAAU,KACtCK,UAAWN,GAAQ,EACnBE,aACJ"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import a from"../../../../_virtual/index.js";import{ARIA_ERROR_SUFFIX as c,ARIA_CONTEXT_SUFFIX as t}from"../../../../core/Errors/constants.js";function o({classNameModifiers:o=[],label:n,isInvalid:r,onChange:s,...i}){const{uniqueId:l,showErrorElement:d,showContextualElement:u,..._}=i;return e("label",{className:"adyen-checkout__checkbox",htmlFor:l},e("input",{id:l,..._,...d&&{"aria-describedby":`${l}${c}`},...u&&{"aria-describedby":`${l}${t}`},className:a(["adyen-checkout__checkbox__input",[i.className],{"adyen-checkout__checkbox__input--invalid":r},o.map((e=>`adyen-checkout__input--${e}`))]),type:"checkbox",onChange:s}),e("span",{className:"adyen-checkout__checkbox__label"},n))}o.defaultProps={onChange:()=>{}};export{o as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import a from"../../../../_virtual/index.js";import{ARIA_CONTEXT_SUFFIX as c,ARIA_ERROR_SUFFIX as t}from"../../../../core/Errors/constants.js";function o({classNameModifiers:o=[],label:n,isInvalid:s,onChange:r,disabled:i=!1,...l}){const{uniqueId:d,showErrorElement:u,showContextualElement:_,...h}=l;return e("label",{className:"adyen-checkout__checkbox",htmlFor:d},e("input",{id:d,...h,...u&&{"aria-describedby":`${d}${t}`},..._&&{"aria-describedby":`${d}${c}`},className:a(["adyen-checkout__checkbox__input",[l.className],{"adyen-checkout__checkbox__input--invalid":s},o.map((e=>`adyen-checkout__input--${e}`))]),type:"checkbox",disabled:i,onChange:r}),e("span",{className:"adyen-checkout__checkbox__label"},n))}o.defaultProps={onChange:()=>{}};export{o as default};
2
2
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/internal/FormFields/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ComponentChild, h } from 'preact';\nimport cx from 'classnames';\nimport './Checkbox.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\n\ninterface CheckboxProps {\n checked?: boolean;\n classNameModifiers?: string[];\n label?: string | ComponentChild;\n name?: string;\n isInvalid?: boolean;\n onChange?;\n onInput?;\n className?: string;\n value?: string;\n uniqueId?: string;\n showErrorElement?: boolean;\n showContextualElement?: boolean;\n}\n\nexport default function Checkbox({ classNameModifiers = [], label, isInvalid, onChange, ...props }: CheckboxProps) {\n // Strip some values from props. We need to reference them but don't want to set them as attributes.\n const { uniqueId: uid, showErrorElement, showContextualElement, ...newProps } = props;\n\n return (\n <label className=\"adyen-checkout__checkbox\" htmlFor={uid}>\n <input\n id={uid}\n {...newProps}\n {...(showErrorElement && { 'aria-describedby': `${uid}${ARIA_ERROR_SUFFIX}` })}\n {...(showContextualElement && { 'aria-describedby': `${uid}${ARIA_CONTEXT_SUFFIX}` })}\n className={cx([\n 'adyen-checkout__checkbox__input',\n [props.className],\n { 'adyen-checkout__checkbox__input--invalid': isInvalid },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n ])}\n type=\"checkbox\"\n onChange={onChange}\n />\n <span className=\"adyen-checkout__checkbox__label\">{label}</span>\n </label>\n );\n}\n\nCheckbox.defaultProps = {\n onChange: () => {}\n};\n"],"names":["Checkbox","classNameModifiers","label","isInvalid","onChange","props","uniqueId","uid","showErrorElement","showContextualElement","newProps","h","className","htmlFor","input","id","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","cx","map","m","type","span","defaultProps"],"mappings":"0NAoBe,SAASA,GAASC,mBAAEA,EAAqB,GAAEC,MAAEA,EAAKC,UAAEA,EAASC,SAAEA,KAAaC,IAEvF,MAAQC,SAAUC,EAAGC,iBAAEA,EAAgBC,sBAAEA,KAA0BC,GAAaL,EAEhF,OACIM,EAACT,QAAAA,CAAMU,UAAU,2BAA2BC,QAASN,GACjDI,EAACG,QAAAA,CACGC,GAAIR,KACAG,KACCF,GAAoB,CAAE,mBAAoB,GAAGD,IAAMS,QACnDP,GAAyB,CAAE,mBAAoB,GAAGF,IAAMU,KAC7DL,UAAWM,EAAG,CACV,kCACA,CAACb,EAAMO,WACP,CAAE,2CAA4CT,GAC9CF,EAAmBkB,KAAIC,GAAK,0BAA0BA,QAE1DC,KAAK,WACLjB,SAAUA,IAEdO,EAACW,OAAAA,CAAKV,UAAU,mCAAmCV,GAG/D,CAEAF,EAASuB,aAAe,CACpBnB,SAAU"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../../../../src/components/internal/FormFields/Checkbox/Checkbox.tsx"],"sourcesContent":["import { ComponentChild, h } from 'preact';\nimport cx from 'classnames';\nimport './Checkbox.scss';\nimport { ARIA_CONTEXT_SUFFIX, ARIA_ERROR_SUFFIX } from '../../../../core/Errors/constants';\n\ninterface CheckboxProps {\n checked?: boolean;\n classNameModifiers?: string[];\n label?: string | ComponentChild;\n name?: string;\n isInvalid?: boolean;\n onChange?;\n onInput?;\n className?: string;\n value?: string;\n uniqueId?: string;\n showErrorElement?: boolean;\n showContextualElement?: boolean;\n disabled?: boolean;\n}\n\nexport default function Checkbox({ classNameModifiers = [], label, isInvalid, onChange, disabled = false, ...props }: CheckboxProps) {\n // Strip some values from props. We need to reference them but don't want to set them as attributes.\n const { uniqueId: uid, showErrorElement, showContextualElement, ...newProps } = props;\n\n return (\n <label className=\"adyen-checkout__checkbox\" htmlFor={uid}>\n <input\n id={uid}\n {...newProps}\n {...(showErrorElement && { 'aria-describedby': `${uid}${ARIA_ERROR_SUFFIX}` })}\n {...(showContextualElement && { 'aria-describedby': `${uid}${ARIA_CONTEXT_SUFFIX}` })}\n className={cx([\n 'adyen-checkout__checkbox__input',\n [props.className],\n { 'adyen-checkout__checkbox__input--invalid': isInvalid },\n classNameModifiers.map(m => `adyen-checkout__input--${m}`)\n ])}\n type=\"checkbox\"\n disabled={disabled}\n onChange={onChange}\n />\n <span className=\"adyen-checkout__checkbox__label\">{label}</span>\n </label>\n );\n}\n\nCheckbox.defaultProps = {\n onChange: () => {}\n};\n"],"names":["Checkbox","classNameModifiers","label","isInvalid","onChange","disabled","props","uniqueId","uid","showErrorElement","showContextualElement","newProps","h","className","htmlFor","input","id","ARIA_ERROR_SUFFIX","ARIA_CONTEXT_SUFFIX","cx","map","m","type","span","defaultProps"],"mappings":"0NAqBe,SAASA,GAASC,mBAAEA,EAAqB,GAAEC,MAAEA,EAAKC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,GAAW,KAAUC,IAEzG,MAAQC,SAAUC,EAAGC,iBAAEA,EAAgBC,sBAAEA,KAA0BC,GAAaL,EAEhF,OACIM,EAACV,QAAAA,CAAMW,UAAU,2BAA2BC,QAASN,GACjDI,EAACG,QAAAA,CACGC,GAAIR,KACAG,KACCF,GAAoB,CAAE,mBAAoB,GAAGD,IAAMS,QACnDP,GAAyB,CAAE,mBAAoB,GAAGF,IAAMU,KAC7DL,UAAWM,EAAG,CACV,kCACA,CAACb,EAAMO,WACP,CAAE,2CAA4CV,GAC9CF,EAAmBmB,KAAIC,GAAK,0BAA0BA,QAE1DC,KAAK,WACLjB,SAAUA,EACVD,SAAUA,IAEdQ,EAACW,OAAAA,CAAKV,UAAU,mCAAmCX,GAG/D,CAEAF,EAASwB,aAAe,CACpBpB,SAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/components/internal/FormFields/InputDate/utils.ts"],"sourcesContent":["/**\n * Returns either the date input is supported or not in the current browser\n */\nconst checkDateInputSupport = (): boolean => {\n const input = document.createElement('input');\n input.setAttribute('type', 'date');\n return input.type === 'date';\n};\n\n/**\n * Returns a formatted date\n * @param value -\n * @example\n * formatDate('22111990');\n * // '22/11/1990'\n */\nconst formatDate = (value: string): string => {\n const date = value\n .replace(/\\D|\\s/g, '') // Digits only\n .replace(/^(00)(.*)?/, '01$2') // 00 -> 01\n .replace(/^(3[2-9])(.*)?/, '0$1$2') // 34 -> 03/04\n .replace(/^([4-9])(.*)?/, '0$1') // 4 -> 04\n .replace(/^([0-9]{2})(00)(.*)?/, '$101') // 01/00 -> 01/01\n .replace(/^(3[01])(02)(.*)?/, '29$2') // Force up to day 29 for Feb\n .replace(/^([0-9]{2})([2-9]|1[3-9])(.*)?/, '$10$2') // 01/4 -> 01/04\n .replace(/^([0-9]{2})([0-9]{2})([0-9])/, '$1/$2/$3') // 22111990 -> 22/11/1990\n .replace(/^([0-9]{2})([0-9])/, '$1/$2'); // 2211 -> 22/11\n\n const [day = '', month = '', year = ''] = date.split('/');\n\n // Check leap year\n if (year.length === 4 && day === '29' && month === '02' && (Number(year) % 4 !== 0 || (year.substr(2, 2) === '00' && Number(year) % 400 !== 0))) {\n return date.replace(/^29/, '28');\n }\n\n return date;\n};\n\n/**\n * Receives a formatted date and returns it as the API expects it\n * @param value -\n * @example\n * unformatDate('22/11/1990');\n * // '1990-11-22'\n */\nconst unformatDate = (value = ''): string => {\n if (value.indexOf('/') === -1) return value;\n const [day = '', month = '', year = ''] = value.split('/');\n if (!day || !month || !year) return null;\n return `${year}-${month}-${day}`;\n};\n\nexport { checkDateInputSupport, formatDate, unformatDate };\n"],"names":["checkDateInputSupport","input","document","createElement","setAttribute","type","formatDate","value","date","replace","day","month","year","split","length","Number","substr","unformatDate","indexOf"],"mappings":"MAGMA,EAAwB,KAC1B,MAAMC,EAAQC,SAASC,cAAc,SAErC,OADAF,EAAMG,aAAa,OAAQ,QACL,SAAfH,EAAMI,IAAS,EAUpBC,EAAcC,IAChB,MAAMC,EAAOD,EACRE,QAAQ,SAAU,IAClBA,QAAQ,aAAc,QACtBA,QAAQ,iBAAkB,SAC1BA,QAAQ,gBAAiB,OACzBA,QAAQ,uBAAwB,QAChCA,QAAQ,oBAAqB,QAC7BA,QAAQ,iCAAkC,SAC1CA,QAAQ,+BAAgC,YACxCA,QAAQ,qBAAsB,UAE5BC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,EAAKK,MAAM,KAGrD,OAAoB,IAAhBD,EAAKE,QAAwB,OAARJ,GAA0B,OAAVC,IAAmBI,OAAOH,GAAQ,GAAM,GAA4B,OAAtBA,EAAKI,OAAO,EAAG,IAAeD,OAAOH,GAAQ,KAAQ,GACjIJ,EAAKC,QAAQ,MAAO,MAGxBD,CAAAA,EAULS,EAAe,CAACV,EAAQ,MAC1B,IAA4B,IAAxBA,EAAMW,QAAQ,KAAa,OAAOX,EACtC,MAAOG,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAML,EAAMM,MAAM,KACtD,OAAKH,GAAQC,GAAUC,EAChB,GAAGA,KAAQD,KAASD,IADS,IACJ"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/components/internal/FormFields/InputDate/utils.ts"],"sourcesContent":["/**\n * Returns either the date input is supported or not in the current browser\n */\nconst checkDateInputSupport = (): boolean => {\n const input = document.createElement('input');\n input.setAttribute('type', 'date');\n return input.type === 'date';\n};\n\n/**\n * Returns a formatted date\n * @param value -\n * @example\n * formatDate('22111990');\n * // '22/11/1990'\n */\nconst formatDate = (value: string): string => {\n const date = value\n .replace(/\\D|\\s/g, '') // Digits only\n .replace(/^(00)(.*)?/, '01$2') // 00 -> 01\n .replace(/^(3[2-9])(.*)?/, '0$1$2') // 34 -> 03/04\n .replace(/^([4-9])(.*)?/, '0$1') // 4 -> 04\n .replace(/^([0-9]{2})(00)(.*)?/, '$101') // 01/00 -> 01/01\n .replace(/^(3[01])(02)(.*)?/, '29$2') // Force up to day 29 for Feb\n .replace(/^([0-9]{2})([2-9]|1[3-9])(.*)?/, '$10$2') // 01/4 -> 01/04\n .replace(/^([0-9]{2})([0-9]{2})([0-9])/, '$1/$2/$3') // 22111990 -> 22/11/1990\n .replace(/^([0-9]{2})([0-9])/, '$1/$2'); // 2211 -> 22/11\n\n const [day = '', month = '', year = ''] = date.split('/');\n\n // Check leap year\n if (year.length === 4 && day === '29' && month === '02' && (Number(year) % 4 !== 0 || (year.substr(2, 2) === '00' && Number(year) % 400 !== 0))) {\n return date.replace(/^29/, '28');\n }\n\n return date;\n};\n\n/**\n * Receives a formatted date and returns it as the API expects it\n * @param value -\n * @example\n * unformatDate('22/11/1990');\n * // '1990-11-22'\n */\nconst unformatDate = (value = ''): string => {\n if (value.indexOf('/') === -1) return value;\n const [day = '', month = '', year = ''] = value.split('/');\n if (!day || !month || !year) return null;\n return `${year}-${month}-${day}`;\n};\n\nexport { checkDateInputSupport, formatDate, unformatDate };\n"],"names":["checkDateInputSupport","input","document","createElement","setAttribute","type","formatDate","value","date","replace","day","month","year","split","length","Number","substr","unformatDate","indexOf"],"mappings":"MAGMA,EAAwB,KAC1B,MAAMC,EAAQC,SAASC,cAAc,SAErC,OADAF,EAAMG,aAAa,OAAQ,QACL,SAAfH,EAAMI,IAAS,EAUpBC,EAAcC,IAChB,MAAMC,EAAOD,EACRE,QAAQ,SAAU,IAClBA,QAAQ,aAAc,QACtBA,QAAQ,iBAAkB,SAC1BA,QAAQ,gBAAiB,OACzBA,QAAQ,uBAAwB,QAChCA,QAAQ,oBAAqB,QAC7BA,QAAQ,iCAAkC,SAC1CA,QAAQ,+BAAgC,YACxCA,QAAQ,qBAAsB,UAE5BC,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAMJ,EAAKK,MAAM,KAGrD,OAAoB,IAAhBD,EAAKE,QAAwB,OAARJ,GAA0B,OAAVC,IAAmBI,OAAOH,GAAQ,GAAM,GAA4B,OAAtBA,EAAKI,OAAO,EAAG,IAAeD,OAAOH,GAAQ,KAAQ,GACjIJ,EAAKC,QAAQ,MAAO,MAGxBD,CAAAA,EAULS,EAAe,CAACV,EAAQ,MAC1B,IAA2B,IAAvBA,EAAMW,QAAQ,KAAa,OAAOX,EACtC,MAAOG,EAAM,GAAIC,EAAQ,GAAIC,EAAO,IAAML,EAAMM,MAAM,KACtD,OAAKH,GAAQC,GAAUC,EAChB,GAAGA,KAAQD,KAASD,IADS,IACJ"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import n from"../../../../../_virtual/index.js";import o from"../../../Img/Img.js";function a({filterable:t,toggleButtonRef:n,...o}){if(t){const{id:t,...a}=o;return e("div",{...a,ref:n})}return e("button",{id:o.id,"aria-describedby":o.ariaDescribedBy,type:"button",...o,ref:n})}function d(d){const{active:r,selected:i,inputText:c,readonly:l,showList:s,required:u}=d,_=i.selectedOptionName||i.name||d.placeholder||"",p=s?c:_,f=l?null:d.filterable?e=>{e.preventDefault(),document.activeElement===d.filterInputRef.current?d.showList||d.toggleList(e):d.filterInputRef.current&&d.filterInputRef.current.focus()}:d.toggleList,b=l?null:d.onFocus,y=r.id?`listItem-${r.id}`:"";return e(a,{className:n({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":l,"adyen-checkout__dropdown__button--active":s,"adyen-checkout__dropdown__button--invalid":d.isInvalid,"adyen-checkout__dropdown__button--valid":d.isValid,"adyen-checkout__dropdown__button--disabled":i.disabled}),disabled:d.disabled,filterable:d.filterable,onClick:f,onKeyDown:l?null:d.onButtonKeyDown,toggleButtonRef:d.toggleButtonRef,...d.allowIdOnButton&&d.id&&{id:d.id}},d.filterable?e(t,null,!s&&i.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("input",{value:p,"aria-autocomplete":"list","aria-controls":d.selectListId,"aria-expanded":s,"aria-owns":d.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:d.onInput,onFocus:b,ref:d.filterInputRef,role:"combobox","aria-activedescendant":y,type:"text",readOnly:d.readonly,id:d.id,"aria-describedby":d.ariaDescribedBy,required:u}),!s&&i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)):e(t,null,i.icon&&e(o,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("span",{className:"adyen-checkout__dropdown__button__text"},_),i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)))}export{d as default};
1
+ import{createElement as e,Fragment as t}from"../../../../../external/preact/dist/preact.js";import o from"../../../../../_virtual/index.js";import n from"../../../Img/Img.js";import{useMemo as a}from"../../../../../external/preact/hooks/dist/hooks.js";function d({filterable:t,toggleButtonRef:o,...n}){if(t){const{id:t,...a}=n;return e("div",{...a,ref:o})}return e("button",{id:n.id,"aria-describedby":n.ariaDescribedBy,type:"button",...n,ref:o})}function r(r){const{active:c,selected:i,inputText:l,readonly:s,showList:u,required:_}=r,p=a((()=>{const e=i.selectedOptionName||i.name;return!0!==("string"==typeof e&&""!==e.trim())}),[i,r.placeholder]),f=i.selectedOptionName||i.name||r.placeholder||"",m=u?l:f,y=s?null:r.filterable?e=>{e.preventDefault(),document.activeElement===r.filterInputRef.current?r.showList||r.toggleList(e):r.filterInputRef.current&&r.filterInputRef.current.focus()}:r.toggleList,b=s?null:r.onFocus,h=c.id?`listItem-${c.id}`:"";return e(d,{className:o({"adyen-checkout__dropdown__button":!0,"adyen-checkout__dropdown__button--readonly":s,"adyen-checkout__dropdown__button--active":u,"adyen-checkout__dropdown__button--invalid":r.isInvalid,"adyen-checkout__dropdown__button--valid":r.isValid,"adyen-checkout__dropdown__button--disabled":i.disabled}),disabled:r.disabled,filterable:r.filterable,onClick:y,onKeyDown:s?null:r.onButtonKeyDown,toggleButtonRef:r.toggleButtonRef,...r.allowIdOnButton&&r.id&&{id:r.id}},r.filterable?e(t,null,!u&&i.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("input",{value:m,"aria-autocomplete":"list","aria-controls":r.selectListId,"aria-expanded":u,"aria-owns":r.selectListId,autoComplete:"off",className:"adyen-checkout__filter-input",onInput:r.onInput,onFocus:b,ref:r.filterInputRef,role:"combobox","aria-activedescendant":h,type:"text",readOnly:r.readonly,id:r.id,"aria-describedby":r.ariaDescribedBy,required:_}),!u&&i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)):e(t,null,i.icon&&e(n,{className:"adyen-checkout__dropdown__button__icon",src:i.icon,alt:i.name}),e("span",{className:o("adyen-checkout__dropdown__button__text",{"adyen-checkout__dropdown__button__text-placeholder":p})},f),i.secondaryText&&e("span",{className:"adyen-checkout__dropdown__button__secondary-text"},i.secondaryText)))}export{r as default};
2
2
  //# sourceMappingURL=SelectButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return <button id={props.id} aria-describedby={props.ariaDescribedBy} type={'button'} {...props} ref={toggleButtonRef} />;\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n const onFocusHandler = readonly ? null : props.onFocus;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n // Only for some dropdowns e.g. the one found in installments when it is just in the form of a single dropdown, do we want to add an id that links to a label's for attr\n // If we allow an id to be added to the buttons in CtPCardsList, for example, unit tests start failing because it seems a button with an id no longer has a name property that can be used\n // as a qualifier in findByRole\n {...(props.allowIdOnButton && props.id && { id: props.id })}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span className=\"adyen-checkout__dropdown__button__text\">{displayText}</span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n onFocus={onFocusHandler}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","filterable","toggleButtonRef","props","id","strippedProps","h","div","ref","button","aria-describedby","ariaDescribedBy","type","SelectButton","active","selected","inputText","readonly","showList","required","displayText","selectedOptionName","name","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","onFocusHandler","onFocus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","allowIdOnButton","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-controls","selectListId","aria-expanded","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span"],"mappings":"+KAKA,SAASA,GAAoBC,WAAEA,EAAUC,gBAAEA,KAAoBC,IAC3D,GAAIF,EAAY,CAEZ,MAAMG,GAAEA,KAAOC,GAAkBF,EACjC,OAAOG,EAACC,MAAAA,IAAQF,EAAeG,IAAKN,GACxC,CAEA,OAAOI,EAACG,SAAAA,CAAOL,GAAID,EAAMC,GAAIM,mBAAkBP,EAAMQ,gBAAiBC,KAAM,YAAcT,EAAOK,IAAKN,GAC1G,CAEA,SAASW,EAAaV,GA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uBzB,EACvBxB,KAAK,OACLkD,SAAU3D,EAAMc,SAChBb,GAAID,EAAMC,GACVM,mBAAkBP,EAAMQ,gBACxBQ,SAAUA,KAEZD,GAAYH,EAASgD,eACnBzD,EAAC0D,OAAAA,CAAK3B,UAAU,oDAAoDtB,EAASgD,gBA5BrFzD,EAACwC,OACI/B,EAASgC,MAAQzC,EAAC0C,EAAAA,CAAIX,UAAU,yCAAyCY,IAAKlC,EAASgC,KAAMG,IAAKnC,EAASO,OAC5GhB,EAAC0D,OAAAA,CAAK3B,UAAU,0CAA0CjB,GACzDL,EAASgD,eAAiBzD,EAAC0D,OAAAA,CAAK3B,UAAU,oDAAoDtB,EAASgD,gBA+B5H"}
1
+ {"version":3,"file":"SelectButton.js","sources":["../../../../../../../src/components/internal/FormFields/Select/components/SelectButton.tsx"],"sourcesContent":["import { h, Fragment } from 'preact';\nimport cx from 'classnames';\nimport { SelectButtonProps } from '../types';\nimport Img from '../../../Img';\nimport { useMemo } from 'preact/hooks';\nimport classnames from 'classnames';\n\nfunction SelectButtonElement({ filterable, toggleButtonRef, ...props }) {\n if (filterable) {\n // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element\n const { id, ...strippedProps } = props;\n return <div {...strippedProps} ref={toggleButtonRef} />;\n }\n\n return <button id={props.id} aria-describedby={props.ariaDescribedBy} type={'button'} {...props} ref={toggleButtonRef} />;\n}\n\nfunction SelectButton(props: Readonly<SelectButtonProps>) {\n const { active, selected, inputText, readonly, showList, required } = props;\n\n const isShowingPlaceholder = useMemo(() => {\n const displayText = selected.selectedOptionName || selected.name;\n const isValidValue = typeof displayText === 'string' && displayText.trim() !== '';\n return isValidValue !== true;\n }, [selected, props.placeholder]);\n\n // display fallback order\n const displayText = selected.selectedOptionName || selected.name || props.placeholder || '';\n // displayInputText only used for the text input for the filter\n // display the \"typed\" filter text when showing the dropdown,\n // hide it and show the \"selected\" value when collapsed\n const displayInputText = showList ? inputText : displayText;\n\n const setFocus = (e: Event) => {\n e.preventDefault();\n if (document.activeElement === props.filterInputRef.current) {\n if (!props.showList) {\n props.toggleList(e);\n }\n } else if (props.filterInputRef.current) props.filterInputRef.current.focus();\n };\n\n // 1. If readonly we ignore the click action\n // 2. If filterable we want to show the list and focus on the input\n // 3. Otherwise we just toggle the list\n const onClickHandler = readonly ? null : props.filterable ? setFocus : props.toggleList;\n\n const onFocusHandler = readonly ? null : props.onFocus;\n\n // check COWEB-1301 [Investigate] Drop-in Accessibility - ADA Compliance questions\n const currentSelectedItemId = active.id ? `listItem-${active.id}` : '';\n\n return (\n <SelectButtonElement\n className={cx({\n 'adyen-checkout__dropdown__button': true,\n 'adyen-checkout__dropdown__button--readonly': readonly,\n 'adyen-checkout__dropdown__button--active': showList,\n 'adyen-checkout__dropdown__button--invalid': props.isInvalid,\n 'adyen-checkout__dropdown__button--valid': props.isValid,\n 'adyen-checkout__dropdown__button--disabled': selected.disabled\n })}\n disabled={props.disabled}\n filterable={props.filterable}\n onClick={onClickHandler}\n onKeyDown={!readonly ? props.onButtonKeyDown : null}\n toggleButtonRef={props.toggleButtonRef}\n // Only for some dropdowns e.g. the one found in installments when it is just in the form of a single dropdown, do we want to add an id that links to a label's for attr\n // If we allow an id to be added to the buttons in CtPCardsList, for example, unit tests start failing because it seems a button with an id no longer has a name property that can be used\n // as a qualifier in findByRole\n {...(props.allowIdOnButton && props.id && { id: props.id })}\n >\n {!props.filterable ? (\n <Fragment>\n {selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <span\n className={classnames('adyen-checkout__dropdown__button__text', {\n 'adyen-checkout__dropdown__button__text-placeholder': isShowingPlaceholder\n })}\n >\n {displayText}\n </span>\n {selected.secondaryText && <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>}\n </Fragment>\n ) : (\n <Fragment>\n {!showList && selected.icon && <Img className=\"adyen-checkout__dropdown__button__icon\" src={selected.icon} alt={selected.name} />}\n <input\n value={displayInputText}\n aria-autocomplete=\"list\"\n aria-controls={props.selectListId}\n aria-expanded={showList}\n aria-owns={props.selectListId}\n autoComplete=\"off\"\n className=\"adyen-checkout__filter-input\"\n onInput={props.onInput}\n onFocus={onFocusHandler}\n ref={props.filterInputRef}\n role=\"combobox\"\n aria-activedescendant={currentSelectedItemId}\n type=\"text\"\n readOnly={props.readonly}\n id={props.id}\n aria-describedby={props.ariaDescribedBy}\n required={required}\n />\n {!showList && selected.secondaryText && (\n <span className=\"adyen-checkout__dropdown__button__secondary-text\">{selected.secondaryText}</span>\n )}\n </Fragment>\n )}\n </SelectButtonElement>\n );\n}\n\nexport default SelectButton;\n"],"names":["SelectButtonElement","filterable","toggleButtonRef","props","id","strippedProps","h","div","ref","button","aria-describedby","ariaDescribedBy","type","SelectButton","active","selected","inputText","readonly","showList","required","isShowingPlaceholder","useMemo","displayText","selectedOptionName","name","trim","placeholder","displayInputText","onClickHandler","e","preventDefault","document","activeElement","filterInputRef","current","toggleList","focus","onFocusHandler","onFocus","currentSelectedItemId","className","cx","isInvalid","isValid","disabled","onClick","onKeyDown","onButtonKeyDown","allowIdOnButton","Fragment","icon","Img","src","alt","input","value","aria-autocomplete","aria-controls","selectListId","aria-expanded","aria-owns","autoComplete","onInput","role","aria-activedescendant","readOnly","secondaryText","span","classnames"],"mappings":"4PAOA,SAASA,GAAoBC,WAAEA,EAAUC,gBAAEA,KAAoBC,IAC3D,GAAIF,EAAY,CAEZ,MAAMG,GAAEA,KAAOC,GAAkBF,EACjC,OAAOG,EAACC,MAAAA,IAAQF,EAAeG,IAAKN,GACxC,CAEA,OAAOI,EAACG,SAAAA,CAAOL,GAAID,EAAMC,GAAIM,mBAAkBP,EAAMQ,gBAAiBC,KAAM,YAAcT,EAAOK,IAAKN,GAC1G,CAEA,SAASW,EAAaV,GAClB,MAAMW,OAAEA,EAAMC,SAAEA,EAAQC,UAAEA,EAASC,SAAEA,EAAQC,SAAEA,EAAQC,SAAEA,GAAahB,EAEhEiB,EAAuBC,GAAQ,KACjC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L,EAAM8B,eACX8B,KAAK,WACLC,wBAAuBzB,EACvB3B,KAAK,OACLqD,SAAU9D,EAAMc,SAChBb,GAAID,EAAMC,GACVM,mBAAkBP,EAAMQ,gBACxBQ,SAAUA,KAEZD,GAAYH,EAASmD,eACnB5D,EAAC6D,OAAAA,CAAK3B,UAAU,oDAAoDzB,EAASmD,gBAlCrF5D,EAAC2C,OACIlC,EAASmC,MAAQ5C,EAAC6C,EAAAA,CAAIX,UAAU,yCAAyCY,IAAKrC,EAASmC,KAAMG,IAAKtC,EAASS,OAC5GlB,EAAC6D,OAAAA,CACG3B,UAAW4B,EAAW,yCAA0C,CAC5D,qDAAsDhD,KAGzDE,GAEJP,EAASmD,eAAiB5D,EAAC6D,OAAAA,CAAK3B,UAAU,oDAAoDzB,EAASmD,gBA+B5H"}
@@ -1,2 +1,2 @@
1
- import{electronicFormat as t,getCountryCode as n,iso13616Prepare as e,iso7064Mod97_10 as i,getIbanCountrySpecification as l,regex as s}from"./utils.js";import{isEmpty as o}from"../../../utils/validator-utils.js";function r(t,n=null){this.status=t,this.code=n}const a=n=>{const l=t(n),o=e(l);return 1===i(o)&&(t=>{const n=t.slice(0,2),e=s(t,n);return e.test&&e.test(t.slice(4))||!1})(l)},u=e=>{const i=t(e);if(e.length<2)return new r("no-validate","TOO_SHORT");const s=n(i),o=l(s);return o?i.length>o.length?new r("invalid","TOO_LONG"):i.length===o.length?a(e)?new r("valid","VALID"):new r("invalid","INVALID_IBAN"):new r("no-validate","UNKNOWN"):new r("invalid","INVALID_COUNTRY")},c=t=>!o(t)||null;export{u as checkIbanStatus,c as isValidHolder,a as isValidIBAN};
1
+ import{electronicFormat as t,getCountryCode as n,getIbanCountrySpecification as e,iso13616Prepare as i,iso7064Mod97_10 as l,regex as s}from"./utils.js";import{isEmpty as o}from"../../../utils/validator-utils.js";function r(t,n=null){this.status=t,this.code=n}const a=n=>{const e=t(n),o=i(e);return 1===l(o)&&(t=>{const n=t.slice(0,2),e=s(t,n);return e.test&&e.test(t.slice(4))||!1})(e)},u=i=>{const l=t(i);if(i.length<2)return new r("no-validate","TOO_SHORT");const s=n(l),o=e(s);return o?l.length>o.length?new r("invalid","TOO_LONG"):l.length===o.length?a(i)?new r("valid","VALID"):new r("invalid","INVALID_IBAN"):new r("no-validate","UNKNOWN"):new r("invalid","INVALID_COUNTRY")},c=t=>!o(t)||null;export{u as checkIbanStatus,c as isValidHolder,a as isValidIBAN};
2
2
  //# sourceMappingURL=validate.js.map
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../../utils/useForm/useForm.js";import n from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u 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 c}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_SELECTED_STR as f,ANALYTICS_DISPLAYED_STR as C,ANALYTICS_LIST as F,ANALYTICS_SEARCH_DEBOUNCE_TIME as j,ANALYTICS_INPUT_STR as y,ANALYTICS_LIST_SEARCH as x,ANALYTICS_FEATURED_ISSUER as S}from"../../../core/Analytics/constants.js";import{debounce as _}from"../../../utils/debounce.js";const b=({issuer:e,items:s},t)=>{const r=s.find((s=>s.id===e))?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},v=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function M({items:M,placeholder:A,issuer:k,highlightedIds:E=[],showContextualElement:T,contextualText:V,...w}){const{i18n:B}=m(),{handleChangeFor:N,triggerValidation:P,data:R,valid:D,errors:L,isValid:G}=a({schema:v,defaultData:{issuer:k},rules:I}),[$,K]=t("ready"),[O,q]=t(1),{setSRMessagesFromObjects:z,shouldMoveFocusSR:H}=d(),J=z?.({});this.setStatus=e=>{K(e)};const Q=r((e=>s=>{const t=1===e?F:S,r=M.find((e=>e.id===s.target.value));w.onSubmitAnalytics({type:f,target:t,issuer:r.name}),q(e),N("issuer")(s)}),[N]),U=r((e=>{e&&w.onSubmitAnalytics({type:C,target:F})}),[]),W=o(_(w.onSubmitAnalytics,j)),X=r((()=>{W.current({type:y,target:x})}),[]);i((()=>{w.onChange({data:R,valid:D,errors:L,isValid:G});const e=J?.({errors:L,isValidating:!0});e?.action===c&&H&&g(".adyen-checkout__issuer-list",e.fieldToFocus)}),[R,D,L,G]),this.showValidation=()=>{P()};const{highlightedItems:Y}=M.reduce(((e,s)=>(E.includes(s.id)&&e.highlightedItems.push({...s}),e)),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!Y.length&&e(s,null,e(l,{selectedIssuerId:0===O?R.issuer:null,items:Y,onChange:Q(0)}),e(u,null)),e(n,{label:B.get("issuerList.selectField.label"),errorMessage:(Z=L.issuer,Z&&Z.errorMessage?B.get(Z.errorMessage):!!Z),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:T,contextualText:V},e(p,{items:M,selectedValue:1===O?R.issuer:null,placeholder:A,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:Q(1),onListToggle:U,onInput:X})),w.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:B.get(w.termsAndConditions.translationKey),urls:w.termsAndConditions.urls})),w.showPayButton&&w.payButton({status:$,label:b({issuer:R.issuer,items:[...M,...Y]},B)}));var Z}M.defaultProps={onChange:()=>{}};export{M as default};
1
+ import{createElement as e,Fragment as s}from"../../../external/preact/dist/preact.js";import{useState as t,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import a from"../../../utils/useForm/useForm.js";import n from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u 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 c}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as f,ANALYTICS_FEATURED_ISSUER as C,ANALYTICS_SELECTED_STR as j,ANALYTICS_DISPLAYED_STR as y,ANALYTICS_SEARCH_DEBOUNCE_TIME as F,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as S}from"../../../core/Analytics/constants.js";import{debounce as _}from"../../../utils/debounce.js";const b=({issuer:e,items:s},t)=>{const r=s.find((s=>s.id===e))?.name;return e&&r?`${t.get("continueTo")} ${r}`:t.get("continue")},v=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function M({items:M,placeholder:A,issuer:k,highlightedIds:E=[],showContextualElement:V,contextualText:w,...T}){const{i18n:B}=m(),{handleChangeFor:N,triggerValidation:P,data:R,valid:D,errors:L,isValid:G}=a({schema:v,defaultData:{issuer:k},rules:I}),[$,K]=t("ready"),[O,q]=t(1),{setSRMessagesFromObjects:z,shouldMoveFocusSR:H}=d(),J=z?.({});this.setStatus=e=>{K(e)};const Q=r((e=>s=>{const t=1===e?f:C,r=M.find((e=>e.id===s.target.value));T.onSubmitAnalytics({type:j,target:t,issuer:r.name}),q(e),N("issuer")(s)}),[N]),U=r((e=>{e&&T.onSubmitAnalytics({type:y,target:f})}),[]),W=o(_(T.onSubmitAnalytics,F)),X=r((()=>{W.current({type:S,target:x})}),[]);i((()=>{T.onChange({data:R,valid:D,errors:L,isValid:G});const e=J?.({errors:L,isValidating:!0});e?.action===c&&H&&g(".adyen-checkout__issuer-list","issuer-list")}),[R,D,L,G]),this.showValidation=()=>{P()};const{highlightedItems:Y}=M.reduce(((e,s)=>(E.includes(s.id)&&e.highlightedItems.push({...s}),e)),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!Y.length&&e(s,null,e(l,{selectedIssuerId:0===O?R.issuer:null,items:Y,onChange:Q(0)}),e(u,null)),e(n,{label:B.get("issuerList.selectField.label"),errorMessage:(Z=L.issuer,Z&&Z.errorMessage?B.get(Z.errorMessage):!!Z),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:V,contextualText:w},e(p,{items:M,selectedValue:1===O?R.issuer:null,placeholder:A,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:Q(1),onListToggle:U,onInput:X})),T.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:B.get(T.termsAndConditions.translationKey),urls:T.termsAndConditions.urls})),T.showPayButton&&T.payButton({status:$,label:b({issuer:R.issuer,items:[...M,...Y]},B)}));var Z}M.defaultProps={onChange:()=>{}};export{M 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';\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 './IssuerList.scss';\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 {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\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({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: 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 getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\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('.adyen-checkout__issuer-list', srPanelResp.fieldToFocus);\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\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 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={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","showValidation","highlightedItems","reduce","memo","item","includes","push","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"mjCA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACvC,MAAMC,EAAaF,EAAMG,M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OxF,EAAe,CAAEC,OAAQwB,EAAc,OAAEvB,MAAO,IAAIA,KAAUwE,IAAqBvE,MA9FlFsF,IAAAA,CAkG5B,CAEAzE,EAAWsF,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';\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 './IssuerList.scss';\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 {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\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({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: 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 getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\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('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\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 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={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","placeholder","highlightedIds","showContextualElement","contextualText","props","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"mjCA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACvC,MAAMC,EAAaF,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,KAASO,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,GAAWd,MAAEA,EAAKe,YAAEA,EAAWhB,OAAEA,EAAMiB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,KAAmBC,IAC7G,MAAMlB,KAAEA,GAASmB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFnB,SACAoB,YAAa,CAAE7B,UACf8B,MAAOpB,KAEJqB,EAAQC,GAAaC,EAAS,UAC9B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AAOuE,EACPP,SAAUvB,EAAAA,KAEdoC,EAACM,SAITN,EAACO,EAAAA,CACGC,MAAOpF,EAAKM,IAAI,gCAChBK,cAnEY0E,EAmEkB7D,EAAO1B,OAnEfuF,GAASA,EAAM1E,aAAeX,EAAKM,IAAI+E,EAAM1E,gBAAkB0E,GAoErFC,mBAAoB,CAAC,eACrBjF,KAAM,SACNW,sBAAuBA,EACvBC,eAAgBA,GAEhB2D,EAACW,EAAAA,CACGxF,MAAOA,EACPyF,cAA6DlE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ER,YAAaA,EACbT,KAAM,SACNyE,UAAW,wCACXf,SAAUvB,EAAAA,GACViD,aAActC,EACduC,QAAShC,KAIhBxC,EAAMyE,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAAS7F,EAAKM,IAAIY,EAAMyE,mBAAmBG,gBAAiBC,KAAM7E,EAAMyE,mBAAmBI,QAIrH7E,EAAM8E,eACH9E,EAAM+E,UAAU,CACZpE,SACAuD,MAAOvF,EAAe,CAAEC,OAAQwB,EAAc,OAAEvB,MAAO,IAAIA,KAAUuE,IAAqBtE,MA9FlFqF,IAAAA,CAkG5B,CAEAxE,EAAWqF,aAAe,CACtBnC,SAAU"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useMemo as s,useEffect as r}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as o}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as a,ERROR_ACTION_FOCUS_FIELD as l}from"../../../core/Errors/constants.js";import n from"../../../core/Errors/useSRPanelContext.js";import c from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as p}from"../../../utils/hookUtils.js";import{getArrayDifferences as u}from"../../../utils/arrayUtils.js";import{mapFieldKey as m}from"./utils.js";const y=({errors:y,data:f,props:b,isValidating:j})=>{const[g,A]=e(null),F=p(g),{setSRMessagesFromObjects:S,setSRMessagesFromStrings:h,clearSRPanel:C,shouldMoveFocusSR:k}=n(),v=S?.({fieldTypeMappingFn:m}),D=s((()=>new c),[]),E=s((()=>new c(b.deliveryAddressSpecification)),[]);r((()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:r,personalDetails:n,bankAccount:c,billingAddress:p,deliveryAddress:m,...g}=y,S=o(p,s),M=o(m,e),R={..."object"==typeof r&&r,..."object"==typeof n&&n,..."object"==typeof c&&c,..."object"==typeof S&&S,..."object"==typeof M&&M,...g},x=t,L=b.personalDetailsRequiredFields??i,P=i.filter((e=>L?.includes(e))),$=["holder","iban"],w=D.getAddressSchemaForCountryFlat(f.billingAddress?.country).map((e=>`${s}${e}`)),T=E.getAddressSchemaForCountryFlat(f.deliveryAddress?.country).map((s=>`${e}${s}`)),U=x.concat(P,$,w,T,["consentCheckbox"]),V=D.getAddressLabelsForCountry(f.billingAddress?.country),_=E.getAddressLabelsForCountry(f.deliveryAddress?.country),q=v?.({errors:R,isValidating:j.current,layout:U,countrySpecificLabels:{...V,..._}}),B=q?.currentErrorsSortedByLayout;switch(A(B),q?.action){case l:k&&d(".adyen-checkout__open-invoice",q.fieldToFocus),setTimeout((()=>{j.current=!1}),300);break;case a:{const e=u(B,F,"field"),s=e?.[0];if(s){const e="shopperEmail.invalid"===s.errorCode?s.errorMessage:null;h(e)}else C();break}}}catch(e){}}),[y,f])};export{y as default};
1
+ import{useState as e,useMemo as s,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as r}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as t}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as i}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as l,ERROR_ACTION_FOCUS_FIELD as a}from"../../../core/Errors/constants.js";import c from"../../../core/Errors/useSRPanelContext.js";import n from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as p}from"../../../utils/arrayUtils.js";import{mapFieldKey as f}from"./utils.js";const m=({errors:m,data:y,props:b,isValidating:j})=>{const[F,g]=e(null),A=u(F),{setSRMessagesFromObjects:h,setSRMessagesFromStrings:S,clearSRPanel:k,shouldMoveFocusSR:C}=c(),v=h?.({fieldTypeMappingFn:f}),D=s((()=>new n),[]),T=s((()=>new n(b.deliveryAddressSpecification)),[]);o((()=>{try{const e="deliveryAddress:",s="billingAddress:",{companyDetails:o,personalDetails:c,bankAccount:n,billingAddress:u,deliveryAddress:f,...F}=m,h=r(u,s),E=r(f,e),M={..."object"==typeof o&&o,..."object"==typeof c&&c,..."object"==typeof n&&n,..."object"==typeof h&&h,..."object"==typeof E&&E,...F},R=t,$=b.personalDetailsRequiredFields??i,x=i.filter((e=>$?.includes(e))),L=["holder","iban"],P=D.getAddressSchemaForCountryFlat(y.billingAddress?.country).map((e=>`${s}${e}`)),_=T.getAddressSchemaForCountryFlat(y.deliveryAddress?.country).map((s=>`${e}${s}`)),w=R.concat(x,L,P,_,["consentCheckbox"]),U=D.getAddressLabelsForCountry(y.billingAddress?.country),V=T.getAddressLabelsForCountry(y.deliveryAddress?.country),q=v?.({errors:M,isValidating:j.current,layout:w,countrySpecificLabels:{...U,...V}}),B=q?.currentErrorsSortedByLayout;switch(g(B),q?.action){case a:{const e=q.fieldToFocus.includes(":")?q.fieldToFocus.split(":")[1]:q.fieldToFocus;let s="";const o=q.fieldToFocus.includes(":")?q.fieldToFocus.split(":")[0]:"";o.length&&(s=`.adyen-checkout__fieldset--${o} `),C&&d(".adyen-checkout__open-invoice",e,s),setTimeout((()=>{j.current=!1}),300);break}case l:{const e=p(B,A,"field"),s=e?.[0];if(s){const e="shopperEmail"===s.field&&"field.error.invalid"===s.errorCode?s.errorMessage:null;S(e)}else k();break}}}catch(e){}}),[m,y])};export{m 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}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', srPanelResp.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.errorCode === 'shopperEmail.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorCode","errorMessage","_"],"mappings":"6vBAsBMA,MAAAA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,IAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,GAAQ,IAAM,IAAIC,GAAkB,IACnEC,EAAgCF,GAAQ,IAAM,IAAIC,EAAejB,EAAMmB,+BAA+B,IAE5GC,GAAU,KACN,IACI,MAAMC,EAA0B,mBAC1BC,EAAyB,mBAK3BC,eAAgBC,EAChBC,gBAAiBC,EACjBC,YAAaC,EACbC,eAAgBC,EAChBC,gBAAiBC,KACdC,GACHnC,EAIEoC,EAA+BC,EAAuBL,EAA+BR,GACrFc,EAAgCD,EAAuBH,EAAgCX,GAGvFgB,EAAiB,IAC0B,iBAAlCb,GAA8CA,KACX,iBAAnCE,GAA+CA,KAChB,iBAA/BE,GAA2CA,KACV,iBAAjCM,GAA6CA,KACX,iBAAlCE,GAA8CA,KACtDH,GAIDK,EAAiCC,EAEjCC,EAAqCxC,EAAMyC,+BAAiCC,EAC5EC,EAAiCD,EAAwBE,QAAOC,GAAKL,GAA0BM,SAASD,KAExGE,EAAoB,CAAC,SAAU,QAI/BC,EAFuBjC,EAA6BkC,+BAA+BlD,EAAK8B,gBAAgBqB,SAEpDC,KAAIC,GAAQ,GAAG9B,IAAyB8B,MAG5FC,EADwBnC,EAA8B+B,+BAA+BlD,EAAKgC,iBAAiBmB,SACrDC,KAAIC,GAAQ,GAAG/B,IAA0B+B,MAE/FE,EAAahB,EAAqBiB,OACpCZ,EACAI,EACAC,EACAK,EACA,CAAC,oBAICG,EAAgCzC,EAA6B0C,2BAA2B1D,EAAK8B,gBAAgBqB,SAC7GQ,EAAiCxC,EAA8BuC,2BAA2B1D,EAAKgC,iBAAiBmB,SAGhHS,EAAyC/C,IAAgB,CAC3Dd,OAAQuC,EACRpC,aAAcA,EAAa2D,QAC3BC,OAAQP,EACRQ,sBAAuB,IAAKN,KAAkCE,KAI5DK,EAA8BJ,GAAaI,4BAQjD,OALA5D,EAAmB4D,GAKXJ,GAAaK,QAEjB,KAAKC,EAEGvD,GAAmBwD,EAAgB,gCAAiCP,EAAYQ,cAEpFC,YAAW,KACPnE,EAAa2D,SAAU,CAAA,GACxB,KACH,MAGJ,KAAKS,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBR,EAA6B1D,EAAsB,SAEpFmE,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAHgD,yBAA7BD,EAAeE,UAGCF,EAAeG,aAAe,KACvEnE,EAAyBiE,QAGzBhE,IAGJ,KACJ,EAIR,CAAE,MAAOmE,GAET,IACD,CAAC9E,EAAQC,GAAK"}
1
+ {"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\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 if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', 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","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","field","errorCode","errorMessage","_"],"mappings":"6vBAsBMA,MAAAA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,IAA2B,CACpEM,mBAAoBC,IAGlBC,EAA+BC,GAAQ,IAAM,IAAIC,GAAkB,IACnEC,EAAgCF,GAAQ,IAAM,IAAIC,EAAejB,EAAMmB,+BAA+B,IAE5GC,GAAU,KACN,IACI,MAAMC,EAA0B,mBAC1BC,EAAyB,mBAK3BC,eAAgBC,EAChBC,gBAAiBC,EACjBC,YAAaC,EACbC,eAAgBC,EAChBC,gBAAiBC,KACdC,GACHnC,EAIEoC,EAA+BC,EAAuBL,EAA+BR,GACrFc,EAAgCD,EAAuBH,EAAgCX,GAGvFgB,EAAiB,IAC0B,iBAAlCb,GAA8CA,KACX,iBAAnCE,GAA+CA,KAChB,iBAA/BE,GAA2CA,KACV,iBAAjCM,GAA6CA,KACX,iBAAlCE,GAA8CA,KACtDH,GAIDK,EAAiCC,EAEjCC,EAAqCxC,EAAMyC,+BAAiCC,EAC5EC,EAAiCD,EAAwBE,QAAOC,GAAKL,GAA0BM,SAASD,KAExGE,EAAoB,CAAC,SAAU,QAI/BC,EAFuBjC,EAA6BkC,+BAA+BlD,EAAK8B,gBAAgBqB,SAEpDC,KAAIC,GAAQ,GAAG9B,IAAyB8B,MAG5FC,EADwBnC,EAA8B+B,+BAA+BlD,EAAKgC,iBAAiBmB,SACrDC,KAAIC,GAAQ,GAAG/B,IAA0B+B,MAE/FE,EAAahB,EAAqBiB,OACpCZ,EACAI,EACAC,EACAK,EACA,CAAC,oBAICG,EAAgCzC,EAA6B0C,2BAA2B1D,EAAK8B,gBAAgBqB,SAC7GQ,EAAiCxC,EAA8BuC,2BAA2B1D,EAAKgC,iBAAiBmB,SAGhHS,EAAyC/C,IAAgB,CAC3Dd,OAAQuC,EACRpC,aAAcA,EAAa2D,QAC3BC,OAAQP,EACRQ,sBAAuB,IAAKN,KAAkCE,KAI5DK,EAA8BJ,GAAaI,4BAQjD,OALA5D,EAAmB4D,GAKXJ,GAAaK,QAEjB,KAAKC,EAA0B,CAK3B,MAAMC,EAAeP,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAKR,EAAYO,aAGnH,IAAIE,EAAuB,GAC3B,MAAMC,EAAeV,EAAYO,aAAapB,SAAS,KAAOa,EAAYO,aAAaC,MAAM,KAAK,GAAK,GACnGE,EAAaC,SACbF,EAAuB,8BAA8BC,MAIrD3D,GAAmB6D,EAAgB,gCAAiCL,EAAcE,GAEtFI,YAAW,KACPvE,EAAa2D,SAAU,CAAA,GACxB,KACH,KACJ,CAKA,KAAKa,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBZ,EAA6B1D,EAAsB,SAEpFuE,EAAiBF,IAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAH4C,iBAAzBD,EAAeE,OAAyD,wBAA7BF,EAAeG,UAG1CH,EAAeI,aAAe,KACvExE,EAAyBqE,QAGzBpE,IAGJ,KACJ,EAIR,CAAE,MAAOwE,GAET,IACD,CAACnF,EAAQC,GAAK"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as o,useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import s from"../../../utils/useForm/useForm.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{phoneValidationRules as n,phoneFormatters as a}from"./validate.js";import l from"../FormFields/Fieldset/Fieldset.js";import m from"./PhoneInputFields.js";function u(u){const{i18n:p}=i(),d=u.requiredFields||[...u?.items?.length?["phonePrefix"]:[],"phoneNumber"],f=d.includes("phonePrefix")&&!!u?.items?.length,h=d.includes("phoneNumber"),c=s({i18n:p,...u,schema:d,defaultData:u.data,rules:n,formatters:a});r((()=>{c.setSchema(d)}),[d.toString()]);const{data:g,valid:b,errors:x,isValid:F,triggerValidation:j}=c;r((()=>{u.onChange({data:g,valid:b,errors:x,isValid:F})}),[g,b,x,F]);const N=o({showValidation:j});r((()=>{u.setComponentRef(N.current)}),[u.setComponentRef]);const P=t((e=>{if(x[e]){const r="phoneNumber"===e?"phoneNumberErrorKey":"phonePrefixErrorKey",o=u[r]?u[r]:x[e].errorMessage;return p.get(o)??null}return null}),[x]);return e(l,{classNameModifiers:["phone-input"]},e(m,{getError:P,showNumber:h,showPrefix:f,form:c,...u}))}u.defaultProps={phoneLabel:"telephoneNumber"};export{u as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as o,useCallback as t}from"../../../external/preact/hooks/dist/hooks.js";import s from"../../../utils/useForm/useForm.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{phoneValidationRules as n,phoneFormatters as a}from"./validate.js";import l from"../FormFields/Fieldset/Fieldset.js";import m from"./PhoneInputFields.js";function u(u){const{i18n:p}=i(),d=u.requiredFields||[...u?.items?.length?["phonePrefix"]:[],"phoneNumber"],f=d.includes("phonePrefix")&&!!u?.items?.length,h=d.includes("phoneNumber"),c=s({...u,schema:d,defaultData:u.data,rules:n,formatters:a});r((()=>{c.setSchema(d)}),[d.toString()]);const{data:g,valid:b,errors:x,isValid:F,triggerValidation:j}=c;r((()=>{u.onChange({data:g,valid:b,errors:x,isValid:F})}),[g,b,x,F]);const N=o({showValidation:j});r((()=>{u.setComponentRef(N.current)}),[u.setComponentRef]);const P=t((e=>{if(x[e]){const r="phoneNumber"===e?"phoneNumberErrorKey":"phonePrefixErrorKey",o=u[r]?u[r]:x[e].errorMessage;return p.get(o)??null}return null}),[x]);return e(l,{classNameModifiers:["phone-input"]},e(m,{getError:P,showNumber:h,showPrefix:f,form:c,...u}))}u.defaultProps={phoneLabel:"telephoneNumber"};export{u as default};
2
2
  //# sourceMappingURL=PhoneInputForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInputForm.js","sources":["../../../../../src/components/internal/PhoneInput/PhoneInputForm.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './PhoneInput.scss';\nimport { phoneFormatters, phoneValidationRules } from './validate';\nimport { PhoneInputFormProps, PhoneInputSchema } from './types';\nimport Fieldset from '../FormFields/Fieldset';\nimport PhoneInputFields from './PhoneInputFields';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\n/**\n *\n * @param PhoneInputFormProps\n * @constructor\n */\nfunction PhoneInputForm(props: PhoneInputFormProps) {\n const { i18n } = useCoreContext();\n\n const schema = props.requiredFields || [...(props?.items?.length ? ['phonePrefix'] : []), 'phoneNumber'];\n const showPrefix = schema.includes('phonePrefix') && !!props?.items?.length;\n const showNumber = schema.includes('phoneNumber');\n\n const form = useForm<PhoneInputSchema>({\n i18n,\n ...props,\n schema,\n defaultData: props.data,\n rules: phoneValidationRules,\n formatters: phoneFormatters\n });\n\n useEffect(() => {\n form.setSchema(schema);\n }, [schema.toString()]);\n\n const { data, valid, errors, isValid, triggerValidation } = form;\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const componentRef = useRef<ComponentMethodsRef>({\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n props.setComponentRef(componentRef.current);\n }, [props.setComponentRef]);\n\n // This is here for MBWay, prob should be moved up\n // MBWay has a weird way of loading its error messages\n // They come form the prop phoneNumberErrorKey: 'mobileNumber.invalid'\n // Strangely it's defined as invalidPhoneNumber in the validation rules\n const getPhoneFieldError = useCallback(\n (field: string) => {\n if (errors[field]) {\n const propsField = field === 'phoneNumber' ? 'phoneNumberErrorKey' : 'phonePrefixErrorKey';\n const key = props[propsField] ? props[propsField] : errors[field].errorMessage;\n return i18n.get(key) ?? null;\n }\n return null;\n },\n [errors]\n );\n\n return (\n <Fieldset classNameModifiers={['phone-input']}>\n <PhoneInputFields getError={getPhoneFieldError} showNumber={showNumber} showPrefix={showPrefix} form={form} {...props} />\n </Fieldset>\n );\n}\n\nPhoneInputForm.defaultProps = {\n phoneLabel: 'telephoneNumber'\n};\n\nexport default PhoneInputForm;\n"],"names":["PhoneInputForm","props","i18n","useCoreContext","schema","requiredFields","items","length","showPrefix","includes","showNumber","form","useForm","defaultData","data","rules","phoneValidationRules","formatters","phoneFormatters","useEffect","setSchema","toString","valid","errors","isValid","triggerValidation","onChange","componentRef","useRef","showValidation","setComponentRef","current","getPhoneFieldError","useCallback","field","propsField","key","errorMessage","get","h","Fieldset","classNameModifiers","PhoneInputFields","getError","defaultProps","phoneLabel"],"mappings":"ucAgBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,IAEXC,EAASH,EAAMI,gBAAkB,IAAKJ,GAAOK,OAAOC,OAAS,CAAC,eAAiB,GAAK,eACpFC,EAAaJ,EAAOK,SAAS,kBAAoBR,GAAOK,OAAOC,OAC/DG,EAAaN,EAAOK,SAAS,eAE7BE,EAAOC,EAA0B,CACnCV,UACGD,EACHG,SACAS,YAAaZ,EAAMa,KACnBC,MAAOC,EACPC,WAAYC,IAGhBC,GAAU,KACNR,EAAKS,UAAUhB,EAAAA,GAChB,CAACA,EAAOiB,aAEX,MAAMP,KAAEA,EAAIQ,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,kBAAEA,GAAsBd,EAE5DQ,GAAU,KACNlB,EAAMyB,SAAS,CAAEZ,OAAMQ,QAAOC,SAAQC,WAAQ,GAC/C,CAACV,EAAMQ,EAAOC,EAAQC,IAEzB,MAAMG,EAAeC,EAA4B,CAC7CC,eAAgBJ,IAGpBN,GAAU,KACNlB,EAAM6B,gBAAgBH,EAAaI,QAAO,GAC3C,CAAC9B,EAAM6B,kBAMV,MAAME,EAAqBC,GACtBC,IACG,GAAIX,EAAOW,GAAQ,CACf,MAAMC,EAAuB,gBAAVD,EAA0B,sBAAwB,sBAC/DE,EAAMnC,EAAMkC,GAAclC,EAAMkC,GAAcZ,EAAOW,GAAOG,aAClE,OAAOnC,EAAKoC,IAAIF,IAAQ,IAC5B,CACA,OAAO,IAAA,GAEX,CAACb,IAGL,OACIgB,EAACC,EAAAA,CAASC,mBAAoB,CAAC,gBAC3BF,EAACG,EAAAA,CAAiBC,SAAUX,EAAoBtB,WAAYA,EAAYF,WAAYA,EAAYG,KAAMA,KAAUV,IAG5H,CAEAD,EAAe4C,aAAe,CAC1BC,WAAY"}
1
+ {"version":3,"file":"PhoneInputForm.js","sources":["../../../../../src/components/internal/PhoneInput/PhoneInputForm.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport './PhoneInput.scss';\nimport { phoneFormatters, phoneValidationRules } from './validate';\nimport { PhoneInputFormProps, PhoneInputSchema } from './types';\nimport Fieldset from '../FormFields/Fieldset';\nimport PhoneInputFields from './PhoneInputFields';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\n/**\n *\n * @param PhoneInputFormProps\n * @constructor\n */\nfunction PhoneInputForm(props: PhoneInputFormProps) {\n const { i18n } = useCoreContext();\n\n const schema = props.requiredFields || [...(props?.items?.length ? ['phonePrefix'] : []), 'phoneNumber'];\n const showPrefix = schema.includes('phonePrefix') && !!props?.items?.length;\n const showNumber = schema.includes('phoneNumber');\n\n const form = useForm<PhoneInputSchema>({\n i18n,\n ...props,\n schema,\n defaultData: props.data,\n rules: phoneValidationRules,\n formatters: phoneFormatters\n });\n\n useEffect(() => {\n form.setSchema(schema);\n }, [schema.toString()]);\n\n const { data, valid, errors, isValid, triggerValidation } = form;\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n const componentRef = useRef<ComponentMethodsRef>({\n showValidation: triggerValidation\n });\n\n useEffect(() => {\n props.setComponentRef(componentRef.current);\n }, [props.setComponentRef]);\n\n // This is here for MBWay, prob should be moved up\n // MBWay has a weird way of loading its error messages\n // They come form the prop phoneNumberErrorKey: 'mobileNumber.invalid'\n // Strangely it's defined as invalidPhoneNumber in the validation rules\n const getPhoneFieldError = useCallback(\n (field: string) => {\n if (errors[field]) {\n const propsField = field === 'phoneNumber' ? 'phoneNumberErrorKey' : 'phonePrefixErrorKey';\n const key = props[propsField] ? props[propsField] : errors[field].errorMessage;\n return i18n.get(key) ?? null;\n }\n return null;\n },\n [errors]\n );\n\n return (\n <Fieldset classNameModifiers={['phone-input']}>\n <PhoneInputFields getError={getPhoneFieldError} showNumber={showNumber} showPrefix={showPrefix} form={form} {...props} />\n </Fieldset>\n );\n}\n\nPhoneInputForm.defaultProps = {\n phoneLabel: 'telephoneNumber'\n};\n\nexport default PhoneInputForm;\n"],"names":["PhoneInputForm","props","i18n","useCoreContext","schema","requiredFields","items","length","showPrefix","includes","showNumber","form","useForm","defaultData","data","rules","phoneValidationRules","formatters","phoneFormatters","useEffect","setSchema","toString","valid","errors","isValid","triggerValidation","onChange","componentRef","useRef","showValidation","setComponentRef","current","getPhoneFieldError","useCallback","field","propsField","key","errorMessage","get","h","Fieldset","classNameModifiers","PhoneInputFields","getError","defaultProps","phoneLabel"],"mappings":"ucAgBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,IAEXC,EAASH,EAAMI,gBAAkB,IAAKJ,GAAOK,OAAOC,OAAS,CAAC,eAAiB,GAAK,eACpFC,EAAaJ,EAAOK,SAAS,kBAAoBR,GAAOK,OAAOC,OAC/DG,EAAaN,EAAOK,SAAS,eAE7BE,EAAOC,EAA0B,IAEhCX,EACHG,SACAS,YAAaZ,EAAMa,KACnBC,MAAOC,EACPC,WAAYC,IAGhBC,GAAU,KACNR,EAAKS,UAAUhB,EAAAA,GAChB,CAACA,EAAOiB,aAEX,MAAMP,KAAEA,EAAIQ,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,EAAOC,kBAAEA,GAAsBd,EAE5DQ,GAAU,KACNlB,EAAMyB,SAAS,CAAEZ,OAAMQ,QAAOC,SAAQC,WAAQ,GAC/C,CAACV,EAAMQ,EAAOC,EAAQC,IAEzB,MAAMG,EAAeC,EAA4B,CAC7CC,eAAgBJ,IAGpBN,GAAU,KACNlB,EAAM6B,gBAAgBH,EAAaI,QAAO,GAC3C,CAAC9B,EAAM6B,kBAMV,MAAME,EAAqBC,GACtBC,IACG,GAAIX,EAAOW,GAAQ,CACf,MAAMC,EAAuB,gBAAVD,EAA0B,sBAAwB,sBAC/DE,EAAMnC,EAAMkC,GAAclC,EAAMkC,GAAcZ,EAAOW,GAAOG,aAClE,OAAOnC,EAAKoC,IAAIF,IAAQ,IAC5B,CACA,OAAO,IAAA,GAEX,CAACb,IAGL,OACIgB,EAACC,EAAAA,CAASC,mBAAoB,CAAC,gBAC3BF,EAACG,EAAAA,CAAiBC,SAAUX,EAAoBtB,WAAYA,EAAYF,WAAYA,EAAYG,KAAMA,KAAUV,IAG5H,CAEAD,EAAe4C,aAAe,CAC1BC,WAAY"}
@@ -1,2 +1,2 @@
1
- import{getFormattingRegEx as e,isEmpty as r}from"../../../utils/validator-utils.js";const o=/\b(2\d{1}|(9(3|6|2|1)))\d{7}\b/,t=/^(\d){4,}$/,a={phoneNumber:{modes:["blur"],validate:(e,a)=>{const d="+351"===a.state.data.phonePrefix?o:t;return r(e)?null:d.test(e)},errorMessage:"invalidPhoneNumber"},phonePrefix:{modes:["blur"],validate:e=>!!e,errorMessage:"invalidCountryCode"}},d={phoneNumber:{formatterFn:r=>r.replace(e("^\\d","g"),"")}};export{d as phoneFormatters,a as phoneValidationRules};
1
+ import{isEmpty as e,getFormattingRegEx as r}from"../../../utils/validator-utils.js";const o=/\b(2\d{1}|(9(3|6|2|1)))\d{7}\b/,t=/^(\d){4,}$/,a={phoneNumber:{modes:["blur"],validate:(r,a)=>{const d="+351"===a.state.data.phonePrefix?o:t;return e(r)?null:d.test(r)},errorMessage:"invalidPhoneNumber"},phonePrefix:{modes:["blur"],validate:e=>!!e,errorMessage:"invalidCountryCode"}},d={phoneNumber:{formatterFn:e=>e.replace(r("^\\d","g"),"")}};export{d as phoneFormatters,a as phoneValidationRules};
2
2
  //# sourceMappingURL=validate.js.map