@adyen/kyc-components 4.18.0 → 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-BBkIzStE.js → AccountSetupRejected-BVzz6Scm.js} +2 -2
- package/dist/{AdaptiveWorkflow-BeNeSJmr.js → AdaptiveWorkflow-DsZ_wY_H.js} +31 -34
- package/dist/{AdaptiveWorkflowComponent-vGohaG9V.js → AdaptiveWorkflowComponent-1LmhvzA8.js} +56 -56
- package/dist/{Address-pRy7yAyT.js → Address-Dn9YYuVv.js} +7 -7
- package/dist/{AddressField-D5VvYpTn.js → AddressField-BLlc_T5f.js} +11 -14
- package/dist/{Avatar-CdBNstmD.js → Avatar-Y_RdG_YY.js} +1 -1
- package/dist/{BusinessFinancingDropin-BVJmBiV-.js → BusinessFinancingDropin-BJ7Z_6_q.js} +31 -36
- package/dist/{BusinessFinancingPage-D6Ltqocq.js → BusinessFinancingPage-C72fEfR8.js} +32 -32
- package/dist/{BusinessTypeSelectionPage-COGrE8in.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-Cse5eWmF.js → CompanyRegistrationNumberTypeSelector-Dw2BkLur.js} +8 -8
- package/dist/{ContactDetails-Bg6E-Qdo.js → ContactDetails-Bi_d3c4V.js} +7 -8
- package/dist/{ContextGuidance-OW20JTmA.js → ContextGuidance-D7YPJhH5.js} +2 -2
- package/dist/CountryField-CEttz1qx.js +1653 -0
- package/dist/{Currency-BB-aCS9R.js → Currency-D3ooH-P1.js} +8 -9
- package/dist/{CustomerSupport-CxLYgFMf.js → CustomerSupport-BPkPpm4S.js} +14 -15
- package/dist/{DataConflictsModal-Din0HvnQ.js → DataConflictsModal-CjK5meAj.js} +7 -7
- package/dist/{DebugModal-CCmbbYz8.js → DebugModal-BdzRooB8.js} +11 -12
- package/dist/{DecisionMakerDetails-CfQw5zLh.js → DecisionMakerDetails-CEvexevf.js} +16 -17
- package/dist/{DecisionMakerDetailsPage-DKdZRCWu.js → DecisionMakerDetailsPage-PdJIWA0L.js} +35 -35
- package/dist/{DecisionMakers-SZrdoYjV.js → DecisionMakers-B62TqNnC.js} +43 -43
- package/dist/{Dropzone-VbRNXGWC.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-zNH_hlni.js → EntityAssociation-DsQNaCo7.js} +7 -7
- package/dist/{ErrorPanel-BUnSs30r.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-dtWJoFtm.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-D_hA5jmK.js → Introduction-DZ-ov19S.js} +8 -8
- package/dist/{InvitedDecisionMakerComponent-UOdB2Gdf.js → InvitedDecisionMakerComponent-KwRWIgOY.js} +67 -67
- package/dist/{JpAddress-Bzh05zSM.js → JpAddress-DA4HeKHD.js} +13 -13
- package/dist/{JpAddress.module-Bdx0E9ys.js → JpAddress.module-h_ZcUDUu.js} +4 -4
- package/dist/{JpAddressFields-BcNA2qQ-.js → JpAddressFields-BG4Hvw6r.js} +10 -10
- package/dist/{LegalCompanyNameField-B4tZnTsz.js → LegalCompanyNameField-RnzsmUKo.js} +5 -5
- package/dist/{LegalRepresentativeDetailsPage-BJdt2arC.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-fg7rPWNN.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-01MQcP8O.js → NewSummary-RLsN58Mb.js} +7 -7
- package/dist/{PatriotActDisclosure-EIRUow5b.js → PatriotActDisclosure-CGU1K5gU.js} +14 -16
- package/dist/{PayoutDetailsDropin-Ba7MTkCv.js → PayoutDetailsDropin-CyF7UckP.js} +31 -40
- package/dist/{PayoutDetailsPage-rpkLlwhy.js → PayoutDetailsPage-D54T0cTR.js} +9 -9
- package/dist/{RadioGroup-Bt1Dv_S8.js → RadioGroup-lkTq-fXj.js} +4 -4
- package/dist/{Review-CgR-Yydj.js → Review-CQP_ivDp.js} +8 -8
- package/dist/RootBusinessDetailsPage-74wy-iuF.js +68 -0
- package/dist/{RootBusinessLinesPage-BMT3gr2J.js → RootBusinessLinesPage-DdbHs3i6.js} +30 -36
- package/dist/{RootIndividualDetailsPage-D3Hm7OrC.js → RootIndividualDetailsPage-CRiGz1L-.js} +33 -33
- package/dist/{Select-D4oEtS2n.js → Select-C2axJYZG.js} +322 -9
- package/dist/{SignPCIComponent-g8v3tteD.js → SignPCIComponent-2jkpTNie.js} +40 -42
- package/dist/{SingpassSelection-Bx4GOfIq.js → SingpassSelection-C0Nj8agM.js} +6 -6
- package/dist/{SoleProprietorshipPage-CG51YTEA.js → SoleProprietorshipPage-DL9KxFfM.js} +34 -34
- package/dist/{SourceOfFundsPage-BJKj0z9v.js → SourceOfFundsPage-CoriFRrS.js} +33 -39
- package/dist/{StructuredList-Ci4Ut4E5.js → StructuredList-Mj-OPN9u.js} +71 -3
- package/dist/{TaskListItem-D54ulnyc.js → TaskListItem-DOnEqpoq.js} +11 -11
- package/dist/{TaskVerificationStatus-CKHPTEpH.js → TaskVerificationStatus-ITLSeoau.js} +1 -1
- package/dist/{TaxReportingDropin-DgB6Uo-8.js → TaxReportingDropin-BnEktotO.js} +18 -19
- package/dist/{TermsOfServiceManagement-B73EAUQT.js → TermsOfServiceManagement-CY49Ivu1.js} +41 -45
- package/dist/{TextArea-BUx3yuMJ.js → TextArea-BzCbFjRp.js} +4 -4
- package/dist/{TrustDetailsPage-DbRZo3eo.js → TrustDetailsPage-BOt9PbYw.js} +33 -38
- package/dist/{TrustMemberCompanyPage-fjaHnVnu.js → TrustMemberCompanyPage-D36IOylX.js} +35 -35
- package/dist/{TrustMemberIndividualPage-ChdfyypX.js → TrustMemberIndividualPage-aAZXiZKb.js} +33 -33
- package/dist/{TrustMemberRoleAndTypePage-4FiocM2Q.js → TrustMemberRoleAndTypePage-C9zB9BEk.js} +17 -22
- package/dist/{TrustMembersOverview-BfW7xcig.js → TrustMembersOverview-DxAuj55H.js} +13 -13
- package/dist/{UnincorporatedPartnershipIndividualPage-CoxFU8hC.js → UnincorporatedPartnershipIndividualPage-C4jwWyYn.js} +33 -33
- package/dist/{UnincorporatedPartnershipMemberCompanyPage-qtLLtEBZ.js → UnincorporatedPartnershipMemberCompanyPage-0JVxcpB4.js} +35 -35
- package/dist/{UnincorporatedPartnershipMemberRoleAndTypePage-CcrbCZHP.js → UnincorporatedPartnershipMemberRoleAndTypePage-DfxG-RyJ.js} +12 -12
- package/dist/{UnincorporatedPartnershipMembersOverview-BcIX_dew.js → UnincorporatedPartnershipMembersOverview-DecZD9DL.js} +9 -9
- package/dist/{VerificationErrorAlert-CBkiCj7f.js → VerificationErrorAlert-kLh424Dx.js} +5 -5
- package/dist/{accountHolderUtils-BRcGuXPg.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-4O_2-mb6.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-B8KqUjNk.js → omitObscuredFieldsIfUnchanged-P2CVFokX.js} +2 -2
- package/dist/{patternValidators-DxkAZhsA.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-D9l2eO9k.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-DoST1OsT.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/api/companyDataSet/companyDataset.types.d.ts +1 -3
- 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 +2 -1
- 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-ZmBKQqoD.js → useBusinessDetailsData-DJxoXaI7.js} +123 -118
- package/dist/{useBusinessLines-BFsRoAAj.js → useBusinessLines-CfQYLNkw.js} +1 -1
- package/dist/{useCanSeeIntroduction-BV78oSLN.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-CV0UezXM.js → useForm-BV6TtEpQ.js} +4 -4
- package/dist/{invalidateRootLegalEntity-CNKlzaEg.js → useId-BiYSHcau.js} +28 -6
- package/dist/{useLegalEntity-CtlUQv_J.js → useLegalEntity-BqO7Fmt0.js} +1 -1
- package/dist/{useNavigate-C32tng3x.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-DsHD7BN-.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-Bk3h9Ga3.js → useUpdateLegalEntity-CavZl01k.js} +3 -3
- package/dist/{utils-UMZuwGLj.js → utils-BZ6sjmH0.js} +5 -5
- package/dist/{utils-C_W1-emm.js → utils-Bu9Q872y.js} +7 -7
- package/dist/{utils-BIsRIG8_.js → utils-CxPOLLKk.js} +2 -2
- package/dist/{utils-Cjauzs_k.js → utils-wOuhjMhJ.js} +13 -14
- package/dist/{validate-CMxq61UU.js → validate-K01plHbc.js} +5 -5
- package/dist/{validate-DZs3J_LS.js → validate-XXwQLqzu.js} +1 -1
- package/dist/{validateExtractionResult-BkzUg6_Q.js → validateExtractionResult-BkuHB6PK.js} +10 -11
- package/dist/{validationError-B33RQfsy.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-B4jNKNdQ.js +0 -37
- package/dist/Field-Dg-2A6bG.js +0 -155
- package/dist/GlobalEntryModal-CjuK78f0.js +0 -34
- package/dist/GlobalEntryPage-DRvb0gLz.js +0 -44
- package/dist/LandingLayout-iZpW1Vsx.js +0 -81
- package/dist/MaybeModal-evIPP9Uh.js +0 -24
- package/dist/ProgressBar-DWFxLMUA.js +0 -38
- package/dist/RootBusinessDetailsPage-D-aCSPPF.js +0 -68
- package/dist/Summary-DPMBCqZT.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/Business/mapping/businessDetails/mapOrganizationTypeToCompanyType.d.ts +0 -9
- package/dist/types/components/GlobalEntry/forms/GlobalEntryModal/GlobalEntryModal.d.ts +0 -1
- package/dist/types/core/models/api/organization-type.d.ts +0 -5
- package/dist/useFormContext-BWw5svgR.js +0 -503
- package/dist/useId-BkDhUta2.js +0 -28
- package/dist/useMultiForm-DysFfqIA.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
|
@@ -0,0 +1,1653 @@
|
|
|
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] = "94b10fd2-4924-42f4-8ed8-2cea4dc61321", e._sentryDebugIdIdentifier = "sentry-dbid-94b10fd2-4924-42f4-8ed8-2cea4dc61321");
|
|
4
|
+
} catch (e) {}
|
|
5
|
+
import { o as createLogger, r as useTranslation } from "./translation-CcKrUksA.js";
|
|
6
|
+
import { C as useDataset, k as Header, nt as isEmpty, w as datasetIdentifier } from "./resolveEnvironment-DEX5KqEv.js";
|
|
7
|
+
import { n as IconButton, t as Button } from "./Button-BuhgDsyo.js";
|
|
8
|
+
import { o as objectsDeepEqual, s as entriesOf } from "./AnalyticsContext-BnRQ9H1u.js";
|
|
9
|
+
import { t as DecisionMakerTypes } from "./decision-maker-type-NR4GFAeT.js";
|
|
10
|
+
import { n as TrustMemberGuidanceLabels, r as TrustMemberTypes } from "./trustMemberGuidance-CgdU2v0j.js";
|
|
11
|
+
import { i as useAnalyticsContext } from "./Modal-BYdlsXkf.js";
|
|
12
|
+
import { t as formDebugInfo } from "./debugStore-DpSgCNGn.js";
|
|
13
|
+
import { a as MaybeModal, c as getDataByFields, d as translateTranslatable, f as LoaderWrapper, i as ProgressBar, l as omitKeys, o as ValidationResult, r as Field, s as addKeys, t as Select } from "./Select-C2axJYZG.js";
|
|
14
|
+
import { n as Confirm, t as StructuredList } from "./StructuredList-Mj-OPN9u.js";
|
|
15
|
+
import { t as Image } from "./Image-Dc5Xg1_Y.js";
|
|
16
|
+
import { t as List } from "./List-ywoRPg-q.js";
|
|
17
|
+
import { r as FormRouterContext, t as ErrorPanel } from "./ErrorPanel-C51kA_mU.js";
|
|
18
|
+
import { t as UnincorporatedPartnershipMemberTypes } from "./unincorporated-partnership-DNTK5Y_5.js";
|
|
19
|
+
import { lazy } from "preact/compat";
|
|
20
|
+
import { useCallback as useCallback$1, useContext as useContext$1, useEffect as useEffect$1, useMemo as useMemo$1, useReducer, useRef as useRef$1, useState as useState$1 } from "preact/hooks";
|
|
21
|
+
import cx from "classnames";
|
|
22
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
23
|
+
import { createContext as createContext$1 } from "preact";
|
|
24
|
+
//#region src/context/FormContext/FormContext.ts
|
|
25
|
+
var FormContext = createContext$1(null);
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/context/FormContext/FormContextProvider.tsx
|
|
28
|
+
function FormContextProvider({ children, form }) {
|
|
29
|
+
const contextValue = useMemo$1(() => ({ form }), [form]);
|
|
30
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, {
|
|
31
|
+
value: contextValue,
|
|
32
|
+
children
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/hooks/usePageLandedEvent.ts
|
|
37
|
+
/**
|
|
38
|
+
* Hook that automatically sends a "Landed on page" analytics event on when active form changes.
|
|
39
|
+
* Used on form component level (i.e. Basic information, Additional details etc.) to explicitly track page visits.
|
|
40
|
+
* This centralizes the common analytics pattern used across form components.
|
|
41
|
+
*/
|
|
42
|
+
var usePageLandedEvent = (formName) => {
|
|
43
|
+
const userEvents = useAnalyticsContext();
|
|
44
|
+
const oldFormNameRef = useRef$1(void 0);
|
|
45
|
+
if (formName && oldFormNameRef.current !== formName) {
|
|
46
|
+
userEvents.updateSharedEventProperties({ page: formName });
|
|
47
|
+
userEvents.addPageEvent("Landed on page", { actionType: "navigate" });
|
|
48
|
+
oldFormNameRef.current = formName;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/utils/analytics/trackNavigation.ts
|
|
53
|
+
var trackNavigation = ({ userEvents, actionType, toForm, label, returnValue, additionalTrackingParams }) => {
|
|
54
|
+
userEvents.addPageEvent("Clicked button", {
|
|
55
|
+
actionType,
|
|
56
|
+
toPage: toForm,
|
|
57
|
+
label,
|
|
58
|
+
returnValue,
|
|
59
|
+
...additionalTrackingParams
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils/formUtils.ts
|
|
64
|
+
var createFormUtils = (props, t) => ({
|
|
65
|
+
getLabel: (field, fallbackLabelKey) => {
|
|
66
|
+
let translationKey = props.labels?.[field] ?? fallbackLabelKey ?? field;
|
|
67
|
+
if (props.labels && !props.labels?.[field] && Object.keys(props.labels).length) {
|
|
68
|
+
const parentKey = Object.keys(props.labels).find((fieldKey) => typeof props.labels?.[fieldKey] === "object");
|
|
69
|
+
if (parentKey) translationKey = props.labels[parentKey][field] ?? translationKey;
|
|
70
|
+
}
|
|
71
|
+
return t(($) => $[translationKey]);
|
|
72
|
+
},
|
|
73
|
+
getMask: (field) => props.masks?.[field],
|
|
74
|
+
isRequiredField: (field, showIfNotInRequiredFields = true) => props.requiredFields ? props.requiredFields.includes(field) && (field !== "role" || field === "role" && props.taskType !== "individual") : showIfNotInRequiredFields,
|
|
75
|
+
isOptionalField: (field) => props.optionalFields?.includes(field) ?? false,
|
|
76
|
+
isVisibleField(field, showIfNotInRequiredFields = true) {
|
|
77
|
+
return this.isRequiredField(field, showIfNotInRequiredFields) || this.isOptionalField(field);
|
|
78
|
+
},
|
|
79
|
+
isReadOnly: (field) => props.readOnly || (props.readOnlyFields ? props.readOnlyFields.includes(field) : false),
|
|
80
|
+
isObscured: (field) => props.obscuredFields ? props.obscuredFields.includes(field) : false,
|
|
81
|
+
isTrusted: (field) => props.trustedFields ? props.trustedFields.includes(field) : false,
|
|
82
|
+
getErrorMessage: (field, errors, fieldProblems) => {
|
|
83
|
+
return errors?.[field]?.errorMessage || Boolean(fieldProblems?.[field]);
|
|
84
|
+
},
|
|
85
|
+
getFieldData: (formData, fieldKeys) => getDataByFields(formData, fieldKeys),
|
|
86
|
+
getFieldValid: (formValid, fieldKeys) => entriesOf(formValid).reduce((acc, [key, val]) => fieldKeys.includes(key) ? {
|
|
87
|
+
...acc,
|
|
88
|
+
[key]: val
|
|
89
|
+
} : acc, {}),
|
|
90
|
+
getFieldErrors: (formErrors, fieldProblems, fieldKeys) => Object.keys(formErrors).reduce((acc, key) => {
|
|
91
|
+
if (fieldKeys.includes(key)) {
|
|
92
|
+
const error = formErrors?.[key]?.errorMessage;
|
|
93
|
+
return error ? {
|
|
94
|
+
...acc,
|
|
95
|
+
[key]: error
|
|
96
|
+
} : {
|
|
97
|
+
...acc,
|
|
98
|
+
[key]: Boolean(fieldProblems?.[key])
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return acc;
|
|
102
|
+
}, {}),
|
|
103
|
+
getFieldLabels: (fieldKeys, fallbackLabelKeys) => fieldKeys.reduce((acc, field) => {
|
|
104
|
+
let translationKey = props.labels?.[field] ?? fallbackLabelKeys?.[field] ?? field;
|
|
105
|
+
if (props.labels && !props.labels?.[field] && Object.keys(props.labels).length) {
|
|
106
|
+
const parentKey = Object.keys(props.labels).find((fieldKey) => typeof props.labels?.[fieldKey] === "object");
|
|
107
|
+
if (parentKey) translationKey = props.labels[parentKey][field] ?? translationKey;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
...acc,
|
|
111
|
+
[field]: t(($) => $[translationKey])
|
|
112
|
+
};
|
|
113
|
+
}, {})
|
|
114
|
+
});
|
|
115
|
+
var mergeFieldMetadataIntoProps = (fieldName, metadata, otherProps) => {
|
|
116
|
+
const existingProps = otherProps ?? {};
|
|
117
|
+
return {
|
|
118
|
+
...existingProps,
|
|
119
|
+
labels: {
|
|
120
|
+
...existingProps.labels,
|
|
121
|
+
[fieldName]: metadata.label
|
|
122
|
+
},
|
|
123
|
+
masks: {
|
|
124
|
+
...existingProps.masks,
|
|
125
|
+
[fieldName]: metadata.mask
|
|
126
|
+
},
|
|
127
|
+
validators: {
|
|
128
|
+
...existingProps.validators,
|
|
129
|
+
[fieldName]: metadata.validators
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/utils/roleMetadata.ts
|
|
135
|
+
var roleMetadata = {
|
|
136
|
+
[DecisionMakerTypes.CONTROLLING_PERSON]: {
|
|
137
|
+
name: "controllingPerson",
|
|
138
|
+
description: "controllingPersonDescription"
|
|
139
|
+
},
|
|
140
|
+
[DecisionMakerTypes.OWNER]: {
|
|
141
|
+
name: "owner",
|
|
142
|
+
description: "ownerDescription"
|
|
143
|
+
},
|
|
144
|
+
[DecisionMakerTypes.SIGNATORY]: {
|
|
145
|
+
name: "signatory",
|
|
146
|
+
description: "signatoryDescription"
|
|
147
|
+
},
|
|
148
|
+
[DecisionMakerTypes.DIRECTOR]: {
|
|
149
|
+
name: "director",
|
|
150
|
+
description: "directorDescription"
|
|
151
|
+
},
|
|
152
|
+
[TrustMemberTypes.DEFINED_BENEFICIARY]: {
|
|
153
|
+
name: "definedBeneficiary",
|
|
154
|
+
description: "definedBeneficiaryDescription"
|
|
155
|
+
},
|
|
156
|
+
[TrustMemberTypes.UNDEFINED_BENEFICIARY]: {
|
|
157
|
+
name: "undefinedBeneficiary",
|
|
158
|
+
description: "undefinedBeneficiaryDescription"
|
|
159
|
+
},
|
|
160
|
+
[TrustMemberTypes.PROTECTOR]: {
|
|
161
|
+
name: "protector",
|
|
162
|
+
description: "personAppointmentUnderTrustInstrument"
|
|
163
|
+
},
|
|
164
|
+
[TrustMemberTypes.TRUSTEE]: {
|
|
165
|
+
name: "trustee",
|
|
166
|
+
description: "legalOwnerOfProperty"
|
|
167
|
+
},
|
|
168
|
+
[TrustMemberTypes.SETTLOR]: {
|
|
169
|
+
name: "settlor",
|
|
170
|
+
description: "entityEstablishingTrust"
|
|
171
|
+
},
|
|
172
|
+
[TrustMemberGuidanceLabels.BENEFICIARY]: { name: TrustMemberGuidanceLabels.BENEFICIARY },
|
|
173
|
+
[TrustMemberGuidanceLabels.TRUSTEE]: { name: TrustMemberGuidanceLabels.TRUSTEE },
|
|
174
|
+
[UnincorporatedPartnershipMemberTypes.SECONDARY_PARTNER]: {
|
|
175
|
+
name: UnincorporatedPartnershipMemberTypes.SECONDARY_PARTNER,
|
|
176
|
+
description: "secondaryPartnerGuideDescription"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var getRoleTagVariant = (role) => roleMetadata[role]?.variant ?? "blue";
|
|
180
|
+
var getRoleName = (role) => roleMetadata[role]?.name ?? role;
|
|
181
|
+
var Summary_module_default = {
|
|
182
|
+
summary: "_summary_1op7a_1",
|
|
183
|
+
"summary-content": "_summary-content_1op7a_7",
|
|
184
|
+
summaryContent: "_summary-content_1op7a_7",
|
|
185
|
+
"summary-list": "_summary-list_1op7a_13",
|
|
186
|
+
summaryList: "_summary-list_1op7a_13",
|
|
187
|
+
"summary-list-header": "_summary-list-header_1op7a_27",
|
|
188
|
+
summaryListHeader: "_summary-list-header_1op7a_27",
|
|
189
|
+
"summary-list-header-title": "_summary-list-header-title_1op7a_32",
|
|
190
|
+
summaryListHeaderTitle: "_summary-list-header-title_1op7a_32",
|
|
191
|
+
"summary-list-item": "_summary-list-item_1op7a_41",
|
|
192
|
+
summaryListItem: "_summary-list-item_1op7a_41",
|
|
193
|
+
"summary-list-item-key": "_summary-list-item-key_1op7a_55",
|
|
194
|
+
summaryListItemKey: "_summary-list-item-key_1op7a_55",
|
|
195
|
+
"summary-list-item-value": "_summary-list-item-value_1op7a_67",
|
|
196
|
+
summaryListItemValue: "_summary-list-item-value_1op7a_67",
|
|
197
|
+
"summary-content-legal-caption": "_summary-content-legal-caption_1op7a_73",
|
|
198
|
+
summaryContentLegalCaption: "_summary-content-legal-caption_1op7a_73",
|
|
199
|
+
"summary-content-list": "_summary-content-list_1op7a_88",
|
|
200
|
+
summaryContentList: "_summary-content-list_1op7a_88",
|
|
201
|
+
"summary-content-logo": "_summary-content-logo_1op7a_92",
|
|
202
|
+
summaryContentLogo: "_summary-content-logo_1op7a_92"
|
|
203
|
+
};
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/components/Shared/Summary/summaryItem.ts
|
|
206
|
+
var isSummaryItem = (val) => typeof val === "object" && val !== null && "summaryLabel" in val && "summaryValue" in val;
|
|
207
|
+
var summaryItem = (summaryLabel, summaryValue) => ({
|
|
208
|
+
summaryLabel,
|
|
209
|
+
summaryValue
|
|
210
|
+
});
|
|
211
|
+
var preTranslatedSummaryItem = (summaryLabel, summaryValue) => ({
|
|
212
|
+
summaryLabel,
|
|
213
|
+
summaryValue,
|
|
214
|
+
preTranslated: true
|
|
215
|
+
});
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/components/Shared/Summary/Summary.tsx
|
|
218
|
+
var onfidoLogo = lazy(() => import("./onfido-logo-CMRuSr8M.js"));
|
|
219
|
+
var summaryStep = {
|
|
220
|
+
formId: "summary",
|
|
221
|
+
formName: "summary"
|
|
222
|
+
};
|
|
223
|
+
/** @deprecated, use NewSummary */
|
|
224
|
+
function Summary({ data, forms, gotoForm, labels, problems, omitted = {}, showFormHeader = true, showSectionHeader = true, showLegalCaption = false, showTaxExemptedLegalCaption = false, useStructuredList = false }) {
|
|
225
|
+
const { t } = useTranslation("common");
|
|
226
|
+
const userEvents = useAnalyticsContext();
|
|
227
|
+
const editForm = (formId) => {
|
|
228
|
+
const formIndex = forms.findIndex((form) => form.formId === formId);
|
|
229
|
+
if (formIndex >= 0) gotoForm(formIndex);
|
|
230
|
+
};
|
|
231
|
+
const allValidationErrors = problems?.validationErrors && Object.values(problems.validationErrors)?.reduce((acc, validError) => ({
|
|
232
|
+
...acc,
|
|
233
|
+
...validError
|
|
234
|
+
}), {});
|
|
235
|
+
const allVerificationErrors = problems?.verificationErrors && Object.values(problems.verificationErrors)?.reduce((acc, verifError) => ({
|
|
236
|
+
...acc,
|
|
237
|
+
...verifError
|
|
238
|
+
}), {});
|
|
239
|
+
const formUtils = createFormUtils({ labels }, t);
|
|
240
|
+
const summarySectionHeader = (formName, formId) => /* @__PURE__ */ jsxs("header", {
|
|
241
|
+
className: Summary_module_default.summaryListHeader,
|
|
242
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
243
|
+
className: Summary_module_default.summaryListHeaderTitle,
|
|
244
|
+
children: formName
|
|
245
|
+
}), !omitted.summaryEditButton?.includes(formId) && /* @__PURE__ */ jsx(IconButton, {
|
|
246
|
+
variant: "tertiary",
|
|
247
|
+
icon: "edit",
|
|
248
|
+
onClick: () => {
|
|
249
|
+
trackNavigation({
|
|
250
|
+
userEvents,
|
|
251
|
+
actionType: "edit",
|
|
252
|
+
toForm: formName,
|
|
253
|
+
label: "Pencil icon"
|
|
254
|
+
});
|
|
255
|
+
editForm(formId);
|
|
256
|
+
},
|
|
257
|
+
ariaLabel: t(($) => $["editForm"], { formName })
|
|
258
|
+
})]
|
|
259
|
+
});
|
|
260
|
+
const renderSummarySection = (fieldData, labelData = {}, formName, formId, useStructuredList) => {
|
|
261
|
+
const structuredListItems = Object.entries(fieldData).map(([key, value]) => {
|
|
262
|
+
return {
|
|
263
|
+
term: t(($) => $[labelData[key] || key]),
|
|
264
|
+
details: value
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
return !useStructuredList ? /* @__PURE__ */ jsxs(List, {
|
|
268
|
+
variant: "grouped-secondary",
|
|
269
|
+
children: [showSectionHeader && summarySectionHeader(formName, formId), /* @__PURE__ */ jsx("dl", {
|
|
270
|
+
className: Summary_module_default.summaryList,
|
|
271
|
+
children: Array.isArray(fieldData) ? fieldData.map((item) => renderBulletedListField(item)) : renderSummaryItems(fieldData, labelData)
|
|
272
|
+
})]
|
|
273
|
+
}) : /* @__PURE__ */ jsxs(List, {
|
|
274
|
+
variant: "grouped-secondary",
|
|
275
|
+
children: [showSectionHeader && summarySectionHeader(formName, formId), /* @__PURE__ */ jsx(StructuredList, { items: structuredListItems })]
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
const renderSummaryContent = (summaryData, useStructuredList) => {
|
|
279
|
+
const summaryList = [];
|
|
280
|
+
forms.forEach(({ formId, formName }) => {
|
|
281
|
+
const currentFormData = summaryData[formId];
|
|
282
|
+
if (!currentFormData || Object.values(currentFormData).every((value) => isEmpty(value)) || formId === summaryStep.formId || omitted.forms?.includes(formId)) return;
|
|
283
|
+
const summaryItems = currentFormData.hasInnerForms ? renderInnerForms(labels?.[formId], formId, currentFormData) : renderSummarySection(currentFormData, labels?.[formId], t(($) => $[typeof labels?.[formId] === "string" ? labels[formId] : formName]), formId, useStructuredList);
|
|
284
|
+
summaryList.push(summaryItems);
|
|
285
|
+
});
|
|
286
|
+
return summaryList;
|
|
287
|
+
};
|
|
288
|
+
const renderInnerForms = (labelData, parentFormId, innerForms = {}) => {
|
|
289
|
+
if (!innerForms) return [];
|
|
290
|
+
const dataList = [];
|
|
291
|
+
Object.entries(innerForms).forEach(([innerFormName, innerFormFieldData]) => {
|
|
292
|
+
const formName = t(($) => $[labelData?.[innerFormName] || innerFormName]);
|
|
293
|
+
if (typeof innerFormFieldData === "object" && innerFormFieldData !== null) {
|
|
294
|
+
if (Object.values(innerFormFieldData).every((value) => isEmpty(value))) return;
|
|
295
|
+
dataList.push(renderSummarySection(innerFormFieldData, labelData, formName, parentFormId));
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
return dataList;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Renders a single label-value pair as a field in the summary section.
|
|
302
|
+
*
|
|
303
|
+
* This helper function creates the markup for a single piece of data,
|
|
304
|
+
* displaying a label and its corresponding value using a definition list
|
|
305
|
+
* for semantic correctness (`<dt>` for label, `<dd>` for data).
|
|
306
|
+
*
|
|
307
|
+
* @param label The translated label to display for the field.
|
|
308
|
+
* @param value The value of the field, which can be a simple string or a JSX element for more complex rendering.
|
|
309
|
+
* @returns A JSX element representing the summary field.
|
|
310
|
+
*/
|
|
311
|
+
const renderField = (label, value) => /* @__PURE__ */ jsxs("div", {
|
|
312
|
+
className: Summary_module_default.summaryListItem,
|
|
313
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
314
|
+
className: Summary_module_default.summaryListItemKey,
|
|
315
|
+
children: label
|
|
316
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
317
|
+
className: Summary_module_default.summaryListItemValue,
|
|
318
|
+
children: value
|
|
319
|
+
})]
|
|
320
|
+
});
|
|
321
|
+
const renderBulletedListField = (item) => /* @__PURE__ */ jsx("ul", {
|
|
322
|
+
className: Summary_module_default.summaryContentList,
|
|
323
|
+
children: /* @__PURE__ */ jsx("li", { children: item })
|
|
324
|
+
});
|
|
325
|
+
/**
|
|
326
|
+
* Recursively renders the data fields for a summary section.
|
|
327
|
+
*
|
|
328
|
+
* This function iterates through the properties of the `formData` object.
|
|
329
|
+
* It handles different data types by:
|
|
330
|
+
* - Displaying simple string or number values with their corresponding labels.
|
|
331
|
+
* - Handling 'role' arrays specifically to show a comma-separated list of roles.
|
|
332
|
+
* - Recognizing and rendering `SummaryItem` objects with their custom labels and values.
|
|
333
|
+
* - Recursively calling itself for nested objects to render their properties.
|
|
334
|
+
*
|
|
335
|
+
* Fields listed in the `omitted.keys` prop are skipped.
|
|
336
|
+
*
|
|
337
|
+
* @param formData The data object for the current section, containing key-value pairs to be rendered.
|
|
338
|
+
* @param labelData A map of field keys to their corresponding translation keys for fetching display labels.
|
|
339
|
+
* @returns An array of JSX elements representing the rendered summary fields for the section.
|
|
340
|
+
*/
|
|
341
|
+
const renderSummaryItems = (formData = {}, labelData = {}) => {
|
|
342
|
+
if (!formData) return [];
|
|
343
|
+
if (formData?.idVerificationMethod === "instantVerification") return [renderField(t(($) => $["verificationMethod"]), /* @__PURE__ */ jsx(Image, {
|
|
344
|
+
lazyLoadedImage: onfidoLogo,
|
|
345
|
+
className: Summary_module_default.summaryContentLogo,
|
|
346
|
+
alt: "onfido-logo"
|
|
347
|
+
}))];
|
|
348
|
+
const dataList = [];
|
|
349
|
+
Object.entries(formData).forEach(([field, fieldData]) => {
|
|
350
|
+
if (omitted.keys?.includes(field) || !fieldData) return;
|
|
351
|
+
const fieldName = t(($) => $[labelData[field] || field]);
|
|
352
|
+
if (field === "role" && Array.isArray(fieldData)) {
|
|
353
|
+
const label = fieldData.length > 1 ? t(($) => $["roles"]) : fieldName;
|
|
354
|
+
const roles = fieldData.map((role) => t(($) => $[getRoleName(role)])).join(", ");
|
|
355
|
+
dataList.push(renderField(label, roles));
|
|
356
|
+
} else if (isSummaryItem(fieldData)) {
|
|
357
|
+
const { summaryLabel, summaryValue, preTranslated } = fieldData;
|
|
358
|
+
if (preTranslated) dataList.push(renderField(summaryLabel, summaryValue));
|
|
359
|
+
else dataList.push(renderField(translateTranslatable(t, summaryLabel) ?? "", summaryValue));
|
|
360
|
+
} else if (typeof fieldData === "object") dataList.push(renderSummaryItems(fieldData, labelData));
|
|
361
|
+
else if (["string", "number"].includes(typeof fieldData)) dataList.push(renderField(fieldName, fieldData));
|
|
362
|
+
});
|
|
363
|
+
return dataList;
|
|
364
|
+
};
|
|
365
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
366
|
+
role: "region",
|
|
367
|
+
className: Summary_module_default.summary,
|
|
368
|
+
children: [showFormHeader && /* @__PURE__ */ jsx(Header, {
|
|
369
|
+
title: t(($) => $["summary"]),
|
|
370
|
+
description: t(($) => $["summaryDescription"])
|
|
371
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
372
|
+
className: Summary_module_default.summaryContent,
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ jsx(ErrorPanel, {
|
|
375
|
+
validationErrors: allValidationErrors,
|
|
376
|
+
verificationErrors: allVerificationErrors,
|
|
377
|
+
formUtils,
|
|
378
|
+
id: "ariaErrorField"
|
|
379
|
+
}),
|
|
380
|
+
renderSummaryContent(data, useStructuredList),
|
|
381
|
+
showLegalCaption && /* @__PURE__ */ jsx("div", {
|
|
382
|
+
className: Summary_module_default.summaryContentLegalCaption,
|
|
383
|
+
children: t(($) => $["summaryLegalCaption"])
|
|
384
|
+
}),
|
|
385
|
+
showTaxExemptedLegalCaption && /* @__PURE__ */ jsxs("div", {
|
|
386
|
+
className: Summary_module_default.summaryContentLegalCaption,
|
|
387
|
+
children: [/* @__PURE__ */ jsx("p", { children: t(($) => $["summaryTaxExemptionLegalCaptionTitle"]) }), /* @__PURE__ */ jsxs("ul", { children: [
|
|
388
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["summaryTaxExemptionLegalCaption_1"]) }),
|
|
389
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["summaryTaxExemptionLegalCaption_2"]) }),
|
|
390
|
+
/* @__PURE__ */ jsx("li", { children: t(($) => $["summaryTaxExemptionLegalCaption_3"]) })
|
|
391
|
+
] })]
|
|
392
|
+
})
|
|
393
|
+
]
|
|
394
|
+
})]
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/utils/scrollToInvalidField.ts
|
|
399
|
+
var INVALID_FIELD_SELECTOR = ".adyen-kyc-field--error, .adyen-kyc-label__text--error";
|
|
400
|
+
var SCROLLABLE_OVERFLOW_VALUES = new Set([
|
|
401
|
+
"auto",
|
|
402
|
+
"scroll",
|
|
403
|
+
"overlay"
|
|
404
|
+
]);
|
|
405
|
+
var isWindow = (container) => container === window;
|
|
406
|
+
var getInvalidFieldTarget = (element) => element.closest(".adyen-kyc-field") ?? element;
|
|
407
|
+
var isCustomElement = (element) => element.tagName.includes("-");
|
|
408
|
+
var queryInvalidField = (root) => {
|
|
409
|
+
const invalidField = root.querySelector(INVALID_FIELD_SELECTOR);
|
|
410
|
+
if (invalidField) return getInvalidFieldTarget(invalidField);
|
|
411
|
+
for (const element of Array.from(root.querySelectorAll("*")).filter(isCustomElement)) {
|
|
412
|
+
if (!element.shadowRoot) continue;
|
|
413
|
+
const shadowInvalidField = queryInvalidField(element.shadowRoot);
|
|
414
|
+
if (shadowInvalidField) return shadowInvalidField;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
};
|
|
418
|
+
var isElementVisibleInContainer = (element, container) => {
|
|
419
|
+
const elementRect = element.getBoundingClientRect();
|
|
420
|
+
if (isWindow(container)) return elementRect.top >= 0 && elementRect.bottom <= window.innerHeight;
|
|
421
|
+
const containerRect = container.getBoundingClientRect();
|
|
422
|
+
return elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;
|
|
423
|
+
};
|
|
424
|
+
var findScrollContainer = (element) => {
|
|
425
|
+
let parent = element.parentElement;
|
|
426
|
+
while (parent) {
|
|
427
|
+
const style = window.getComputedStyle(parent);
|
|
428
|
+
const canScroll = parent.scrollHeight > parent.clientHeight;
|
|
429
|
+
const hasScrollableOverflow = SCROLLABLE_OVERFLOW_VALUES.has(style.overflowY);
|
|
430
|
+
if (canScroll && hasScrollableOverflow) return parent;
|
|
431
|
+
parent = parent.parentElement;
|
|
432
|
+
}
|
|
433
|
+
return window;
|
|
434
|
+
};
|
|
435
|
+
var scrollElementIntoContainer = (element, container) => {
|
|
436
|
+
if (isWindow(container)) {
|
|
437
|
+
element.scrollIntoView({
|
|
438
|
+
behavior: "smooth",
|
|
439
|
+
block: "center"
|
|
440
|
+
});
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const elementRect = element.getBoundingClientRect();
|
|
444
|
+
const containerRect = container.getBoundingClientRect();
|
|
445
|
+
const offset = elementRect.top - containerRect.top - containerRect.height / 3;
|
|
446
|
+
container.scrollBy({
|
|
447
|
+
top: offset,
|
|
448
|
+
behavior: "smooth"
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
var scrollToInvalidField = () => {
|
|
452
|
+
const invalidField = queryInvalidField(document);
|
|
453
|
+
if (!invalidField) return;
|
|
454
|
+
const container = findScrollContainer(invalidField);
|
|
455
|
+
if (isElementVisibleInContainer(invalidField, container)) return;
|
|
456
|
+
scrollElementIntoContainer(invalidField, container);
|
|
457
|
+
};
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/hooks/useFormComposer.ts
|
|
460
|
+
var logger$2 = createLogger();
|
|
461
|
+
/**
|
|
462
|
+
* The step we open to for editing an existing entity should be the summary if there are verification errors
|
|
463
|
+
* Otherwise (including for a new entity), just show the first step
|
|
464
|
+
*/
|
|
465
|
+
var getOpeningStep = (forms, remediationActions) => {
|
|
466
|
+
if (remediationActions && Object.keys(remediationActions).length > 0) {
|
|
467
|
+
const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => rem.forms?.length > 0);
|
|
468
|
+
if (allRemediationActions.length === 1 && allRemediationActions[0]?.forms.length === 1) {
|
|
469
|
+
const form = forms.find((form) => form?.formId === allRemediationActions[0]?.forms[0]);
|
|
470
|
+
if (form) return form;
|
|
471
|
+
}
|
|
472
|
+
return forms[forms.length - 1];
|
|
473
|
+
}
|
|
474
|
+
return forms[0];
|
|
475
|
+
};
|
|
476
|
+
var useFormComposer = ({ problems, navigationTrackingParams, forms, externalBackClick, onSubmit, triggerValidation }) => {
|
|
477
|
+
const userEvents = useAnalyticsContext();
|
|
478
|
+
const [shouldValidate, setShouldValidate] = useState$1(false);
|
|
479
|
+
const [activeForm, setActiveForm] = useState$1(forms[0]);
|
|
480
|
+
const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
|
|
481
|
+
const getFormIndex = (formId) => forms.findIndex((form) => form.formId === formId);
|
|
482
|
+
const currentStep = getFormIndex(activeForm.formId);
|
|
483
|
+
const totalSteps = forms.length;
|
|
484
|
+
const isFinalStep = currentStep === totalSteps - 1;
|
|
485
|
+
const isFirstStep = currentStep === 0;
|
|
486
|
+
const firstStepId = forms[0]?.formId;
|
|
487
|
+
usePageLandedEvent(activeForm.formName);
|
|
488
|
+
const [oldForms, setOldForms] = useState$1(forms);
|
|
489
|
+
if (oldForms !== forms) {
|
|
490
|
+
setActiveForm((activeForm) => forms.find(({ formId }) => formId === activeForm.formId) ?? activeForm);
|
|
491
|
+
setOldForms(forms);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Opening step can be calculated once since the problems are already known on drop-in load
|
|
495
|
+
*/
|
|
496
|
+
const [oldFirstStepId, setOldFirstStepId] = useState$1(void 0);
|
|
497
|
+
if (oldFirstStepId !== firstStepId) {
|
|
498
|
+
/** TODO: need a better solution
|
|
499
|
+
* If firstStepId changes it means form configurations are being setup,
|
|
500
|
+
* not able to put forms as the dependency here as it also updates whenever validity changes
|
|
501
|
+
* should separate out forms into forms and validity
|
|
502
|
+
***/
|
|
503
|
+
setActiveForm(getOpeningStep(forms, problems?.remediationActions));
|
|
504
|
+
setOldFirstStepId(firstStepId);
|
|
505
|
+
}
|
|
506
|
+
const gotoFormByFormIndex = (nextFormIndex, currentForms) => {
|
|
507
|
+
setActiveForm(currentForms?.[nextFormIndex] ?? forms[nextFormIndex]);
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* We often run into a situation where we want to navigate to a specific form immediately after
|
|
511
|
+
* rearranging the forms in the flow.
|
|
512
|
+
*
|
|
513
|
+
* The issue here is that the callback, (e.g. {@link IdVerificationMethod.handleVerifyByInvite})
|
|
514
|
+
* has a reference only to the current forms, not what the forms will be post-rearrangement.
|
|
515
|
+
* Hence, it is impossible to call {@link gotoFormByFormIndex} because we have no idea what the
|
|
516
|
+
* eventual index of the form will be.
|
|
517
|
+
*
|
|
518
|
+
* The solution: set a desired form ID, then resolve the navigation as part of the render
|
|
519
|
+
* once {@link forms} contains it. The subsequent {@link gotoFormByFormIndex} will immediately
|
|
520
|
+
* cancel the current render and trigger a new one.
|
|
521
|
+
*/
|
|
522
|
+
const [desiredFormId, setDesiredFormId] = useState$1();
|
|
523
|
+
if (desiredFormId) {
|
|
524
|
+
const targetFormIndex = forms.findIndex((form) => form.formId === desiredFormId);
|
|
525
|
+
if (targetFormIndex === -1) logger$2.warn(`Desired form ${desiredFormId} not present. \nCurrent forms: ${forms.map((f) => f.formId).join(", ")}`);
|
|
526
|
+
else {
|
|
527
|
+
setDesiredFormId(void 0);
|
|
528
|
+
gotoFormByFormIndex(targetFormIndex);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
const gotoFormByFormId = (formId) => {
|
|
532
|
+
setDesiredFormId(formId);
|
|
533
|
+
};
|
|
534
|
+
const trackSubmitClick = () => {
|
|
535
|
+
trackNavigation({
|
|
536
|
+
userEvents,
|
|
537
|
+
actionType: "submit",
|
|
538
|
+
label: "submit",
|
|
539
|
+
additionalTrackingParams: navigationTrackingParams
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
const handleNextClick = async (updatedForms) => {
|
|
543
|
+
const currentForms = updatedForms ?? forms;
|
|
544
|
+
if (isFormSummaryStep(activeForm)) {
|
|
545
|
+
trackSubmitClick();
|
|
546
|
+
onSubmit();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Returns validation result of async validators if any
|
|
551
|
+
*/
|
|
552
|
+
const isAsyncValidationValid = await triggerValidation?.(activeForm.formId) ?? true;
|
|
553
|
+
/**
|
|
554
|
+
* Checks if both static validations and asyncValidations pass
|
|
555
|
+
*/
|
|
556
|
+
if (!activeForm.isValid || !isAsyncValidationValid) {
|
|
557
|
+
/**
|
|
558
|
+
* shouldValidate is not required with useMultiForm
|
|
559
|
+
*/
|
|
560
|
+
setShouldValidate(true);
|
|
561
|
+
requestAnimationFrame(scrollToInvalidField);
|
|
562
|
+
trackNavigation({
|
|
563
|
+
userEvents,
|
|
564
|
+
actionType: "next",
|
|
565
|
+
label: "next",
|
|
566
|
+
returnValue: "validation error",
|
|
567
|
+
additionalTrackingParams: navigationTrackingParams
|
|
568
|
+
});
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (isFinalStep) {
|
|
572
|
+
trackSubmitClick();
|
|
573
|
+
onSubmit();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
setShouldValidate(false);
|
|
577
|
+
const toFormIndex = currentStep + 1;
|
|
578
|
+
gotoFormByFormIndex(toFormIndex, currentForms);
|
|
579
|
+
trackNavigation({
|
|
580
|
+
userEvents,
|
|
581
|
+
actionType: "next",
|
|
582
|
+
toForm: currentForms[toFormIndex]?.formName,
|
|
583
|
+
label: "next",
|
|
584
|
+
returnValue: "success",
|
|
585
|
+
additionalTrackingParams: navigationTrackingParams
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
const handleBackClick = () => {
|
|
589
|
+
if (currentStep > 0) {
|
|
590
|
+
const toForm = forms[currentStep - 1];
|
|
591
|
+
setActiveForm(toForm);
|
|
592
|
+
trackNavigation({
|
|
593
|
+
userEvents,
|
|
594
|
+
actionType: "back",
|
|
595
|
+
toForm: toForm?.formName,
|
|
596
|
+
label: "back",
|
|
597
|
+
additionalTrackingParams: navigationTrackingParams
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
return {
|
|
602
|
+
handleBackClick: isFirstStep ? externalBackClick : handleBackClick,
|
|
603
|
+
handleNextClick,
|
|
604
|
+
gotoFormByFormIndex,
|
|
605
|
+
gotoFormByFormId,
|
|
606
|
+
activeForm,
|
|
607
|
+
shouldValidate,
|
|
608
|
+
setShouldValidate,
|
|
609
|
+
steps: {
|
|
610
|
+
current: currentStep,
|
|
611
|
+
total: totalSteps
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/hooks/useMultiForm/reducer.ts
|
|
617
|
+
var hasValueChanged = (newData, prevData) => {
|
|
618
|
+
if (typeof newData === "object") return !objectsDeepEqual(newData, prevData);
|
|
619
|
+
return newData !== prevData;
|
|
620
|
+
};
|
|
621
|
+
/** Formats and validates a field */
|
|
622
|
+
var processField = ({ key, value, formName, mode, defaultData, data, fieldContext, formatters, staticValidate }) => {
|
|
623
|
+
const formatterFn = formatters?.[key]?.formatter ? formatters[key]?.formatter : formatters?.[key];
|
|
624
|
+
const formattedValue = formatterFn && typeof formatterFn === "function" ? formatterFn(value, fieldContext) : value;
|
|
625
|
+
const fieldHasDefaultValue = key in (defaultData ?? {});
|
|
626
|
+
const fieldHasChanged = defaultData?.[key] !== value;
|
|
627
|
+
const validationResult = (fieldContext.state.obscuredFields?.includes(key) ? fieldHasChanged : fieldHasChanged || fieldHasDefaultValue) ? staticValidate({
|
|
628
|
+
key,
|
|
629
|
+
value: formattedValue,
|
|
630
|
+
mode,
|
|
631
|
+
formName
|
|
632
|
+
}, data, fieldContext) : new ValidationResult([{
|
|
633
|
+
isValid: true,
|
|
634
|
+
hasError: false
|
|
635
|
+
}]);
|
|
636
|
+
const asyncValidationResult = fieldContext.state?.asyncErrors?.[key];
|
|
637
|
+
/** Add any existing async validation result to validation result */
|
|
638
|
+
if (asyncValidationResult) validationResult.addError(asyncValidationResult);
|
|
639
|
+
return [formattedValue, validationResult];
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* The function takes in the below params and spits out an initial state, by running the validations
|
|
643
|
+
* across all forms and fields. It makes sure all validations are done and only sets the validity
|
|
644
|
+
* instead of the errors, this is to avoid users seeing error immaturely on initial load.
|
|
645
|
+
*
|
|
646
|
+
* @param requiredFields
|
|
647
|
+
* @param staticValidate
|
|
648
|
+
* @param asyncValidate
|
|
649
|
+
* @param defaultData
|
|
650
|
+
* @param obscuredFields
|
|
651
|
+
* @param optionalFields
|
|
652
|
+
* @param trustedFields
|
|
653
|
+
* @param fieldProblems
|
|
654
|
+
* @param formatters
|
|
655
|
+
* @param data
|
|
656
|
+
*/
|
|
657
|
+
function init({ requiredFields, staticValidate, defaultData, obscuredFields, optionalFields, trustedFields, fieldProblems, formatters, data, asyncErrors }) {
|
|
658
|
+
/**
|
|
659
|
+
* Fetches the validation result of a field in a form
|
|
660
|
+
* @param fieldKey
|
|
661
|
+
* @param formName
|
|
662
|
+
*/
|
|
663
|
+
const getProcessedState = (fieldKey, formName) => {
|
|
664
|
+
const [formattedValue, validationResult] = processField({
|
|
665
|
+
key: fieldKey,
|
|
666
|
+
value: data?.[formName]?.[fieldKey] ?? defaultData?.[formName]?.[fieldKey] ?? null,
|
|
667
|
+
mode: "blur",
|
|
668
|
+
formName,
|
|
669
|
+
formatters: formatters?.[formName],
|
|
670
|
+
defaultData: defaultData?.[formName],
|
|
671
|
+
data,
|
|
672
|
+
fieldContext: { state: {
|
|
673
|
+
data: data?.[formName],
|
|
674
|
+
obscuredFields: obscuredFields?.[formName],
|
|
675
|
+
optionalFields: optionalFields?.[formName],
|
|
676
|
+
trustedFields: trustedFields?.[formName],
|
|
677
|
+
requiredFields: requiredFields?.[formName],
|
|
678
|
+
asyncErrors: asyncErrors?.[formName]
|
|
679
|
+
} },
|
|
680
|
+
staticValidate
|
|
681
|
+
});
|
|
682
|
+
return {
|
|
683
|
+
valid: validationResult.isValid && !fieldProblems?.[formName]?.[fieldKey] || false,
|
|
684
|
+
errors: null,
|
|
685
|
+
data: formattedValue,
|
|
686
|
+
fieldProblems: fieldProblems?.[formName]?.[fieldKey]
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* requiredFields can be undefined if the configuration api call is not yet completed
|
|
691
|
+
* returned default state in this case
|
|
692
|
+
*/
|
|
693
|
+
if (!requiredFields) return {
|
|
694
|
+
data: defaultData,
|
|
695
|
+
errors: {},
|
|
696
|
+
fieldProblems: {},
|
|
697
|
+
valid: {},
|
|
698
|
+
requiredFields: {},
|
|
699
|
+
asyncErrors: {},
|
|
700
|
+
defaultData
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Make sure forms containing only optional fields are also taken into account
|
|
704
|
+
*/
|
|
705
|
+
const formsForOptionalFields = Object.keys(optionalFields ?? {});
|
|
706
|
+
const formsForRequiredFields = Object.keys(requiredFields);
|
|
707
|
+
/**
|
|
708
|
+
* Visits every field and builds a state with the validity
|
|
709
|
+
*/
|
|
710
|
+
return Array.from(new Set([...formsForOptionalFields, ...formsForRequiredFields])).reduce((acc, formName) => {
|
|
711
|
+
const form = formName;
|
|
712
|
+
const optionalsFormFields = optionalFields?.[form] ?? [];
|
|
713
|
+
const requiredFormFields = requiredFields?.[form] ?? [];
|
|
714
|
+
const formState = [...optionalsFormFields, ...requiredFormFields].reduce((acc, field) => {
|
|
715
|
+
const { valid, errors, data, fieldProblems: processedFieldProblems } = getProcessedState(field, form);
|
|
716
|
+
return {
|
|
717
|
+
...acc,
|
|
718
|
+
data: {
|
|
719
|
+
...acc.data,
|
|
720
|
+
[field]: data
|
|
721
|
+
},
|
|
722
|
+
valid: {
|
|
723
|
+
...acc.valid,
|
|
724
|
+
[field]: valid
|
|
725
|
+
},
|
|
726
|
+
errors: {
|
|
727
|
+
...acc.errors,
|
|
728
|
+
[field]: errors
|
|
729
|
+
},
|
|
730
|
+
fieldProblems: {
|
|
731
|
+
...acc.fieldProblems,
|
|
732
|
+
...processedFieldProblems ? { [field]: processedFieldProblems } : {}
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}, {});
|
|
736
|
+
return {
|
|
737
|
+
requiredFields,
|
|
738
|
+
data: {
|
|
739
|
+
...acc.data,
|
|
740
|
+
[formName]: formState.data
|
|
741
|
+
},
|
|
742
|
+
valid: {
|
|
743
|
+
...acc.valid,
|
|
744
|
+
[formName]: formState.valid
|
|
745
|
+
},
|
|
746
|
+
errors: {
|
|
747
|
+
...acc.errors,
|
|
748
|
+
[formName]: formState.errors
|
|
749
|
+
},
|
|
750
|
+
fieldProblems: {
|
|
751
|
+
...acc.fieldProblems,
|
|
752
|
+
[formName]: formState.fieldProblems
|
|
753
|
+
},
|
|
754
|
+
asyncErrors: { ...acc.asyncErrors },
|
|
755
|
+
obscuredFields,
|
|
756
|
+
optionalFields,
|
|
757
|
+
trustedFields,
|
|
758
|
+
defaultData
|
|
759
|
+
};
|
|
760
|
+
}, {
|
|
761
|
+
requiredFields,
|
|
762
|
+
data: {},
|
|
763
|
+
valid: {},
|
|
764
|
+
errors: {},
|
|
765
|
+
fieldProblems: {},
|
|
766
|
+
obscuredFields,
|
|
767
|
+
optionalFields,
|
|
768
|
+
trustedFields,
|
|
769
|
+
asyncErrors: {}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
function reducer({ staticValidate, obscuredFields, optionalFields, trustedFields, formatters, defaultData }) {
|
|
773
|
+
return (state, { type, key, mode, value, formData, formName, selectedSchema, innerFormFields, requiredFields, optionalFields: newOptionalFields, asyncValidationResults }) => {
|
|
774
|
+
const clonedState = structuredClone(state);
|
|
775
|
+
switch (type) {
|
|
776
|
+
case "setData":
|
|
777
|
+
if (!key || !formName) return state;
|
|
778
|
+
clonedState.data[formName] ??= {};
|
|
779
|
+
clonedState.data[formName][key] = value;
|
|
780
|
+
return clonedState;
|
|
781
|
+
case "setFormData": {
|
|
782
|
+
if (!formName || !formData) return state;
|
|
783
|
+
const formRequiredFields = clonedState.requiredFields?.[formName] ?? [];
|
|
784
|
+
const formOptionalFields = clonedState.optionalFields?.[formName] ?? [];
|
|
785
|
+
const allowedFields = [...formRequiredFields, ...formOptionalFields];
|
|
786
|
+
const filteredUpdates = {};
|
|
787
|
+
for (const formDataKey in formData) if (allowedFields.includes(formDataKey)) filteredUpdates[formDataKey] = formData[formDataKey];
|
|
788
|
+
clonedState.data[formName] = filteredUpdates;
|
|
789
|
+
const formValidity = allowedFields.reduce((acc, field) => {
|
|
790
|
+
const [, validation] = processField({
|
|
791
|
+
key: field,
|
|
792
|
+
value: filteredUpdates[field],
|
|
793
|
+
mode: "blur",
|
|
794
|
+
formName,
|
|
795
|
+
defaultData: defaultData?.[formName],
|
|
796
|
+
data: clonedState.data,
|
|
797
|
+
formatters: formatters?.[formName],
|
|
798
|
+
fieldContext: { state: {
|
|
799
|
+
data: clonedState?.data?.[formName],
|
|
800
|
+
obscuredFields: obscuredFields?.[formName],
|
|
801
|
+
optionalFields: optionalFields?.[formName],
|
|
802
|
+
trustedFields: trustedFields?.[formName],
|
|
803
|
+
errors: clonedState.errors?.[formName],
|
|
804
|
+
valid: clonedState.valid?.[formName],
|
|
805
|
+
fieldProblems: clonedState.fieldProblems?.[formName],
|
|
806
|
+
asyncErrors: clonedState.asyncErrors?.[formName]
|
|
807
|
+
} },
|
|
808
|
+
staticValidate
|
|
809
|
+
});
|
|
810
|
+
return {
|
|
811
|
+
...acc,
|
|
812
|
+
[field]: validation.isValid
|
|
813
|
+
};
|
|
814
|
+
}, {});
|
|
815
|
+
clonedState.data[formName] = filteredUpdates;
|
|
816
|
+
clonedState.valid[formName] = formValidity;
|
|
817
|
+
return clonedState;
|
|
818
|
+
}
|
|
819
|
+
case "setValid":
|
|
820
|
+
if (!key || !formName || clonedState.valid[formName]?.[key] === value) return state;
|
|
821
|
+
clonedState.valid[formName] ??= {};
|
|
822
|
+
clonedState.valid[formName][key] = !!value;
|
|
823
|
+
return clonedState;
|
|
824
|
+
case "setErrors":
|
|
825
|
+
if (!key || !formName) return state;
|
|
826
|
+
clonedState.errors[formName] ??= {};
|
|
827
|
+
clonedState.errors[formName][key] = value;
|
|
828
|
+
return clonedState;
|
|
829
|
+
case "setRequiredFields": {
|
|
830
|
+
/**
|
|
831
|
+
* If defaultData changes reset the data in the form to new defaultData
|
|
832
|
+
* Fetching documents are bit delayed, this accomodates that delay
|
|
833
|
+
*/
|
|
834
|
+
const hasDefaultDataChanged = !objectsDeepEqual(defaultData, state.defaultData);
|
|
835
|
+
if (objectsDeepEqual(requiredFields, clonedState.requiredFields) && objectsDeepEqual(newOptionalFields, clonedState.optionalFields) && !hasDefaultDataChanged) return state;
|
|
836
|
+
const updatedData = hasDefaultDataChanged ? defaultData : structuredClone(clonedState.data);
|
|
837
|
+
/**
|
|
838
|
+
* When schema changes without a defaultData refresh, re-add any fields that were
|
|
839
|
+
* previously removed and are now reintroduced from the local stash.
|
|
840
|
+
*
|
|
841
|
+
* This preserves user-entered values across dynamic required/optional transitions,
|
|
842
|
+
* such as when rule-driven fields are temporarily hidden and then shown again.
|
|
843
|
+
*/
|
|
844
|
+
if (!hasDefaultDataChanged && updatedData) for (const formName in requiredFields) {
|
|
845
|
+
const form = formName;
|
|
846
|
+
const prevFields = [...clonedState.requiredFields?.[form] ?? [], ...clonedState.optionalFields?.[form] ?? []];
|
|
847
|
+
[...requiredFields?.[form] ?? [], ...newOptionalFields?.[form] ?? []].filter((field) => !prevFields.includes(field)).forEach((field) => {
|
|
848
|
+
const currentValue = updatedData?.[form]?.[field];
|
|
849
|
+
const localValue = clonedState.local?.[form]?.data?.[field];
|
|
850
|
+
if (typeof currentValue === "undefined" && typeof localValue !== "undefined") {
|
|
851
|
+
if (!updatedData[form]) return;
|
|
852
|
+
updatedData[form][field] = localValue;
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
const newState = init({
|
|
857
|
+
requiredFields,
|
|
858
|
+
data: updatedData,
|
|
859
|
+
fieldProblems: clonedState.fieldProblems,
|
|
860
|
+
obscuredFields,
|
|
861
|
+
optionalFields: newOptionalFields,
|
|
862
|
+
trustedFields,
|
|
863
|
+
staticValidate,
|
|
864
|
+
defaultData
|
|
865
|
+
});
|
|
866
|
+
if (hasDefaultDataChanged) return newState;
|
|
867
|
+
/**
|
|
868
|
+
* Persist values of fields that are being removed from the active schema into local.
|
|
869
|
+
*
|
|
870
|
+
* These values are later used to restore data for reintroduced fields in subsequent
|
|
871
|
+
* schema transitions, avoiding silent data loss during dynamic form updates.
|
|
872
|
+
*/
|
|
873
|
+
const local = Object.keys(requiredFields ?? {}).reduce((acc, formName) => {
|
|
874
|
+
const form = formName;
|
|
875
|
+
const prevFields = [...clonedState.requiredFields?.[form] ?? [], ...clonedState.optionalFields?.[form] ?? []];
|
|
876
|
+
const nextFields = [...requiredFields?.[form] ?? [], ...newOptionalFields?.[form] ?? []];
|
|
877
|
+
const removedFields = prevFields.filter((field) => !nextFields.includes(field));
|
|
878
|
+
if (!removedFields.length) {
|
|
879
|
+
if (clonedState.local?.[form]) return {
|
|
880
|
+
...acc,
|
|
881
|
+
[form]: clonedState.local[form]
|
|
882
|
+
};
|
|
883
|
+
return acc;
|
|
884
|
+
}
|
|
885
|
+
const localFormData = {
|
|
886
|
+
...clonedState.local?.[form]?.data ?? {},
|
|
887
|
+
...removedFields.reduce((fieldAcc, field) => {
|
|
888
|
+
const value = clonedState.data?.[form]?.[field];
|
|
889
|
+
if (typeof value !== "undefined") return {
|
|
890
|
+
...fieldAcc,
|
|
891
|
+
[field]: value
|
|
892
|
+
};
|
|
893
|
+
return fieldAcc;
|
|
894
|
+
}, {})
|
|
895
|
+
};
|
|
896
|
+
return {
|
|
897
|
+
...acc,
|
|
898
|
+
[form]: {
|
|
899
|
+
...clonedState.local?.[form] ?? {},
|
|
900
|
+
data: localFormData
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
}, {});
|
|
904
|
+
return {
|
|
905
|
+
...newState,
|
|
906
|
+
local
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
case "setInnerFormRequiredFields": {
|
|
910
|
+
/**
|
|
911
|
+
* This sets the requiredFields in a single form.
|
|
912
|
+
* Ideally this should not be used anywhere, as this goes against the idea of having all
|
|
913
|
+
* the rules of calculating requiredFields in a single place. keeping this in case we have
|
|
914
|
+
* any exceptional scenarios where this would be required. Can be removed once all forms
|
|
915
|
+
* migrated to useMultiform
|
|
916
|
+
*/
|
|
917
|
+
if (!innerFormFields || !formName) return state;
|
|
918
|
+
const requiredFields = {
|
|
919
|
+
...clonedState.requiredFields,
|
|
920
|
+
[formName]: innerFormFields
|
|
921
|
+
};
|
|
922
|
+
const defaultState = init({
|
|
923
|
+
requiredFields,
|
|
924
|
+
defaultData,
|
|
925
|
+
fieldProblems: clonedState.fieldProblems,
|
|
926
|
+
obscuredFields,
|
|
927
|
+
optionalFields,
|
|
928
|
+
trustedFields,
|
|
929
|
+
staticValidate,
|
|
930
|
+
data: defaultData
|
|
931
|
+
});
|
|
932
|
+
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));
|
|
933
|
+
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));
|
|
934
|
+
const formLocal = {
|
|
935
|
+
data: omitKeys(clonedState.data?.[formName], newFields),
|
|
936
|
+
errors: omitKeys(clonedState.errors?.[formName], newFields),
|
|
937
|
+
valid: omitKeys(clonedState.valid?.[formName], newFields),
|
|
938
|
+
fieldProblems: omitKeys(clonedState.fieldProblems?.[formName], newFields)
|
|
939
|
+
};
|
|
940
|
+
const local = {
|
|
941
|
+
...clonedState.local,
|
|
942
|
+
[formName]: formLocal
|
|
943
|
+
};
|
|
944
|
+
const updatedFormData = addKeys(omitKeys(clonedState.data?.[formName], removedFields), newFields, null, defaultState.data?.[formName], clonedState.local?.[formName].data);
|
|
945
|
+
const updatedData = {
|
|
946
|
+
...clonedState.data,
|
|
947
|
+
[formName]: updatedFormData
|
|
948
|
+
};
|
|
949
|
+
const updatedFormValidity = addKeys(omitKeys(clonedState.valid?.[formName], removedFields), newFields, false, defaultState.valid?.[formName], clonedState.local?.[formName].valid);
|
|
950
|
+
const updatedValidity = {
|
|
951
|
+
...clonedState.valid,
|
|
952
|
+
[formName]: updatedFormValidity
|
|
953
|
+
};
|
|
954
|
+
const updatedFormErrors = addKeys(omitKeys(clonedState.errors?.[formName], removedFields), newFields, null, defaultState.errors?.[formName], clonedState.local?.[formName].errors);
|
|
955
|
+
const updatedErrors = {
|
|
956
|
+
...clonedState.errors,
|
|
957
|
+
[formName]: updatedFormErrors
|
|
958
|
+
};
|
|
959
|
+
const updatedFormFieldProblems = addKeys(omitKeys(clonedState.fieldProblems?.[formName], removedFields), newFields, false, defaultState.fieldProblems?.[formName], clonedState.local?.[formName].fieldProblems);
|
|
960
|
+
return {
|
|
961
|
+
requiredFields,
|
|
962
|
+
data: updatedData,
|
|
963
|
+
valid: updatedValidity,
|
|
964
|
+
errors: updatedErrors,
|
|
965
|
+
fieldProblems: {
|
|
966
|
+
...clonedState.fieldProblems,
|
|
967
|
+
[formName]: updatedFormFieldProblems
|
|
968
|
+
},
|
|
969
|
+
asyncErrors: clonedState.asyncErrors,
|
|
970
|
+
optionalFields,
|
|
971
|
+
trustedFields,
|
|
972
|
+
local,
|
|
973
|
+
defaultData
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
case "updateField": {
|
|
977
|
+
/**
|
|
978
|
+
* Called when a field value changes in form
|
|
979
|
+
* Validates the field and updates data, validity, error in the state for the field
|
|
980
|
+
*/
|
|
981
|
+
if (!key || !mode || !formName) return state;
|
|
982
|
+
const updatedData = {
|
|
983
|
+
...clonedState.data,
|
|
984
|
+
[formName]: {
|
|
985
|
+
...clonedState.data?.[formName],
|
|
986
|
+
[key]: value
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* Wipe async errors for the field if value has been changed
|
|
991
|
+
*/
|
|
992
|
+
const updatedAsyncErrors = hasValueChanged(value, clonedState.data?.[formName]?.[key]) ? {
|
|
993
|
+
...clonedState.asyncErrors,
|
|
994
|
+
[formName]: {
|
|
995
|
+
...clonedState.asyncErrors?.[formName],
|
|
996
|
+
[key]: null
|
|
997
|
+
}
|
|
998
|
+
} : clonedState.asyncErrors;
|
|
999
|
+
const [formattedValue, validation] = processField({
|
|
1000
|
+
key,
|
|
1001
|
+
value,
|
|
1002
|
+
mode,
|
|
1003
|
+
formName,
|
|
1004
|
+
defaultData: defaultData?.[formName],
|
|
1005
|
+
data: updatedData,
|
|
1006
|
+
formatters: formatters?.[formName],
|
|
1007
|
+
fieldContext: { state: {
|
|
1008
|
+
data: clonedState.data?.[formName],
|
|
1009
|
+
obscuredFields: obscuredFields?.[formName],
|
|
1010
|
+
optionalFields: optionalFields?.[formName],
|
|
1011
|
+
trustedFields: trustedFields?.[formName],
|
|
1012
|
+
errors: clonedState.errors[formName],
|
|
1013
|
+
valid: clonedState.valid[formName],
|
|
1014
|
+
fieldProblems: clonedState.fieldProblems[formName],
|
|
1015
|
+
asyncErrors: updatedAsyncErrors[formName]
|
|
1016
|
+
} },
|
|
1017
|
+
staticValidate
|
|
1018
|
+
});
|
|
1019
|
+
const clearFieldProblems = (clonedState.data?.[formName])?.[key] !== formattedValue;
|
|
1020
|
+
return {
|
|
1021
|
+
...clonedState,
|
|
1022
|
+
data: {
|
|
1023
|
+
...clonedState.data,
|
|
1024
|
+
[formName]: {
|
|
1025
|
+
...clonedState.data?.[formName],
|
|
1026
|
+
[key]: formattedValue
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
asyncErrors: updatedAsyncErrors,
|
|
1030
|
+
errors: {
|
|
1031
|
+
...clonedState.errors,
|
|
1032
|
+
[formName]: {
|
|
1033
|
+
...clonedState.errors[formName],
|
|
1034
|
+
[key]: validation.getError() ?? null
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
valid: {
|
|
1038
|
+
...clonedState.valid,
|
|
1039
|
+
[formName]: {
|
|
1040
|
+
...clonedState?.valid?.[formName],
|
|
1041
|
+
[key]: (validation.isValid && !clonedState.fieldProblems?.[formName]?.[key]) ?? false
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
fieldProblems: {
|
|
1045
|
+
...clonedState.fieldProblems,
|
|
1046
|
+
[formName]: {
|
|
1047
|
+
...clonedState.fieldProblems[formName],
|
|
1048
|
+
...!clearFieldProblems && clonedState.fieldProblems?.[formName]?.[key] ? { [key]: true } : {}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
case "validateForm": {
|
|
1054
|
+
/**
|
|
1055
|
+
* Called when triggerValidation('formName') is called, validates all the fields in the form
|
|
1056
|
+
* and populates the errors in the state
|
|
1057
|
+
*/
|
|
1058
|
+
if (!formName) return state;
|
|
1059
|
+
const formFields = clonedState.requiredFields?.[formName];
|
|
1060
|
+
if (!formFields) return state;
|
|
1061
|
+
const formState = (selectedSchema || formFields).reduce((acc, field) => {
|
|
1062
|
+
const formData = clonedState.data?.[formName];
|
|
1063
|
+
const [formattedValue, validation] = processField({
|
|
1064
|
+
key: field,
|
|
1065
|
+
mode: "blur",
|
|
1066
|
+
value: formData?.[field] ?? null,
|
|
1067
|
+
formName,
|
|
1068
|
+
defaultData: defaultData?.[formName],
|
|
1069
|
+
data: clonedState.data,
|
|
1070
|
+
formatters: formatters?.[formName],
|
|
1071
|
+
fieldContext: { state: {
|
|
1072
|
+
data: clonedState.data?.[formName],
|
|
1073
|
+
obscuredFields: obscuredFields?.[formName],
|
|
1074
|
+
optionalFields: optionalFields?.[formName],
|
|
1075
|
+
trustedFields: trustedFields?.[formName],
|
|
1076
|
+
errors: clonedState.errors[formName],
|
|
1077
|
+
valid: clonedState.valid[formName],
|
|
1078
|
+
fieldProblems: clonedState.fieldProblems[formName],
|
|
1079
|
+
asyncErrors: clonedState.asyncErrors[formName]
|
|
1080
|
+
} },
|
|
1081
|
+
staticValidate
|
|
1082
|
+
});
|
|
1083
|
+
const clearFieldProblems = (clonedState?.data?.[formName])?.[field] !== formattedValue;
|
|
1084
|
+
const fieldAsyncValidationResult = asyncValidationResults?.[field];
|
|
1085
|
+
return {
|
|
1086
|
+
data: formData,
|
|
1087
|
+
asyncErrors: {
|
|
1088
|
+
...acc.asyncErrors,
|
|
1089
|
+
[field]: fieldAsyncValidationResult?.getError() ?? null
|
|
1090
|
+
},
|
|
1091
|
+
errors: {
|
|
1092
|
+
...acc.errors,
|
|
1093
|
+
[field]: validation.getError() ?? fieldAsyncValidationResult?.getError() ?? null
|
|
1094
|
+
},
|
|
1095
|
+
valid: {
|
|
1096
|
+
...acc.valid,
|
|
1097
|
+
[field]: validation.isValid && (fieldAsyncValidationResult?.isValid ?? true) && !clonedState.fieldProblems[formName][field]
|
|
1098
|
+
},
|
|
1099
|
+
fieldProblems: {
|
|
1100
|
+
...acc.fieldProblems,
|
|
1101
|
+
...!clearFieldProblems && acc.fieldProblems?.[field] ? { [field]: true } : {}
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
}, {});
|
|
1105
|
+
return {
|
|
1106
|
+
...clonedState,
|
|
1107
|
+
errors: {
|
|
1108
|
+
...clonedState.errors,
|
|
1109
|
+
[formName]: formState.errors
|
|
1110
|
+
},
|
|
1111
|
+
asyncErrors: {
|
|
1112
|
+
...clonedState.asyncErrors,
|
|
1113
|
+
[formName]: formState.asyncErrors
|
|
1114
|
+
},
|
|
1115
|
+
valid: {
|
|
1116
|
+
...clonedState.valid,
|
|
1117
|
+
[formName]: formState.valid
|
|
1118
|
+
},
|
|
1119
|
+
fieldProblems: {
|
|
1120
|
+
...clonedState.fieldProblems,
|
|
1121
|
+
[formName]: formState.fieldProblems
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
default: throw new Error("Undefined useForm action");
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/hooks/useMultiForm/useMultiFormAsyncValidator.ts
|
|
1131
|
+
var logger$1 = createLogger();
|
|
1132
|
+
/**
|
|
1133
|
+
* Returns
|
|
1134
|
+
* - triggerAsyncValidation function which can execute the async validation for a field and populate the sync validation results
|
|
1135
|
+
* - asyncValidationResult state which keeps track of async validations of all fields.
|
|
1136
|
+
* @param asyncRules
|
|
1137
|
+
*/
|
|
1138
|
+
var useMultiFormAsyncValidator = (asyncRules) => {
|
|
1139
|
+
const validResult = {
|
|
1140
|
+
isValid: true,
|
|
1141
|
+
hasError: false
|
|
1142
|
+
};
|
|
1143
|
+
const triggerAsyncValidation = useCallback$1(async (field, formName, data) => {
|
|
1144
|
+
if (!asyncRules) return new ValidationResult([validResult]);
|
|
1145
|
+
const rule = typeof asyncRules === "function" ? asyncRules(data)[formName]?.[field] : asyncRules[formName][field];
|
|
1146
|
+
const value = data?.[formName]?.[field];
|
|
1147
|
+
if (!rule || !value) return new ValidationResult([validResult]);
|
|
1148
|
+
const isValid = await rule.asyncValidate(value).catch(logger$1.error);
|
|
1149
|
+
if (isValid === false) return new ValidationResult([{
|
|
1150
|
+
isValid,
|
|
1151
|
+
errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value) : rule.errorMessage,
|
|
1152
|
+
hasError: !isValid
|
|
1153
|
+
}]);
|
|
1154
|
+
return new ValidationResult([validResult]);
|
|
1155
|
+
}, [asyncRules]);
|
|
1156
|
+
const triggerAsyncFormValidation = async (formName, state, selectedSchema) => {
|
|
1157
|
+
const fields = selectedSchema ?? state.requiredFields?.[formName];
|
|
1158
|
+
if (!fields?.length) return { isValid: true };
|
|
1159
|
+
const asyncValidationResults = await fields.reduce(async (accPromise, fieldName) => {
|
|
1160
|
+
const acc = await accPromise;
|
|
1161
|
+
const asyncValidationResult = await triggerAsyncValidation(fieldName, formName, state.data);
|
|
1162
|
+
return {
|
|
1163
|
+
...acc,
|
|
1164
|
+
[fieldName]: asyncValidationResult
|
|
1165
|
+
};
|
|
1166
|
+
}, Promise.resolve({}));
|
|
1167
|
+
const isValid = Object.values(asyncValidationResults).every((validationResult) => validationResult.isValid);
|
|
1168
|
+
return {
|
|
1169
|
+
...asyncValidationResults,
|
|
1170
|
+
isValid
|
|
1171
|
+
};
|
|
1172
|
+
};
|
|
1173
|
+
return { triggerAsyncFormValidation };
|
|
1174
|
+
};
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region src/utils/validation/commonValidators.ts
|
|
1177
|
+
var isTruthyValidator = {
|
|
1178
|
+
validate: (value) => !!value,
|
|
1179
|
+
modes: ["blur"],
|
|
1180
|
+
errorMessage: "fieldIsRequired"
|
|
1181
|
+
};
|
|
1182
|
+
var isNotEmptyValidator = {
|
|
1183
|
+
validate: (value) => !isEmpty(value),
|
|
1184
|
+
modes: ["blur"],
|
|
1185
|
+
errorMessage: "fieldIsRequired"
|
|
1186
|
+
};
|
|
1187
|
+
//#endregion
|
|
1188
|
+
//#region src/hooks/useMultiForm/useMultiFormStaticValidator.ts
|
|
1189
|
+
var useMultiFormStaticValidator = (rules) => {
|
|
1190
|
+
const getRulesForField = useCallback$1((field, form, data) => {
|
|
1191
|
+
const fallbackRule = {
|
|
1192
|
+
validate: () => true,
|
|
1193
|
+
modes: ["blur", "input"]
|
|
1194
|
+
};
|
|
1195
|
+
if (!form) return [fallbackRule];
|
|
1196
|
+
const fieldRules = typeof rules === "function" ? rules(data)?.[form]?.[field] ?? [fallbackRule] : rules?.[form]?.[field] ?? [fallbackRule];
|
|
1197
|
+
return Array.isArray(fieldRules) ? fieldRules : [fieldRules];
|
|
1198
|
+
}, [rules]);
|
|
1199
|
+
return { triggerStaticValidation: useCallback$1(({ key, value, mode = "blur", formName }, data, context) => {
|
|
1200
|
+
const fieldRules = getRulesForField(key, formName, data);
|
|
1201
|
+
const isFieldOptional = !!context?.state.optionalFields?.includes(key);
|
|
1202
|
+
const isFieldObscured = !!context?.state.obscuredFields?.includes(key);
|
|
1203
|
+
if (!isFieldOptional) fieldRules.unshift(isNotEmptyValidator);
|
|
1204
|
+
return new ValidationResult(fieldRules.map((rule) => {
|
|
1205
|
+
const shouldValidate = rule.modes.includes(mode) && !isFieldObscured;
|
|
1206
|
+
const isValid = isFieldOptional && isEmpty(value) ? true : rule.validate(value, context);
|
|
1207
|
+
return {
|
|
1208
|
+
isValid,
|
|
1209
|
+
errorMessage: typeof rule.errorMessage === "function" ? rule.errorMessage(value, context) : rule.errorMessage,
|
|
1210
|
+
hasError: shouldValidate && !isValid
|
|
1211
|
+
};
|
|
1212
|
+
}));
|
|
1213
|
+
}, [getRulesForField]) };
|
|
1214
|
+
};
|
|
1215
|
+
//#endregion
|
|
1216
|
+
//#region src/hooks/useMultiForm/useMultiForm.ts
|
|
1217
|
+
function useMultiForm({ defaultData, rules, asyncRules, fieldProblems, allFields, requiredFields, obscuredFields, optionalFields, trustedFields, formatters }) {
|
|
1218
|
+
const { triggerStaticValidation } = useMultiFormStaticValidator(rules);
|
|
1219
|
+
const { triggerAsyncFormValidation } = useMultiFormAsyncValidator(asyncRules);
|
|
1220
|
+
const getRequiredFields = useMemo$1(() => typeof requiredFields === "function" ? requiredFields : () => requiredFields, [requiredFields]);
|
|
1221
|
+
const getSchema = useMemo$1(() => getRequiredFields(defaultData), [defaultData, getRequiredFields]);
|
|
1222
|
+
const getReducer = useCallback$1(() => reducer({
|
|
1223
|
+
staticValidate: triggerStaticValidation,
|
|
1224
|
+
defaultData,
|
|
1225
|
+
obscuredFields,
|
|
1226
|
+
optionalFields,
|
|
1227
|
+
trustedFields,
|
|
1228
|
+
formatters
|
|
1229
|
+
}), [
|
|
1230
|
+
triggerStaticValidation,
|
|
1231
|
+
obscuredFields,
|
|
1232
|
+
optionalFields,
|
|
1233
|
+
trustedFields,
|
|
1234
|
+
formatters,
|
|
1235
|
+
defaultData
|
|
1236
|
+
]);
|
|
1237
|
+
const initialData = useMemo$1(() => ({
|
|
1238
|
+
requiredFields: getSchema,
|
|
1239
|
+
defaultData,
|
|
1240
|
+
fieldProblems,
|
|
1241
|
+
obscuredFields,
|
|
1242
|
+
optionalFields,
|
|
1243
|
+
trustedFields,
|
|
1244
|
+
formatters,
|
|
1245
|
+
staticValidate: triggerStaticValidation,
|
|
1246
|
+
data: defaultData
|
|
1247
|
+
}), [
|
|
1248
|
+
getSchema,
|
|
1249
|
+
defaultData,
|
|
1250
|
+
fieldProblems,
|
|
1251
|
+
obscuredFields,
|
|
1252
|
+
optionalFields,
|
|
1253
|
+
trustedFields,
|
|
1254
|
+
formatters,
|
|
1255
|
+
triggerStaticValidation
|
|
1256
|
+
]);
|
|
1257
|
+
const [state, dispatch] = useReducer(getReducer(), initialData, init);
|
|
1258
|
+
const isValid = useMemo$1(() => {
|
|
1259
|
+
const formsForOptionalFields = Object.keys(state.optionalFields ?? {});
|
|
1260
|
+
const formsForRequiredFields = Object.keys(state.requiredFields ?? {});
|
|
1261
|
+
return Array.from(new Set([...formsForOptionalFields, ...formsForRequiredFields])).reduce((acc, formName) => {
|
|
1262
|
+
const form = formName;
|
|
1263
|
+
const optionalsFormFields = state.optionalFields?.[form] ?? [];
|
|
1264
|
+
const requiredFormFields = state.requiredFields?.[form] ?? [];
|
|
1265
|
+
const formFields = [...optionalsFormFields, ...requiredFormFields];
|
|
1266
|
+
const formValidity = state.valid[formName] ?? {};
|
|
1267
|
+
return {
|
|
1268
|
+
...acc,
|
|
1269
|
+
[formName]: Object.entries(formValidity)?.every(([field, valid]) => formFields.includes(field) ? valid : true)
|
|
1270
|
+
};
|
|
1271
|
+
}, {});
|
|
1272
|
+
}, [state.requiredFields, state.valid]);
|
|
1273
|
+
const getTargetValue = useCallback$1((formName, key, e) => {
|
|
1274
|
+
if (!e?.target) return e;
|
|
1275
|
+
if (e.target.type === "checkbox") return !state.data?.[formName][key];
|
|
1276
|
+
return e.target.value;
|
|
1277
|
+
}, [state.data]);
|
|
1278
|
+
const setErrors = useCallback$1((formName, key, value) => {
|
|
1279
|
+
dispatch({
|
|
1280
|
+
type: "setErrors",
|
|
1281
|
+
key,
|
|
1282
|
+
value,
|
|
1283
|
+
formName
|
|
1284
|
+
});
|
|
1285
|
+
}, []);
|
|
1286
|
+
const setValid = useCallback$1((formName, key, value) => {
|
|
1287
|
+
dispatch({
|
|
1288
|
+
type: "setValid",
|
|
1289
|
+
key,
|
|
1290
|
+
value,
|
|
1291
|
+
formName
|
|
1292
|
+
});
|
|
1293
|
+
}, []);
|
|
1294
|
+
const setData = useCallback$1((formName, key, value) => {
|
|
1295
|
+
dispatch({
|
|
1296
|
+
type: "setData",
|
|
1297
|
+
key,
|
|
1298
|
+
value,
|
|
1299
|
+
formName
|
|
1300
|
+
});
|
|
1301
|
+
}, []);
|
|
1302
|
+
const setFormData = useCallback$1((formName, formData) => {
|
|
1303
|
+
dispatch({
|
|
1304
|
+
type: "setFormData",
|
|
1305
|
+
formName,
|
|
1306
|
+
formData
|
|
1307
|
+
});
|
|
1308
|
+
}, []);
|
|
1309
|
+
const handleChangeFor = useCallback$1((formName, key, mode = "blur") => (e) => {
|
|
1310
|
+
dispatch({
|
|
1311
|
+
type: "updateField",
|
|
1312
|
+
key,
|
|
1313
|
+
value: getTargetValue(formName, key, e),
|
|
1314
|
+
mode,
|
|
1315
|
+
formName
|
|
1316
|
+
});
|
|
1317
|
+
}, [getTargetValue]);
|
|
1318
|
+
const triggerValidation = useCallback$1(async (formName, selectedSchema) => {
|
|
1319
|
+
const asyncValidationResults = await triggerAsyncFormValidation(formName, state, selectedSchema);
|
|
1320
|
+
dispatch({
|
|
1321
|
+
type: "validateForm",
|
|
1322
|
+
formName,
|
|
1323
|
+
selectedSchema,
|
|
1324
|
+
asyncValidationResults
|
|
1325
|
+
});
|
|
1326
|
+
return asyncValidationResults.isValid;
|
|
1327
|
+
}, [state, triggerAsyncFormValidation]);
|
|
1328
|
+
const resetToDefaultData = useCallback$1(() => {
|
|
1329
|
+
if (!getSchema) return;
|
|
1330
|
+
Object.entries(getSchema).forEach(([formName]) => {
|
|
1331
|
+
const form = formName;
|
|
1332
|
+
const formData = defaultData?.[form];
|
|
1333
|
+
getSchema[form].forEach((field) => {
|
|
1334
|
+
if (!formData || typeof formData[field] !== "undefined") {
|
|
1335
|
+
handleChangeFor(form, field)(formData);
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
setValid(form, field, false);
|
|
1339
|
+
setErrors(form, field, null);
|
|
1340
|
+
setData(form, field, formData[field]);
|
|
1341
|
+
});
|
|
1342
|
+
});
|
|
1343
|
+
}, [
|
|
1344
|
+
defaultData,
|
|
1345
|
+
getSchema,
|
|
1346
|
+
handleChangeFor,
|
|
1347
|
+
setData,
|
|
1348
|
+
setErrors,
|
|
1349
|
+
setValid
|
|
1350
|
+
]);
|
|
1351
|
+
useEffect$1(() => {
|
|
1352
|
+
const requiredFields = getRequiredFields(state.data);
|
|
1353
|
+
if (!requiredFields) return;
|
|
1354
|
+
dispatch({
|
|
1355
|
+
type: "setRequiredFields",
|
|
1356
|
+
requiredFields,
|
|
1357
|
+
defaultData,
|
|
1358
|
+
optionalFields
|
|
1359
|
+
});
|
|
1360
|
+
}, [
|
|
1361
|
+
getRequiredFields,
|
|
1362
|
+
state.data,
|
|
1363
|
+
defaultData,
|
|
1364
|
+
optionalFields
|
|
1365
|
+
]);
|
|
1366
|
+
return {
|
|
1367
|
+
setData,
|
|
1368
|
+
setFormData,
|
|
1369
|
+
setValid,
|
|
1370
|
+
setErrors,
|
|
1371
|
+
handleChangeFor,
|
|
1372
|
+
triggerValidation,
|
|
1373
|
+
resetToDefaultData,
|
|
1374
|
+
isValid,
|
|
1375
|
+
allFields,
|
|
1376
|
+
requiredFields: state.requiredFields,
|
|
1377
|
+
optionalFields: state.optionalFields,
|
|
1378
|
+
trustedFields: state.trustedFields,
|
|
1379
|
+
obscuredFields: state.obscuredFields,
|
|
1380
|
+
valid: state.valid,
|
|
1381
|
+
errors: state.errors,
|
|
1382
|
+
data: state.data,
|
|
1383
|
+
fieldProblems: state.fieldProblems,
|
|
1384
|
+
defaultData,
|
|
1385
|
+
asyncErrors: state.asyncErrors
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
//#endregion
|
|
1389
|
+
//#region src/context/FormRouterContext/FormRouterContextProvider.tsx
|
|
1390
|
+
var logger = createLogger();
|
|
1391
|
+
function FormRouterContextProvider({ children, forms, setFormIndex, goToFormByFormId }) {
|
|
1392
|
+
const fieldActionsRef = useRef$1({});
|
|
1393
|
+
const registerFieldAction = useCallback$1((fieldName, action) => {
|
|
1394
|
+
fieldActionsRef.current[fieldName] = action;
|
|
1395
|
+
}, []);
|
|
1396
|
+
const unregisterFieldAction = useCallback$1((fieldName) => {
|
|
1397
|
+
delete fieldActionsRef.current[fieldName];
|
|
1398
|
+
}, []);
|
|
1399
|
+
const getFieldAction = useCallback$1((fieldName) => {
|
|
1400
|
+
return fieldActionsRef.current[fieldName];
|
|
1401
|
+
}, []);
|
|
1402
|
+
const contextValue = useMemo$1(() => ({
|
|
1403
|
+
setFormIndex,
|
|
1404
|
+
goToFormByFormId,
|
|
1405
|
+
goToFormByFieldName: (fieldName) => {
|
|
1406
|
+
if (fieldName === "idDocument") fieldName = "idVerificationMethod";
|
|
1407
|
+
const formIndex = forms.findIndex((form) => form?.fields?.some((field) => field === fieldName));
|
|
1408
|
+
if (formIndex > -1) setFormIndex(formIndex);
|
|
1409
|
+
else logger.error("No form was found to have that field so form navigation failed.");
|
|
1410
|
+
},
|
|
1411
|
+
registerFieldAction,
|
|
1412
|
+
unregisterFieldAction,
|
|
1413
|
+
getFieldAction
|
|
1414
|
+
}), [
|
|
1415
|
+
setFormIndex,
|
|
1416
|
+
goToFormByFormId,
|
|
1417
|
+
registerFieldAction,
|
|
1418
|
+
unregisterFieldAction,
|
|
1419
|
+
getFieldAction,
|
|
1420
|
+
forms
|
|
1421
|
+
]);
|
|
1422
|
+
return /* @__PURE__ */ jsx(FormRouterContext.Provider, {
|
|
1423
|
+
value: contextValue,
|
|
1424
|
+
children
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
var FormFlow_module_default = {
|
|
1428
|
+
"form-flow": "_form-flow_lhddu_1",
|
|
1429
|
+
formFlow: "_form-flow_lhddu_1",
|
|
1430
|
+
"form-flow-content": "_form-flow-content_lhddu_9",
|
|
1431
|
+
formFlowContent: "_form-flow-content_lhddu_9",
|
|
1432
|
+
"form-flow-footer": "_form-flow-footer_lhddu_30",
|
|
1433
|
+
formFlowFooter: "_form-flow-footer_lhddu_30",
|
|
1434
|
+
"form-flow-footer-border": "_form-flow-footer-border_lhddu_45",
|
|
1435
|
+
formFlowFooterBorder: "_form-flow-footer-border_lhddu_45",
|
|
1436
|
+
"form-flow-actions": "_form-flow-actions_lhddu_49",
|
|
1437
|
+
formFlowActions: "_form-flow-actions_lhddu_49",
|
|
1438
|
+
"form-flow-primary-actions": "_form-flow-primary-actions_lhddu_56",
|
|
1439
|
+
formFlowPrimaryActions: "_form-flow-primary-actions_lhddu_56"
|
|
1440
|
+
};
|
|
1441
|
+
//#endregion
|
|
1442
|
+
//#region src/components/Shared/FormFlow/FormFlow.tsx
|
|
1443
|
+
var FormFlow = ({ asModal = false, children, currentStep = 0, disableBackButton, disableNextButton, nextButtonLoading = false, forms, activeForm, gotoFormByFormIndex, gotoFormByFormId, handleBackClick, handleCancelClick, handleNextClick, loadingStatus, summary, summaryComponent, totalSteps = 1 }) => {
|
|
1444
|
+
const contentRef = useRef$1(null);
|
|
1445
|
+
const userEvents = useAnalyticsContext();
|
|
1446
|
+
const { t } = useTranslation("common");
|
|
1447
|
+
const [isConfirmPresented, setIsConfirmPresented] = useState$1(false);
|
|
1448
|
+
const [isSubmitting, setIsSubmitting] = useState$1(false);
|
|
1449
|
+
const isActionDisabled = isSubmitting || isConfirmPresented || loadingStatus === "loading";
|
|
1450
|
+
const hasBackButton = !!handleBackClick;
|
|
1451
|
+
const hasCancelButton = !!handleCancelClick;
|
|
1452
|
+
const isFirstStep = currentStep === 0;
|
|
1453
|
+
const isLastStep = currentStep === totalSteps - 1;
|
|
1454
|
+
const isSingleStepForm = totalSteps < 2;
|
|
1455
|
+
const progress = Math.floor(currentStep / (totalSteps - 1) * 100);
|
|
1456
|
+
const scrollToTop = () => {
|
|
1457
|
+
if (contentRef.current) contentRef.current.scroll({
|
|
1458
|
+
top: 0,
|
|
1459
|
+
behavior: "smooth"
|
|
1460
|
+
});
|
|
1461
|
+
};
|
|
1462
|
+
const handleSubmit = () => {
|
|
1463
|
+
setIsSubmitting(true);
|
|
1464
|
+
Promise.resolve(handleNextClick()).then(() => {
|
|
1465
|
+
setIsSubmitting(false);
|
|
1466
|
+
scrollToTop();
|
|
1467
|
+
});
|
|
1468
|
+
};
|
|
1469
|
+
const handleNext = () => {
|
|
1470
|
+
scrollToTop();
|
|
1471
|
+
handleNextClick();
|
|
1472
|
+
};
|
|
1473
|
+
const handleBack = () => {
|
|
1474
|
+
scrollToTop();
|
|
1475
|
+
handleBackClick?.();
|
|
1476
|
+
};
|
|
1477
|
+
const handleDismiss = () => {
|
|
1478
|
+
if (!hasCancelButton) return;
|
|
1479
|
+
setIsConfirmPresented(true);
|
|
1480
|
+
};
|
|
1481
|
+
const handleCancelDismiss = () => {
|
|
1482
|
+
userEvents.addPageEvent("Closed modal", {
|
|
1483
|
+
actionType: "close",
|
|
1484
|
+
label: "cancel"
|
|
1485
|
+
});
|
|
1486
|
+
setIsConfirmPresented(false);
|
|
1487
|
+
};
|
|
1488
|
+
const handleConfirmDismiss = () => {
|
|
1489
|
+
userEvents.addPageEvent("Clicked button", {
|
|
1490
|
+
actionType: "navigate",
|
|
1491
|
+
label: "leave"
|
|
1492
|
+
});
|
|
1493
|
+
setIsConfirmPresented(false);
|
|
1494
|
+
handleCancelClick?.();
|
|
1495
|
+
};
|
|
1496
|
+
const footerClassName = cx(FormFlow_module_default.formFlowFooter, { [FormFlow_module_default.formFlowFooterBorder]: isSingleStepForm });
|
|
1497
|
+
return /* @__PURE__ */ jsxs(MaybeModal, {
|
|
1498
|
+
inline: !asModal,
|
|
1499
|
+
onClose: handleDismiss,
|
|
1500
|
+
size: "large",
|
|
1501
|
+
showCloseButton: hasCancelButton,
|
|
1502
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1503
|
+
ref: contentRef,
|
|
1504
|
+
className: FormFlow_module_default.formFlow,
|
|
1505
|
+
"data-form-valid": activeForm.isValid,
|
|
1506
|
+
"data-testid": "form-flow",
|
|
1507
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1508
|
+
className: FormFlow_module_default.formFlowContent,
|
|
1509
|
+
children: /* @__PURE__ */ jsx(LoaderWrapper, {
|
|
1510
|
+
status: loadingStatus,
|
|
1511
|
+
formOpacityWhenLoading: 0,
|
|
1512
|
+
loaderSize: "large",
|
|
1513
|
+
children: /* @__PURE__ */ jsx(FormRouterContextProvider, {
|
|
1514
|
+
forms,
|
|
1515
|
+
setFormIndex: gotoFormByFormIndex,
|
|
1516
|
+
goToFormByFormId: gotoFormByFormId,
|
|
1517
|
+
children: isLastStep ? summaryComponent ? summaryComponent : summary !== void 0 ? /* @__PURE__ */ jsx(Summary, {
|
|
1518
|
+
...summary,
|
|
1519
|
+
forms,
|
|
1520
|
+
gotoForm: gotoFormByFormIndex
|
|
1521
|
+
}) : children : children
|
|
1522
|
+
})
|
|
1523
|
+
})
|
|
1524
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1525
|
+
className: footerClassName,
|
|
1526
|
+
children: [!isSingleStepForm && /* @__PURE__ */ jsx(ProgressBar, {
|
|
1527
|
+
ariaLabel: t(($) => $["progress"]),
|
|
1528
|
+
progress
|
|
1529
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1530
|
+
className: FormFlow_module_default.formFlowActions,
|
|
1531
|
+
children: [
|
|
1532
|
+
isFirstStep && hasCancelButton && /* @__PURE__ */ jsx(Button, {
|
|
1533
|
+
disabled: isActionDisabled || disableBackButton,
|
|
1534
|
+
onClick: handleDismiss,
|
|
1535
|
+
variant: "secondary",
|
|
1536
|
+
children: t(($) => $["cancel"])
|
|
1537
|
+
}),
|
|
1538
|
+
!isFirstStep && hasBackButton && /* @__PURE__ */ jsx(Button, {
|
|
1539
|
+
disabled: isActionDisabled || disableBackButton,
|
|
1540
|
+
icon: "chevron-left",
|
|
1541
|
+
onClick: handleBack,
|
|
1542
|
+
variant: "secondary",
|
|
1543
|
+
children: t(($) => $["back"])
|
|
1544
|
+
}),
|
|
1545
|
+
/* @__PURE__ */ jsx("div", {
|
|
1546
|
+
className: FormFlow_module_default.formFlowPrimaryActions,
|
|
1547
|
+
children: isLastStep ? /* @__PURE__ */ jsx(Button, {
|
|
1548
|
+
onClick: handleSubmit,
|
|
1549
|
+
loading: isSubmitting,
|
|
1550
|
+
children: t(($) => $["submit"])
|
|
1551
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
1552
|
+
onClick: handleNext,
|
|
1553
|
+
disabled: isActionDisabled || disableNextButton,
|
|
1554
|
+
loading: nextButtonLoading,
|
|
1555
|
+
children: t(($) => $["continue"])
|
|
1556
|
+
})
|
|
1557
|
+
})
|
|
1558
|
+
]
|
|
1559
|
+
})]
|
|
1560
|
+
})]
|
|
1561
|
+
}), isConfirmPresented && /* @__PURE__ */ jsx(Confirm, {
|
|
1562
|
+
confirmText: t(($) => $["leave"]),
|
|
1563
|
+
description: t(($) => $["unsavedChangesDescription"]),
|
|
1564
|
+
onCancel: handleCancelDismiss,
|
|
1565
|
+
onConfirm: handleConfirmDismiss,
|
|
1566
|
+
title: t(($) => $["unsavedChanges"])
|
|
1567
|
+
})]
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
//#endregion
|
|
1571
|
+
//#region src/utils/dropinUtils.ts
|
|
1572
|
+
/**
|
|
1573
|
+
* @@description Based requiredfields and optionalFields determine what forms need to be shown and add a summaryStep in the dropin
|
|
1574
|
+
*
|
|
1575
|
+
* @param forms
|
|
1576
|
+
* @param requiredFields
|
|
1577
|
+
* @param optionalFields
|
|
1578
|
+
* @param skipSummary
|
|
1579
|
+
*/
|
|
1580
|
+
var getRequiredForms = (forms, requiredFields, optionalFields, skipSummary) => {
|
|
1581
|
+
const reasons = [];
|
|
1582
|
+
const requiredForms = Object.values(forms).filter(({ formId }) => {
|
|
1583
|
+
if (requiredFields || optionalFields) {
|
|
1584
|
+
const hasRequired = Boolean(requiredFields?.[formId]?.length);
|
|
1585
|
+
const hasOptional = Boolean(optionalFields?.[formId]?.length);
|
|
1586
|
+
const isIncluded = hasRequired || hasOptional;
|
|
1587
|
+
const inclusionReasons = [];
|
|
1588
|
+
if (hasRequired) inclusionReasons.push("has required fields");
|
|
1589
|
+
if (hasOptional) inclusionReasons.push("has optional fields");
|
|
1590
|
+
if (isIncluded) reasons.push(`Form '${formId}': INCLUDED (${inclusionReasons.join(" & ")})`);
|
|
1591
|
+
else reasons.push(`Form '${formId}': EXCLUDED (no required or optional fields)`);
|
|
1592
|
+
return isIncluded;
|
|
1593
|
+
}
|
|
1594
|
+
reasons.push(`Form '${formId}': INCLUDED (no required/optional fields check)`);
|
|
1595
|
+
return true;
|
|
1596
|
+
});
|
|
1597
|
+
formDebugInfo.value = {
|
|
1598
|
+
...formDebugInfo.value,
|
|
1599
|
+
__FORMS__: {
|
|
1600
|
+
status: "INFO",
|
|
1601
|
+
reasons
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
if (skipSummary) return requiredForms;
|
|
1605
|
+
return [...requiredForms, summaryStep];
|
|
1606
|
+
};
|
|
1607
|
+
/**
|
|
1608
|
+
* @description Based on validity of fields from formValidity and existence of validationErrors/Verification errors from backend determine whether the forms needs to be shown as valid or not
|
|
1609
|
+
*
|
|
1610
|
+
* @param forms
|
|
1611
|
+
* @param formValidity
|
|
1612
|
+
* @param problems
|
|
1613
|
+
*/
|
|
1614
|
+
var addValidityToForms = (forms, formValidity, problems) => forms.map(({ formId, formName, fields }) => ({
|
|
1615
|
+
formId,
|
|
1616
|
+
formName,
|
|
1617
|
+
fields,
|
|
1618
|
+
isValid: formValidity?.[formId] ?? false,
|
|
1619
|
+
hasServerValidationErrors: Boolean(problems?.validationErrors?.[formId])
|
|
1620
|
+
}));
|
|
1621
|
+
//#endregion
|
|
1622
|
+
//#region src/context/FormContext/useFormContext.ts
|
|
1623
|
+
function useFormContext() {
|
|
1624
|
+
return useContext$1(FormContext);
|
|
1625
|
+
}
|
|
1626
|
+
//#endregion
|
|
1627
|
+
//#region src/components/Shared/fields/CountryField/CountryField.tsx
|
|
1628
|
+
var COUNTRY_FIELD = ["country"];
|
|
1629
|
+
function CountryField({ name = "country", data, valid, errors, labels, readonly, handleChangeFor, helperText, allowedCountries, handleBlur }) {
|
|
1630
|
+
const { t } = useTranslation("common");
|
|
1631
|
+
const { dataset: countriesFromApi } = useDataset(datasetIdentifier.country);
|
|
1632
|
+
const countries = useMemo$1(() => countriesFromApi.filter((country) => allowedCountries ? allowedCountries.includes(country.id) : true), [allowedCountries, countriesFromApi]);
|
|
1633
|
+
return /* @__PURE__ */ jsx(Field, {
|
|
1634
|
+
name,
|
|
1635
|
+
label: labels?.country || t(($) => $["country"]),
|
|
1636
|
+
errorMessage: errors.country,
|
|
1637
|
+
isValid: valid.country,
|
|
1638
|
+
helper: helperText,
|
|
1639
|
+
dataTestId: "country",
|
|
1640
|
+
children: (childProps) => /* @__PURE__ */ jsx(Select, {
|
|
1641
|
+
...childProps,
|
|
1642
|
+
name,
|
|
1643
|
+
placeholder: t(($) => $["selectCountryRegion"]),
|
|
1644
|
+
selected: data.country,
|
|
1645
|
+
items: countries,
|
|
1646
|
+
readonly: (countries.length === 1 || readonly) && !!data,
|
|
1647
|
+
onChange: handleChangeFor("country"),
|
|
1648
|
+
onBlur: handleBlur
|
|
1649
|
+
})
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
//#endregion
|
|
1653
|
+
export { FormContextProvider as C, trackNavigation as S, getRoleName as _, getRequiredForms as a, createFormUtils as b, useMultiForm as c, useFormComposer as d, Summary as f, Summary_module_default as g, summaryItem as h, addValidityToForms as i, isNotEmptyValidator as l, preTranslatedSummaryItem as m, CountryField as n, FormFlow as o, summaryStep as p, useFormContext as r, FormFlow_module_default as s, COUNTRY_FIELD as t, isTruthyValidator as u, getRoleTagVariant as v, mergeFieldMetadataIntoProps as x, roleMetadata as y };
|