@adyen/kyc-components 4.18.1 → 4.19.0-beta.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.
- package/dist/{Accordion-IXKjwyLD.js → Accordion-BnhH5-eC.js} +1 -1
- package/dist/{AccountSetupRejected-PhOe1B-n.js → AccountSetupRejected-BVzz6Scm.js} +2 -2
- package/dist/{AdaptiveWorkflow-CXpNjZCn.js → AdaptiveWorkflow-DsZ_wY_H.js} +31 -34
- package/dist/{AdaptiveWorkflowComponent-dPpu76rs.js → AdaptiveWorkflowComponent-1LmhvzA8.js} +56 -56
- package/dist/{Address-3-_aLbjP.js → Address-Dn9YYuVv.js} +7 -7
- package/dist/{AddressField-CPPPFBvl.js → AddressField-BLlc_T5f.js} +11 -14
- package/dist/{Avatar-CdBNstmD.js → Avatar-Y_RdG_YY.js} +1 -1
- package/dist/{BusinessFinancingDropin-BR51jlH2.js → BusinessFinancingDropin-BJ7Z_6_q.js} +31 -36
- package/dist/{BusinessFinancingPage-B3Ov1kac.js → BusinessFinancingPage-C72fEfR8.js} +32 -32
- package/dist/{BusinessTypeSelectionPage-D4vw6aNU.js → BusinessTypeSelectionPage-CJT4_LdC.js} +14 -15
- package/dist/{Button-i8I2dHP8.js → Button-BuhgDsyo.js} +1 -1
- package/dist/Checkbox-CFN5ywvv.js +108 -0
- package/dist/{CompanyRegistrationNumberTypeSelector-6xHWLs1p.js → CompanyRegistrationNumberTypeSelector-Dw2BkLur.js} +8 -8
- package/dist/{ContactDetails-YmwbTqND.js → ContactDetails-Bi_d3c4V.js} +7 -8
- package/dist/{ContextGuidance-5E-t22kR.js → ContextGuidance-D7YPJhH5.js} +2 -2
- package/dist/CountryField-CEttz1qx.js +1653 -0
- package/dist/{Currency-BO39M1ox.js → Currency-D3ooH-P1.js} +8 -9
- package/dist/{CustomerSupport-DQzE9mMY.js → CustomerSupport-BPkPpm4S.js} +14 -15
- package/dist/{DataConflictsModal-4y4dA4sI.js → DataConflictsModal-CjK5meAj.js} +7 -7
- package/dist/{DebugModal-CVQozZAM.js → DebugModal-BdzRooB8.js} +11 -12
- package/dist/{DecisionMakerDetails-DV6Iee3-.js → DecisionMakerDetails-CEvexevf.js} +16 -17
- package/dist/{DecisionMakerDetailsPage-BxT3qKxe.js → DecisionMakerDetailsPage-PdJIWA0L.js} +35 -35
- package/dist/{DecisionMakers-CVJTMrVX.js → DecisionMakers-B62TqNnC.js} +43 -43
- package/dist/{Dropzone-DZNPVw36.js → Dropzone-VfjqDlA_.js} +7 -7
- package/dist/{EmbeddedStatus-g37gc_ic.js → EmbeddedStatus-sHJnhw3K.js} +4 -4
- package/dist/{EndStateLayout-CBRHUXyY.js → EndStateLayout-CddZpAGD.js} +2 -2
- package/dist/{EntityAssociation-CN9ol7v2.js → EntityAssociation-DsQNaCo7.js} +7 -7
- package/dist/{ErrorPanel-ax7k2mv_.js → ErrorPanel-C51kA_mU.js} +4 -4
- package/dist/GlobalEntryModal-rYmoNH8G.js +188 -0
- package/dist/GlobalEntryPage-CeBpyE1f.js +74 -0
- package/dist/{unincorporated-partnership-nnTW3FnG.js → Image-Dc5Xg1_Y.js} +3 -10
- package/dist/{Individual.rules-Caf9UMUo.js → Individual.rules-CE8liYua.js} +4 -4
- package/dist/{IndividualDropin-BBr2IB14.js → IndividualDropin-BGY5Ddrh.js} +47 -54
- package/dist/{InputDate-CxzAaaCm.js → InputDate-Cp2ga0F5.js} +2 -2
- package/dist/{InputText-CQcWyZ8_.js → InputText-CRkApOKK.js} +3 -3
- package/dist/{Introduction-C8TItyVA.js → Introduction-DZ-ov19S.js} +8 -8
- package/dist/{InvitedDecisionMakerComponent-DWiwWubd.js → InvitedDecisionMakerComponent-KwRWIgOY.js} +67 -67
- package/dist/{JpAddress-CKVMqpT-.js → JpAddress-DA4HeKHD.js} +13 -13
- package/dist/{JpAddress.module-Bdx0E9ys.js → JpAddress.module-h_ZcUDUu.js} +4 -4
- package/dist/{JpAddressFields-Cu7qWdqH.js → JpAddressFields-BG4Hvw6r.js} +10 -10
- package/dist/{LegalCompanyNameField-JYzmeM_X.js → LegalCompanyNameField-RnzsmUKo.js} +5 -5
- package/dist/{LegalRepresentativeDetailsPage-DIsZS1kl.js → LegalRepresentativeDetailsPage-DVYi8ja1.js} +33 -33
- package/dist/{Link-JFzfaUOa.js → Link-PH3F7iTO.js} +1 -1
- package/dist/{ListItem-BnVTcObB.js → ListItem-B-gDVdRO.js} +2 -2
- package/dist/MX-CXUYOKFF.js +20 -0
- package/dist/{MaskedInput-C4s4LV8L.js → MaskedInput-BK38onJ9.js} +6 -6
- package/dist/{Modal-ByJare7m.js → Modal-BYdlsXkf.js} +1 -1
- package/dist/{Name-Cw7gZ538.js → Name-CnahYmZE.js} +5 -5
- package/dist/{NewSummary-BaN8B8zh.js → NewSummary-RLsN58Mb.js} +7 -7
- package/dist/{PatriotActDisclosure-DPd_hY4F.js → PatriotActDisclosure-CGU1K5gU.js} +14 -16
- package/dist/{PayoutDetailsDropin-CEfr5YRq.js → PayoutDetailsDropin-CyF7UckP.js} +31 -40
- package/dist/{PayoutDetailsPage-RPNP-k15.js → PayoutDetailsPage-D54T0cTR.js} +9 -9
- package/dist/{RadioGroup-Bt1Dv_S8.js → RadioGroup-lkTq-fXj.js} +4 -4
- package/dist/{Review-CB-4-2Hj.js → Review-CQP_ivDp.js} +8 -8
- package/dist/RootBusinessDetailsPage-74wy-iuF.js +68 -0
- package/dist/{RootBusinessLinesPage-oB7EXos0.js → RootBusinessLinesPage-DdbHs3i6.js} +30 -36
- package/dist/{RootIndividualDetailsPage-_ii9YD6S.js → RootIndividualDetailsPage-CRiGz1L-.js} +33 -33
- package/dist/{Select-D4oEtS2n.js → Select-C2axJYZG.js} +322 -9
- package/dist/{SignPCIComponent-ByROwVCw.js → SignPCIComponent-2jkpTNie.js} +40 -42
- package/dist/{SingpassSelection-OXKZwOga.js → SingpassSelection-C0Nj8agM.js} +6 -6
- package/dist/{SoleProprietorshipPage-CZs5zpAu.js → SoleProprietorshipPage-DL9KxFfM.js} +34 -34
- package/dist/{SourceOfFundsPage-BQvkDxha.js → SourceOfFundsPage-CoriFRrS.js} +33 -39
- package/dist/{StructuredList-Ci4Ut4E5.js → StructuredList-Mj-OPN9u.js} +71 -3
- package/dist/{TaskListItem-x1xsj1Bn.js → TaskListItem-DOnEqpoq.js} +11 -11
- package/dist/{TaskVerificationStatus-CKHPTEpH.js → TaskVerificationStatus-ITLSeoau.js} +1 -1
- package/dist/{TaxReportingDropin-CK2T7wb2.js → TaxReportingDropin-BnEktotO.js} +18 -19
- package/dist/{TermsOfServiceManagement-dE1jAodi.js → TermsOfServiceManagement-CY49Ivu1.js} +41 -45
- package/dist/{TextArea-BUx3yuMJ.js → TextArea-BzCbFjRp.js} +4 -4
- package/dist/{TrustDetailsPage-DGZBVOHn.js → TrustDetailsPage-BOt9PbYw.js} +33 -38
- package/dist/{TrustMemberCompanyPage-CUKl1KJI.js → TrustMemberCompanyPage-D36IOylX.js} +35 -35
- package/dist/{TrustMemberIndividualPage-BsNLXF2o.js → TrustMemberIndividualPage-aAZXiZKb.js} +33 -33
- package/dist/{TrustMemberRoleAndTypePage-CXNAMink.js → TrustMemberRoleAndTypePage-C9zB9BEk.js} +17 -22
- package/dist/{TrustMembersOverview-njl6GYCL.js → TrustMembersOverview-DxAuj55H.js} +13 -13
- package/dist/{UnincorporatedPartnershipIndividualPage-DkCrdK7_.js → UnincorporatedPartnershipIndividualPage-C4jwWyYn.js} +33 -33
- package/dist/{UnincorporatedPartnershipMemberCompanyPage-CamEVaxx.js → UnincorporatedPartnershipMemberCompanyPage-0JVxcpB4.js} +35 -35
- package/dist/{UnincorporatedPartnershipMemberRoleAndTypePage-JxnZz1cS.js → UnincorporatedPartnershipMemberRoleAndTypePage-DfxG-RyJ.js} +12 -12
- package/dist/{UnincorporatedPartnershipMembersOverview-D7of0-eU.js → UnincorporatedPartnershipMembersOverview-DecZD9DL.js} +9 -9
- package/dist/{VerificationErrorAlert-CYQVK3Yc.js → VerificationErrorAlert-kLh424Dx.js} +5 -5
- package/dist/{accountHolderUtils-CwYzrNX6.js → accountHolderUtils-DqrHbaM7.js} +1 -1
- package/dist/adyen-business-financing.js +33 -33
- package/dist/adyen-individual-configuration.js +59 -59
- package/dist/adyen-individual-status.js +33 -33
- package/dist/adyen-invited-decision-maker.js +3 -3
- package/dist/adyen-onboarding.js +83 -82
- package/dist/adyen-terms-of-service-management.js +3 -3
- package/dist/adyen-terms-of-service-status.js +6 -6
- package/dist/adyen-transfer-instrument-configuration.js +32 -32
- package/dist/adyen-transfer-instrument-management.js +39 -40
- package/dist/adyen-verification-status.js +6 -6
- package/dist/{TileGroup-PzJay6GP.js → bafinUtils-BnTI4Ice.js} +111 -5
- package/dist/{bg-BG-kWtPqE0Y.js → bg-BG-BXAB4Qsj.js} +2 -2
- package/dist/bg-BG-BkIvSbsH.js +7 -0
- package/dist/{bg-BG-DcW6QkFZ.js → bg-BG-DTGU1aVs.js} +6 -2
- package/dist/bg-BG-DbS559bK.js +7 -0
- package/dist/bg-BG-Smu9r9Kp.js +13 -0
- package/dist/{constants-C3Jgup22.js → constants-f8C0SAkf.js} +5 -6
- package/dist/cs-CZ-4yvBEVL0.js +7 -0
- package/dist/{cs-CZ-BbNA0Bfn.js → cs-CZ-9tDZSfxe.js} +6 -2
- package/dist/cs-CZ-BQ5B0-Kt.js +13 -0
- package/dist/cs-CZ-CPvgcrDs.js +7 -0
- package/dist/{cs-CZ-C4gChMCC.js → cs-CZ-DG5rPvy2.js} +2 -2
- package/dist/{da-DK-CI1yBdPD.js → da-DK-B04gegkM.js} +6 -2
- package/dist/{da-DK-Bfi-eUhB.js → da-DK-BnW-O75l.js} +2 -2
- package/dist/da-DK-CXAIXO3c.js +13 -0
- package/dist/da-DK-D3mbpcHG.js +7 -0
- package/dist/da-DK-D5969QKP.js +7 -0
- package/dist/{de-DE-BuV4qgKM.js → de-DE-BvxSDtLA.js} +6 -2
- package/dist/de-DE-D6R-XC2F.js +7 -0
- package/dist/de-DE-DFQGGPCj.js +13 -0
- package/dist/{de-DE-DKSWXTNm.js → de-DE-DUiPzmSc.js} +2 -2
- package/dist/de-DE-uDUBu-3n.js +7 -0
- package/dist/{types-Cwq1JAWT.js → debugStore-DpSgCNGn.js} +11 -2
- package/dist/{el-GR-C4waexVM.js → el-GR-1n3FJpd3.js} +2 -2
- package/dist/el-GR-CedmhUFh.js +7 -0
- package/dist/{el-GR-tnyJOS2Y.js → el-GR-DEBCgQrC.js} +6 -2
- package/dist/el-GR-DEBvBgI-.js +13 -0
- package/dist/el-GR-DWh7gn7M.js +7 -0
- package/dist/en-US-BV2Gye3t.js +7 -0
- package/dist/en-US-CqjOvqxV.js +7 -0
- package/dist/{es-ES-CCk0CPW1.js → es-ES-2b5zl9Dh.js} +6 -2
- package/dist/es-ES-C7XCTACS.js +7 -0
- package/dist/{es-ES-BNOsR44t.js → es-ES-Cp45mlyV.js} +2 -2
- package/dist/es-ES-DTUHhE47.js +7 -0
- package/dist/es-ES-_qbfha1o.js +13 -0
- package/dist/{es-LA-svZ9JWfs.js → es-LA-CE8hE_Qb.js} +6 -2
- package/dist/es-LA-Cyf48j4P.js +7 -0
- package/dist/es-LA-DF0v3VMe.js +13 -0
- package/dist/{es-LA-BQoC1xVD.js → es-LA-De_gTMKb.js} +2 -2
- package/dist/es-LA-DlL8vCjJ.js +7 -0
- package/dist/{et-EE-nB00sVxj.js → et-EE-B4czzgF8.js} +2 -2
- package/dist/et-EE-DqhEsLik.js +7 -0
- package/dist/{et-EE-4OTBQhPM.js → et-EE-OAYKzRjG.js} +2 -2
- package/dist/et-EE-evCiUrFW.js +13 -0
- package/dist/{et-EE-Ykuzi3IN.js → et-EE-yEWgHoyl.js} +6 -2
- package/dist/{fi-FI-BfcDfpuq.js → fi-FI-BRaWGHEa.js} +6 -2
- package/dist/fi-FI-BTG87BwH.js +13 -0
- package/dist/fi-FI-Cdof5NRG.js +7 -0
- package/dist/{fi-FI-11WMt6xZ.js → fi-FI-D08MUkuM.js} +2 -2
- package/dist/fi-FI-RfGqWbnB.js +7 -0
- package/dist/{process-field-configurations-DBtjrbif.js → form-rules-wh_oE1AN.js} +86 -6
- package/dist/{fr-FR-DZ3x24wa.js → fr-FR-B1fQcJnJ.js} +6 -2
- package/dist/{fr-FR-CTX8eIfK.js → fr-FR-BxDpVfWO.js} +2 -2
- package/dist/fr-FR-DIiBHkhs.js +13 -0
- package/dist/fr-FR-NOULV1vy.js +7 -0
- package/dist/fr-FR-zDxTr2D3.js +7 -0
- package/dist/{getProblemsForEntity-ubvE1Px7.js → getProblemsForEntity-set4Krmx.js} +2 -2
- package/dist/hr-HR-2h3d5-q3.js +7 -0
- package/dist/{hr-HR-crREB4Gm.js → hr-HR-CiE3y0Ub.js} +6 -2
- package/dist/{hr-HR-q4LEknkW.js → hr-HR-DGQMquDg.js} +2 -2
- package/dist/hr-HR-DPjuJ54x.js +7 -0
- package/dist/hr-HR-DofgeWWO.js +13 -0
- package/dist/{http-8qgzqVqk.js → http-CFac2y4i.js} +1 -1
- package/dist/{hu-HU-D6LVf95k.js → hu-HU-Eofp7khl.js} +2 -2
- package/dist/hu-HU-FdLZGnBz.js +13 -0
- package/dist/{hu-HU-DsUOhM2K.js → hu-HU-VLUIAFMp.js} +2 -2
- package/dist/{hu-HU-CwugDrK-.js → hu-HU-bRcefVUd.js} +6 -2
- package/dist/hu-HU-hB61p4H9.js +7 -0
- package/dist/{it-IT-DmJ2fsTy.js → it-IT-B-nXU1YK.js} +6 -2
- package/dist/it-IT-BMXQzE0P.js +7 -0
- package/dist/{it-IT-COvAChQK.js → it-IT-CD7NJtJa.js} +2 -2
- package/dist/it-IT-CWIAGNlE.js +7 -0
- package/dist/it-IT-CXgZZgyU.js +13 -0
- package/dist/ja-JP-BuFZko8b.js +7 -0
- package/dist/ja-JP-C1c2UPpy.js +7 -0
- package/dist/{ja-JP-Ct_9QX6z.js → ja-JP-DX2RsV88.js} +6 -2
- package/dist/ja-JP-Yi2wExJE.js +13 -0
- package/dist/{ja-JP-qNISvG1u.js → ja-JP-YvXztswF.js} +2 -2
- package/dist/{localizeDateString-Bmx3yBcR.js → localizeDateString-BRB4gPDZ.js} +1 -1
- package/dist/lt-LT-BZ6seLuB.js +13 -0
- package/dist/{lt-LT-DkHCYjtT.js → lt-LT-Bzv_v-Qg.js} +6 -2
- package/dist/lt-LT-C62dFtWW.js +7 -0
- package/dist/{lt-LT-BZAM9Txq.js → lt-LT-Cjx4H-0R.js} +2 -2
- package/dist/lt-LT-D4raqCUa.js +7 -0
- package/dist/lv-LV-CMYrAWqu.js +13 -0
- package/dist/{lv-LV-CrmNCJJK.js → lv-LV-Ckf37gXo.js} +2 -2
- package/dist/lv-LV-DBms129k.js +7 -0
- package/dist/{lv-LV-D7eJdsac.js → lv-LV-DVv2mhEv.js} +6 -2
- package/dist/lv-LV-W0I-UUyj.js +7 -0
- package/dist/{mapExistingFile-BvFf01k6.js → mapExistingFile-BOXehUNN.js} +3 -3
- package/dist/{mapJpAddressSchemaToAddressLocalizations-DHL5chu8.js → mapJpAddressSchemaToAddressLocalizations-ClMxibP5.js} +2 -2
- package/dist/{mapLegalEntityToIndividualSchema-BeR7ESyx.js → mapLegalEntityToIndividualSchema-CI0cH-k5.js} +8 -8
- package/dist/{mapTransferInstrumentToPayoutAccount-2iWuaqS_.js → mapTransferInstrumentToPayoutAccount-DAXQcZKf.js} +3 -3
- package/dist/nl-NL-C9HoBicG.js +7 -0
- package/dist/nl-NL-CiH1raQa.js +13 -0
- package/dist/{nl-NL-D-rQ6aIY.js → nl-NL-DFHAkUK3.js} +2 -2
- package/dist/{nl-NL-BVbkn6Cc.js → nl-NL-DwrCD0Bp.js} +6 -2
- package/dist/nl-NL-UhYf45fo.js +7 -0
- package/dist/{no-NO-m32g5fSG.js → no-NO-B6frLiko.js} +2 -2
- package/dist/no-NO-Bo9rlROU.js +7 -0
- package/dist/no-NO-Ce2vzrp7.js +13 -0
- package/dist/{no-NO-DKa4b11A.js → no-NO-ClSO9-BH.js} +6 -2
- package/dist/no-NO-DN7Ovyir.js +7 -0
- package/dist/{omitObscuredFieldsIfUnchanged-DETtemfp.js → omitObscuredFieldsIfUnchanged-P2CVFokX.js} +2 -2
- package/dist/{patternValidators-DVuOyW9t.js → patternValidators-BXreB-rx.js} +1 -1
- package/dist/pl-PL-BmiDQi18.js +7 -0
- package/dist/{pl-PL-a3bZNR8A.js → pl-PL-DWH2wPZx.js} +6 -2
- package/dist/{pl-PL-CPw2fm9P.js → pl-PL-DnYkTdjO.js} +2 -2
- package/dist/pl-PL-STp7eeFE.js +7 -0
- package/dist/pl-PL-aErZF5Xz.js +13 -0
- package/dist/{processCapabilities-C2kMryYn.js → processCapabilities-zti_0yUx.js} +3 -1
- package/dist/{processValidationErrors-CBt5e49b.js → processValidationErrors-Bm_TOvWG.js} +3 -3
- package/dist/{pt-BR-D1_qNWjQ.js → pt-BR-65dQv8uO.js} +2 -2
- package/dist/pt-BR-CFGpH3BW.js +7 -0
- package/dist/pt-BR-DXGEP6IP.js +7 -0
- package/dist/pt-BR-hRRebYjo.js +13 -0
- package/dist/{pt-BR-iKANHYsk.js → pt-BR-iYXbhMqT.js} +6 -2
- package/dist/pt-PT-BHR4CEnv.js +7 -0
- package/dist/pt-PT-BXIKj_3F.js +7 -0
- package/dist/{pt-PT-DN5Kzv0P.js → pt-PT-CNqZ8c_1.js} +6 -2
- package/dist/{pt-PT-DsN17CwV.js → pt-PT-D0fXeW1f.js} +2 -2
- package/dist/pt-PT-UAIvemf-.js +13 -0
- package/dist/{resolveEnvironment-t5oalzfF.js → resolveEnvironment-DEX5KqEv.js} +43 -38
- package/dist/ro-RO-BJeKitCz.js +13 -0
- package/dist/{ro-RO-BRa0uLv-.js → ro-RO-CNj95qQn.js} +2 -2
- package/dist/ro-RO-D4TQUwVB.js +7 -0
- package/dist/{ro-RO-HROrtm3u.js → ro-RO-DcHQ--3j.js} +6 -2
- package/dist/ro-RO-ni-ZNqXU.js +7 -0
- package/dist/{sk-SK-BdncFi12.js → sk-SK-C0x9Vs2X.js} +2 -2
- package/dist/sk-SK-CszMszV5.js +7 -0
- package/dist/{sk-SK-BHvTY7sQ.js → sk-SK-D8_n1xzc.js} +6 -2
- package/dist/sk-SK-DQAGAOJW.js +7 -0
- package/dist/sk-SK-ztSYyXUE.js +13 -0
- package/dist/sl-SI-B-MLX0nT.js +7 -0
- package/dist/sl-SI-BY4TzP-F.js +13 -0
- package/dist/{sl-SI-Drd_ptUm.js → sl-SI-BikBCOJK.js} +2 -2
- package/dist/{sl-SI-DgVD1kZK.js → sl-SI-BlhEijpT.js} +6 -2
- package/dist/sl-SI-DOAJBgQV.js +7 -0
- package/dist/style.css +345 -317
- package/dist/styles-DYaAeu4q.js +345 -317
- package/dist/sv-SE--LlaHl85.js +7 -0
- package/dist/{sv-SE-oLc1R4YI.js → sv-SE-BGP9Lmku.js} +2 -2
- package/dist/sv-SE-CNQCI2nX.js +7 -0
- package/dist/sv-SE-CrUbxniG.js +13 -0
- package/dist/{sv-SE-Dn9j5Ykd.js → sv-SE-DWQAUW9A.js} +6 -2
- package/dist/{translation-BYvhW5zA.js → translation-CcKrUksA.js} +10 -4
- package/dist/types/components/Business/forms/AdditionalInformation/types.d.ts +1 -0
- package/dist/types/components/Business/forms/rules.d.ts +4 -2
- package/dist/types/components/EFP/mapping/businessFinancingKeyMappings.d.ts +12 -0
- package/dist/types/components/GlobalEntry/constants.d.ts +14 -0
- package/dist/types/components/GlobalEntry/fields/EntitySetupField/EntitySetupField.d.ts +2 -0
- package/dist/types/components/GlobalEntry/fields/EntitySetupField/types.d.ts +5 -0
- package/dist/types/components/GlobalEntry/forms/EntityInformation/EntityInformation.d.ts +7 -0
- package/dist/types/components/GlobalEntry/forms/EntityInformation/types.d.ts +3 -0
- package/dist/types/components/GlobalEntry/tasks/GlobalEntry.d.ts +6 -0
- package/dist/types/components/GlobalEntry/tasks/GlobalEntryModal.d.ts +4 -0
- package/dist/types/components/GlobalEntry/tasks/types.d.ts +4 -0
- package/dist/types/components/GlobalEntry/utils.d.ts +3 -0
- package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
- package/dist/types/components/ui/atoms/Checkbox/Checkbox.d.ts +1 -2
- package/dist/types/context/SettingsContext/types.d.ts +1 -1
- package/dist/types/context/StateContext/types.d.ts +2 -1
- package/dist/types/context/ToggleContext/types.d.ts +5 -0
- package/dist/types/core/models/api/legal-arrangement.d.ts +1 -0
- package/dist/types/core/models/api/organization.d.ts +1 -0
- package/dist/types/types/form-rules.d.ts +2 -1
- package/dist/types/utils/entityStatusUtil.d.ts +1 -1
- package/dist/{types-KjTYEnAG.js → types-lzI_sUwT.js} +1 -1
- package/dist/unincorporated-partnership-DNTK5Y_5.js +11 -0
- package/dist/{useAssociatedLegalEntity-CkuvFV-D.js → useAssociatedLegalEntity-DB8HCSwp.js} +2 -2
- package/dist/{useBusinessDetailsData-CU0nteh0.js → useBusinessDetailsData-DJxoXaI7.js} +120 -94
- package/dist/{useBusinessLines-BFsRoAAj.js → useBusinessLines-CfQYLNkw.js} +1 -1
- package/dist/{useCanSeeIntroduction--o2DZz_r.js → useCanSeeIntroduction-CMh-srNo.js} +3 -3
- package/dist/{useCreateLegalEntity-CoBr-K0N.js → useCreateLegalEntity-CVBjJUw_.js} +1 -1
- package/dist/{useDataMissingRemediations-BzbA8Mu4.js → useDataMissingRemediations-BEdoAjt3.js} +2 -2
- package/dist/{useForm-i6sGgDd7.js → useForm-BV6TtEpQ.js} +4 -4
- package/dist/{invalidateRootLegalEntity-CI3oWmKW.js → useId-BiYSHcau.js} +28 -6
- package/dist/{useLegalEntity-CtlUQv_J.js → useLegalEntity-BqO7Fmt0.js} +1 -1
- package/dist/{useNavigate-C5pijQS-.js → useNavigate-BbaMx4B6.js} +33 -33
- package/dist/{useOnboardingStatus-BlXlrSAS.js → useOnboardingStatus-Bg1z2ftv.js} +1 -1
- package/dist/{usePciQuestionnaireList-CbkNC_Ye.js → usePciQuestionnaireList-Dq1w684P.js} +1 -1
- package/dist/{useSalesChannels-CQjvFAb2.js → useSalesChannels-D66W1KV8.js} +4 -4
- package/dist/{useScenarios-DeLWDtIg.js → useScenarios-BunWDxgO.js} +1 -1
- package/dist/{useTaskLandedEvent-BiIxm8IU.js → useTaskLandedEvent-BTVaABDA.js} +1 -1
- package/dist/{useTaskStatus-wrAxqtIR.js → useTaskStatus-B_-IRF4H.js} +1 -1
- package/dist/{useTermsOfServiceStatus-D1_ECrkO.js → useTermsOfServiceStatus-CGIpBA0U.js} +1 -1
- package/dist/{useTrustMembers-BdC-skoy.js → useTrustMembers-DExoLajS.js} +4 -4
- package/dist/{useUnincorporatedPartnershipMembers-B5WCX6yK.js → useUnincorporatedPartnershipMembers-DgD91qBf.js} +4 -4
- package/dist/{useUpdateBusinessLines-Cncate8L.js → useUpdateBusinessLines-C2xW-32U.js} +1 -1
- package/dist/{useUpdateLegalEntity-BzJEGtlf.js → useUpdateLegalEntity-CavZl01k.js} +3 -3
- package/dist/{utils-BQKCRnHy.js → utils-BZ6sjmH0.js} +5 -5
- package/dist/{utils-DL1Gw7UQ.js → utils-Bu9Q872y.js} +7 -7
- package/dist/{utils-BIsRIG8_.js → utils-CxPOLLKk.js} +2 -2
- package/dist/{utils-DO746J4_.js → utils-wOuhjMhJ.js} +13 -14
- package/dist/{validate-CMxq61UU.js → validate-K01plHbc.js} +5 -5
- package/dist/{validate-DXDTOfCD.js → validate-XXwQLqzu.js} +1 -1
- package/dist/{validateExtractionResult-vWa9ixyo.js → validateExtractionResult-BkuHB6PK.js} +10 -11
- package/dist/{validationError-ChwCFXwH.js → validationError-DZqoMG3g.js} +2 -2
- package/package.json +1 -1
- package/dist/Checkbox-DdEBnXOB.js +0 -55
- package/dist/Confirm-DcqMV7rd.js +0 -75
- package/dist/CountryField-CMQ5_moy.js +0 -37
- package/dist/Field-Dg-2A6bG.js +0 -155
- package/dist/GlobalEntryModal-D61Hc3LY.js +0 -34
- package/dist/GlobalEntryPage-DWg2N_pv.js +0 -44
- package/dist/LandingLayout-iZpW1Vsx.js +0 -81
- package/dist/MaybeModal-BSkLRwI2.js +0 -24
- package/dist/ProgressBar-DWFxLMUA.js +0 -38
- package/dist/RootBusinessDetailsPage-CUio3PpO.js +0 -68
- package/dist/Summary-DiBuR9QD.js +0 -234
- package/dist/bafinUtils-CbfyDBkh.js +0 -112
- package/dist/bg-BG-DWtVZckB.js +0 -7
- package/dist/bg-BG-VIyyeYUh.js +0 -7
- package/dist/cs-CZ-D8nnXFEh.js +0 -7
- package/dist/cs-CZ-DeM0O93X.js +0 -7
- package/dist/da-DK-Cq-1LB6T.js +0 -7
- package/dist/da-DK-DrYRErQi.js +0 -7
- package/dist/de-DE-Bc55gBv4.js +0 -7
- package/dist/de-DE-CNHKj2ar.js +0 -7
- package/dist/debouncedInputEvent-Fwwp_K_-.js +0 -54
- package/dist/debugStore-Dwn1FXrh.js +0 -9
- package/dist/el-GR-Cr-3NgPk.js +0 -7
- package/dist/el-GR-DC8wWZlc.js +0 -7
- package/dist/en-US-BNfqvbyW.js +0 -7
- package/dist/en-US-DXMKV9NN.js +0 -7
- package/dist/es-ES-L_7CovzS.js +0 -7
- package/dist/es-ES-uVSZu-EQ.js +0 -7
- package/dist/es-LA-BU5Op1kh.js +0 -7
- package/dist/es-LA-DPvp-UlN.js +0 -7
- package/dist/et-EE-BFb0MPqf.js +0 -7
- package/dist/fi-FI-6yq1jSRa.js +0 -7
- package/dist/fi-FI-BI9sCCEP.js +0 -7
- package/dist/form-rules-CUUQGacJ.js +0 -7
- package/dist/formUtils-BrLGUOLK.js +0 -78
- package/dist/fr-FR-DBM2tUge.js +0 -7
- package/dist/fr-FR-_TkFnevF.js +0 -7
- package/dist/hr-HR-DubR_a2h.js +0 -7
- package/dist/hr-HR-Vx0hO2h4.js +0 -7
- package/dist/hu-HU-CK6lbZ-D.js +0 -7
- package/dist/it-IT-CL_4Y1hK.js +0 -7
- package/dist/it-IT-CVVOlFfY.js +0 -7
- package/dist/ja-JP-B8sNFjt_.js +0 -7
- package/dist/ja-JP-CNBPrNgM.js +0 -7
- package/dist/lt-LT-C9lXLzZA.js +0 -7
- package/dist/lt-LT-CPBTVJeD.js +0 -7
- package/dist/lv-LV-2Q8G1u4p.js +0 -7
- package/dist/lv-LV-CBsGjmsA.js +0 -7
- package/dist/nl-NL-C5MHFAIE.js +0 -7
- package/dist/nl-NL-DMdoFepr.js +0 -7
- package/dist/no-NO-Bna_-q84.js +0 -7
- package/dist/no-NO-CwgewQst.js +0 -7
- package/dist/pl-PL-D-TVYshE.js +0 -7
- package/dist/pl-PL-Ddtqvtag.js +0 -7
- package/dist/pt-BR-D3oWr3QJ.js +0 -7
- package/dist/pt-BR-DwHag_mp.js +0 -7
- package/dist/pt-PT-BVcFY8gr.js +0 -7
- package/dist/pt-PT-DpYwMinP.js +0 -7
- package/dist/ro-RO-CZpwJ4Sy.js +0 -7
- package/dist/ro-RO-D3Yk1KoW.js +0 -7
- package/dist/roleMetadata-a4sEtgHv.js +0 -56
- package/dist/sk-SK-D3UYKttr.js +0 -7
- package/dist/sk-SK-DyKdrRnN.js +0 -7
- package/dist/sl-SI-BkcElOhl.js +0 -7
- package/dist/sl-SI-nHUFaEcp.js +0 -7
- package/dist/summaryItem-uDWmtYtt.js +0 -16
- package/dist/sv-SE-DkZ2LyW5.js +0 -7
- package/dist/sv-SE-DxMX8Ox_.js +0 -7
- package/dist/types/components/GlobalEntry/forms/GlobalEntryModal/GlobalEntryModal.d.ts +0 -1
- package/dist/useFormContext-C7TMXwWg.js +0 -503
- package/dist/useId-BkDhUta2.js +0 -28
- package/dist/useMultiForm-DmRII_NM.js +0 -783
- package/dist/utils-C1buyvRw.js +0 -61
- package/dist/validationResult-Dzvfkukj.js +0 -77
- /package/dist/types/components/GlobalEntry/{forms/GlobalEntryModal/isGlobalEntryModalOpen.d.ts → globalEntryStore.d.ts} +0 -0
|
@@ -1,783 +0,0 @@
|
|
|
1
|
-
try {
|
|
2
|
-
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
3
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "11d9c062-fe38-4ed8-b4ea-7f59b42fa498", e._sentryDebugIdIdentifier = "sentry-dbid-11d9c062-fe38-4ed8-b4ea-7f59b42fa498");
|
|
4
|
-
} catch (e) {}
|
|
5
|
-
import { o as createLogger } from "./translation-BYvhW5zA.js";
|
|
6
|
-
import { nt as isEmpty } from "./resolveEnvironment-t5oalzfF.js";
|
|
7
|
-
import { o as objectsDeepEqual } from "./AnalyticsContext-BnRQ9H1u.js";
|
|
8
|
-
import { i as omitKeys, n as addKeys, t as ValidationResult } from "./validationResult-Dzvfkukj.js";
|
|
9
|
-
import { useCallback, useEffect, useMemo, useReducer } from "preact/hooks";
|
|
10
|
-
//#region src/hooks/useMultiForm/reducer.ts
|
|
11
|
-
var hasValueChanged = (newData, prevData) => {
|
|
12
|
-
if (typeof newData === "object") return !objectsDeepEqual(newData, prevData);
|
|
13
|
-
return newData !== prevData;
|
|
14
|
-
};
|
|
15
|
-
/** Formats and validates a field */
|
|
16
|
-
var processField = ({ key, value, formName, mode, defaultData, data, fieldContext, formatters, staticValidate }) => {
|
|
17
|
-
const formatterFn = formatters?.[key]?.formatter ? formatters[key]?.formatter : formatters?.[key];
|
|
18
|
-
const formattedValue = formatterFn && typeof formatterFn === "function" ? formatterFn(value, fieldContext) : value;
|
|
19
|
-
const fieldHasDefaultValue = key in (defaultData ?? {});
|
|
20
|
-
const fieldHasChanged = defaultData?.[key] !== value;
|
|
21
|
-
const validationResult = (fieldContext.state.obscuredFields?.includes(key) ? fieldHasChanged : fieldHasChanged || fieldHasDefaultValue) ? staticValidate({
|
|
22
|
-
key,
|
|
23
|
-
value: formattedValue,
|
|
24
|
-
mode,
|
|
25
|
-
formName
|
|
26
|
-
}, data, fieldContext) : new ValidationResult([{
|
|
27
|
-
isValid: true,
|
|
28
|
-
hasError: false
|
|
29
|
-
}]);
|
|
30
|
-
const asyncValidationResult = fieldContext.state?.asyncErrors?.[key];
|
|
31
|
-
/** Add any existing async validation result to validation result */
|
|
32
|
-
if (asyncValidationResult) validationResult.addError(asyncValidationResult);
|
|
33
|
-
return [formattedValue, validationResult];
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The function takes in the below params and spits out an initial state, by running the validations
|
|
37
|
-
* across all forms and fields. It makes sure all validations are done and only sets the validity
|
|
38
|
-
* instead of the errors, this is to avoid users seeing error immaturely on initial load.
|
|
39
|
-
*
|
|
40
|
-
* @param requiredFields
|
|
41
|
-
* @param staticValidate
|
|
42
|
-
* @param asyncValidate
|
|
43
|
-
* @param defaultData
|
|
44
|
-
* @param obscuredFields
|
|
45
|
-
* @param optionalFields
|
|
46
|
-
* @param trustedFields
|
|
47
|
-
* @param fieldProblems
|
|
48
|
-
* @param formatters
|
|
49
|
-
* @param data
|
|
50
|
-
*/
|
|
51
|
-
function init({ requiredFields, staticValidate, defaultData, obscuredFields, optionalFields, trustedFields, fieldProblems, formatters, data, asyncErrors }) {
|
|
52
|
-
/**
|
|
53
|
-
* Fetches the validation result of a field in a form
|
|
54
|
-
* @param fieldKey
|
|
55
|
-
* @param formName
|
|
56
|
-
*/
|
|
57
|
-
const getProcessedState = (fieldKey, formName) => {
|
|
58
|
-
const [formattedValue, validationResult] = processField({
|
|
59
|
-
key: fieldKey,
|
|
60
|
-
value: data?.[formName]?.[fieldKey] ?? defaultData?.[formName]?.[fieldKey] ?? null,
|
|
61
|
-
mode: "blur",
|
|
62
|
-
formName,
|
|
63
|
-
formatters: formatters?.[formName],
|
|
64
|
-
defaultData: defaultData?.[formName],
|
|
65
|
-
data,
|
|
66
|
-
fieldContext: { state: {
|
|
67
|
-
data: data?.[formName],
|
|
68
|
-
obscuredFields: obscuredFields?.[formName],
|
|
69
|
-
optionalFields: optionalFields?.[formName],
|
|
70
|
-
trustedFields: trustedFields?.[formName],
|
|
71
|
-
requiredFields: requiredFields?.[formName],
|
|
72
|
-
asyncErrors: asyncErrors?.[formName]
|
|
73
|
-
} },
|
|
74
|
-
staticValidate
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
valid: validationResult.isValid && !fieldProblems?.[formName]?.[fieldKey] || false,
|
|
78
|
-
errors: null,
|
|
79
|
-
data: formattedValue,
|
|
80
|
-
fieldProblems: fieldProblems?.[formName]?.[fieldKey]
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* requiredFields can be undefined if the configuration api call is not yet completed
|
|
85
|
-
* returned default state in this case
|
|
86
|
-
*/
|
|
87
|
-
if (!requiredFields) return {
|
|
88
|
-
data: defaultData,
|
|
89
|
-
errors: {},
|
|
90
|
-
fieldProblems: {},
|
|
91
|
-
valid: {},
|
|
92
|
-
requiredFields: {},
|
|
93
|
-
asyncErrors: {},
|
|
94
|
-
defaultData
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Make sure forms containing only optional fields are also taken into account
|
|
98
|
-
*/
|
|
99
|
-
const formsForOptionalFields = Object.keys(optionalFields ?? {});
|
|
100
|
-
const formsForRequiredFields = Object.keys(requiredFields);
|
|
101
|
-
/**
|
|
102
|
-
* Visits every field and builds a state with the validity
|
|
103
|
-
*/
|
|
104
|
-
return Array.from(new Set([...formsForOptionalFields, ...formsForRequiredFields])).reduce((acc, formName) => {
|
|
105
|
-
const form = formName;
|
|
106
|
-
const optionalsFormFields = optionalFields?.[form] ?? [];
|
|
107
|
-
const requiredFormFields = requiredFields?.[form] ?? [];
|
|
108
|
-
const formState = [...optionalsFormFields, ...requiredFormFields].reduce((acc, field) => {
|
|
109
|
-
const { valid, errors, data, fieldProblems: processedFieldProblems } = getProcessedState(field, form);
|
|
110
|
-
return {
|
|
111
|
-
...acc,
|
|
112
|
-
data: {
|
|
113
|
-
...acc.data,
|
|
114
|
-
[field]: data
|
|
115
|
-
},
|
|
116
|
-
valid: {
|
|
117
|
-
...acc.valid,
|
|
118
|
-
[field]: valid
|
|
119
|
-
},
|
|
120
|
-
errors: {
|
|
121
|
-
...acc.errors,
|
|
122
|
-
[field]: errors
|
|
123
|
-
},
|
|
124
|
-
fieldProblems: {
|
|
125
|
-
...acc.fieldProblems,
|
|
126
|
-
...processedFieldProblems ? { [field]: processedFieldProblems } : {}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}, {});
|
|
130
|
-
return {
|
|
131
|
-
requiredFields,
|
|
132
|
-
data: {
|
|
133
|
-
...acc.data,
|
|
134
|
-
[formName]: formState.data
|
|
135
|
-
},
|
|
136
|
-
valid: {
|
|
137
|
-
...acc.valid,
|
|
138
|
-
[formName]: formState.valid
|
|
139
|
-
},
|
|
140
|
-
errors: {
|
|
141
|
-
...acc.errors,
|
|
142
|
-
[formName]: formState.errors
|
|
143
|
-
},
|
|
144
|
-
fieldProblems: {
|
|
145
|
-
...acc.fieldProblems,
|
|
146
|
-
[formName]: formState.fieldProblems
|
|
147
|
-
},
|
|
148
|
-
asyncErrors: { ...acc.asyncErrors },
|
|
149
|
-
obscuredFields,
|
|
150
|
-
optionalFields,
|
|
151
|
-
trustedFields,
|
|
152
|
-
defaultData
|
|
153
|
-
};
|
|
154
|
-
}, {
|
|
155
|
-
requiredFields,
|
|
156
|
-
data: {},
|
|
157
|
-
valid: {},
|
|
158
|
-
errors: {},
|
|
159
|
-
fieldProblems: {},
|
|
160
|
-
obscuredFields,
|
|
161
|
-
optionalFields,
|
|
162
|
-
trustedFields,
|
|
163
|
-
asyncErrors: {}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
function reducer({ staticValidate, obscuredFields, optionalFields, trustedFields, formatters, defaultData }) {
|
|
167
|
-
return (state, { type, key, mode, value, formData, formName, selectedSchema, innerFormFields, requiredFields, optionalFields: newOptionalFields, asyncValidationResults }) => {
|
|
168
|
-
const clonedState = structuredClone(state);
|
|
169
|
-
switch (type) {
|
|
170
|
-
case "setData":
|
|
171
|
-
if (!key || !formName) return state;
|
|
172
|
-
clonedState.data[formName] ??= {};
|
|
173
|
-
clonedState.data[formName][key] = value;
|
|
174
|
-
return clonedState;
|
|
175
|
-
case "setFormData": {
|
|
176
|
-
if (!formName || !formData) return state;
|
|
177
|
-
const formRequiredFields = clonedState.requiredFields?.[formName] ?? [];
|
|
178
|
-
const formOptionalFields = clonedState.optionalFields?.[formName] ?? [];
|
|
179
|
-
const allowedFields = [...formRequiredFields, ...formOptionalFields];
|
|
180
|
-
const filteredUpdates = {};
|
|
181
|
-
for (const formDataKey in formData) if (allowedFields.includes(formDataKey)) filteredUpdates[formDataKey] = formData[formDataKey];
|
|
182
|
-
clonedState.data[formName] = filteredUpdates;
|
|
183
|
-
const formValidity = allowedFields.reduce((acc, field) => {
|
|
184
|
-
const [, validation] = processField({
|
|
185
|
-
key: field,
|
|
186
|
-
value: filteredUpdates[field],
|
|
187
|
-
mode: "blur",
|
|
188
|
-
formName,
|
|
189
|
-
defaultData: defaultData?.[formName],
|
|
190
|
-
data: clonedState.data,
|
|
191
|
-
formatters: formatters?.[formName],
|
|
192
|
-
fieldContext: { state: {
|
|
193
|
-
data: clonedState?.data?.[formName],
|
|
194
|
-
obscuredFields: obscuredFields?.[formName],
|
|
195
|
-
optionalFields: optionalFields?.[formName],
|
|
196
|
-
trustedFields: trustedFields?.[formName],
|
|
197
|
-
errors: clonedState.errors?.[formName],
|
|
198
|
-
valid: clonedState.valid?.[formName],
|
|
199
|
-
fieldProblems: clonedState.fieldProblems?.[formName],
|
|
200
|
-
asyncErrors: clonedState.asyncErrors?.[formName]
|
|
201
|
-
} },
|
|
202
|
-
staticValidate
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
...acc,
|
|
206
|
-
[field]: validation.isValid
|
|
207
|
-
};
|
|
208
|
-
}, {});
|
|
209
|
-
clonedState.data[formName] = filteredUpdates;
|
|
210
|
-
clonedState.valid[formName] = formValidity;
|
|
211
|
-
return clonedState;
|
|
212
|
-
}
|
|
213
|
-
case "setValid":
|
|
214
|
-
if (!key || !formName || clonedState.valid[formName]?.[key] === value) return state;
|
|
215
|
-
clonedState.valid[formName] ??= {};
|
|
216
|
-
clonedState.valid[formName][key] = !!value;
|
|
217
|
-
return clonedState;
|
|
218
|
-
case "setErrors":
|
|
219
|
-
if (!key || !formName) return state;
|
|
220
|
-
clonedState.errors[formName] ??= {};
|
|
221
|
-
clonedState.errors[formName][key] = value;
|
|
222
|
-
return clonedState;
|
|
223
|
-
case "setRequiredFields": {
|
|
224
|
-
/**
|
|
225
|
-
* If defaultData changes reset the data in the form to new defaultData
|
|
226
|
-
* Fetching documents are bit delayed, this accomodates that delay
|
|
227
|
-
*/
|
|
228
|
-
const hasDefaultDataChanged = !objectsDeepEqual(defaultData, state.defaultData);
|
|
229
|
-
if (objectsDeepEqual(requiredFields, clonedState.requiredFields) && objectsDeepEqual(newOptionalFields, clonedState.optionalFields) && !hasDefaultDataChanged) return state;
|
|
230
|
-
const updatedData = hasDefaultDataChanged ? defaultData : structuredClone(clonedState.data);
|
|
231
|
-
/**
|
|
232
|
-
* When schema changes without a defaultData refresh, re-add any fields that were
|
|
233
|
-
* previously removed and are now reintroduced from the local stash.
|
|
234
|
-
*
|
|
235
|
-
* This preserves user-entered values across dynamic required/optional transitions,
|
|
236
|
-
* such as when rule-driven fields are temporarily hidden and then shown again.
|
|
237
|
-
*/
|
|
238
|
-
if (!hasDefaultDataChanged && updatedData) for (const formName in requiredFields) {
|
|
239
|
-
const form = formName;
|
|
240
|
-
const prevFields = [...clonedState.requiredFields?.[form] ?? [], ...clonedState.optionalFields?.[form] ?? []];
|
|
241
|
-
[...requiredFields?.[form] ?? [], ...newOptionalFields?.[form] ?? []].filter((field) => !prevFields.includes(field)).forEach((field) => {
|
|
242
|
-
const currentValue = updatedData?.[form]?.[field];
|
|
243
|
-
const localValue = clonedState.local?.[form]?.data?.[field];
|
|
244
|
-
if (typeof currentValue === "undefined" && typeof localValue !== "undefined") {
|
|
245
|
-
if (!updatedData[form]) return;
|
|
246
|
-
updatedData[form][field] = localValue;
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
const newState = init({
|
|
251
|
-
requiredFields,
|
|
252
|
-
data: updatedData,
|
|
253
|
-
fieldProblems: clonedState.fieldProblems,
|
|
254
|
-
obscuredFields,
|
|
255
|
-
optionalFields: newOptionalFields,
|
|
256
|
-
trustedFields,
|
|
257
|
-
staticValidate,
|
|
258
|
-
defaultData
|
|
259
|
-
});
|
|
260
|
-
if (hasDefaultDataChanged) return newState;
|
|
261
|
-
/**
|
|
262
|
-
* Persist values of fields that are being removed from the active schema into local.
|
|
263
|
-
*
|
|
264
|
-
* These values are later used to restore data for reintroduced fields in subsequent
|
|
265
|
-
* schema transitions, avoiding silent data loss during dynamic form updates.
|
|
266
|
-
*/
|
|
267
|
-
const local = Object.keys(requiredFields ?? {}).reduce((acc, formName) => {
|
|
268
|
-
const form = formName;
|
|
269
|
-
const prevFields = [...clonedState.requiredFields?.[form] ?? [], ...clonedState.optionalFields?.[form] ?? []];
|
|
270
|
-
const nextFields = [...requiredFields?.[form] ?? [], ...newOptionalFields?.[form] ?? []];
|
|
271
|
-
const removedFields = prevFields.filter((field) => !nextFields.includes(field));
|
|
272
|
-
if (!removedFields.length) {
|
|
273
|
-
if (clonedState.local?.[form]) return {
|
|
274
|
-
...acc,
|
|
275
|
-
[form]: clonedState.local[form]
|
|
276
|
-
};
|
|
277
|
-
return acc;
|
|
278
|
-
}
|
|
279
|
-
const localFormData = {
|
|
280
|
-
...clonedState.local?.[form]?.data ?? {},
|
|
281
|
-
...removedFields.reduce((fieldAcc, field) => {
|
|
282
|
-
const value = clonedState.data?.[form]?.[field];
|
|
283
|
-
if (typeof value !== "undefined") return {
|
|
284
|
-
...fieldAcc,
|
|
285
|
-
[field]: value
|
|
286
|
-
};
|
|
287
|
-
return fieldAcc;
|
|
288
|
-
}, {})
|
|
289
|
-
};
|
|
290
|
-
return {
|
|
291
|
-
...acc,
|
|
292
|
-
[form]: {
|
|
293
|
-
...clonedState.local?.[form] ?? {},
|
|
294
|
-
data: localFormData
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}, {});
|
|
298
|
-
return {
|
|
299
|
-
...newState,
|
|
300
|
-
local
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
case "setInnerFormRequiredFields": {
|
|
304
|
-
/**
|
|
305
|
-
* This sets the requiredFields in a single form.
|
|
306
|
-
* Ideally this should not be used anywhere, as this goes against the idea of having all
|
|
307
|
-
* the rules of calculating requiredFields in a single place. keeping this in case we have
|
|
308
|
-
* any exceptional scenarios where this would be required. Can be removed once all forms
|
|
309
|
-
* migrated to useMultiform
|
|
310
|
-
*/
|
|
311
|
-
if (!innerFormFields || !formName) return state;
|
|
312
|
-
const requiredFields = {
|
|
313
|
-
...clonedState.requiredFields,
|
|
314
|
-
[formName]: innerFormFields
|
|
315
|
-
};
|
|
316
|
-
const defaultState = init({
|
|
317
|
-
requiredFields,
|
|
318
|
-
defaultData,
|
|
319
|
-
fieldProblems: clonedState.fieldProblems,
|
|
320
|
-
obscuredFields,
|
|
321
|
-
optionalFields,
|
|
322
|
-
trustedFields,
|
|
323
|
-
staticValidate,
|
|
324
|
-
data: defaultData
|
|
325
|
-
});
|
|
326
|
-
const removedFields = clonedState.optionalFields?.[formName].length ? [...(clonedState.requiredFields?.[formName] ?? []).filter((field) => !innerFormFields.includes(field)), ...clonedState.optionalFields[formName].filter((field) => !optionalFields?.[formName].includes(field))] : clonedState.requiredFields?.[formName].filter((field) => !innerFormFields.includes(field));
|
|
327
|
-
const newFields = optionalFields?.[formName].length ? [...innerFormFields.filter((field) => !clonedState.requiredFields?.[formName].includes(field)), ...(optionalFields[formName] ?? []).filter((field) => !clonedState.optionalFields?.[formName].includes(field))] : innerFormFields.filter((field) => !clonedState.requiredFields?.[formName].includes(field));
|
|
328
|
-
const formLocal = {
|
|
329
|
-
data: omitKeys(clonedState.data?.[formName], newFields),
|
|
330
|
-
errors: omitKeys(clonedState.errors?.[formName], newFields),
|
|
331
|
-
valid: omitKeys(clonedState.valid?.[formName], newFields),
|
|
332
|
-
fieldProblems: omitKeys(clonedState.fieldProblems?.[formName], newFields)
|
|
333
|
-
};
|
|
334
|
-
const local = {
|
|
335
|
-
...clonedState.local,
|
|
336
|
-
[formName]: formLocal
|
|
337
|
-
};
|
|
338
|
-
const updatedFormData = addKeys(omitKeys(clonedState.data?.[formName], removedFields), newFields, null, defaultState.data?.[formName], clonedState.local?.[formName].data);
|
|
339
|
-
const updatedData = {
|
|
340
|
-
...clonedState.data,
|
|
341
|
-
[formName]: updatedFormData
|
|
342
|
-
};
|
|
343
|
-
const updatedFormValidity = addKeys(omitKeys(clonedState.valid?.[formName], removedFields), newFields, false, defaultState.valid?.[formName], clonedState.local?.[formName].valid);
|
|
344
|
-
const updatedValidity = {
|
|
345
|
-
...clonedState.valid,
|
|
346
|
-
[formName]: updatedFormValidity
|
|
347
|
-
};
|
|
348
|
-
const updatedFormErrors = addKeys(omitKeys(clonedState.errors?.[formName], removedFields), newFields, null, defaultState.errors?.[formName], clonedState.local?.[formName].errors);
|
|
349
|
-
const updatedErrors = {
|
|
350
|
-
...clonedState.errors,
|
|
351
|
-
[formName]: updatedFormErrors
|
|
352
|
-
};
|
|
353
|
-
const updatedFormFieldProblems = addKeys(omitKeys(clonedState.fieldProblems?.[formName], removedFields), newFields, false, defaultState.fieldProblems?.[formName], clonedState.local?.[formName].fieldProblems);
|
|
354
|
-
return {
|
|
355
|
-
requiredFields,
|
|
356
|
-
data: updatedData,
|
|
357
|
-
valid: updatedValidity,
|
|
358
|
-
errors: updatedErrors,
|
|
359
|
-
fieldProblems: {
|
|
360
|
-
...clonedState.fieldProblems,
|
|
361
|
-
[formName]: updatedFormFieldProblems
|
|
362
|
-
},
|
|
363
|
-
asyncErrors: clonedState.asyncErrors,
|
|
364
|
-
optionalFields,
|
|
365
|
-
trustedFields,
|
|
366
|
-
local,
|
|
367
|
-
defaultData
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
case "updateField": {
|
|
371
|
-
/**
|
|
372
|
-
* Called when a field value changes in form
|
|
373
|
-
* Validates the field and updates data, validity, error in the state for the field
|
|
374
|
-
*/
|
|
375
|
-
if (!key || !mode || !formName) return state;
|
|
376
|
-
const updatedData = {
|
|
377
|
-
...clonedState.data,
|
|
378
|
-
[formName]: {
|
|
379
|
-
...clonedState.data?.[formName],
|
|
380
|
-
[key]: value
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
/**
|
|
384
|
-
* Wipe async errors for the field if value has been changed
|
|
385
|
-
*/
|
|
386
|
-
const updatedAsyncErrors = hasValueChanged(value, clonedState.data?.[formName]?.[key]) ? {
|
|
387
|
-
...clonedState.asyncErrors,
|
|
388
|
-
[formName]: {
|
|
389
|
-
...clonedState.asyncErrors?.[formName],
|
|
390
|
-
[key]: null
|
|
391
|
-
}
|
|
392
|
-
} : clonedState.asyncErrors;
|
|
393
|
-
const [formattedValue, validation] = processField({
|
|
394
|
-
key,
|
|
395
|
-
value,
|
|
396
|
-
mode,
|
|
397
|
-
formName,
|
|
398
|
-
defaultData: defaultData?.[formName],
|
|
399
|
-
data: updatedData,
|
|
400
|
-
formatters: formatters?.[formName],
|
|
401
|
-
fieldContext: { state: {
|
|
402
|
-
data: clonedState.data?.[formName],
|
|
403
|
-
obscuredFields: obscuredFields?.[formName],
|
|
404
|
-
optionalFields: optionalFields?.[formName],
|
|
405
|
-
trustedFields: trustedFields?.[formName],
|
|
406
|
-
errors: clonedState.errors[formName],
|
|
407
|
-
valid: clonedState.valid[formName],
|
|
408
|
-
fieldProblems: clonedState.fieldProblems[formName],
|
|
409
|
-
asyncErrors: updatedAsyncErrors[formName]
|
|
410
|
-
} },
|
|
411
|
-
staticValidate
|
|
412
|
-
});
|
|
413
|
-
const clearFieldProblems = (clonedState.data?.[formName])?.[key] !== formattedValue;
|
|
414
|
-
return {
|
|
415
|
-
...clonedState,
|
|
416
|
-
data: {
|
|
417
|
-
...clonedState.data,
|
|
418
|
-
[formName]: {
|
|
419
|
-
...clonedState.data?.[formName],
|
|
420
|
-
[key]: formattedValue
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
asyncErrors: updatedAsyncErrors,
|
|
424
|
-
errors: {
|
|
425
|
-
...clonedState.errors,
|
|
426
|
-
[formName]: {
|
|
427
|
-
...clonedState.errors[formName],
|
|
428
|
-
[key]: validation.getError() ?? null
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
valid: {
|
|
432
|
-
...clonedState.valid,
|
|
433
|
-
[formName]: {
|
|
434
|
-
...clonedState?.valid?.[formName],
|
|
435
|
-
[key]: (validation.isValid && !clonedState.fieldProblems?.[formName]?.[key]) ?? false
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
fieldProblems: {
|
|
439
|
-
...clonedState.fieldProblems,
|
|
440
|
-
[formName]: {
|
|
441
|
-
...clonedState.fieldProblems[formName],
|
|
442
|
-
...!clearFieldProblems && clonedState.fieldProblems?.[formName]?.[key] ? { [key]: true } : {}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
case "validateForm": {
|
|
448
|
-
/**
|
|
449
|
-
* Called when triggerValidation('formName') is called, validates all the fields in the form
|
|
450
|
-
* and populates the errors in the state
|
|
451
|
-
*/
|
|
452
|
-
if (!formName) return state;
|
|
453
|
-
const formFields = clonedState.requiredFields?.[formName];
|
|
454
|
-
if (!formFields) return state;
|
|
455
|
-
const formState = (selectedSchema || formFields).reduce((acc, field) => {
|
|
456
|
-
const formData = clonedState.data?.[formName];
|
|
457
|
-
const [formattedValue, validation] = processField({
|
|
458
|
-
key: field,
|
|
459
|
-
mode: "blur",
|
|
460
|
-
value: formData?.[field] ?? null,
|
|
461
|
-
formName,
|
|
462
|
-
defaultData: defaultData?.[formName],
|
|
463
|
-
data: clonedState.data,
|
|
464
|
-
formatters: formatters?.[formName],
|
|
465
|
-
fieldContext: { state: {
|
|
466
|
-
data: clonedState.data?.[formName],
|
|
467
|
-
obscuredFields: obscuredFields?.[formName],
|
|
468
|
-
optionalFields: optionalFields?.[formName],
|
|
469
|
-
trustedFields: trustedFields?.[formName],
|
|
470
|
-
errors: clonedState.errors[formName],
|
|
471
|
-
valid: clonedState.valid[formName],
|
|
472
|
-
fieldProblems: clonedState.fieldProblems[formName],
|
|
473
|
-
asyncErrors: clonedState.asyncErrors[formName]
|
|
474
|
-
} },
|
|
475
|
-
staticValidate
|
|
476
|
-
});
|
|
477
|
-
const clearFieldProblems = (clonedState?.data?.[formName])?.[field] !== formattedValue;
|
|
478
|
-
const fieldAsyncValidationResult = asyncValidationResults?.[field];
|
|
479
|
-
return {
|
|
480
|
-
data: formData,
|
|
481
|
-
asyncErrors: {
|
|
482
|
-
...acc.asyncErrors,
|
|
483
|
-
[field]: fieldAsyncValidationResult?.getError() ?? null
|
|
484
|
-
},
|
|
485
|
-
errors: {
|
|
486
|
-
...acc.errors,
|
|
487
|
-
[field]: validation.getError() ?? fieldAsyncValidationResult?.getError() ?? null
|
|
488
|
-
},
|
|
489
|
-
valid: {
|
|
490
|
-
...acc.valid,
|
|
491
|
-
[field]: validation.isValid && (fieldAsyncValidationResult?.isValid ?? true) && !clonedState.fieldProblems[formName][field]
|
|
492
|
-
},
|
|
493
|
-
fieldProblems: {
|
|
494
|
-
...acc.fieldProblems,
|
|
495
|
-
...!clearFieldProblems && acc.fieldProblems?.[field] ? { [field]: true } : {}
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
}, {});
|
|
499
|
-
return {
|
|
500
|
-
...clonedState,
|
|
501
|
-
errors: {
|
|
502
|
-
...clonedState.errors,
|
|
503
|
-
[formName]: formState.errors
|
|
504
|
-
},
|
|
505
|
-
asyncErrors: {
|
|
506
|
-
...clonedState.asyncErrors,
|
|
507
|
-
[formName]: formState.asyncErrors
|
|
508
|
-
},
|
|
509
|
-
valid: {
|
|
510
|
-
...clonedState.valid,
|
|
511
|
-
[formName]: formState.valid
|
|
512
|
-
},
|
|
513
|
-
fieldProblems: {
|
|
514
|
-
...clonedState.fieldProblems,
|
|
515
|
-
[formName]: formState.fieldProblems
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
default: throw new Error("Undefined useForm action");
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
//#endregion
|
|
524
|
-
//#region src/hooks/useMultiForm/useMultiFormAsyncValidator.ts
|
|
525
|
-
var logger = createLogger();
|
|
526
|
-
/**
|
|
527
|
-
* Returns
|
|
528
|
-
* - triggerAsyncValidation function which can execute the async validation for a field and populate the sync validation results
|
|
529
|
-
* - asyncValidationResult state which keeps track of async validations of all fields.
|
|
530
|
-
* @param asyncRules
|
|
531
|
-
*/
|
|
532
|
-
var useMultiFormAsyncValidator = (asyncRules) => {
|
|
533
|
-
const validResult = {
|
|
534
|
-
isValid: true,
|
|
535
|
-
hasError: false
|
|
536
|
-
};
|
|
537
|
-
const triggerAsyncValidation = useCallback(async (field, formName, data) => {
|
|
538
|
-
if (!asyncRules) return new ValidationResult([validResult]);
|
|
539
|
-
const rule = typeof asyncRules === "function" ? asyncRules(data)[formName]?.[field] : asyncRules[formName][field];
|
|
540
|
-
const value = data?.[formName]?.[field];
|
|
541
|
-
if (!rule || !value) return new ValidationResult([validResult]);
|
|
542
|
-
const isValid = await rule.asyncValidate(value).catch(logger.error);
|
|
543
|
-
if (isValid === false) return new ValidationResult([{
|
|
544
|
-
isValid,
|
|
545
|
-
errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value) : rule.errorMessage,
|
|
546
|
-
hasError: !isValid
|
|
547
|
-
}]);
|
|
548
|
-
return new ValidationResult([validResult]);
|
|
549
|
-
}, [asyncRules]);
|
|
550
|
-
const triggerAsyncFormValidation = async (formName, state, selectedSchema) => {
|
|
551
|
-
const fields = selectedSchema ?? state.requiredFields?.[formName];
|
|
552
|
-
if (!fields?.length) return { isValid: true };
|
|
553
|
-
const asyncValidationResults = await fields.reduce(async (accPromise, fieldName) => {
|
|
554
|
-
const acc = await accPromise;
|
|
555
|
-
const asyncValidationResult = await triggerAsyncValidation(fieldName, formName, state.data);
|
|
556
|
-
return {
|
|
557
|
-
...acc,
|
|
558
|
-
[fieldName]: asyncValidationResult
|
|
559
|
-
};
|
|
560
|
-
}, Promise.resolve({}));
|
|
561
|
-
const isValid = Object.values(asyncValidationResults).every((validationResult) => validationResult.isValid);
|
|
562
|
-
return {
|
|
563
|
-
...asyncValidationResults,
|
|
564
|
-
isValid
|
|
565
|
-
};
|
|
566
|
-
};
|
|
567
|
-
return { triggerAsyncFormValidation };
|
|
568
|
-
};
|
|
569
|
-
//#endregion
|
|
570
|
-
//#region src/utils/validation/commonValidators.ts
|
|
571
|
-
var isTruthyValidator = {
|
|
572
|
-
validate: (value) => !!value,
|
|
573
|
-
modes: ["blur"],
|
|
574
|
-
errorMessage: "fieldIsRequired"
|
|
575
|
-
};
|
|
576
|
-
var isNotEmptyValidator = {
|
|
577
|
-
validate: (value) => !isEmpty(value),
|
|
578
|
-
modes: ["blur"],
|
|
579
|
-
errorMessage: "fieldIsRequired"
|
|
580
|
-
};
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/hooks/useMultiForm/useMultiFormStaticValidator.ts
|
|
583
|
-
var useMultiFormStaticValidator = (rules) => {
|
|
584
|
-
const getRulesForField = useCallback((field, form, data) => {
|
|
585
|
-
const fallbackRule = {
|
|
586
|
-
validate: () => true,
|
|
587
|
-
modes: ["blur", "input"]
|
|
588
|
-
};
|
|
589
|
-
if (!form) return [fallbackRule];
|
|
590
|
-
const fieldRules = typeof rules === "function" ? rules(data)?.[form]?.[field] ?? [fallbackRule] : rules?.[form]?.[field] ?? [fallbackRule];
|
|
591
|
-
return Array.isArray(fieldRules) ? fieldRules : [fieldRules];
|
|
592
|
-
}, [rules]);
|
|
593
|
-
return { triggerStaticValidation: useCallback(({ key, value, mode = "blur", formName }, data, context) => {
|
|
594
|
-
const fieldRules = getRulesForField(key, formName, data);
|
|
595
|
-
const isFieldOptional = !!context?.state.optionalFields?.includes(key);
|
|
596
|
-
const isFieldObscured = !!context?.state.obscuredFields?.includes(key);
|
|
597
|
-
if (!isFieldOptional) fieldRules.unshift(isNotEmptyValidator);
|
|
598
|
-
return new ValidationResult(fieldRules.map((rule) => {
|
|
599
|
-
const shouldValidate = rule.modes.includes(mode) && !isFieldObscured;
|
|
600
|
-
const isValid = isFieldOptional && isEmpty(value) ? true : rule.validate(value, context);
|
|
601
|
-
return {
|
|
602
|
-
isValid,
|
|
603
|
-
errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value, context) : rule.errorMessage,
|
|
604
|
-
hasError: shouldValidate && !isValid
|
|
605
|
-
};
|
|
606
|
-
}));
|
|
607
|
-
}, [getRulesForField]) };
|
|
608
|
-
};
|
|
609
|
-
//#endregion
|
|
610
|
-
//#region src/hooks/useMultiForm/useMultiForm.ts
|
|
611
|
-
function useMultiForm({ defaultData, rules, asyncRules, fieldProblems, allFields, requiredFields, obscuredFields, optionalFields, trustedFields, formatters }) {
|
|
612
|
-
const { triggerStaticValidation } = useMultiFormStaticValidator(rules);
|
|
613
|
-
const { triggerAsyncFormValidation } = useMultiFormAsyncValidator(asyncRules);
|
|
614
|
-
const getRequiredFields = useMemo(() => typeof requiredFields === "function" ? requiredFields : () => requiredFields, [requiredFields]);
|
|
615
|
-
const getSchema = useMemo(() => getRequiredFields(defaultData), [defaultData, getRequiredFields]);
|
|
616
|
-
const getReducer = useCallback(() => reducer({
|
|
617
|
-
staticValidate: triggerStaticValidation,
|
|
618
|
-
defaultData,
|
|
619
|
-
obscuredFields,
|
|
620
|
-
optionalFields,
|
|
621
|
-
trustedFields,
|
|
622
|
-
formatters
|
|
623
|
-
}), [
|
|
624
|
-
triggerStaticValidation,
|
|
625
|
-
obscuredFields,
|
|
626
|
-
optionalFields,
|
|
627
|
-
trustedFields,
|
|
628
|
-
formatters,
|
|
629
|
-
defaultData
|
|
630
|
-
]);
|
|
631
|
-
const initialData = useMemo(() => ({
|
|
632
|
-
requiredFields: getSchema,
|
|
633
|
-
defaultData,
|
|
634
|
-
fieldProblems,
|
|
635
|
-
obscuredFields,
|
|
636
|
-
optionalFields,
|
|
637
|
-
trustedFields,
|
|
638
|
-
formatters,
|
|
639
|
-
staticValidate: triggerStaticValidation,
|
|
640
|
-
data: defaultData
|
|
641
|
-
}), [
|
|
642
|
-
getSchema,
|
|
643
|
-
defaultData,
|
|
644
|
-
fieldProblems,
|
|
645
|
-
obscuredFields,
|
|
646
|
-
optionalFields,
|
|
647
|
-
trustedFields,
|
|
648
|
-
formatters,
|
|
649
|
-
triggerStaticValidation
|
|
650
|
-
]);
|
|
651
|
-
const [state, dispatch] = useReducer(getReducer(), initialData, init);
|
|
652
|
-
const isValid = useMemo(() => {
|
|
653
|
-
const formsForOptionalFields = Object.keys(state.optionalFields ?? {});
|
|
654
|
-
const formsForRequiredFields = Object.keys(state.requiredFields ?? {});
|
|
655
|
-
return Array.from(new Set([...formsForOptionalFields, ...formsForRequiredFields])).reduce((acc, formName) => {
|
|
656
|
-
const form = formName;
|
|
657
|
-
const optionalsFormFields = state.optionalFields?.[form] ?? [];
|
|
658
|
-
const requiredFormFields = state.requiredFields?.[form] ?? [];
|
|
659
|
-
const formFields = [...optionalsFormFields, ...requiredFormFields];
|
|
660
|
-
const formValidity = state.valid[formName] ?? {};
|
|
661
|
-
return {
|
|
662
|
-
...acc,
|
|
663
|
-
[formName]: Object.entries(formValidity)?.every(([field, valid]) => formFields.includes(field) ? valid : true)
|
|
664
|
-
};
|
|
665
|
-
}, {});
|
|
666
|
-
}, [state.requiredFields, state.valid]);
|
|
667
|
-
const getTargetValue = useCallback((formName, key, e) => {
|
|
668
|
-
if (!e?.target) return e;
|
|
669
|
-
if (e.target.type === "checkbox") return !state.data?.[formName][key];
|
|
670
|
-
return e.target.value;
|
|
671
|
-
}, [state.data]);
|
|
672
|
-
const setErrors = useCallback((formName, key, value) => {
|
|
673
|
-
dispatch({
|
|
674
|
-
type: "setErrors",
|
|
675
|
-
key,
|
|
676
|
-
value,
|
|
677
|
-
formName
|
|
678
|
-
});
|
|
679
|
-
}, []);
|
|
680
|
-
const setValid = useCallback((formName, key, value) => {
|
|
681
|
-
dispatch({
|
|
682
|
-
type: "setValid",
|
|
683
|
-
key,
|
|
684
|
-
value,
|
|
685
|
-
formName
|
|
686
|
-
});
|
|
687
|
-
}, []);
|
|
688
|
-
const setData = useCallback((formName, key, value) => {
|
|
689
|
-
dispatch({
|
|
690
|
-
type: "setData",
|
|
691
|
-
key,
|
|
692
|
-
value,
|
|
693
|
-
formName
|
|
694
|
-
});
|
|
695
|
-
}, []);
|
|
696
|
-
const setFormData = useCallback((formName, formData) => {
|
|
697
|
-
dispatch({
|
|
698
|
-
type: "setFormData",
|
|
699
|
-
formName,
|
|
700
|
-
formData
|
|
701
|
-
});
|
|
702
|
-
}, []);
|
|
703
|
-
const handleChangeFor = useCallback((formName, key, mode = "blur") => (e) => {
|
|
704
|
-
dispatch({
|
|
705
|
-
type: "updateField",
|
|
706
|
-
key,
|
|
707
|
-
value: getTargetValue(formName, key, e),
|
|
708
|
-
mode,
|
|
709
|
-
formName
|
|
710
|
-
});
|
|
711
|
-
}, [getTargetValue]);
|
|
712
|
-
const triggerValidation = useCallback(async (formName, selectedSchema) => {
|
|
713
|
-
const asyncValidationResults = await triggerAsyncFormValidation(formName, state, selectedSchema);
|
|
714
|
-
dispatch({
|
|
715
|
-
type: "validateForm",
|
|
716
|
-
formName,
|
|
717
|
-
selectedSchema,
|
|
718
|
-
asyncValidationResults
|
|
719
|
-
});
|
|
720
|
-
return asyncValidationResults.isValid;
|
|
721
|
-
}, [state, triggerAsyncFormValidation]);
|
|
722
|
-
const resetToDefaultData = useCallback(() => {
|
|
723
|
-
if (!getSchema) return;
|
|
724
|
-
Object.entries(getSchema).forEach(([formName]) => {
|
|
725
|
-
const form = formName;
|
|
726
|
-
const formData = defaultData?.[form];
|
|
727
|
-
getSchema[form].forEach((field) => {
|
|
728
|
-
if (!formData || typeof formData[field] !== "undefined") {
|
|
729
|
-
handleChangeFor(form, field)(formData);
|
|
730
|
-
return;
|
|
731
|
-
}
|
|
732
|
-
setValid(form, field, false);
|
|
733
|
-
setErrors(form, field, null);
|
|
734
|
-
setData(form, field, formData[field]);
|
|
735
|
-
});
|
|
736
|
-
});
|
|
737
|
-
}, [
|
|
738
|
-
defaultData,
|
|
739
|
-
getSchema,
|
|
740
|
-
handleChangeFor,
|
|
741
|
-
setData,
|
|
742
|
-
setErrors,
|
|
743
|
-
setValid
|
|
744
|
-
]);
|
|
745
|
-
useEffect(() => {
|
|
746
|
-
const requiredFields = getRequiredFields(state.data);
|
|
747
|
-
if (!requiredFields) return;
|
|
748
|
-
dispatch({
|
|
749
|
-
type: "setRequiredFields",
|
|
750
|
-
requiredFields,
|
|
751
|
-
defaultData,
|
|
752
|
-
optionalFields
|
|
753
|
-
});
|
|
754
|
-
}, [
|
|
755
|
-
getRequiredFields,
|
|
756
|
-
state.data,
|
|
757
|
-
defaultData,
|
|
758
|
-
optionalFields
|
|
759
|
-
]);
|
|
760
|
-
return {
|
|
761
|
-
setData,
|
|
762
|
-
setFormData,
|
|
763
|
-
setValid,
|
|
764
|
-
setErrors,
|
|
765
|
-
handleChangeFor,
|
|
766
|
-
triggerValidation,
|
|
767
|
-
resetToDefaultData,
|
|
768
|
-
isValid,
|
|
769
|
-
allFields,
|
|
770
|
-
requiredFields: state.requiredFields,
|
|
771
|
-
optionalFields: state.optionalFields,
|
|
772
|
-
trustedFields: state.trustedFields,
|
|
773
|
-
obscuredFields: state.obscuredFields,
|
|
774
|
-
valid: state.valid,
|
|
775
|
-
errors: state.errors,
|
|
776
|
-
data: state.data,
|
|
777
|
-
fieldProblems: state.fieldProblems,
|
|
778
|
-
defaultData,
|
|
779
|
-
asyncErrors: state.asyncErrors
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
//#endregion
|
|
783
|
-
export { isNotEmptyValidator as n, isTruthyValidator as r, useMultiForm as t };
|