@adyen/kyc-components 4.0.0-beta.5 → 4.0.0-beta.7

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 (453) hide show
  1. package/dist/{AcceptTermsOfServiceComponent-Bjj3cdYk.js → AcceptTermsOfServiceComponent-BPD80NBV.js} +43 -15
  2. package/dist/{AccountSetupRejected-CSQTnRkO.js → AccountSetupRejected-DMxK6_NZ.js} +6 -4
  3. package/dist/Address-BxCJg97r.js +1076 -0
  4. package/dist/Alert-JxANwoOi.js +231 -0
  5. package/dist/{Avatar-DL_WbHEO.js → Avatar-BEsogKxf.js} +2 -2
  6. package/dist/BusinessDetailsDropin-3EfuXcxm.js +5088 -0
  7. package/dist/BusinessFinancingComponent-C7-oATO_.js +45 -0
  8. package/dist/{BusinessFinancingDropin-MrOVSlPu.js → BusinessFinancingDropin-Cszqojtx.js} +51 -26
  9. package/dist/BusinessFinancingPage-BcmQhmS2.js +40 -0
  10. package/dist/{BusinessTypeSelectionPage-DJ5bfr8m.js → BusinessTypeSelectionPage-CkX2PhOw.js} +9 -5
  11. package/dist/Card-DPXJw_ou.js +145 -0
  12. package/dist/Confirm-C6hGSEWi.js +64 -0
  13. package/dist/{ContractViewer-z3KbE1Vf.js → ContractViewer-Byp71k2e.js} +34 -46
  14. package/dist/CountryField-ziRVRc5r.js +864 -0
  15. package/dist/CreateIndividualComponent-C87nTEy0.js +72 -0
  16. package/dist/CreateTransferInstrumentComponent-BH92eRcz.js +67 -0
  17. package/dist/Currency-DAbA2YTu.js +238 -0
  18. package/dist/{CustomerSupport-CUPUElh7.js → CustomerSupport-C2Ugl1ZJ.js} +10 -6
  19. package/dist/{DebugModal-BC-xS3Y1.js → DebugModal-BiGsN2MR.js} +8 -5
  20. package/dist/DecisionMakerDetailsPage-BKqkZ5TL.js +100 -0
  21. package/dist/{DecisionMakers-5m_hI3ko.js → DecisionMakers-Dfub_FaY.js} +247 -134
  22. package/dist/DetailViewLayout-Z9cuUp4X.js +65 -0
  23. package/dist/Dropzone-DwdkWB-s.js +218 -0
  24. package/dist/{EmbeddedStatus-8yA_zZvi.js → EmbeddedStatus-C2FaB1kG.js} +4 -4
  25. package/dist/EndStateLayout-BhU2LTbj.js +71 -0
  26. package/dist/{FormFlow-6j8qCSuK.js → FormFlow-BaU8ND7m.js} +8 -2
  27. package/dist/FormNavigation-BAN7IHi5.js +162 -0
  28. package/dist/{IndividualOnfidoDropin-B0G_nHXY.js → IndividualOnfidoDropin-ZdnLLkuv.js} +3240 -258
  29. package/dist/InputDate-DgqNliIM.js +43 -0
  30. package/dist/InputGroup-WBfGDV5F.js +32 -0
  31. package/dist/InputText-CufyDwPI.js +161 -0
  32. package/dist/{Introduction-aPZmTW68.js → Introduction-BMLVCUN7.js} +58 -4
  33. package/dist/LegalRepresentativeDetailsPage-Z1TS1eMK.js +61 -0
  34. package/dist/Link-D6KEr49t.js +35 -0
  35. package/dist/ManageIndividualComponent-B0P2UcYb.js +47 -0
  36. package/dist/ManageTermsOfServiceComponent-BVGYJlbf.js +47 -0
  37. package/dist/{ManageTransferInstrumentComponent-Ds1QZxxR.js → ManageTransferInstrumentComponent-BLOM9_st.js} +37 -42
  38. package/dist/MaskedInput-CMGa4-AZ.js +799 -0
  39. package/dist/MaybeModal-C32AiZaM.js +25 -0
  40. package/dist/Modal-BvBRzt44.js +136 -0
  41. package/dist/{OnboardingDropinComponent-DLvTQVTE.js → OnboardingDropinComponent-BdhXxmZJ.js} +235 -90
  42. package/dist/PayoutDetailsDropin-CFOc-3Cg.js +3694 -0
  43. package/dist/RadioGroup-CnXRr_Ap.js +143 -0
  44. package/dist/RegistrationAddress-C48VQay3.js +2334 -0
  45. package/dist/{Review-DEeOefPe.js → Review-Dp8VRYjm.js} +8 -4
  46. package/dist/{RootBusinessDetailsPage-B2VBJ6x2.js → RootBusinessDetailsPage-C9oZvSeQ.js} +66 -44
  47. package/dist/RootIndividualDetailsPage-BHTLpnk6.js +77 -0
  48. package/dist/SignPCIComponent-Mtb9Ipxw.js +294 -0
  49. package/dist/{SingpassSelection--f8TDTJH.js → SingpassSelection-C5WwyGgd.js} +19 -11
  50. package/dist/SoleProprietorshipPage-Dweeg8jm.js +50 -0
  51. package/dist/{SourceOfFundsPage-avNGxkCP.js → SourceOfFundsPage-PEf5WB77.js} +49 -32
  52. package/dist/Spacer-BK3jDget.js +18 -0
  53. package/dist/StepProgressIndicator-D-k_XSe0.js +78 -0
  54. package/dist/StoreProvider-_YW7glEh.js +7072 -0
  55. package/dist/StructuredList-DaepaiVE.js +38 -0
  56. package/dist/{TaskItemStatus-DMPUHtWU.js → TaskItemStatus-3Xrr8mL4.js} +4 -3
  57. package/dist/{TaskStatusIndicator-Bfc4X_jG.js → TaskStatusIndicator-B1ZRr1qx.js} +3 -3
  58. package/dist/TaxInformationField-Cc4iBLBk.js +3062 -0
  59. package/dist/{TaxReportingDropin-B7FXPbLq.js → TaxReportingDropin-yiL_vTaE.js} +28 -17
  60. package/dist/{TileGroup-DUoq3Lh4.js → TileGroup-C0Rfm3yy.js} +4 -2
  61. package/dist/{TrustDetailsPage-J4MShc8J.js → TrustDetailsPage-D_ZIBi6O.js} +506 -19
  62. package/dist/TrustMemberCompanyPage-DkzAv8u6.js +60 -0
  63. package/dist/TrustMemberIndividualPage-DXWrDuq4.js +66 -0
  64. package/dist/UnincorporatedPartnershipIndividualPage-B6tWGs6K.js +66 -0
  65. package/dist/UnincorporatedPartnershipMemberCompanyPage-C_awQ-ZH.js +64 -0
  66. package/dist/{ViewVerificationStatusComponent-ZtYIqtnO.js → ViewVerificationStatusComponent-DjO4MIbD.js} +4 -3
  67. package/dist/adyen-business-financing.js +33 -22
  68. package/dist/adyen-individual-configuration.js +59 -0
  69. package/dist/adyen-individual-status.js +47 -0
  70. package/dist/adyen-kyc-components.js +28 -15
  71. package/dist/adyen-onboarding.js +3 -3
  72. package/dist/adyen-terms-of-service-management.js +63 -0
  73. package/dist/adyen-terms-of-service-status.js +47 -0
  74. package/dist/adyen-transfer-instrument-configuration.js +73 -0
  75. package/dist/adyen-transfer-instrument-management.js +61 -0
  76. package/dist/adyen-verification-status.js +44 -36
  77. package/dist/analytics-BY--2-JY.js +61 -0
  78. package/dist/{LandingLayout-Xi3iuRMx.js → bafinUtils-DJvocoVP.js} +218 -8
  79. package/dist/basePatterns-BwdnMQxI.js +15 -0
  80. package/dist/bg-BG-B0-ZcjR0.js +22 -0
  81. package/dist/{bg-BG-BiYtb1Tz.js → bg-BG-BYkC3yKf.js} +4 -1
  82. package/dist/bg-BG-CW9c658c.js +13 -0
  83. package/dist/bg-BG-CZ8v3rdy.js +30 -0
  84. package/dist/{bg-BG-Dy6-IwuZ.js → bg-BG-D5192UVe.js} +9 -2
  85. package/dist/{bg-BG-NMIts2sa.js → bg-BG-QC5irNEG.js} +2 -4
  86. package/dist/commonValidators-DcQ7Z0J8.js +24 -0
  87. package/dist/{cs-CZ-Dbow28-o.js → cs-CZ-DOqH0WeT.js} +9 -2
  88. package/dist/cs-CZ-Dk1ePReM.js +22 -0
  89. package/dist/cs-CZ-Dx6momCa.js +30 -0
  90. package/dist/cs-CZ-dU9fnQ1g.js +13 -0
  91. package/dist/{cs-CZ-Csr_35T-.js → cs-CZ-t297LwYw.js} +2 -4
  92. package/dist/{cs-CZ-wdftovLe.js → cs-CZ-zTkICtXj.js} +4 -1
  93. package/dist/currency-BGwQyxBo.js +36 -0
  94. package/dist/{da-DK-Adj8R5Qn.js → da-DK-B45X2VaJ.js} +9 -2
  95. package/dist/da-DK-BJ7aTPir.js +13 -0
  96. package/dist/{da-DK-Dm8o1giq.js → da-DK-BoQic3Gy.js} +2 -4
  97. package/dist/{da-DK-4QAKic_C.js → da-DK-D0N1TVVU.js} +4 -1
  98. package/dist/da-DK-D4H69PX3.js +30 -0
  99. package/dist/da-DK-DStNe471.js +22 -0
  100. package/dist/de-DE-C78RLE2G.js +13 -0
  101. package/dist/de-DE-CGoBPCPv.js +22 -0
  102. package/dist/{de-DE-BG0tKqvi.js → de-DE-CWvgMDqU.js} +9 -2
  103. package/dist/{de-DE-BzumFI3T.js → de-DE-Dtuu-nE7.js} +4 -1
  104. package/dist/{de-DE-DMFaycio.js → de-DE-Dwagawx1.js} +2 -4
  105. package/dist/de-DE-wp5-H-ov.js +30 -0
  106. package/dist/{digital-wallet-with-local-currencies-POeLD54e.js → digital-wallet-D_IpxnkN.js} +3 -3
  107. package/dist/dropinUtils-CMGrblnm.js +192 -0
  108. package/dist/el-GR-B69zcWyB.js +22 -0
  109. package/dist/el-GR-BZRKurtr.js +13 -0
  110. package/dist/{el-GR-DerT143K.js → el-GR-C3rkK_oc.js} +9 -2
  111. package/dist/el-GR-CK2heqPJ.js +30 -0
  112. package/dist/{el-GR-CGeBAkDN.js → el-GR-CxwhV-TX.js} +2 -4
  113. package/dist/{el-GR-CXmTklMq.js → el-GR-DaO38A1s.js} +4 -1
  114. package/dist/emitEvent-CzZf80Am.js +28 -0
  115. package/dist/{en-US-DLm6gy6T.js → en-US-546hB2Wn.js} +3 -1
  116. package/dist/{en-US-CkZcSKGh.js → en-US-BbAzROHT.js} +5 -4
  117. package/dist/en-US-CAm3meB1.js +30 -0
  118. package/dist/{en-US-SbE0c1gn.js → en-US-DIdQJky-.js} +1 -2
  119. package/dist/en-US.instructions-Ddr7AO05.js +22 -0
  120. package/dist/{es-ES-BhQOdKge.js → es-ES-BsQpwaPN.js} +4 -1
  121. package/dist/{es-ES-pXHx3ODy.js → es-ES-Bsoco8Fj.js} +2 -4
  122. package/dist/es-ES-BtUSEzkE.js +13 -0
  123. package/dist/es-ES-CKMfS8Yy.js +22 -0
  124. package/dist/{es-ES-BM4U0hT3.js → es-ES-DKCCgVF8.js} +9 -2
  125. package/dist/es-ES-Ds3-DtqZ.js +30 -0
  126. package/dist/et-EE-BCnK305R.js +13 -0
  127. package/dist/{et-EE-OJg_PSHf.js → et-EE-Bc6ioJRG.js} +9 -2
  128. package/dist/et-EE-Co-8akjV.js +30 -0
  129. package/dist/{et-EE-CFlzRBEx.js → et-EE-DF_GqBgK.js} +4 -1
  130. package/dist/{et-EE-QLVnr6Vl.js → et-EE-DdGlUpaQ.js} +2 -4
  131. package/dist/et-EE-Dw-aPF7J.js +22 -0
  132. package/dist/{fi-FI-Djollt2G.js → fi-FI-BJ9RzrL3.js} +4 -1
  133. package/dist/{fi-FI-DT351N-G.js → fi-FI-ClnsYt3L.js} +2 -4
  134. package/dist/fi-FI-Cvar63RH.js +13 -0
  135. package/dist/fi-FI-DPNeTsJS.js +30 -0
  136. package/dist/{fi-FI-BJ2l42Pj.js → fi-FI-Hhku9Lmc.js} +9 -2
  137. package/dist/fi-FI-REYOX46I.js +22 -0
  138. package/dist/fieldConfigurations-Bct_fXIF.js +458 -0
  139. package/dist/form-rules-DhbF2mY4.js +13 -0
  140. package/dist/fr-FR-B5543Fe-.js +13 -0
  141. package/dist/{fr-FR-g7lmxEsI.js → fr-FR-BYuKsZIb.js} +9 -2
  142. package/dist/{fr-FR-BNXXNUX_.js → fr-FR-CJI0bIig.js} +2 -4
  143. package/dist/{fr-FR-l36qBV3a.js → fr-FR-CNR5-s9g.js} +4 -1
  144. package/dist/fr-FR-ChmNQciP.js +30 -0
  145. package/dist/fr-FR-D9qaP6nx.js +22 -0
  146. package/dist/getName-BfigaSFZ.js +41 -0
  147. package/dist/{hasDataChanged-CTE9vdfO.js → hasDataChanged-D5Rq4ntg.js} +2 -2
  148. package/dist/{hr-HR-B8AZ4eHJ.js → hr-HR-C0yWizOX.js} +2 -4
  149. package/dist/{hr-HR-CDUE36Dg.js → hr-HR-CPO5Yw2B.js} +9 -2
  150. package/dist/hr-HR-CbxEvbrE.js +22 -0
  151. package/dist/{hr-HR-DTCY4iL8.js → hr-HR-CjA4MWAU.js} +4 -1
  152. package/dist/hr-HR-DqC8Cgs6.js +30 -0
  153. package/dist/hr-HR-ZreFlbK9.js +13 -0
  154. package/dist/hu-HU-B3BihdGh.js +13 -0
  155. package/dist/hu-HU-BOanVlKb.js +30 -0
  156. package/dist/hu-HU-D0C6UfXB.js +22 -0
  157. package/dist/{hu-HU-BznXPoc2.js → hu-HU-NhwFr6o-.js} +4 -1
  158. package/dist/{hu-HU-Bmf13NMf.js → hu-HU-mo_0ULJG.js} +9 -2
  159. package/dist/{hu-HU-DRi6Dz9U.js → hu-HU-wnSie9tz.js} +2 -4
  160. package/dist/iframeWidget-D2bi8wJe.js +234 -0
  161. package/dist/{payout-verification-instant-BIcnFP-p.js → instant-verification-Dvvkyfmp.js} +3 -3
  162. package/dist/isEmpty-Ck0I6out.js +23 -0
  163. package/dist/{it-IT-BEWyAQUU.js → it-IT-BV9K87FK.js} +4 -1
  164. package/dist/{it-IT-BeYbInCQ.js → it-IT-BeC2Y1F8.js} +2 -4
  165. package/dist/it-IT-Biduphjt.js +22 -0
  166. package/dist/it-IT-Dd6xGSe-.js +13 -0
  167. package/dist/{it-IT-DYIx7myn.js → it-IT-Nl57jui-.js} +9 -2
  168. package/dist/it-IT-eCrTB65E.js +30 -0
  169. package/dist/ja-JP-B2txEVPx.js +22 -0
  170. package/dist/ja-JP-BJljbFIZ.js +30 -0
  171. package/dist/{ja-JP-BhS-_dIx.js → ja-JP-CbgaW99b.js} +2 -2
  172. package/dist/{ja-JP-tx1DbZYD.js → ja-JP-D3oQAH7z.js} +10 -3
  173. package/dist/{ja-JP-D7oL6xGY.js → ja-JP-DXcP0ojZ.js} +13 -10
  174. package/dist/{ja-JP-C1OQ16fo.js → ja-JP-YoU7mNrK.js} +2 -4
  175. package/dist/ja-JP-iTbqSPNL.js +13 -0
  176. package/dist/keys-BpNgnAsD.js +23 -0
  177. package/dist/{localizeDateString-DaAGYSWR.js → localizeDateString-DmnKzDGI.js} +2 -2
  178. package/dist/{lt-LT-BxScCodJ.js → lt-LT-CVasDmF3.js} +9 -2
  179. package/dist/lt-LT-C_YMgjp9.js +22 -0
  180. package/dist/lt-LT-DE-4IXNG.js +13 -0
  181. package/dist/{lt-LT-_MzAcXJo.js → lt-LT-DIe4cKlu.js} +2 -4
  182. package/dist/lt-LT-DckQGgoT.js +30 -0
  183. package/dist/{lt-LT-De7dLXxI.js → lt-LT-tXTApHm2.js} +4 -1
  184. package/dist/lv-LV-B3sT3_cw.js +22 -0
  185. package/dist/lv-LV-CeivEZms.js +13 -0
  186. package/dist/lv-LV-DP9oRTFv.js +30 -0
  187. package/dist/{lv-LV-De9rdme0.js → lv-LV-DSaQNC67.js} +4 -1
  188. package/dist/{lv-LV-CRhXAjn6.js → lv-LV-DXgW5zWl.js} +2 -4
  189. package/dist/{lv-LV-F9_Fiu3w.js → lv-LV-Sbsv8-nD.js} +9 -2
  190. package/dist/{payout-verification-manual-DH9-DdlZ.js → manual-verification-BvZWqA00.js} +3 -3
  191. package/dist/mapExistingFile-qQ4y79Lm.js +231 -0
  192. package/dist/mapScriptLocalization-D7RKQgK6.js +72 -0
  193. package/dist/mapTransferInstrumentToPayoutAccount-BbdTQhjr.js +30 -0
  194. package/dist/{nl-NL-Cht7cSwD.js → nl-NL-BHkRnVrj.js} +9 -2
  195. package/dist/{nl-NL-Dbx0ZmI7.js → nl-NL-Cysslsh2.js} +2 -4
  196. package/dist/nl-NL-D2QKudfh.js +30 -0
  197. package/dist/nl-NL-DVENFpd5.js +13 -0
  198. package/dist/{nl-NL-lZcJhRsP.js → nl-NL-DywVQ9km.js} +4 -1
  199. package/dist/nl-NL-G1wVnmzT.js +22 -0
  200. package/dist/{no-NO-BEIyAMmZ.js → no-NO-B8oxqfNI.js} +4 -1
  201. package/dist/no-NO-BTtAuqCb.js +22 -0
  202. package/dist/no-NO-C_snYWBc.js +30 -0
  203. package/dist/no-NO-Dn2UkdoI.js +13 -0
  204. package/dist/{no-NO-BQAqVzF4.js → no-NO-kaAdT9B8.js} +9 -2
  205. package/dist/{no-NO-C0sfkp82.js → no-NO-zSnPtrDi.js} +2 -4
  206. package/dist/pl-PL--qPaNyJD.js +22 -0
  207. package/dist/{pl-PL-DD3wVcKc.js → pl-PL-C89s21hn.js} +4 -1
  208. package/dist/pl-PL-CQ6c2Qz_.js +30 -0
  209. package/dist/{pl-PL-CqxMKpBm.js → pl-PL-DD8JN4Qf.js} +9 -2
  210. package/dist/pl-PL-DFAzuceF.js +13 -0
  211. package/dist/{pl-PL-DAPGaxWi.js → pl-PL-UB5J5JcB.js} +2 -4
  212. package/dist/{pt-PT-BsDCHbWN.js → pt-PT-BvK00TeI.js} +4 -1
  213. package/dist/pt-PT-C-hbNnsB.js +30 -0
  214. package/dist/{pt-PT-BY9rcwcF.js → pt-PT-CjsyP_OK.js} +2 -4
  215. package/dist/pt-PT-Dk48OVtf.js +22 -0
  216. package/dist/{pt-PT-CBbmkr_J.js → pt-PT-Xm-pm3mb.js} +9 -2
  217. package/dist/pt-PT-_o5xgnxS.js +13 -0
  218. package/dist/{resolveEnvironment-D0tYcn_s.js → resolveEnvironment-D4ONN9a2.js} +3 -3
  219. package/dist/ro-RO-BLuOjrS0.js +22 -0
  220. package/dist/ro-RO-BrTWk1Ui.js +30 -0
  221. package/dist/{ro-RO-IY3AMhwm.js → ro-RO-C3m6aJVP.js} +9 -2
  222. package/dist/{ro-RO-DJLWmWZ4.js → ro-RO-C8yYXQc_.js} +2 -4
  223. package/dist/{ro-RO-CUg8-CQ8.js → ro-RO-CpGd9emB.js} +4 -1
  224. package/dist/ro-RO-D7c_Rj8V.js +13 -0
  225. package/dist/{rules-DXnRkeBJ.js → rules-DD7cnV-t.js} +5 -2
  226. package/dist/sk-SK-BBSuh2fA.js +13 -0
  227. package/dist/sk-SK-BTFtoPmI.js +30 -0
  228. package/dist/{sk-SK-BDKRZ2mM.js → sk-SK-BVc-vNQm.js} +9 -2
  229. package/dist/sk-SK-C1Ky2nl_.js +22 -0
  230. package/dist/{sk-SK-B7o3L57C.js → sk-SK-DbOE9C6n.js} +2 -4
  231. package/dist/{sk-SK-Cjrkrb85.js → sk-SK-DlX5KvBV.js} +4 -1
  232. package/dist/sl-SI-BB7iVcFI.js +22 -0
  233. package/dist/sl-SI-BLTuWNf5.js +13 -0
  234. package/dist/sl-SI-BhVTSmhQ.js +30 -0
  235. package/dist/{sl-SI-C8CMAkD0.js → sl-SI-Br0UEUPL.js} +2 -4
  236. package/dist/{sl-SI-BB0suyr1.js → sl-SI-D_rqR0D7.js} +9 -2
  237. package/dist/{sl-SI-BE_ndzZ2.js → sl-SI-NI2OJAvm.js} +4 -1
  238. package/dist/style.css +3226 -2972
  239. package/dist/styles-CLV89_hH.js +3226 -2972
  240. package/dist/sv-SE-66rqYTxi.js +30 -0
  241. package/dist/{sv-SE-DYruQSzt.js → sv-SE-B3zoXMuH.js} +9 -2
  242. package/dist/sv-SE-BUfESAQK.js +13 -0
  243. package/dist/{sv-SE-Bwh0wKFk.js → sv-SE-BtXmvxx4.js} +2 -4
  244. package/dist/{sv-SE-BryiIPVv.js → sv-SE-CAZpDX9G.js} +4 -1
  245. package/dist/sv-SE-DbI-1JqN.js +22 -0
  246. package/dist/translation-CpuWYSlU.js +472 -0
  247. package/dist/types/api/configurations/useScenarios.d.ts +8 -7
  248. package/dist/types/api/idNowProvider/idNowProvider.types.d.ts +1 -1
  249. package/dist/types/api/idNowProvider/useIdNowProvider.d.ts +9 -5
  250. package/dist/types/api/industryCodes/industryCodes.types.d.ts +2 -0
  251. package/dist/types/api/industryCodes/useIndustryCodes.d.ts +6 -0
  252. package/dist/types/api/queryKeys.d.ts +2 -1
  253. package/dist/types/components/BankAccount/forms/PayoutDetails/PayoutDetails.d.ts +1 -0
  254. package/dist/types/components/BankAccount/forms/PayoutVerificationMethod/payoutVerificationMethodMetadata.d.ts +3 -3
  255. package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/payoutDetailsFormConfig.d.ts +0 -9
  256. package/dist/types/components/Business/forms/BasicInformation/BasicInformationMultiform.d.ts +0 -1
  257. package/dist/types/components/Business/forms/BusinessDetails/forms.d.ts +7 -1
  258. package/dist/types/components/Business/forms/rules.d.ts +1 -3
  259. package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +1 -2
  260. package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/BusinessDetailsMultiform.d.ts +1 -1
  261. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/ServiceAgreementDropin.d.ts +1 -1
  262. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/types.d.ts +1 -0
  263. package/dist/types/components/EFP/mapping/businessFinancingKeyMappings.d.ts +0 -3
  264. package/dist/types/components/EFP/tasks/SourceOfFundsDropin/utils.d.ts +0 -1
  265. package/dist/types/components/EmbeddedDropins/AcceptTermsOfServiceComponent/AcceptTermsOfServiceComponent.d.ts +4 -3
  266. package/dist/types/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentOverviewItemModal/ManageTransferInstrumentOverviewItemModal.d.ts +0 -1
  267. package/dist/types/components/Individual/fields/NameFields/types.d.ts +4 -18
  268. package/dist/types/components/Individual/forms/Individual/IdVerificationMethod/idVerificationMethodMetadata.d.ts +3 -3
  269. package/dist/types/components/Individual/forms/Individual/Individual.d.ts +4 -0
  270. package/dist/types/components/Individual/forms/Individual/ProofOfRelationship/types.d.ts +0 -5
  271. package/dist/types/components/Individual/forms/IndividualOnfido/AdditionalPersonalDetails/AdditionalPersonalDetails.types.d.ts +1 -1
  272. package/dist/types/components/Individual/forms/IndividualOnfido/BasicDetails/BasicDetails.types.d.ts +1 -1
  273. package/dist/types/components/Individual/forms/IndividualOnfido/IdNowVerificationModal/IdNowVerificationModal.d.ts +4 -0
  274. package/dist/types/components/Individual/forms/IndividualOnfido/IdNowVerificationModal/isIdNowModalOpen.d.ts +17 -0
  275. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/IdVerificationMethod.types.d.ts +2 -0
  276. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/mapExtractionResultToSchema.d.ts +2 -1
  277. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/validateExtractionResult.d.ts +12 -0
  278. package/dist/types/components/Individual/forms/IndividualOnfido/IndividualOnfido.types.d.ts +5 -3
  279. package/dist/types/components/Individual/helpers/bafinUtils.d.ts +35 -0
  280. package/dist/types/components/Individual/helpers/isDecisionMakerTask.d.ts +2 -0
  281. package/dist/types/components/Individual/helpers/shouldShowMotionCapture.d.ts +2 -2
  282. package/dist/types/components/Individual/pages/DecisionMakerDetailsPage.d.ts +2 -1
  283. package/dist/types/components/Shared/SingpassBanner/ProviderButton/ProviderButton.d.ts +7 -0
  284. package/dist/types/components/Shared/fields/IdFieldTypeSelector/countryIdNumberTypes.d.ts +1 -1
  285. package/dist/types/components/Shared/fields/LocalizedLegalCompanyNameField/fieldConfig.d.ts +4 -5
  286. package/dist/types/components/Shared/fields/LocalizedLegalCompanyNameField/types.d.ts +4 -5
  287. package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
  288. package/dist/types/components/Trust/forms/Trust/Trust.d.ts +1 -0
  289. package/dist/types/components/Trust/forms/TrustRegistrationDetails/types.d.ts +1 -2
  290. package/dist/types/components/Trust/tasks/TrustMembers/TrustMembersOverview.d.ts +2 -1
  291. package/dist/types/components/UnincorporatedPartnership/pages/UnincorporatedPartnershipMemberCompanyPage.d.ts +2 -1
  292. package/dist/types/components/ui/atoms/ActionsMenu/ActionsMenu.d.ts +2 -1
  293. package/dist/types/components/ui/atoms/Button/Button.types.d.ts +4 -5
  294. package/dist/types/components/ui/atoms/Image/Image.d.ts +18 -0
  295. package/dist/types/components/ui/atoms/ListItem/ListItem.d.ts +2 -1
  296. package/dist/types/components/ui/atoms/Modal/MaybeModal.d.ts +1 -1
  297. package/dist/types/components/ui/atoms/RadioGroupCard/RadioGroupCard.types.d.ts +0 -14
  298. package/dist/types/components/ui/atoms/RadioWithLabel/RadioWithLabel.d.ts +2 -1
  299. package/dist/types/components/ui/atoms/Remove/Remove.d.ts +1 -1
  300. package/dist/types/components/ui/atoms/SelectList/SelectList.d.ts +1 -0
  301. package/dist/types/components/ui/atoms/StepProgressIndicator/StepProgressIndicator.d.ts +2 -1
  302. package/dist/types/components/ui/atoms/StructuredList/StructuredList.d.ts +2 -1
  303. package/dist/types/components/ui/atoms/Svg/svgs.d.ts +0 -76
  304. package/dist/types/components/ui/atoms/TaskStatusIndicator/TaskStatusIndicator.d.ts +4 -4
  305. package/dist/types/components/ui/layout/DetailViewLayout/DetailViewLayout.d.ts +12 -0
  306. package/dist/types/components/ui/layout/EndStateLayout/EndStateLayout.d.ts +13 -0
  307. package/dist/types/components/ui/layout/LandingLayout/LandingLayout.d.ts +8 -3
  308. package/dist/types/components/ui/layout/StackLayout/StackLayout.d.ts +2 -1
  309. package/dist/types/components/ui/molecules/DocumentGuidance/DocumentGuidance.types.d.ts +2 -3
  310. package/dist/types/components/ui/molecules/InputCurrency/InputCurrency.d.ts +2 -1
  311. package/dist/types/components/ui/molecules/InputEmail/InputEmail.d.ts +2 -1
  312. package/dist/types/components/ui/molecules/InputGroup/InputGroup.d.ts +2 -1
  313. package/dist/types/components/ui/molecules/InputTelephone/InputTelephone.d.ts +2 -1
  314. package/dist/types/components/ui/molecules/InputText/InputText.d.ts +2 -0
  315. package/dist/types/components/ui/molecules/MaskedInput/MaskedInput.d.ts +0 -1
  316. package/dist/types/components/ui/molecules/Tabs/Tabs.d.ts +1 -1
  317. package/dist/types/context/StateContext/types.d.ts +1 -1
  318. package/dist/types/core/models/api/accountIdentification.d.ts +5 -4
  319. package/dist/types/core/models/api/contracts.d.ts +1 -1
  320. package/dist/types/core/models/api/get-scenarios.d.ts +11 -5
  321. package/dist/types/core/models/api/individual.d.ts +5 -10
  322. package/dist/types/core/models/api/legal-arrangement.d.ts +0 -8
  323. package/dist/types/core/models/api/organization.d.ts +4 -8
  324. package/dist/types/core/models/api/scriptLocalization.d.ts +9 -0
  325. package/dist/types/core/process-field-configurations.d.ts +14 -3
  326. package/dist/types/embeds/business-financing/AdyenBusinessFinancing.d.ts +1 -1
  327. package/dist/types/embeds/business-financing/adyen-business-financing.types.d.ts +1 -5
  328. package/dist/types/embeds/emitEvent.d.ts +14 -0
  329. package/dist/types/embeds/{individual → individual-configuration}/AdyenIndividual.d.ts +4 -4
  330. package/dist/types/embeds/{individual/adyen-individual.types.d.ts → individual-configuration/adyen-individual-configuration.types.d.ts} +7 -7
  331. package/dist/types/embeds/{manage-individual → individual-status}/AdyenManageIndividual.d.ts +5 -5
  332. package/dist/types/embeds/{manage-individual/adyen-manage-individual.types.d.ts → individual-status/adyen-individual-status.types.d.ts} +6 -6
  333. package/dist/types/embeds/{terms-of-service → terms-of-service-management}/AdyenTermsOfService.d.ts +4 -4
  334. package/dist/types/embeds/{terms-of-service/adyen-terms-of-service.types.d.ts → terms-of-service-management/adyen-terms-of-service-management.types.d.ts} +9 -8
  335. package/dist/types/embeds/{manage-terms-of-service → terms-of-service-status}/AdyenManageTermsOfService.d.ts +5 -5
  336. package/dist/types/embeds/{manage-terms-of-service/adyen-manage-terms-of-service.types.d.ts → terms-of-service-status/adyen-terms-of-service-status.types.d.ts} +6 -6
  337. package/dist/types/embeds/{transfer-instrument → transfer-instrument-configuration}/AdyenTransferInstrument.d.ts +4 -4
  338. package/dist/types/embeds/{transfer-instrument/adyen-transfer-instrument.types.d.ts → transfer-instrument-configuration/adyen-transfer-instrument-configuration.types.d.ts} +7 -7
  339. package/dist/types/embeds/{manage-transfer-instruments → transfer-instrument-management}/AdyenManageTransferInstrument.d.ts +7 -8
  340. package/dist/types/embeds/{manage-transfer-instruments/adyen-manage-transfer-instruments.types.d.ts → transfer-instrument-management/adyen-transfer-instrument-management.types.d.ts} +8 -9
  341. package/dist/types/embeds/verification-status/adyen-verification-status.types.d.ts +3 -3
  342. package/dist/types/hooks/introduction/useIntroductionScreens.d.ts +2 -1
  343. package/dist/types/hooks/introduction/useShouldShowIntroduction.d.ts +2 -1
  344. package/dist/types/hooks/useMultiForm/types.d.ts +4 -4
  345. package/dist/types/language/utils.d.ts +1 -1
  346. package/dist/types/types/localizedScriptSchema.d.ts +22 -0
  347. package/dist/types/utils/addLinkedFields.d.ts +7 -1
  348. package/dist/types/utils/entityStatusUtil.d.ts +1 -1
  349. package/dist/types/utils/formUtils.d.ts +1 -1
  350. package/dist/types/utils/getDisplayErrorMessage.d.ts +1 -1
  351. package/dist/types/utils/getName.d.ts +2 -1
  352. package/dist/types/utils/makeSelectItemForRole.d.ts +1 -1
  353. package/dist/types/utils/mapScriptLocalization.d.ts +55 -0
  354. package/dist/types/utils/masking/masks/businessRegistrationNumberMasks.d.ts +5 -0
  355. package/dist/types/utils/translation.d.ts +6 -0
  356. package/dist/types-CAznNNSI.js +160 -0
  357. package/dist/types-Cj8YOGeo.js +64 -0
  358. package/dist/types-DW8AoV0s.js +74 -0
  359. package/dist/useAssociatedLegalEntity-DpMCDRB2.js +33 -0
  360. package/dist/useDataset-DgGo4v2J.js +120 -0
  361. package/dist/useForm-C66YXYZG.js +1694 -0
  362. package/dist/useFormContext-beqGS11A.js +23 -0
  363. package/dist/useGlobalData-CLK6kHPg.js +205 -0
  364. package/dist/{useMultiForm-CuBrV4Tk.js → useMultiForm-C2Py7qyc.js} +8 -3
  365. package/dist/{useOnboardingStatus-DUB9BH7M.js → useOnboardingStatus-CAefy-E-.js} +2 -2
  366. package/dist/useScenarios-B9C3euGm.js +46 -0
  367. package/dist/{useTermsOfServiceStatus-BblV2n-A.js → useTermsOfServiceStatus-BoQcnXHY.js} +2 -2
  368. package/dist/useToastContext-DGtAfUak.js +51 -0
  369. package/dist/useUnincorporatedPartnershipMembers-DWYujkfV.js +99 -0
  370. package/dist/utils-398Z4KKf.js +29 -0
  371. package/dist/utils-DNSfZiio.js +70 -0
  372. package/dist/utils-DgGLUM4O.js +159 -0
  373. package/dist/{utils-CoNP20Mi.js → utils-DxvZeEUH.js} +46 -4
  374. package/dist/{validate-BPEF-9EC.js → validate--KA-U0Fs.js} +2 -2
  375. package/dist/validate-BrsSh5ej.js +382 -0
  376. package/dist/validate-ZwWxhap7.js +605 -0
  377. package/dist/validationError-DeiIFLRV.js +86 -0
  378. package/package.json +67 -70
  379. package/dist/BusinessDetailsDropin-JZ29P1pI.js +0 -2163
  380. package/dist/BusinessFinancingComponent-AAD0wzc0.js +0 -38
  381. package/dist/BusinessFinancingPage-DWvnRK3f.js +0 -35
  382. package/dist/CreateIndividualComponent-CO0NnimV.js +0 -64
  383. package/dist/CreateTransferInstrumentComponent-CpUB63yl.js +0 -55
  384. package/dist/DecisionMakerDetailsPage-DBsCSIAU.js +0 -80
  385. package/dist/FormEndState-s8NUp0x5.js +0 -59
  386. package/dist/LegalRepresentativeDetailsPage-Beh9_16w.js +0 -55
  387. package/dist/ManageIndividualComponent-C5ll1EKq.js +0 -42
  388. package/dist/ManageTermsOfServiceComponent-BYgWiamd.js +0 -40
  389. package/dist/RootIndividualDetailsPage-Bi7xeUYJ.js +0 -71
  390. package/dist/SignPCIComponent-Dgnvmjbr.js +0 -279
  391. package/dist/SoleProprietorshipPage-DMYrwSK2.js +0 -44
  392. package/dist/StoreProvider-QThALSrj.js +0 -31918
  393. package/dist/TrustMemberCompanyPage-DKNQ_vHF.js +0 -54
  394. package/dist/TrustMemberIndividualPage-CFo3Is4F.js +0 -60
  395. package/dist/UnincorporatedPartnershipIndividualPage-CfllAxUK.js +0 -60
  396. package/dist/UnincorporatedPartnershipMemberCompanyPage-779IUOW2.js +0 -57
  397. package/dist/VerificationErrorAlert-BtsLa_Ty.js +0 -77
  398. package/dist/adyen-a-filled-czhSM_bc.js +0 -14
  399. package/dist/adyen-individual.js +0 -50
  400. package/dist/adyen-manage-individual.js +0 -48
  401. package/dist/adyen-manage-terms-of-service.js +0 -48
  402. package/dist/adyen-manage-transfer-instruments.js +0 -63
  403. package/dist/adyen-terms-of-service.js +0 -60
  404. package/dist/adyen-transfer-instrument.js +0 -64
  405. package/dist/arrow-left-Dtc2gya1.js +0 -14
  406. package/dist/bg-BG-BvSUDgGF.js +0 -13
  407. package/dist/cs-CZ-y4mvq4Lv.js +0 -13
  408. package/dist/da-DK-qgQOVjDp.js +0 -13
  409. package/dist/de-DE-pSdsxBpQ.js +0 -13
  410. package/dist/document-plus-NwgAdjyB.js +0 -17
  411. package/dist/el-GR-Bvjk5Sw8.js +0 -13
  412. package/dist/en-US-Bq2Twy6x.js +0 -54
  413. package/dist/es-ES-Dy1uR2H_.js +0 -13
  414. package/dist/et-EE-d9V24rcf.js +0 -13
  415. package/dist/fi-FI-B0fnAFV2.js +0 -13
  416. package/dist/fr-FR-BoKzVp2q.js +0 -13
  417. package/dist/getFieldsWithExistingData-CUMH8N-C.js +0 -22
  418. package/dist/hide-CigAXbWC.js +0 -18
  419. package/dist/hr-HR-CF0AHQzi.js +0 -13
  420. package/dist/hu-HU-CSPhOvLC.js +0 -13
  421. package/dist/idea-DwJIwJHR.js +0 -18
  422. package/dist/instant-verification-method-BGfknV9x.js +0 -28
  423. package/dist/it-IT-BH-eqIKH.js +0 -13
  424. package/dist/ja-JP-B3yqM_FM.js +0 -13
  425. package/dist/lt-LT-Lzl_Cbw-.js +0 -13
  426. package/dist/lv-LV-y00wN1pj.js +0 -13
  427. package/dist/mapFinancialReportsToFinancialInformation-Bo2uW3j7.js +0 -66
  428. package/dist/nl-NL-DmnFXAQC.js +0 -13
  429. package/dist/no-NO-DbvFfP96.js +0 -13
  430. package/dist/pl-PL--mmxopYA.js +0 -13
  431. package/dist/plus-small-Dj1WRyFM.js +0 -14
  432. package/dist/pt-PT-BVzXBFp7.js +0 -13
  433. package/dist/ro-RO-Cdmevo9A.js +0 -13
  434. package/dist/ru-RU-FZb2upqh.js +0 -13
  435. package/dist/sk-SK-nfeuTcY5.js +0 -13
  436. package/dist/sl-SI-DUTZDqkP.js +0 -13
  437. package/dist/sv-SE-BTx2XKAp.js +0 -13
  438. package/dist/types/components/Individual/mapping/mapLocalization.d.ts +0 -3
  439. package/dist/types/components/ui/atoms/OutlinedIcon/OutlinedIcon.d.ts +0 -5
  440. package/dist/types/components/ui/atoms/ProviderButton/ProviderButton.d.ts +0 -3
  441. package/dist/types/components/ui/atoms/ProviderButton/ProviderButton.types.d.ts +0 -5
  442. package/dist/types/components/ui/molecules/FormEndState/FormEndState.d.ts +0 -2
  443. package/dist/types/components/ui/molecules/FormEndState/types.d.ts +0 -8
  444. package/dist/useUpdateLegalEntity-56mDjaQA.js +0 -57
  445. package/dist/validate-Bgc1XuQl.js +0 -40
  446. package/dist/zh-CN-wUb4MmTZ.js +0 -13
  447. package/dist/zh-TW-DNTXHLKa.js +0 -13
  448. /package/dist/types/embeds/{individual/adyen-individual.d.ts → individual-configuration/adyen-individual-configuration.d.ts} +0 -0
  449. /package/dist/types/embeds/{manage-individual/adyen-manage-individual.d.ts → individual-status/adyen-individual-status.d.ts} +0 -0
  450. /package/dist/types/embeds/{manage-terms-of-service/adyen-manage-terms-of-service.d.ts → terms-of-service-management/adyen-terms-of-service-management.d.ts} +0 -0
  451. /package/dist/types/embeds/{manage-transfer-instruments/adyen-manage-transfer-instruments.d.ts → terms-of-service-status/adyen-terms-of-service-status.d.ts} +0 -0
  452. /package/dist/types/embeds/{terms-of-service/adyen-terms-of-service.d.ts → transfer-instrument-configuration/adyen-transfer-instrument-configuration.d.ts} +0 -0
  453. /package/dist/types/embeds/{transfer-instrument/adyen-transfer-instrument.d.ts → transfer-instrument-management/adyen-transfer-instrument-management.d.ts} +0 -0
@@ -0,0 +1,1694 @@
1
+ ;
2
+ {
3
+ try {
4
+ let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "485ea493-c135-47be-a588-a19ed650ab45", e._sentryDebugIdIdentifier = "sentry-dbid-485ea493-c135-47be-a588-a19ed650ab45");
6
+ } catch (e) {
7
+ }
8
+ }
9
+ ;
10
+ import { jsxs, Fragment, jsx } from "preact/jsx-runtime";
11
+ import cx from "classnames";
12
+ import { useState, useEffect, useRef, useMemo, useCallback, useReducer } from "preact/hooks";
13
+ import { U as useAnalyticsContext, a as useTranslation, V as Icon, w as translateStringOrObject, L as Loader, W as noop, x as Typography, N as createLogger, a9 as isEmpty, az as entriesOf, aG as doArraysMatch } from "./StoreProvider-_YW7glEh.js";
14
+ import { computed, signal, useSignal, useSignalEffect } from "@preact/signals";
15
+ import { K as KEYBOARD_KEYS } from "./keys-BpNgnAsD.js";
16
+ import { d as debouncedInputEvent } from "./analytics-BY--2-JY.js";
17
+ function Checkbox({
18
+ id,
19
+ name,
20
+ value,
21
+ className,
22
+ label,
23
+ isInvalid,
24
+ onChange,
25
+ helper,
26
+ checked,
27
+ readonly,
28
+ disabled,
29
+ enableTracking = false,
30
+ "aria-required": ariaRequired,
31
+ "aria-invalid": ariaInvalid,
32
+ "aria-describedby": ariaDescribedBy
33
+ }) {
34
+ const userEvents = useAnalyticsContext();
35
+ const handleChange = (newValue) => {
36
+ if (enableTracking) {
37
+ userEvents.addFieldEvent("Interacted with form field", {
38
+ actionType: "input",
39
+ field: name,
40
+ returnValue: String(newValue)
41
+ });
42
+ }
43
+ onChange(newValue);
44
+ };
45
+ const helperId = `${id}-helper`;
46
+ const ariaDescribedById = `${helper ? helperId : ""} ${ariaDescribedBy ?? ""}`.trim();
47
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ /* @__PURE__ */ jsx(
49
+ "input",
50
+ {
51
+ id,
52
+ name,
53
+ value,
54
+ "aria-describedby": ariaDescribedById,
55
+ "aria-invalid": ariaInvalid || isInvalid,
56
+ "aria-required": ariaRequired,
57
+ readOnly: readonly,
58
+ disabled,
59
+ checked,
60
+ className: cx([
61
+ "adyen-kyc-checkbox__input",
62
+ [className],
63
+ { "adyen-kyc-checkbox__input--invalid": isInvalid }
64
+ ]),
65
+ type: "checkbox",
66
+ onClick: (event) => {
67
+ event.stopPropagation();
68
+ handleChange(!checked);
69
+ }
70
+ }
71
+ ),
72
+ /* @__PURE__ */ jsx("label", { htmlFor: id, className: "adyen-kyc-checkbox__label", children: label }),
73
+ helper && /* @__PURE__ */ jsx("span", { id: helperId, className: "adyen-kyc-checkbox__helper-text", children: helper })
74
+ ] });
75
+ }
76
+ const ARIA_ERROR_SUFFIX = "-ariaError";
77
+ function uuidv4() {
78
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
79
+ let r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
80
+ return v.toString(16);
81
+ });
82
+ }
83
+ const useId = (prefix) => {
84
+ const [uuid] = useState(uuidv4());
85
+ return `${prefix}_${uuid}`;
86
+ };
87
+ const MaybeFieldset = ({
88
+ children,
89
+ className,
90
+ name,
91
+ disabled,
92
+ el,
93
+ dataTestId
94
+ }) => el === "fieldset" ? /* @__PURE__ */ jsx("fieldset", { name, disabled, className, "data-testid": dataTestId, children }) : /* @__PURE__ */ jsx("div", { className, "data-testid": dataTestId, children });
95
+ const Field = ({
96
+ className,
97
+ classNameModifiers = [],
98
+ children,
99
+ disabled,
100
+ optional,
101
+ errorMessage,
102
+ formatGuidance,
103
+ helper,
104
+ helperPosition = "above",
105
+ isValid,
106
+ label,
107
+ name,
108
+ showErrorIconBottom = false,
109
+ showErrorIcon = true,
110
+ el = "div",
111
+ dataTestId,
112
+ onBlur,
113
+ onFieldBlur,
114
+ onFocus
115
+ }) => {
116
+ const uniqueId = useId("field");
117
+ const { t } = useTranslation("common");
118
+ const userEvents = useAnalyticsContext();
119
+ const Label = el === "fieldset" ? "legend" : "label";
120
+ useEffect(() => {
121
+ if (!errorMessage) return;
122
+ const returnValue = typeof errorMessage === "string" && errorMessage || typeof errorMessage === "object" && errorMessage.key || "invalid";
123
+ userEvents.addFieldEvent("Encountered error", {
124
+ actionType: "input",
125
+ field: name,
126
+ returnType: "validation",
127
+ returnValue
128
+ });
129
+ }, [name, errorMessage, userEvents]);
130
+ const elementIds = {
131
+ label: `${uniqueId}-label`,
132
+ helper: `${uniqueId}-helper`,
133
+ error: `${uniqueId}${ARIA_ERROR_SUFFIX}`,
134
+ guidanceText: `${uniqueId}-guidanceText`
135
+ };
136
+ const inputDescribedBy = `${errorMessage ? elementIds.error : ""} ${helper ? elementIds.helper : ""} ${formatGuidance ? elementIds.guidanceText : ""}`.trim();
137
+ return /* @__PURE__ */ jsxs(
138
+ MaybeFieldset,
139
+ {
140
+ className: cx(
141
+ "adyen-kyc-field",
142
+ className,
143
+ classNameModifiers.map((m) => `adyen-kyc-field--${m}`),
144
+ {
145
+ "adyen-kyc-field--error": !!errorMessage,
146
+ "adyen-kyc-field--valid": isValid,
147
+ "adyen-kyc-field--disabled": disabled
148
+ }
149
+ ),
150
+ name,
151
+ disabled,
152
+ el,
153
+ dataTestId,
154
+ children: [
155
+ label && /* @__PURE__ */ jsxs(
156
+ Label,
157
+ {
158
+ id: elementIds.label,
159
+ htmlFor: el === "fieldset" ? void 0 : uniqueId,
160
+ className: cx("adyen-kyc-label__text", {
161
+ "adyen-kyc-label__text--error": !!errorMessage
162
+ }),
163
+ children: [
164
+ label,
165
+ optional && /* @__PURE__ */ jsxs("span", { className: "adyen-kyc-optional-label", children: [
166
+ " ",
167
+ t(($) => $["optional"])
168
+ ] })
169
+ ]
170
+ }
171
+ ),
172
+ helper && helperPosition === "above" && /* @__PURE__ */ jsx("span", { id: elementIds.helper, className: "adyen-kyc-helper-text adyen-kyc-helper-text__above", children: helper }),
173
+ /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-input-wrapper", children: [
174
+ children({
175
+ id: uniqueId,
176
+ "aria-labelledby": elementIds.label,
177
+ "aria-describedby": inputDescribedBy,
178
+ isInvalid: !!errorMessage,
179
+ isValid: !!isValid,
180
+ onBlurHandler: (e) => {
181
+ if (typeof onBlur === "function") onBlur(e);
182
+ if (typeof onFieldBlur === "function") onFieldBlur(e);
183
+ },
184
+ onFocusHandler: (e) => {
185
+ if (typeof onFocus === "function") onFocus(e);
186
+ }
187
+ }),
188
+ helper && helperPosition === "below" && /* @__PURE__ */ jsx(
189
+ "span",
190
+ {
191
+ id: elementIds.helper,
192
+ className: "adyen-kyc-helper-text adyen-kyc-helper-text__below",
193
+ children: helper
194
+ }
195
+ ),
196
+ isValid && /* @__PURE__ */ jsx("span", { className: "adyen-kyc-input__inline-validation adyen-kyc-input__inline-validation--valid", children: /* @__PURE__ */ jsx(Icon, { name: "check" }) }),
197
+ !!errorMessage && !showErrorIconBottom && showErrorIcon && /* @__PURE__ */ jsx("span", { className: "adyen-kyc-input__inline-validation adyen-kyc-input__inline-validation--invalid", children: /* @__PURE__ */ jsx(Icon, { name: "field-error" }) })
198
+ ] }),
199
+ /* @__PURE__ */ jsxs("div", { "aria-live": "polite", "aria-atomic": true, className: "adyen-kyc-error-text", children: [
200
+ /* @__PURE__ */ jsx("span", { className: "adyen-kyc-u-screen-reader-only", children: `${label}:` }),
201
+ !!errorMessage && typeof errorMessage !== "boolean" && /* @__PURE__ */ jsxs("span", { id: elementIds.error, children: [
202
+ translateStringOrObject(t, errorMessage),
203
+ showErrorIconBottom && /* @__PURE__ */ jsx("span", { className: "adyen-kyc-input__inline-validation adyen-kyc-input__inline-validation--invalid-bottom", children: /* @__PURE__ */ jsx(Icon, { name: "field-error" }) })
204
+ ] })
205
+ ] }),
206
+ !errorMessage && formatGuidance && /* @__PURE__ */ jsx("span", { id: elementIds.guidanceText, "aria-live": "polite", className: "adyen-kyc-guidance-text", children: formatGuidance })
207
+ ]
208
+ }
209
+ );
210
+ };
211
+ const loaderWrapperLoader = "adyen-kyc-loader-wrapper-loader";
212
+ const loaderWrapperLoaderActive = "adyen-kyc-loader-wrapper-loader-active";
213
+ const styles$1 = {
214
+ loaderWrapperLoader,
215
+ loaderWrapperLoaderActive
216
+ };
217
+ const LoaderWrapper = ({
218
+ children,
219
+ status,
220
+ formOpacityWhenLoading = 0,
221
+ loaderSize = "medium",
222
+ showSpinner = true,
223
+ className
224
+ }) => {
225
+ const opacitySyle = status === "loading" ? {
226
+ opacity: formOpacityWhenLoading
227
+ } : { opacity: 1 };
228
+ const loaderWrapperClass = cx(styles$1.loaderWrapperLoader, {
229
+ [styles$1.loaderWrapperLoaderActive]: status === "loading" && showSpinner
230
+ });
231
+ const overlayClass = cx(styles$1.loaderWrapper, className);
232
+ return /* @__PURE__ */ jsxs("div", { className: overlayClass, style: { position: "relative" }, children: [
233
+ /* @__PURE__ */ jsx("div", { className: loaderWrapperClass, children: /* @__PURE__ */ jsx(Loader, { size: loaderSize }) }),
234
+ /* @__PURE__ */ jsx("div", { className: styles$1.loaderWrapperForm, style: opacitySyle, children })
235
+ ] });
236
+ };
237
+ const createSelectFocus = ({
238
+ activeItems,
239
+ filteredItems: items
240
+ }) => {
241
+ const numberOfItems = computed(() => items.value.length - 1);
242
+ const focused = signal();
243
+ const getDefaultFocusedItem = () => {
244
+ const firstActiveOption = activeItems.value.find((option) => !option.disabled);
245
+ const firstEnabledOption = items.value.find((option) => !option.disabled);
246
+ return firstActiveOption ?? firstEnabledOption;
247
+ };
248
+ const focusedItemIndex = computed(() => {
249
+ const currFocus = focused.value;
250
+ const toFind = focusedIsItem(currFocus) ? currFocus : getDefaultFocusedItem();
251
+ if (!toFind) {
252
+ console.warn("[Select] No existing focused item, and none of the filtered items are enabled");
253
+ return 0;
254
+ }
255
+ return items.value.findIndex((i) => i.id === toFind.id);
256
+ });
257
+ const findPotentialIndex = (currentIndex, direction) => {
258
+ const potentialIndex = direction === "down" ? currentIndex + 1 : currentIndex - 1;
259
+ const potentialItem = items.value[potentialIndex];
260
+ if (potentialIndex < 0 || potentialIndex > numberOfItems.value) {
261
+ return "exceedsBounds";
262
+ }
263
+ if (potentialItem.disabled) {
264
+ return findPotentialIndex(potentialIndex, direction);
265
+ }
266
+ return potentialIndex;
267
+ };
268
+ const moveFocusToNextItem = () => {
269
+ const nextIndex = findPotentialIndex(focusedItemIndex.value, "down");
270
+ if (nextIndex !== "exceedsBounds") focused.value = items.value[nextIndex];
271
+ };
272
+ const moveFocusToPreviousItem = () => {
273
+ const prevIndex = findPotentialIndex(focusedItemIndex.value, "up");
274
+ if (prevIndex !== "exceedsBounds") focused.value = items.value[prevIndex];
275
+ };
276
+ const moveFocusToFirstItem = () => {
277
+ let currIndex = focusedItemIndex.value;
278
+ while (true) {
279
+ const before = findPotentialIndex(currIndex, "up");
280
+ if (before === "exceedsBounds") break;
281
+ currIndex = before;
282
+ }
283
+ focused.value = items.value[currIndex];
284
+ };
285
+ const moveFocusToLastItem = () => {
286
+ let currIndex = focusedItemIndex.value;
287
+ while (true) {
288
+ const after = findPotentialIndex(currIndex, "down");
289
+ if (after === "exceedsBounds") break;
290
+ currIndex = after;
291
+ }
292
+ focused.value = items.value[currIndex];
293
+ };
294
+ const focusInput = () => {
295
+ focused.value = "input";
296
+ };
297
+ const focusItem = (item) => {
298
+ focused.value = item;
299
+ };
300
+ const focusDefaultItem = () => {
301
+ focused.value = getDefaultFocusedItem();
302
+ };
303
+ const focusNothing = () => {
304
+ focused.value = void 0;
305
+ };
306
+ return {
307
+ focused,
308
+ moveFocusToFirstItem,
309
+ moveFocusToLastItem,
310
+ moveFocusToNextItem,
311
+ moveFocusToPreviousItem,
312
+ focusInput,
313
+ focusItem,
314
+ focusDefaultItem,
315
+ focusNothing
316
+ };
317
+ };
318
+ const useSelectFocus = (options) => {
319
+ const [selectFocus] = useState(createSelectFocus(options));
320
+ return selectFocus;
321
+ };
322
+ const focusedIsItem = (focused) => Boolean(focused) && typeof focused === "object";
323
+ const useWatchingSignal = (value) => {
324
+ const signal2 = useSignal(value);
325
+ if (signal2.peek() !== value) signal2.value = value;
326
+ return signal2;
327
+ };
328
+ const simulateTextChangeFromKeyboardEvent = (keyDownEvent, value) => {
329
+ const { key } = keyDownEvent;
330
+ let newValue = value;
331
+ if (key === KEYBOARD_KEYS.backspace) {
332
+ newValue = newValue.slice(0, newValue.length - 1);
333
+ } else if (key.length === 1) {
334
+ newValue += key;
335
+ }
336
+ return newValue;
337
+ };
338
+ function useMirrorProp(prop, propOnChange, defaultVal) {
339
+ const [isMirroring] = useState(propOnChange !== void 0);
340
+ const [local, setLocal] = useState(defaultVal);
341
+ if (isMirroring) {
342
+ return [prop, propOnChange];
343
+ } else {
344
+ return [local, setLocal];
345
+ }
346
+ }
347
+ const selectInputWrapper = "adyen-kyc-select-input-wrapper";
348
+ const selectInput = "adyen-kyc-select-input";
349
+ const selectInputActive = "adyen-kyc-select-input--active";
350
+ const selectInputReadonly = "adyen-kyc-select-input--readonly";
351
+ const selectInputInvalid = "adyen-kyc-select-input--invalid";
352
+ const selectInputMinimal = "adyen-kyc-select-input--minimal";
353
+ const selectInputSearch = "adyen-kyc-select-input-search";
354
+ const selectInputFilterable = "adyen-kyc-select-input--filterable";
355
+ const selectInputWrapperFilterable = "adyen-kyc-select-input-wrapper--filterable";
356
+ const selectInputWrapperNonFilterable = "adyen-kyc-select-input-wrapper--non-filterable";
357
+ const selectInputListOpen = "adyen-kyc-select-input--list-open";
358
+ const selectInputNonFilterable = "adyen-kyc-select-input--non-filterable";
359
+ const selectInputPlaceholder = "adyen-kyc-select-input--placeholder";
360
+ const ignorePointerEvents = "adyen-kyc-ignore-pointer-events";
361
+ const handlePointerEvents = "adyen-kyc-handle-pointer-events";
362
+ const styles = {
363
+ selectInputWrapper,
364
+ selectInput,
365
+ selectInputActive,
366
+ selectInputReadonly,
367
+ selectInputInvalid,
368
+ selectInputMinimal,
369
+ selectInputSearch,
370
+ selectInputFilterable,
371
+ selectInputWrapperFilterable,
372
+ selectInputWrapperNonFilterable,
373
+ selectInputListOpen,
374
+ selectInputNonFilterable,
375
+ selectInputPlaceholder,
376
+ ignorePointerEvents,
377
+ handlePointerEvents
378
+ };
379
+ const isAppleMobile = /iPhone|iPad/.test(navigator.platform);
380
+ function SelectButton({
381
+ id,
382
+ name,
383
+ active,
384
+ readonly,
385
+ showList,
386
+ isInvalid,
387
+ onClick,
388
+ onButtonKeyDown,
389
+ filterable,
390
+ isFiltering,
391
+ placeholder,
392
+ focusProps: { focused },
393
+ selectListId,
394
+ onInput,
395
+ behaviour,
396
+ loading,
397
+ text,
398
+ enableTracking = false,
399
+ onFocus,
400
+ inputRef,
401
+ minimal,
402
+ "aria-describedby": ariaDescribedBy,
403
+ "aria-labelledby": ariaLabelledBy,
404
+ "aria-label": ariaLabel
405
+ }) {
406
+ const userEvents = useAnalyticsContext();
407
+ const wrapperRef = useRef(null);
408
+ useSignalEffect(() => {
409
+ if (focused.value === "input") {
410
+ inputRef.current?.focus();
411
+ }
412
+ });
413
+ const handleFocus = (e) => {
414
+ if (readonly) return;
415
+ if (enableTracking)
416
+ userEvents.addFieldEvent("Interacted with form field", {
417
+ actionType: "focus",
418
+ field: name
419
+ });
420
+ onFocus(e);
421
+ };
422
+ const handleClick = (e) => {
423
+ e.preventDefault();
424
+ e.stopPropagation();
425
+ if (readonly) return;
426
+ onClick();
427
+ };
428
+ const handleKeyDown = (e) => {
429
+ if (!readonly) onButtonKeyDown(e);
430
+ };
431
+ const handleInput = (e) => {
432
+ if (filterable && !readonly) onInput(e.target.value);
433
+ };
434
+ const truncatedDisplayValue = useMemo(() => {
435
+ if (active.length === 0) return void 0;
436
+ const activeText = active.map(({ selectedOptionName, name: name2 }) => selectedOptionName ?? name2).join(", ");
437
+ return activeText.length > 50 ? activeText.substring(0, 50) + "..." : activeText;
438
+ }, [active]);
439
+ const title = active?.length ? active.map(({ name: name2 }) => name2).join(",") : placeholder;
440
+ const isFocused = focused.value === "input";
441
+ const value = useMemo(() => {
442
+ if (behaviour === "textIsData" || focused.value !== void 0 && // can be focusing either the input or one of the options
443
+ filterable && isFiltering)
444
+ return text;
445
+ return truncatedDisplayValue;
446
+ }, [behaviour, text, focused.value, filterable, isFiltering, truncatedDisplayValue]);
447
+ return (
448
+ // In this case, the `<input>` within is fully accessible - this `onClick` is simply handling the situation
449
+ // where there is no `<label>` around the component. In that case, we should handle click events as if they
450
+ // occurred on the input.
451
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
452
+ /* @__PURE__ */ jsxs(
453
+ "div",
454
+ {
455
+ className: cx({
456
+ [styles.selectInputWrapper]: true,
457
+ [styles.selectInputMinimal]: minimal,
458
+ [styles.selectInputReadonly]: readonly,
459
+ [styles.selectInputActive]: isFocused,
460
+ [styles.selectInputListOpen]: showList,
461
+ [styles.selectInputInvalid]: isInvalid,
462
+ [styles.selectInputSearch]: filterable === "prefiltered",
463
+ [styles.selectInputWrapperFilterable]: filterable,
464
+ [styles.selectInputWrapperNonFilterable]: !filterable,
465
+ // To resolve a bug where filterable select `<input>`s weren't focusable on iOS
466
+ [styles.ignorePointerEvents]: isAppleMobile
467
+ }),
468
+ ref: wrapperRef,
469
+ onClick: handleClick,
470
+ onFocusIn: handleFocus,
471
+ children: [
472
+ /* @__PURE__ */ jsx(
473
+ "input",
474
+ {
475
+ id,
476
+ name,
477
+ title,
478
+ ref: inputRef,
479
+ type: filterable ? "text" : "button",
480
+ role: "combobox",
481
+ "aria-haspopup": "listbox",
482
+ "aria-owns": selectListId,
483
+ "aria-controls": selectListId,
484
+ "aria-expanded": showList,
485
+ "aria-describedby": ariaDescribedBy,
486
+ "aria-disabled": readonly,
487
+ "aria-label": ariaLabel,
488
+ "aria-labelledby": ariaLabelledBy,
489
+ "aria-autocomplete": filterable ? "list" : void 0,
490
+ autoComplete: "off",
491
+ className: cx({
492
+ [styles.selectInput]: true,
493
+ [styles.selectInputFilterable]: filterable,
494
+ [styles.selectInputNonFilterable]: !filterable,
495
+ [styles.selectInputMinimal]: minimal,
496
+ [styles.selectInputReadonly]: readonly,
497
+ // To resolve a bug where filterable select `<input>`s weren't focusable on iOS
498
+ [styles.handlePointerEvents]: isAppleMobile
499
+ }),
500
+ placeholder,
501
+ value,
502
+ disabled: readonly,
503
+ onClick: handleClick,
504
+ onInput: handleInput,
505
+ onKeyDown: handleKeyDown
506
+ }
507
+ ),
508
+ !filterable && !value ? /* @__PURE__ */ jsx("span", { className: styles.selectInputPlaceholder, children: placeholder }) : void 0,
509
+ loading && /* @__PURE__ */ jsx(Loader, { size: "small", dot: true })
510
+ ]
511
+ }
512
+ )
513
+ );
514
+ }
515
+ const SelectListItem = ({
516
+ id,
517
+ item,
518
+ selected,
519
+ isMulti,
520
+ isSearch,
521
+ children,
522
+ onSelect,
523
+ onKeyDown,
524
+ onFocus,
525
+ className
526
+ }) => /* @__PURE__ */ jsx(
527
+ "li",
528
+ {
529
+ "aria-disabled": !!item.disabled,
530
+ "aria-selected": selected,
531
+ className: cx([
532
+ "adyen-kyc-dropdown-element",
533
+ {
534
+ "adyen-kyc-dropdown-element--active": selected,
535
+ "adyen-kyc-dropdown-element--disabled": !!item.disabled,
536
+ "adyen-kyc-dropdown-multi-element": isMulti,
537
+ "adyen-kyc-dropdown-element-description": !isMulti && !isSearch && item.description,
538
+ "adyen-kyc-dropdown-search-element": isSearch
539
+ },
540
+ className
541
+ ]),
542
+ "data-disabled": !!item.disabled,
543
+ "data-value": item.id,
544
+ onFocus: (event) => {
545
+ if (item.disabled) return;
546
+ onFocus?.(event);
547
+ },
548
+ onClick: (e) => {
549
+ e.preventDefault();
550
+ if (item.disabled) return;
551
+ onSelect(!selected);
552
+ },
553
+ onKeyDown: (e) => {
554
+ if (item.disabled) return;
555
+ onKeyDown(e);
556
+ },
557
+ role: "option",
558
+ tabIndex: -1,
559
+ children: isMulti ? /* @__PURE__ */ jsx("span", { style: { pointerEvents: "none", width: "100%" }, children: /* @__PURE__ */ jsx(
560
+ Checkbox,
561
+ {
562
+ id,
563
+ onChange: noop,
564
+ label: item.name,
565
+ disabled: item.disabled,
566
+ helper: item.description,
567
+ checked: selected,
568
+ name: `adyen-kyc-dropdown-element__checkbox adyen-kyc-dropdown-element__checkbox--${item.id}`
569
+ }
570
+ ) }) : children ? [children] : /* @__PURE__ */ jsxs(Fragment, { children: [
571
+ item.icon && /* @__PURE__ */ jsx("span", { className: "adyen-kyc-dropdown-element__icon", children: item.icon }),
572
+ item.description ? /* @__PURE__ */ jsxs(Fragment, { children: [
573
+ /* @__PURE__ */ jsx(
574
+ Typography,
575
+ {
576
+ el: "span",
577
+ variant: "body-strongest",
578
+ className: "adyen-kyc-dropdown-element__label",
579
+ children: item.name
580
+ }
581
+ ),
582
+ /* @__PURE__ */ jsx(
583
+ Typography,
584
+ {
585
+ el: "span",
586
+ color: "secondary",
587
+ className: "adyen-kyc-dropdown-element-description__text",
588
+ children: item.description
589
+ }
590
+ )
591
+ ] }) : /* @__PURE__ */ jsx("span", { className: "adyen-kyc-dropdown-element__label", children: item.name })
592
+ ] })
593
+ }
594
+ );
595
+ const logger$1 = createLogger();
596
+ const DEFAULT_ITEM_HEIGHT = 36;
597
+ function SelectList({
598
+ selectListId,
599
+ active,
600
+ filteredItems,
601
+ showList,
602
+ isMulti,
603
+ inputRef,
604
+ isSearch,
605
+ loading,
606
+ getSearchItem,
607
+ onKeyDown,
608
+ onSelect,
609
+ minimal,
610
+ maxVisibleItems = 5,
611
+ focusProps: {
612
+ focused,
613
+ focusItem,
614
+ focusDefaultItem,
615
+ moveFocusToNextItem,
616
+ moveFocusToPreviousItem,
617
+ moveFocusToFirstItem,
618
+ moveFocusToLastItem
619
+ }
620
+ }) {
621
+ const { t } = useTranslation("ui");
622
+ const [startIndex, setStartIndex] = useState(0);
623
+ const [endIndex, setEndIndex] = useState(maxVisibleItems);
624
+ const listRef = useRef(null);
625
+ const calculatedItemHeight = (() => {
626
+ if (listRef.current && showList) {
627
+ const height2 = listRef.current.firstElementChild?.firstElementChild?.clientHeight;
628
+ if (height2 !== void 0) return height2;
629
+ }
630
+ })();
631
+ const itemHeight = calculatedItemHeight || DEFAULT_ITEM_HEIGHT;
632
+ const totalItems = filteredItems.length;
633
+ const visibleItems = useMemo(
634
+ () => filteredItems.slice(startIndex, endIndex),
635
+ [endIndex, filteredItems, startIndex]
636
+ );
637
+ const findElementForItem = useCallback(
638
+ (item) => {
639
+ const listContainer = listRef.current;
640
+ if (!listContainer) return;
641
+ return listContainer.querySelector(
642
+ `[role="option"][data-value="${item.id}"]`
643
+ );
644
+ },
645
+ [listRef]
646
+ );
647
+ const recalculateScrollIndexes = useCallback(() => {
648
+ if (!listRef.current) return;
649
+ const { scrollTop } = listRef.current;
650
+ const maxStartIndex = totalItems < maxVisibleItems ? totalItems : totalItems - maxVisibleItems;
651
+ const newStartIndex = Math.min(Math.max(0, Math.floor(scrollTop / itemHeight)), maxStartIndex);
652
+ const newEndIndex = Math.min(newStartIndex + maxVisibleItems, totalItems);
653
+ setStartIndex(newStartIndex);
654
+ setEndIndex(newEndIndex);
655
+ }, [totalItems, maxVisibleItems, itemHeight, listRef]);
656
+ useEffect(() => {
657
+ recalculateScrollIndexes();
658
+ }, [recalculateScrollIndexes]);
659
+ const scrollItemIntoView = useCallback(
660
+ (item) => {
661
+ if (!listRef.current) return;
662
+ const itemIndex = filteredItems.indexOf(item);
663
+ if (itemIndex === -1) {
664
+ return;
665
+ }
666
+ const maxScrollTop = totalItems * itemHeight;
667
+ listRef.current.scrollTop = Math.min(itemHeight * (itemIndex + 0.5), maxScrollTop);
668
+ },
669
+ [filteredItems, itemHeight, totalItems, listRef]
670
+ );
671
+ const acquireFocusForItem = useCallback(
672
+ (item) => {
673
+ let itemEl = findElementForItem(item);
674
+ if (!itemEl) {
675
+ scrollItemIntoView(item);
676
+ }
677
+ setTimeout(() => {
678
+ itemEl = itemEl ?? findElementForItem(item);
679
+ if (itemEl) {
680
+ itemEl.focus();
681
+ } else {
682
+ logger$1.warn("[SelectList] still cannot see the option", item.name);
683
+ }
684
+ }, 20);
685
+ },
686
+ [findElementForItem, scrollItemIntoView]
687
+ );
688
+ useSignalEffect(() => {
689
+ const currFocused = focused.value;
690
+ if (focusedIsItem(currFocused)) {
691
+ acquireFocusForItem(currFocused);
692
+ }
693
+ });
694
+ const listListeners = {
695
+ [KEYBOARD_KEYS.arrowUp]: moveFocusToPreviousItem,
696
+ [KEYBOARD_KEYS.arrowDown]: moveFocusToNextItem,
697
+ [KEYBOARD_KEYS.home]: moveFocusToFirstItem,
698
+ [KEYBOARD_KEYS.end]: moveFocusToLastItem
699
+ };
700
+ const onListKeydown = (event) => {
701
+ const listener = listListeners[event.key];
702
+ if (listener) {
703
+ event.preventDefault();
704
+ listener();
705
+ }
706
+ };
707
+ const getItems = () => {
708
+ if (loading) {
709
+ return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropdown-element adyen-kyc-dropdown-element--no-options", children: t(($) => $["loading"]) });
710
+ }
711
+ if (!filteredItems.length) {
712
+ if (startIndex !== 0 || endIndex !== maxVisibleItems) {
713
+ setStartIndex(0);
714
+ setEndIndex(maxVisibleItems);
715
+ }
716
+ return /* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropdown-element adyen-kyc-dropdown-element--no-options", children: t(($) => $["noOptionsFound"]) });
717
+ }
718
+ if (visibleItems.length) {
719
+ return visibleItems.map((item) => /* @__PURE__ */ jsx(
720
+ SelectListItem,
721
+ {
722
+ item,
723
+ id: item.id,
724
+ onKeyDown: (event) => onKeyDown(event, item),
725
+ onFocus: (event) => {
726
+ focusItem(item);
727
+ event.stopPropagation();
728
+ },
729
+ onSelect: () => onSelect(item),
730
+ selected: !!active.find((activeItem) => activeItem.id === item.id),
731
+ isMulti,
732
+ isSearch,
733
+ children: getSearchItem && getSearchItem(item)
734
+ },
735
+ item.id
736
+ ));
737
+ }
738
+ return null;
739
+ };
740
+ const height = useMemo(() => {
741
+ if (loading) return "auto";
742
+ return totalItems > maxVisibleItems && itemHeight ? `${itemHeight * maxVisibleItems}px` : "auto";
743
+ }, [itemHeight, totalItems, loading, maxVisibleItems]);
744
+ const allItemsVisible = totalItems <= maxVisibleItems;
745
+ const [showAbove, setShowAbove] = useState(false);
746
+ useEffect(() => {
747
+ const list = listRef.current;
748
+ const input = inputRef.current;
749
+ const resizeObserver = new ResizeObserver(() => {
750
+ const dropdownHeight = list.offsetHeight;
751
+ const windowHeight = window.innerHeight;
752
+ const position = input.getBoundingClientRect().bottom;
753
+ const isSpaceBelow = windowHeight - position > dropdownHeight;
754
+ const isSpaceAbove = position > dropdownHeight;
755
+ setShowAbove(!isSpaceBelow && isSpaceAbove);
756
+ });
757
+ resizeObserver.observe(list);
758
+ return () => resizeObserver.disconnect();
759
+ }, [inputRef, listRef]);
760
+ return /* @__PURE__ */ jsx(
761
+ "div",
762
+ {
763
+ className: cx({
764
+ "adyen-kyc-dropdown-list": true,
765
+ "adyen-kyc-dropdown-list--minimal": minimal,
766
+ "adyen-kyc-dropdown-list--active": showList,
767
+ "adyen-kyc-dropdown-list--above": showAbove
768
+ }),
769
+ id: selectListId,
770
+ role: "listbox",
771
+ onScroll: recalculateScrollIndexes,
772
+ style: {
773
+ overflowY: allItemsVisible ? "hidden" : "auto",
774
+ position: "absolute",
775
+ height
776
+ },
777
+ onKeyDown: onListKeydown,
778
+ onFocus: focusDefaultItem,
779
+ tabIndex: -1,
780
+ ref: listRef,
781
+ children: /* @__PURE__ */ jsxs(
782
+ "ul",
783
+ {
784
+ className: "adyen-kyc-dropdown-list__transformer",
785
+ style: {
786
+ transform: `translateY(${startIndex * itemHeight}px)`
787
+ },
788
+ children: [
789
+ getItems(),
790
+ /* @__PURE__ */ jsx(
791
+ "div",
792
+ {
793
+ style: {
794
+ // fake the height of the remaining items in the list so scroll position is correct
795
+ height: `${(totalItems - endIndex) * itemHeight}px`
796
+ }
797
+ }
798
+ )
799
+ ]
800
+ }
801
+ )
802
+ }
803
+ );
804
+ }
805
+ const Select = ({
806
+ id,
807
+ items,
808
+ filterable = true,
809
+ readonly = false,
810
+ onChange,
811
+ onSelect,
812
+ selected,
813
+ name,
814
+ isInvalid = false,
815
+ placeholder = "",
816
+ isMulti,
817
+ enableTracking = false,
818
+ maxVisibleItems,
819
+ getSearchItem,
820
+ onBlur = noop,
821
+ text: filterTextProp,
822
+ setText: setFilterTextProp,
823
+ showList: showListProp,
824
+ setShowList: setShowListProp,
825
+ behaviour = "textIsFilter",
826
+ loading = false,
827
+ minimal = false,
828
+ "aria-describedby": ariaDescribedBy,
829
+ "aria-label": ariaLabel,
830
+ "aria-labelledby": ariaLabelledBy,
831
+ excludedValues
832
+ }) => {
833
+ const userEvents = useAnalyticsContext();
834
+ const selectContainerRef = useRef(null);
835
+ const inputRef = useRef(null);
836
+ const selectListId = useId("select");
837
+ const [textFilter, setTextFilter] = useMirrorProp(filterTextProp, setFilterTextProp, "");
838
+ const [isShowList, setIsShowList] = useMirrorProp(showListProp, setShowListProp, false);
839
+ const [isFiltering, setIsFiltering] = useState(false);
840
+ const active = useMemo(() => {
841
+ if (selected === void 0) return [];
842
+ return (Array.isArray(selected) ? selected : [selected]).map((s) => {
843
+ if (typeof s === "object") return s;
844
+ return items.find((i) => i.id === s);
845
+ }).filter(Boolean);
846
+ }, [items, selected]);
847
+ const filtered = useMemo(() => {
848
+ const availableItems = items.filter((item) => !excludedValues?.includes(item));
849
+ return availableItems.filter((item) => {
850
+ if (filterable === "prefiltered" || !isFiltering) return true;
851
+ return item.name.toLowerCase().includes(textFilter.toLowerCase());
852
+ });
853
+ }, [filterable, isFiltering, items, textFilter, excludedValues]);
854
+ const activeSignal = useWatchingSignal(active);
855
+ const filteredSignal = useWatchingSignal(filtered);
856
+ const focusProps = useSelectFocus({
857
+ activeItems: activeSignal,
858
+ filteredItems: filteredSignal
859
+ });
860
+ const {
861
+ focusInput,
862
+ focusItem,
863
+ focusDefaultItem,
864
+ focusNothing,
865
+ moveFocusToNextItem,
866
+ moveFocusToPreviousItem
867
+ } = focusProps;
868
+ const closeList = useCallback(
869
+ (shiftFocusTo) => {
870
+ if (behaviour === "textIsFilter") setTextFilter("");
871
+ setIsShowList(false);
872
+ switch (shiftFocusTo) {
873
+ case "input":
874
+ focusInput();
875
+ break;
876
+ case "nothing":
877
+ focusNothing();
878
+ break;
879
+ }
880
+ },
881
+ [behaviour, focusInput, focusNothing, setIsShowList, setTextFilter]
882
+ );
883
+ const showList = useCallback(() => {
884
+ if (!isShowList) setIsShowList(true);
885
+ }, [isShowList, setIsShowList]);
886
+ const handleSelect = useCallback(
887
+ (selectedItem) => {
888
+ setIsFiltering(false);
889
+ if (readonly) return;
890
+ if (isMulti) {
891
+ const isAlreadySelected = active.find((item) => item.id === selectedItem.id);
892
+ const newActiveItems = isAlreadySelected ? active.filter((i) => i.id !== selectedItem.id) : [...active, selectedItem];
893
+ onSelect?.(newActiveItems);
894
+ onChange?.({ target: { value: newActiveItems.map((i) => i.id), name: name ?? "" } });
895
+ focusItem(selectedItem);
896
+ } else {
897
+ const handleOnSelect = onSelect;
898
+ const handleOnChange = onChange;
899
+ handleOnSelect?.(selectedItem);
900
+ handleOnChange?.({ target: { value: selectedItem.id, name: name ?? "" } });
901
+ closeList("input");
902
+ }
903
+ if (enableTracking) {
904
+ userEvents.addFieldEvent("Interacted with form field", {
905
+ actionType: "select",
906
+ field: name,
907
+ returnValue: selectedItem.id
908
+ });
909
+ }
910
+ },
911
+ [
912
+ readonly,
913
+ isMulti,
914
+ enableTracking,
915
+ active,
916
+ onSelect,
917
+ onChange,
918
+ name,
919
+ focusItem,
920
+ closeList,
921
+ userEvents
922
+ ]
923
+ );
924
+ const handleBlur = (e) => {
925
+ onBlur(e);
926
+ };
927
+ const handleInputKeyDown = async (e) => {
928
+ if (e.key === KEYBOARD_KEYS.enter && isShowList) {
929
+ if (filtered.length === 1) {
930
+ handleSelect(filtered[0]);
931
+ } else {
932
+ e.preventDefault();
933
+ }
934
+ } else if (e.key === KEYBOARD_KEYS.escape) {
935
+ closeList("nothing");
936
+ } else if (e.key === KEYBOARD_KEYS.enter || e.key === KEYBOARD_KEYS.space && (!filterable || !isShowList)) {
937
+ e.preventDefault();
938
+ e.stopPropagation();
939
+ showList();
940
+ focusDefaultItem();
941
+ } else if (e.key === KEYBOARD_KEYS.arrowUp || e.key === KEYBOARD_KEYS.arrowDown) {
942
+ e.preventDefault();
943
+ e.stopPropagation();
944
+ showList();
945
+ focusDefaultItem();
946
+ switch (e.key) {
947
+ case KEYBOARD_KEYS.arrowUp:
948
+ moveFocusToPreviousItem();
949
+ break;
950
+ case KEYBOARD_KEYS.arrowDown:
951
+ moveFocusToNextItem();
952
+ break;
953
+ }
954
+ } else if (e.key === KEYBOARD_KEYS.tab) {
955
+ closeList("nothing");
956
+ }
957
+ };
958
+ const handleClickOutside = (e) => {
959
+ if (!selectContainerRef.current?.contains(e.target)) {
960
+ closeList("nothing");
961
+ }
962
+ };
963
+ const handleListItemKeyDown = (e, item) => {
964
+ switch (e.key) {
965
+ case KEYBOARD_KEYS.escape:
966
+ e.preventDefault();
967
+ closeList("input");
968
+ break;
969
+ case KEYBOARD_KEYS.space:
970
+ case KEYBOARD_KEYS.enter:
971
+ handleSelect(item);
972
+ break;
973
+ case KEYBOARD_KEYS.tab:
974
+ closeList("nothing");
975
+ break;
976
+ case KEYBOARD_KEYS.arrowUp:
977
+ case KEYBOARD_KEYS.arrowDown:
978
+ case KEYBOARD_KEYS.home:
979
+ case KEYBOARD_KEYS.end:
980
+ break;
981
+ default: {
982
+ e.preventDefault();
983
+ e.stopPropagation();
984
+ handleTextFilter(simulateTextChangeFromKeyboardEvent(e, textFilter));
985
+ focusInput();
986
+ }
987
+ }
988
+ };
989
+ const handleTextFilter = useCallback(
990
+ (value) => {
991
+ showList();
992
+ setIsFiltering(true);
993
+ setTextFilter(value);
994
+ if (enableTracking) {
995
+ debouncedInputEvent({ actionType: "input", field: name });
996
+ }
997
+ },
998
+ [enableTracking, name, setTextFilter, showList]
999
+ );
1000
+ useEffect(() => {
1001
+ document.addEventListener("click", handleClickOutside, true);
1002
+ return () => {
1003
+ document.removeEventListener("click", handleClickOutside, true);
1004
+ };
1005
+ }, []);
1006
+ return /* @__PURE__ */ jsxs(
1007
+ "div",
1008
+ {
1009
+ className: cx({ "adyen-kyc-dropdown": true, "adyen-kyc-dropdown--minimal": minimal }),
1010
+ ref: selectContainerRef,
1011
+ onFocusOut: handleBlur,
1012
+ children: [
1013
+ /* @__PURE__ */ jsx(
1014
+ SelectButton,
1015
+ {
1016
+ id,
1017
+ name,
1018
+ active,
1019
+ filterable,
1020
+ isFiltering,
1021
+ isInvalid,
1022
+ onButtonKeyDown: handleInputKeyDown,
1023
+ onInput: handleTextFilter,
1024
+ placeholder,
1025
+ readonly,
1026
+ selectListId,
1027
+ showList: isShowList,
1028
+ focusProps,
1029
+ "aria-describedby": ariaDescribedBy || "",
1030
+ "aria-label": ariaLabel || "",
1031
+ "aria-labelledby": ariaLabelledBy || "",
1032
+ isMulti: Boolean(isMulti),
1033
+ loading,
1034
+ behaviour,
1035
+ text: textFilter,
1036
+ inputRef,
1037
+ enableTracking,
1038
+ minimal,
1039
+ onClick: () => {
1040
+ if (isShowList) {
1041
+ closeList("input");
1042
+ } else {
1043
+ showList();
1044
+ focusInput();
1045
+ }
1046
+ },
1047
+ onFocus: () => focusInput()
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ jsx(
1051
+ SelectList,
1052
+ {
1053
+ active,
1054
+ filteredItems: filtered,
1055
+ onKeyDown: handleListItemKeyDown,
1056
+ onSelect: handleSelect,
1057
+ selectListId,
1058
+ showList: isShowList,
1059
+ textFilter,
1060
+ isMulti: Boolean(isMulti),
1061
+ isSearch: filterable === "prefiltered",
1062
+ getSearchItem,
1063
+ loading,
1064
+ maxVisibleItems,
1065
+ focusProps,
1066
+ inputRef,
1067
+ minimal
1068
+ }
1069
+ )
1070
+ ]
1071
+ }
1072
+ );
1073
+ };
1074
+ class ValidationResult {
1075
+ validationResults;
1076
+ constructor(results) {
1077
+ this.validationResults = results;
1078
+ }
1079
+ /** Checks if all validation rules have passed */
1080
+ get isValid() {
1081
+ return this.validationResults.reduce((acc, result) => acc && result.isValid, true);
1082
+ }
1083
+ /** Checks if any validation rule returned an error */
1084
+ hasError() {
1085
+ return Boolean(this.getError());
1086
+ }
1087
+ /** Returns the first validation result that returned an error */
1088
+ getError() {
1089
+ return this.validationResults.find((result) => result.hasError);
1090
+ }
1091
+ /** Used to add async validation results to the static validation result*/
1092
+ addError(result) {
1093
+ this.validationResults.push(result);
1094
+ return this.validationResults;
1095
+ }
1096
+ }
1097
+ const logger = createLogger();
1098
+ const useAsyncValidator = (asyncRules) => {
1099
+ const [asyncValidationResults, setAsyncValidationResults] = useState({});
1100
+ const clearAsyncValidationResults = useCallback(
1101
+ (field) => setAsyncValidationResults((existingResults) => ({
1102
+ ...existingResults,
1103
+ [field]: void 0
1104
+ })),
1105
+ []
1106
+ );
1107
+ const triggerAsyncValidation = useCallback(
1108
+ (field, formState, mode) => {
1109
+ const rule = asyncRules?.[field];
1110
+ if (!rule || !rule.modes.includes(mode)) {
1111
+ clearAsyncValidationResults(field);
1112
+ return;
1113
+ }
1114
+ const value = formState.data[field];
1115
+ return rule.asyncValidate(formState.data[field], { state: formState }).then((isValid) => {
1116
+ setAsyncValidationResults((existingResults) => ({
1117
+ ...existingResults,
1118
+ [field]: new ValidationResult([
1119
+ {
1120
+ isValid,
1121
+ errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value, { state: formState }) : rule.errorMessage,
1122
+ hasError: !isValid
1123
+ }
1124
+ ])
1125
+ }));
1126
+ }).catch(logger.error);
1127
+ },
1128
+ [asyncRules, clearAsyncValidationResults]
1129
+ );
1130
+ return {
1131
+ asyncValidationResults,
1132
+ triggerAsyncValidation,
1133
+ clearAsyncValidationResults
1134
+ };
1135
+ };
1136
+ const useStaticValidator = (rules) => {
1137
+ const getRulesForField = useCallback(
1138
+ (field) => {
1139
+ const fallbackRule = {
1140
+ validate: () => true,
1141
+ modes: ["blur", "input"]
1142
+ };
1143
+ const fieldRules = rules?.[field] ?? [fallbackRule];
1144
+ return Array.isArray(fieldRules) ? fieldRules : [fieldRules];
1145
+ },
1146
+ [rules]
1147
+ );
1148
+ const triggerStaticValidation = useCallback(
1149
+ ({ key, value, mode = "blur" }, context) => {
1150
+ const fieldRules = getRulesForField(key);
1151
+ const isFieldOptional = !!context?.state.optionalFields?.includes(key);
1152
+ const isFieldObscured = !!context?.state.obscuredFields?.includes(key);
1153
+ const validationRulesResult = fieldRules.map((rule) => {
1154
+ const shouldValidate = rule.modes.includes(mode) && !isFieldObscured;
1155
+ const isValid = isFieldOptional && isEmpty(value) ? true : rule.validate(value, context);
1156
+ return {
1157
+ isValid,
1158
+ errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value, context) : rule.errorMessage,
1159
+ hasError: shouldValidate && !isValid
1160
+ };
1161
+ });
1162
+ return new ValidationResult(validationRulesResult);
1163
+ },
1164
+ [getRulesForField]
1165
+ );
1166
+ return {
1167
+ triggerStaticValidation
1168
+ };
1169
+ };
1170
+ const omitKeys = (obj, omit) => Object.keys(obj).filter((k) => !omit.includes(k)).reduce((a, c) => {
1171
+ a[c] = obj[c];
1172
+ return a;
1173
+ }, {});
1174
+ const addKeys = (obj, add, initialValue, defaultData, pendingData) => add.reduce(
1175
+ (a, c) => ({
1176
+ ...a,
1177
+ [c]: a[c] ?? pendingData?.[c] ?? defaultData?.[c] ?? initialValue
1178
+ }),
1179
+ obj
1180
+ );
1181
+ function getDataByFields(formData, fieldKeys) {
1182
+ return entriesOf(formData).reduce((acc, [key, val]) => {
1183
+ if (fieldKeys.includes(key)) {
1184
+ return { ...acc, [key]: val };
1185
+ }
1186
+ return acc;
1187
+ }, {});
1188
+ }
1189
+ const processField = ({
1190
+ key,
1191
+ value = null,
1192
+ mode,
1193
+ defaultData,
1194
+ fieldContext,
1195
+ formatters,
1196
+ staticValidate,
1197
+ asyncValidate
1198
+ }) => {
1199
+ const formatterFn = formatters?.[key]?.formatter ? formatters[key]?.formatter : formatters?.[key];
1200
+ const formattedValue = formatterFn && typeof formatterFn === "function" ? formatterFn(value, fieldContext) : value;
1201
+ const shouldValidateField = !(defaultData?.[key] === value && !!defaultData?.[key]);
1202
+ if (shouldValidateField && value) {
1203
+ asyncValidate(key, fieldContext.state, mode);
1204
+ }
1205
+ const validationResult = shouldValidateField ? staticValidate({ key, value: formattedValue, mode }, fieldContext) : new ValidationResult([
1206
+ {
1207
+ isValid: true,
1208
+ hasError: false
1209
+ }
1210
+ ]);
1211
+ return [formattedValue, validationResult];
1212
+ };
1213
+ function init({
1214
+ schema,
1215
+ defaultData,
1216
+ fieldProblems,
1217
+ obscuredFields,
1218
+ optionalFields,
1219
+ trustedFields,
1220
+ formatters,
1221
+ staticValidate,
1222
+ asyncValidate
1223
+ }) {
1224
+ const getProcessedState = (fieldKey) => {
1225
+ const [formattedValue, validationResult] = processField({
1226
+ key: fieldKey,
1227
+ value: defaultData?.[fieldKey],
1228
+ mode: "blur",
1229
+ formatters,
1230
+ defaultData,
1231
+ fieldContext: {
1232
+ state: {
1233
+ data: defaultData,
1234
+ obscuredFields,
1235
+ optionalFields,
1236
+ trustedFields
1237
+ }
1238
+ },
1239
+ staticValidate,
1240
+ asyncValidate
1241
+ });
1242
+ if (typeof defaultData?.[fieldKey] === "undefined") {
1243
+ return {
1244
+ valid: validationResult.isValid && !fieldProblems?.[fieldKey] || false,
1245
+ errors: null,
1246
+ data: null,
1247
+ fieldProblems: fieldProblems?.[fieldKey] ?? false
1248
+ };
1249
+ }
1250
+ return {
1251
+ valid: validationResult.isValid && !fieldProblems?.[fieldKey] || false,
1252
+ errors: validationResult.getError() ?? null,
1253
+ data: formattedValue,
1254
+ fieldProblems: fieldProblems?.[fieldKey] ?? false
1255
+ };
1256
+ };
1257
+ const formFields = optionalFields ? [...schema, ...optionalFields] : schema;
1258
+ const formData = formFields.reduce(
1259
+ (acc, field) => {
1260
+ const {
1261
+ valid,
1262
+ errors,
1263
+ data,
1264
+ fieldProblems: processedFieldProblems
1265
+ } = getProcessedState(field);
1266
+ return {
1267
+ ...acc,
1268
+ data: { ...acc.data, [field]: data },
1269
+ valid: { ...acc.valid, [field]: valid },
1270
+ errors: { ...acc.errors, [field]: errors },
1271
+ fieldProblems: { ...acc.fieldProblems, [field]: processedFieldProblems }
1272
+ };
1273
+ },
1274
+ {
1275
+ schema,
1276
+ data: {},
1277
+ valid: {},
1278
+ errors: {},
1279
+ fieldProblems: {},
1280
+ obscuredFields,
1281
+ optionalFields,
1282
+ trustedFields
1283
+ }
1284
+ );
1285
+ return formData;
1286
+ }
1287
+ function reducer({
1288
+ staticValidate,
1289
+ asyncValidate,
1290
+ obscuredFields,
1291
+ optionalFields,
1292
+ trustedFields,
1293
+ formatters
1294
+ }) {
1295
+ return (state, {
1296
+ type,
1297
+ key,
1298
+ mode,
1299
+ value,
1300
+ schema,
1301
+ selectedSchema,
1302
+ formValue,
1303
+ fieldProblems,
1304
+ defaultData
1305
+ }) => {
1306
+ const validationSchema = selectedSchema || state.schema;
1307
+ switch (type) {
1308
+ case "setData": {
1309
+ if (!key) return state;
1310
+ return { ...state, data: { ...state.data, [key]: value } };
1311
+ }
1312
+ case "setValid": {
1313
+ if (!key) return state;
1314
+ return { ...state, valid: { ...state.valid, [key]: value } };
1315
+ }
1316
+ case "setErrors": {
1317
+ if (!key) return state;
1318
+ return { ...state, errors: { ...state.errors, [key]: value } };
1319
+ }
1320
+ case "setFieldProblems": {
1321
+ return state?.schema?.reduce(
1322
+ (acc, field) => ({
1323
+ ...acc,
1324
+ fieldProblems: {
1325
+ ...state.fieldProblems,
1326
+ [field]: fieldProblems?.[field] ?? false
1327
+ },
1328
+ valid: { ...state.valid, [field]: state.valid?.[field] && !fieldProblems?.[field] }
1329
+ }),
1330
+ state
1331
+ );
1332
+ }
1333
+ case "setSchema": {
1334
+ if (!schema) return state;
1335
+ const defaultState = init({
1336
+ schema,
1337
+ // requiredFields
1338
+ defaultData,
1339
+ fieldProblems,
1340
+ obscuredFields,
1341
+ optionalFields,
1342
+ trustedFields,
1343
+ staticValidate,
1344
+ asyncValidate
1345
+ });
1346
+ const removedFields = state.optionalFields?.length ? [
1347
+ ...state.schema.filter((field) => !schema.includes(field)),
1348
+ ...state.optionalFields.filter((field) => !optionalFields?.includes(field))
1349
+ ] : state.schema.filter((field) => !schema.includes(field));
1350
+ const newFields = optionalFields?.length ? [
1351
+ ...schema.filter((field) => !state.schema?.includes(field)),
1352
+ ...optionalFields.filter((field) => !state.optionalFields?.includes(field))
1353
+ ] : schema.filter((field) => !state.schema?.includes(field));
1354
+ const local = {
1355
+ data: omitKeys(state.data, newFields),
1356
+ errors: omitKeys(state.errors, newFields),
1357
+ valid: omitKeys(state.valid, newFields),
1358
+ fieldProblems: omitKeys(state.fieldProblems, newFields)
1359
+ };
1360
+ const updatedData = addKeys(
1361
+ omitKeys(state.data, removedFields),
1362
+ newFields,
1363
+ null,
1364
+ defaultState.data,
1365
+ state.local?.data
1366
+ );
1367
+ const updatedValid = addKeys(
1368
+ omitKeys(state.valid, removedFields),
1369
+ newFields,
1370
+ false,
1371
+ defaultState.valid,
1372
+ state.local?.valid
1373
+ );
1374
+ const updatedErrors = addKeys(
1375
+ omitKeys(state.errors, removedFields),
1376
+ newFields,
1377
+ null,
1378
+ defaultState.errors,
1379
+ state.local?.errors
1380
+ );
1381
+ const updatedFieldProblems = addKeys(
1382
+ omitKeys(state.fieldProblems, removedFields),
1383
+ newFields,
1384
+ false,
1385
+ defaultState.fieldProblems,
1386
+ state.local?.fieldProblems
1387
+ );
1388
+ return {
1389
+ ...state,
1390
+ schema,
1391
+ data: updatedData,
1392
+ valid: updatedValid,
1393
+ errors: updatedErrors,
1394
+ fieldProblems: updatedFieldProblems,
1395
+ obscuredFields,
1396
+ optionalFields,
1397
+ trustedFields,
1398
+ local
1399
+ };
1400
+ }
1401
+ case "updateField": {
1402
+ if (!key || !mode) return state;
1403
+ const [formattedValue, validation] = processField({
1404
+ key,
1405
+ value,
1406
+ mode,
1407
+ defaultData,
1408
+ formatters,
1409
+ fieldContext: { state },
1410
+ staticValidate,
1411
+ asyncValidate
1412
+ });
1413
+ const oldValue = state.data[key];
1414
+ const clearFieldProblems = oldValue !== formattedValue;
1415
+ return {
1416
+ ...state,
1417
+ data: { ...state.data, [key]: formattedValue },
1418
+ errors: {
1419
+ ...state.errors,
1420
+ [key]: validation.getError() ?? null
1421
+ },
1422
+ valid: {
1423
+ ...state.valid,
1424
+ [key]: validation.isValid && !state.fieldProblems?.[key] || false
1425
+ },
1426
+ fieldProblems: {
1427
+ ...state.fieldProblems,
1428
+ [key]: clearFieldProblems ? false : state.fieldProblems?.[key] ?? false
1429
+ }
1430
+ };
1431
+ }
1432
+ case "mergeForm": {
1433
+ const mergedState = {
1434
+ ...state,
1435
+ data: { ...state.data, ...formValue?.data },
1436
+ errors: { ...state.errors, ...formValue?.errors },
1437
+ valid: { ...state.valid, ...formValue?.valid },
1438
+ fieldProblems: { ...state.fieldProblems, ...formValue?.fieldProblems }
1439
+ };
1440
+ if (mergedState.valid) {
1441
+ mergedState.isValid = Object.values(mergedState.valid).every((isValid) => isValid);
1442
+ }
1443
+ return mergedState;
1444
+ }
1445
+ case "validateForm": {
1446
+ const formValidation = validationSchema?.reduce(
1447
+ (acc, cur) => {
1448
+ const [formattedValue, validation] = processField({
1449
+ key: cur,
1450
+ value: state.data[cur],
1451
+ mode: "blur",
1452
+ defaultData,
1453
+ formatters,
1454
+ fieldContext: { state },
1455
+ staticValidate,
1456
+ asyncValidate
1457
+ });
1458
+ const oldValue = state.data[cur];
1459
+ const clearFieldProblems = oldValue !== formattedValue;
1460
+ return {
1461
+ valid: {
1462
+ ...acc.valid,
1463
+ [cur]: validation.isValid && !state.fieldProblems?.[cur] || false
1464
+ },
1465
+ errors: {
1466
+ ...acc.errors,
1467
+ [cur]: validation.getError() ?? null
1468
+ },
1469
+ fieldProblems: {
1470
+ ...acc.fieldProblems,
1471
+ [cur]: clearFieldProblems ? false : state.fieldProblems?.[cur] ?? false
1472
+ }
1473
+ };
1474
+ },
1475
+ { valid: state.valid, errors: state.errors, fieldProblems: state.fieldProblems }
1476
+ );
1477
+ return {
1478
+ ...state,
1479
+ valid: formValidation?.valid,
1480
+ errors: formValidation?.errors,
1481
+ fieldProblems: formValidation?.fieldProblems
1482
+ };
1483
+ }
1484
+ default:
1485
+ throw new Error("Undefined useForm action");
1486
+ }
1487
+ };
1488
+ }
1489
+ const mergeStaticAndAsyncErrorsState = (staticValidationErrors, asyncValidationErrors, schema, setValid, optionalFields) => {
1490
+ const fields = optionalFields ? [...schema, ...optionalFields] : schema;
1491
+ if (!fields.length) return staticValidationErrors;
1492
+ const errors = fields.reduce(
1493
+ (acc, field) => {
1494
+ if (asyncValidationErrors[field]?.getError()) setValid(field, false);
1495
+ return {
1496
+ ...acc,
1497
+ [field]: staticValidationErrors[field] ?? asyncValidationErrors[field]?.getError() ?? null
1498
+ };
1499
+ },
1500
+ {}
1501
+ );
1502
+ return errors;
1503
+ };
1504
+ function useForm({
1505
+ schema,
1506
+ defaultData,
1507
+ rules,
1508
+ asyncRules,
1509
+ fieldProblems,
1510
+ obscuredFields,
1511
+ optionalFields,
1512
+ trustedFields,
1513
+ formatters,
1514
+ shouldValidate = false
1515
+ }) {
1516
+ const { triggerStaticValidation } = useStaticValidator(rules);
1517
+ const { triggerAsyncValidation, asyncValidationResults } = useAsyncValidator(asyncRules);
1518
+ const getRequiredFields = useMemo(
1519
+ () => typeof schema === "function" ? schema : () => schema,
1520
+ [schema]
1521
+ );
1522
+ const getSchema = useMemo(
1523
+ () => defaultData ? getRequiredFields(defaultData) : [],
1524
+ [defaultData, getRequiredFields]
1525
+ );
1526
+ const getReducer = useCallback(
1527
+ () => reducer({
1528
+ staticValidate: triggerStaticValidation,
1529
+ asyncValidate: triggerAsyncValidation,
1530
+ obscuredFields,
1531
+ optionalFields,
1532
+ trustedFields,
1533
+ formatters
1534
+ }),
1535
+ [
1536
+ triggerStaticValidation,
1537
+ triggerAsyncValidation,
1538
+ obscuredFields,
1539
+ optionalFields,
1540
+ trustedFields,
1541
+ formatters
1542
+ ]
1543
+ );
1544
+ const initialData = useMemo(
1545
+ () => ({
1546
+ schema: getSchema,
1547
+ defaultData,
1548
+ fieldProblems,
1549
+ obscuredFields,
1550
+ optionalFields,
1551
+ trustedFields,
1552
+ formatters,
1553
+ staticValidate: triggerStaticValidation,
1554
+ asyncValidate: triggerAsyncValidation
1555
+ }),
1556
+ [
1557
+ getSchema,
1558
+ defaultData,
1559
+ fieldProblems,
1560
+ obscuredFields,
1561
+ optionalFields,
1562
+ trustedFields,
1563
+ formatters,
1564
+ triggerStaticValidation,
1565
+ triggerAsyncValidation
1566
+ ]
1567
+ );
1568
+ const [state, dispatch] = useReducer(getReducer(), initialData, init);
1569
+ const isValid = useMemo(
1570
+ () => state.schema?.every((key) => state.valid[key]),
1571
+ [state.schema, state.valid]
1572
+ );
1573
+ const getTargetValue = useCallback(
1574
+ (key, e) => {
1575
+ if (!e?.target) return e;
1576
+ if (e.target.type === "checkbox") {
1577
+ return !state.data[key];
1578
+ }
1579
+ return e.target.value;
1580
+ },
1581
+ [state.data]
1582
+ );
1583
+ const setErrors = useCallback(
1584
+ (key, value) => dispatch({ type: "setErrors", key, value }),
1585
+ []
1586
+ );
1587
+ const setValid = useCallback(
1588
+ (key, value) => dispatch({ type: "setValid", key, value }),
1589
+ []
1590
+ );
1591
+ const setData = useCallback(
1592
+ (key, value) => dispatch({ type: "setData", key, value }),
1593
+ []
1594
+ );
1595
+ const setSchema = useCallback(
1596
+ (newSchema) => dispatch({ type: "setSchema", schema: newSchema, defaultData }),
1597
+ [defaultData]
1598
+ );
1599
+ const setFieldProblems = useCallback(
1600
+ (newFieldProblems) => dispatch({ type: "setFieldProblems", fieldProblems: newFieldProblems }),
1601
+ []
1602
+ );
1603
+ const mergeForm = useCallback(
1604
+ (formValue) => dispatch({ type: "mergeForm", formValue }),
1605
+ []
1606
+ );
1607
+ const handleChangeFor = useCallback(
1608
+ (key, mode = "blur") => (e) => {
1609
+ const value = getTargetValue(key, e);
1610
+ dispatch({
1611
+ type: "updateField",
1612
+ key,
1613
+ value,
1614
+ mode,
1615
+ defaultData
1616
+ });
1617
+ },
1618
+ [defaultData, getTargetValue]
1619
+ );
1620
+ const triggerValidation = useCallback(
1621
+ (selectedSchema) => {
1622
+ dispatch({
1623
+ type: "validateForm",
1624
+ selectedSchema,
1625
+ defaultData
1626
+ });
1627
+ },
1628
+ [defaultData]
1629
+ );
1630
+ const resetToDefaultData = useCallback(() => {
1631
+ getSchema.forEach((field) => {
1632
+ if (!defaultData || typeof defaultData[field] !== "undefined") {
1633
+ return handleChangeFor(field)(defaultData?.[field]);
1634
+ }
1635
+ setValid(field, false);
1636
+ setErrors(field, null);
1637
+ setData(field, defaultData[field]);
1638
+ });
1639
+ }, [defaultData, getSchema, handleChangeFor, setData, setErrors, setValid]);
1640
+ useEffect(() => {
1641
+ const newSchema = getRequiredFields(state.data);
1642
+ if (!doArraysMatch(state.schema, newSchema)) {
1643
+ setSchema(newSchema);
1644
+ }
1645
+ }, [state.schema, state.data, setSchema, getRequiredFields]);
1646
+ useEffect(() => {
1647
+ if (shouldValidate) {
1648
+ triggerValidation();
1649
+ }
1650
+ }, [shouldValidate, state.schema]);
1651
+ useEffect(() => {
1652
+ if (fieldProblems) {
1653
+ setFieldProblems(fieldProblems);
1654
+ }
1655
+ }, [JSON.stringify(fieldProblems), setFieldProblems]);
1656
+ const formErrors = useMemo(
1657
+ () => mergeStaticAndAsyncErrorsState(
1658
+ state.errors,
1659
+ asyncValidationResults,
1660
+ state.schema,
1661
+ setValid,
1662
+ state.optionalFields
1663
+ ),
1664
+ [asyncValidationResults, state.errors, state.optionalFields, state.schema]
1665
+ );
1666
+ return {
1667
+ mergeForm,
1668
+ setData,
1669
+ setValid,
1670
+ setErrors,
1671
+ setFieldProblems,
1672
+ handleChangeFor,
1673
+ triggerValidation,
1674
+ resetToDefaultData,
1675
+ isValid,
1676
+ schema: state.schema,
1677
+ valid: state.valid,
1678
+ errors: formErrors,
1679
+ data: state.data,
1680
+ fieldProblems: state.fieldProblems
1681
+ };
1682
+ }
1683
+ export {
1684
+ Checkbox as C,
1685
+ Field as F,
1686
+ LoaderWrapper as L,
1687
+ SelectListItem as S,
1688
+ ValidationResult as V,
1689
+ useForm as a,
1690
+ useId as b,
1691
+ Select as c,
1692
+ getDataByFields as g,
1693
+ uuidv4 as u
1694
+ };