@remoteoss/remote-flows 0.4.0-alpha.2 → 0.4.0-alpha.3
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/chunk-2URGWNSM.js +2 -0
- package/dist/chunk-2URGWNSM.js.map +1 -0
- package/dist/chunk-3KAYKVK5.js +2 -0
- package/dist/chunk-3KAYKVK5.js.map +1 -0
- package/dist/{chunk-UIAP5KT2.js → chunk-4N3CYS6F.js} +2 -2
- package/dist/chunk-76JJOA3E.js +2 -0
- package/dist/{chunk-I6NVZI7W.js.map → chunk-76JJOA3E.js.map} +1 -1
- package/dist/chunk-7B32RZXH.js +2 -0
- package/dist/chunk-7B32RZXH.js.map +1 -0
- package/dist/{chunk-SMHHCUP4.js → chunk-C4E24DUG.js} +2 -2
- package/dist/{chunk-PKX5K2UY.js → chunk-DQM4AWYT.js} +2 -2
- package/dist/{chunk-5CJPGBXJ.js → chunk-FNTHWOZU.js} +2 -2
- package/dist/{chunk-CRHTUOZT.js → chunk-JT5XHQEY.js} +2 -2
- package/dist/{chunk-U25ZZ3LM.js → chunk-KGUR7YMA.js} +2 -2
- package/dist/{chunk-5OXN2O6C.js → chunk-MI3HDT5D.js} +2 -2
- package/dist/{chunk-KQ6TGZJS.js → chunk-NVMRRBRE.js} +2 -2
- package/dist/chunk-NVMRRBRE.js.map +1 -0
- package/dist/{chunk-7OMSCFTM.js → chunk-OXOB35EA.js} +2 -2
- package/dist/{chunk-LMDX5IAX.js → chunk-QOXOAPGX.js} +2 -2
- package/dist/{chunk-FZ2HS6G7.js → chunk-S4XU4SE7.js} +1 -1
- package/dist/chunk-S4XU4SE7.js.map +1 -0
- package/dist/{chunk-2YWRQJ7P.js → chunk-SYWI4UB6.js} +2 -2
- package/dist/{chunk-JFOOILST.js → chunk-T3PTQ4QM.js} +2 -2
- package/dist/{chunk-EDNELJVE.js → chunk-TGB3TV3K.js} +2 -2
- package/dist/chunk-TGB3TV3K.js.map +1 -0
- package/dist/{chunk-GR6EY46K.js → chunk-TXLTMGOU.js} +2 -2
- package/dist/chunk-U3I3TJKB.js +2 -0
- package/dist/chunk-U3I3TJKB.js.map +1 -0
- package/dist/{chunk-Y477IGTZ.js → chunk-WZ5AXHQT.js} +2 -2
- package/dist/{chunk-TPPGI73P.js → chunk-XOUAD7MS.js} +2 -2
- package/dist/{chunk-LM5GAAUB.js → chunk-YIBRPAR3.js} +2 -2
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentForm.js +1 -1
- package/dist/flows/ContractAmendment/context.d.ts +1 -1
- package/dist/flows/ContractAmendment/hooks.d.ts +1 -1
- package/dist/flows/ContractAmendment/hooks.js +1 -1
- package/dist/flows/ContractAmendment/index.js +1 -1
- package/dist/flows/ContractAmendment/utils.d.ts +1 -1
- package/dist/flows/ContractAmendment/utils.js +1 -1
- package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
- package/dist/flows/CostCalculator/index.js +1 -1
- package/dist/flows/Onboarding/BasicInformationStep.js +1 -1
- package/dist/flows/Onboarding/BenefitsStep.d.ts +1 -1
- package/dist/flows/Onboarding/BenefitsStep.js +1 -1
- package/dist/flows/Onboarding/ContractDetailsStep.js +1 -1
- package/dist/flows/Onboarding/OnboardingFlow.d.ts +2 -1
- package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
- package/dist/flows/Onboarding/OnboardingForm.d.ts +1 -1
- package/dist/flows/Onboarding/OnboardingForm.js +1 -1
- package/dist/flows/Onboarding/OnboardingInvite.js +1 -1
- package/dist/flows/Onboarding/context.d.ts +6 -1
- package/dist/flows/Onboarding/hooks.d.ts +14 -1
- package/dist/flows/Onboarding/hooks.js +1 -1
- package/dist/flows/Onboarding/index.d.ts +2 -1
- package/dist/flows/Onboarding/index.js +1 -1
- package/dist/flows/Onboarding/utils.d.ts +10 -2
- package/dist/flows/Onboarding/utils.js +1 -1
- package/dist/flows/Termination/AdditionalDetailsForm.js +1 -1
- package/dist/flows/Termination/EmployeeComunicationForm.js +1 -1
- package/dist/flows/Termination/PaidTimeOffForm.js +1 -1
- package/dist/flows/Termination/TerminationDetailsForm.js +1 -1
- package/dist/flows/Termination/TerminationFlow.d.ts +1 -0
- package/dist/flows/Termination/TerminationFlow.js +1 -1
- package/dist/flows/Termination/TerminationForm.js +1 -1
- package/dist/flows/Termination/context.d.ts +2 -1
- package/dist/flows/Termination/hooks.d.ts +2 -1
- package/dist/flows/Termination/hooks.js +1 -1
- package/dist/flows/Termination/index.d.ts +1 -0
- package/dist/flows/Termination/index.js +1 -1
- package/dist/flows/Termination/utils.d.ts +1 -1
- package/dist/flows/Termination/utils.js +1 -1
- package/dist/flows/useStepState.d.ts +10 -4
- package/dist/flows/useStepState.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/{remoteFlows-CswYencu.d.ts → remoteFlows-BqpqaWsU.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2PXGLWCY.js +0 -2
- package/dist/chunk-2PXGLWCY.js.map +0 -1
- package/dist/chunk-EDNELJVE.js.map +0 -1
- package/dist/chunk-FZ2HS6G7.js.map +0 -1
- package/dist/chunk-HDQGO453.js +0 -2
- package/dist/chunk-HDQGO453.js.map +0 -1
- package/dist/chunk-I6NVZI7W.js +0 -2
- package/dist/chunk-KQ6TGZJS.js.map +0 -1
- package/dist/chunk-LCZQVL4U.js +0 -2
- package/dist/chunk-LCZQVL4U.js.map +0 -1
- package/dist/chunk-S56EWAS4.js +0 -2
- package/dist/chunk-S56EWAS4.js.map +0 -1
- /package/dist/{chunk-UIAP5KT2.js.map → chunk-4N3CYS6F.js.map} +0 -0
- /package/dist/{chunk-SMHHCUP4.js.map → chunk-C4E24DUG.js.map} +0 -0
- /package/dist/{chunk-PKX5K2UY.js.map → chunk-DQM4AWYT.js.map} +0 -0
- /package/dist/{chunk-5CJPGBXJ.js.map → chunk-FNTHWOZU.js.map} +0 -0
- /package/dist/{chunk-CRHTUOZT.js.map → chunk-JT5XHQEY.js.map} +0 -0
- /package/dist/{chunk-U25ZZ3LM.js.map → chunk-KGUR7YMA.js.map} +0 -0
- /package/dist/{chunk-5OXN2O6C.js.map → chunk-MI3HDT5D.js.map} +0 -0
- /package/dist/{chunk-7OMSCFTM.js.map → chunk-OXOB35EA.js.map} +0 -0
- /package/dist/{chunk-LMDX5IAX.js.map → chunk-QOXOAPGX.js.map} +0 -0
- /package/dist/{chunk-2YWRQJ7P.js.map → chunk-SYWI4UB6.js.map} +0 -0
- /package/dist/{chunk-JFOOILST.js.map → chunk-T3PTQ4QM.js.map} +0 -0
- /package/dist/{chunk-GR6EY46K.js.map → chunk-TXLTMGOU.js.map} +0 -0
- /package/dist/{chunk-Y477IGTZ.js.map → chunk-WZ5AXHQT.js.map} +0 -0
- /package/dist/{chunk-TPPGI73P.js.map → chunk-XOUAD7MS.js.map} +0 -0
- /package/dist/{chunk-LM5GAAUB.js.map → chunk-YIBRPAR3.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as l}from"./chunk-AYDF3IFZ.js";import{useState as d}from"react";var F=l(n=>{let u=Object.keys(n);if(u.length===0)throw new Error("No steps provided to useStepState");let[a,p]=d({}),[r,i]=d({currentStep:n[u[0]],totalSteps:u.length,values:null});function S(){let{index:t}=r.currentStep,s=Object.values(n).find(e=>e.index===t+1);s&&(i(e=>({...e,currentStep:s,values:{...e.values,[e.currentStep.name]:{...e.values?.[e.currentStep.name],...a}}})),p({}))}l(S,"nextStep");function o(){let{index:t}=r.currentStep,s=Object.values(n).find(e=>e.index===t-1);s&&(i(e=>({...e,currentStep:s,values:{...e.values,[e.currentStep.name]:{...e.values?.[e.currentStep.name],...a}}})),p({}))}l(o,"previousStep");function T(t){r.values?.[t]&&i(c=>({...c,currentStep:n[t]}))}return l(T,"goToStep"),{nextStep:S,previousStep:o,stepState:r,goToStep:T,fieldValues:a,setFieldValues:p}},"useStepState");export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2URGWNSM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/useStepState.ts"],"sourcesContent":["import { useState } from 'react';\nimport { FieldValues } from 'react-hook-form';\n\nexport type Step<T extends string> = {\n index: number;\n name: T;\n};\n\ntype StepState<T extends string, Fields = FieldValues> = {\n currentStep: Step<T>;\n totalSteps: number;\n values:\n | {\n [key in T]: Fields;\n }\n | null;\n};\n\nexport const useStepState = <T extends string, Fields = FieldValues>(\n steps: Record<T, Step<T>>,\n) => {\n const stepKeys = Object.keys(steps) as Array<keyof typeof steps>;\n\n if (stepKeys.length === 0) {\n throw new Error('No steps provided to useStepState');\n }\n\n const [fieldValues, setFieldValues] = useState<Fields>({} as Fields);\n const [stepState, setStepState] = useState<StepState<T, Fields>>({\n currentStep: steps[stepKeys[0]],\n totalSteps: stepKeys.length,\n values: null,\n });\n\n function nextStep() {\n const { index } = stepState.currentStep;\n const stepValues = Object.values<Step<T>>(steps);\n const nextStep = stepValues.find((step) => step.index === index + 1);\n\n if (nextStep) {\n setStepState((previousState) => ({\n ...previousState,\n currentStep: nextStep,\n values: {\n ...previousState.values,\n [previousState.currentStep.name]: {\n ...previousState.values?.[previousState.currentStep.name as T],\n ...fieldValues,\n },\n } as { [key in T]: Fields },\n }));\n setFieldValues({} as Fields); // Reset field values for the next step\n }\n }\n\n function previousStep() {\n const { index } = stepState.currentStep;\n const stepValues = Object.values<Step<T>>(steps);\n const previousStep = stepValues.find((step) => step.index === index - 1);\n\n if (previousStep) {\n setStepState((previousState) => ({\n ...previousState,\n currentStep: previousStep,\n values: {\n ...previousState.values,\n [previousState.currentStep.name]: {\n ...previousState.values?.[previousState.currentStep.name as T],\n ...fieldValues,\n },\n } as { [key in T]: Fields },\n }));\n setFieldValues({} as Fields); // Reset field values for the previous step\n }\n }\n\n function goToStep(step: T) {\n // to avoid going to a steps that hasn't been filled yet\n if (stepState.values?.[step]) {\n setStepState((previousState) => ({\n ...previousState,\n currentStep: steps[step],\n }));\n }\n }\n\n return {\n /**\n * Moves to the next step in the step state.\n * It updates the current step and resets the field values for the next step.\n * The field values for the current step are stored in the step state.\n * @returns {void}\n */\n nextStep,\n /**\n * Moves to the previous step in the step state.\n * It updates the current step and resets the field values for the previous step.\n * The field values for the current step are stored in the step state.\n * @returns {void}\n */\n previousStep,\n /**\n * The current step state containing the current step, total number of steps and\n * the form values for each step.\n * @returns {StepState<T>} The current step state.\n */\n stepState,\n /**\n * Goes to a specific step in the step state.\n * @param step The step to go to.\n * @returns {void}\n */\n goToStep,\n /**\n * The field values for the current step.\n * @returns {FieldValues} The field values for the current step.\n */\n fieldValues,\n /**\n * Sets the field values for the current step.\n * @param values The field values to set.\n * @returns {void}\n */\n setFieldValues,\n };\n};\n"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,QAkBlB,IAAMC,EAAeC,EAC1BC,GACG,CACH,IAAMC,EAAW,OAAO,KAAKD,CAAK,EAElC,GAAIC,EAAS,SAAW,EACtB,MAAM,IAAI,MAAM,mCAAmC,EAGrD,GAAM,CAACC,EAAaC,CAAc,EAAIC,EAAiB,CAAC,CAAW,EAC7D,CAACC,EAAWC,CAAY,EAAIF,EAA+B,CAC/D,YAAaJ,EAAMC,EAAS,CAAC,CAAC,EAC9B,WAAYA,EAAS,OACrB,OAAQ,IACV,CAAC,EAED,SAASM,GAAW,CAClB,GAAM,CAAE,MAAAC,CAAM,EAAIH,EAAU,YAEtBE,EADa,OAAO,OAAgBP,CAAK,EACnB,KAAMS,GAASA,EAAK,QAAUD,EAAQ,CAAC,EAE/DD,IACFD,EAAcI,IAAmB,CAC/B,GAAGA,EACH,YAAaH,EACb,OAAQ,CACN,GAAGG,EAAc,OACjB,CAACA,EAAc,YAAY,IAAI,EAAG,CAChC,GAAGA,EAAc,SAASA,EAAc,YAAY,IAAS,EAC7D,GAAGR,CACL,CACF,CACF,EAAE,EACFC,EAAe,CAAC,CAAW,EAE/B,CAnBSJ,EAAAQ,EAAA,YAqBT,SAASI,GAAe,CACtB,GAAM,CAAE,MAAAH,CAAM,EAAIH,EAAU,YAEtBM,EADa,OAAO,OAAgBX,CAAK,EACf,KAAMS,GAASA,EAAK,QAAUD,EAAQ,CAAC,EAEnEG,IACFL,EAAcI,IAAmB,CAC/B,GAAGA,EACH,YAAaC,EACb,OAAQ,CACN,GAAGD,EAAc,OACjB,CAACA,EAAc,YAAY,IAAI,EAAG,CAChC,GAAGA,EAAc,SAASA,EAAc,YAAY,IAAS,EAC7D,GAAGR,CACL,CACF,CACF,EAAE,EACFC,EAAe,CAAC,CAAW,EAE/B,CAnBSJ,EAAAY,EAAA,gBAqBT,SAASC,EAASH,EAAS,CAErBJ,EAAU,SAASI,CAAI,GACzBH,EAAcI,IAAmB,CAC/B,GAAGA,EACH,YAAaV,EAAMS,CAAI,CACzB,EAAE,CAEN,CARS,OAAAV,EAAAa,EAAA,YAUF,CAOL,SAAAL,EAOA,aAAAI,EAMA,UAAAN,EAMA,SAAAO,EAKA,YAAAV,EAMA,eAAAC,CACF,CACF,EA3G4B","names":["useState","useStepState","__name","steps","stepKeys","fieldValues","setFieldValues","useState","stepState","setStepState","nextStep","index","step","previousState","previousStep","goToStep"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as J,b as x}from"./chunk-7B32RZXH.js";import{a as F}from"./chunk-JRQSZHUU.js";import{d as A,f as v,g as B,j as M,l as I,m as R,n as L,r as U}from"./chunk-DHRIURRT.js";import{a as z}from"./chunk-2URGWNSM.js";import{d as l}from"./chunk-WRDKLT4N.js";import{c as _,d as O}from"./chunk-N25EBX6R.js";import{a as e}from"./chunk-AYDF3IFZ.js";import{createHeadlessForm as H,modify as N}from"@remoteoss/json-schema-form";import{useMutation as E,useQuery as P}from"@tanstack/react-query";import{useRef as se,useState as me}from"react";import ce from"lodash/mergeWith";var le={employment_basic_information:"basic_information",contract_details:"contract_details"},fe=e(t=>{let{client:o}=l();return P({queryKey:["employment",t],retry:!1,enabled:!!t,queryFn:e(async()=>{let n=await R({client:o,headers:{Authorization:""},path:{employment_id:t}});if(n.error||!n.data)throw new Error("Failed to fetch employment data");return n},"queryFn")})},"useEmployment"),ue=e(t=>{let{client:o}=l();return P({queryKey:["benefit-offers",t],retry:!1,enabled:!!t,queryFn:e(async()=>v({client:o,headers:{Authorization:""},path:{employment_id:t}}).then(n=>{if(n.error||!n.data)throw new Error("Failed to fetch benefit offers data");return n}),"queryFn"),select:e(({data:n})=>n?.data?.reduce((i,c)=>({...i,[c.benefit_group.slug]:{value:c.benefit_tier?.slug??""}}),{}),"select")})},"useBenefitOffers"),Be=e(()=>{let{client:t}=l();return E({mutationFn:e(o=>U({client:t,headers:{Authorization:""},path:o}),"mutationFn")})},"useEmploymentInvite"),de=e(({countryCode:t,form:o,fieldValues:n,options:i,employment:c})=>{let{client:r}=l(),f=i?.jsonSchemaVersion?.form_schema?.[o]?{json_schema_version:i.jsonSchemaVersion.form_schema[o]}:{};return P({queryKey:["onboarding-json-schema-form",t,o],retry:!1,queryFn:e(async()=>{let s=await M({client:r,headers:{Authorization:""},path:{country_code:t,form:o},query:{skip_benefits:!0,...f}});if(s.error||!s.data)throw new Error("Failed to fetch onboarding schema");return s},"queryFn"),select:e(({data:s})=>{let p=s?.data||{};if(i&&i.jsfModify){let{schema:a}=N(p,i.jsfModify);p=a}let y=Object.keys(n).length>0,V=le[o],h=c?.[V]||{};return H(p,{initialValues:y?n:h})},"select")})},"useJSONSchemaForm"),pe=e((t,o,n)=>{let i=n?.jsonSchemaVersion?.benefit_offers_form_schema?{json_schema_version:n.jsonSchemaVersion.benefit_offers_form_schema}:{},{client:c}=l();return P({queryKey:["benefit-offers-schema",t],retry:!1,enabled:!!t,queryFn:e(async()=>{let r=await I({client:c,headers:{Authorization:""},path:{employment_id:t},query:i});if(r.error||!r.data)throw new Error("Failed to fetch benefit offers schema");return r},"queryFn"),select:e(({data:r})=>{let f=r?.data?.schema||{};if(n&&n.jsfModify){let{schema:y}=N(f,n.jsfModify);f=y}let s=Object.keys(o).length>0;return H(f,{initialValues:s?{...o}:{}})},"select")})},"useBenefitOffersSchema"),ye=e(()=>{let{client:t}=l();return E({mutationFn:e(o=>A({client:t,headers:{Authorization:""},body:o}),"mutationFn")})},"useCreateEmployment"),he=e(()=>{let{client:t}=l();return E({mutationFn:e(({employmentId:o,...n})=>L({client:t,headers:{Authorization:""},body:n,path:{employment_id:o},query:{skip_benefits:!0}}),"mutationFn")})},"useUpdateEmployment"),Se=e(()=>{let{client:t}=l();return E({mutationFn:e(({employmentId:o,...n})=>B({client:t,headers:{Authorization:""},body:n,path:{employment_id:o}}),"mutationFn")})},"useUpdateBenefitsOffers"),Me=e(({employmentId:t,countryCode:o,type:n,options:i})=>{let c=se({}),[r,f]=me(t),{data:s,isLoading:p}=fe(t),{data:y,isLoading:V}=ue(r),{fieldValues:h,stepState:a,setFieldValues:K,previousStep:D,nextStep:Q,goToStep:W}=z(J),w=ye(),k=he(),j=Se(),{mutateAsync:G}=F(w),{mutateAsync:T}=F(k),{mutateAsync:X}=F(j),Y={basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},{data:u,isLoading:Z}=de({countryCode:o,form:Y[a.currentStep.name]||"employment_basic_information",fieldValues:{...a.values?.[a.currentStep.name],...h},options:i,employment:s?.data?.data?.employment}),{data:g,isLoading:$}=pe(r,h,i),ee={...a.values?.[a.currentStep.name],...h},te=a.currentStep.name==="benefits"?ce({},y,ee):{},b={basic_information:u?.fields||[],contract_details:u?.fields||[],benefits:g?.fields||[],review:[]},ne={basic_information:O(b[a.currentStep.name],s?.data?.data.employment?.basic_information||{}),contract_details:O(b[a.currentStep.name],s?.data?.data.employment?.contract_details||{}),benefits:te||{}};function C(m){return u?_(m,u?.fields,{isPartialValidation:!0}):{}}e(C,"parseFormValues");async function oe(m){c.current[a.currentStep.name]=x(m,b[a.currentStep.name]);let d=C(m);switch(a.currentStep.name){case"basic_information":{if(r)return T({employmentId:r,basic_information:d,pricing_plan_details:{frequency:"monthly"}});{let q={basic_information:d,type:n,country_code:o};try{let S=await G(q);return f(S.data?.data?.employment?.id),S}catch(S){throw console.error("Error creating onboarding:",S),S}}}case"contract_details":return T({employmentId:r,...{contract_details:d}});case"benefits":return X({employmentId:r,...m})}}e(oe,"onSubmit");function ae(){D()}e(ae,"back");function re(){Q()}e(re,"next");function ie(m){W(m)}return e(ie,"goTo"),{employmentId:t,stepState:a,fields:b[a.currentStep.name],isLoading:Z||p||$||V,isSubmitting:w.isPending||k.isPending||j.isPending,initialValues:ne,handleValidation:e(m=>{if(a.currentStep.name==="benefits"&&g){let d=_(m,g?.fields);return g?.handleValidation(d)}if(u){let d=_(m,u?.fields);return u?.handleValidation(d)}return null},"handleValidation"),checkFieldUpdates:K,parseFormValues:C,onSubmit:oe,back:ae,next:re,goTo:ie,meta:{fields:c.current}}},"useOnboarding");export{Be as a,Me as b};
|
|
2
|
+
//# sourceMappingURL=chunk-3KAYKVK5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/Onboarding/hooks.ts"],"sourcesContent":["import {\n Employment,\n EmploymentCreateParams,\n EmploymentFullParams,\n getShowEmployment,\n getShowFormCountry,\n patchUpdateEmployment2,\n postCreateEmployment2,\n postInviteEmploymentInvitation,\n PostInviteEmploymentInvitationData,\n getShowSchema,\n putUpdateBenefitOffer,\n UnifiedEmploymentUpsertBenefitOffersRequest,\n getIndexBenefitOffer,\n} from '@/src/client';\nimport { Client } from '@hey-api/client-fetch';\nimport {\n createHeadlessForm,\n Fields,\n modify,\n} from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { useClient } from '@/src/context';\nimport { useStepState } from '@/src/flows/useStepState';\nimport { prettifyFormValues, STEPS } from '@/src/flows/Onboarding/utils';\nimport {\n getInitialValues,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { mutationToPromise } from '@/src/lib/mutations';\nimport { FieldValues } from 'react-hook-form';\nimport { OnboardingFlowParams } from '@/src/flows/Onboarding/types';\nimport { JSONSchemaFormType } from '@/src/flows/types';\nimport { useRef, useState } from 'react';\nimport mergeWith from 'lodash/mergeWith';\n\ntype OnboardingHookProps = OnboardingFlowParams;\n\nconst jsonSchemaToEmployment: Partial<\n Record<JSONSchemaFormType, keyof Employment>\n> = {\n employment_basic_information: 'basic_information',\n contract_details: 'contract_details',\n};\n\nconst useEmployment = (employmentId: string | undefined) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['employment', employmentId],\n retry: false,\n enabled: !!employmentId,\n queryFn: async () => {\n const response = await getShowEmployment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n employment_id: employmentId as string,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch employment data');\n }\n\n return response;\n },\n });\n};\n\nconst useBenefitOffers = (employmentId: string | undefined) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['benefit-offers', employmentId],\n retry: false,\n enabled: !!employmentId,\n queryFn: async () => {\n return getIndexBenefitOffer({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n employment_id: employmentId as string,\n },\n }).then((response) => {\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch benefit offers data');\n }\n\n return response;\n });\n },\n select: ({ data }) =>\n data?.data?.reduce(\n (acc, item) => {\n return {\n ...acc,\n [item.benefit_group.slug]: {\n value: item.benefit_tier?.slug ?? '',\n },\n };\n },\n {} as Record<string, { value: string }>,\n ),\n });\n};\n/**\n * Use this hook to invite an employee to the onboarding flow\n * @returns\n */\nexport const useEmploymentInvite = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: PostInviteEmploymentInvitationData['path']) => {\n return postInviteEmploymentInvitation({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: payload,\n });\n },\n });\n};\n\n/**\n * Use this hook to get the JSON schema form for the onboarding flow\n * @param param0\n * @returns\n */\nconst useJSONSchemaForm = ({\n countryCode,\n form,\n fieldValues,\n options,\n employment,\n}: {\n countryCode: string;\n form: JSONSchemaFormType;\n fieldValues: FieldValues;\n options?: OnboardingHookProps['options'];\n employment?: Employment;\n}) => {\n const { client } = useClient();\n const jsonSchemaQueryParam = options?.jsonSchemaVersion?.form_schema?.[form]\n ? {\n json_schema_version: options.jsonSchemaVersion.form_schema[form],\n }\n : {};\n return useQuery({\n queryKey: ['onboarding-json-schema-form', countryCode, form],\n retry: false,\n queryFn: async () => {\n const response = await getShowFormCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n country_code: countryCode,\n form: form,\n },\n query: {\n skip_benefits: true,\n ...jsonSchemaQueryParam,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch onboarding schema');\n }\n\n return response;\n },\n select: ({ data }) => {\n let jsfSchema = data?.data || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n const hasFieldValues = Object.keys(fieldValues).length > 0;\n const employmentField = jsonSchemaToEmployment[form] as keyof Employment;\n const employmentFieldData = (employment?.[employmentField] ||\n {}) as Record<string, unknown>;\n return createHeadlessForm(jsfSchema, {\n initialValues: hasFieldValues ? fieldValues : employmentFieldData,\n });\n },\n });\n};\n\nconst useBenefitOffersSchema = (\n employmentId: string,\n fieldValues: FieldValues,\n options: OnboardingHookProps['options'],\n) => {\n const jsonSchemaQueryParam = options?.jsonSchemaVersion\n ?.benefit_offers_form_schema\n ? {\n json_schema_version:\n options.jsonSchemaVersion.benefit_offers_form_schema,\n }\n : {};\n const { client } = useClient();\n return useQuery({\n queryKey: ['benefit-offers-schema', employmentId],\n retry: false,\n enabled: !!employmentId,\n queryFn: async () => {\n const response = await getShowSchema({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n employment_id: employmentId,\n },\n query: jsonSchemaQueryParam,\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch benefit offers schema');\n }\n\n return response;\n },\n select: ({ data }) => {\n let jsfSchema = data?.data?.schema || {};\n\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n const hasFieldValues = Object.keys(fieldValues).length > 0;\n const result = createHeadlessForm(jsfSchema, {\n // we need to clone the fieldValues to prevent side effects\n // if we don't do this, the benefits get included in the other steps\n initialValues: hasFieldValues ? { ...fieldValues } : {},\n });\n return result;\n },\n });\n};\n\n/**\n * Use this hook to create an employment\n * @returns\n */\nconst useCreateEmployment = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: EmploymentCreateParams) => {\n return postCreateEmployment2({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\nconst useUpdateEmployment = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: EmploymentFullParams & { employmentId: string }) => {\n return patchUpdateEmployment2({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n path: {\n employment_id: employmentId,\n },\n query: {\n skip_benefits: true,\n },\n });\n },\n });\n};\n\nconst useUpdateBenefitsOffers = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: UnifiedEmploymentUpsertBenefitOffersRequest & {\n employmentId: string;\n }) => {\n return putUpdateBenefitOffer({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n path: {\n employment_id: employmentId,\n },\n });\n },\n });\n};\n\nexport const useOnboarding = ({\n employmentId,\n countryCode,\n type,\n options,\n}: OnboardingHookProps) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fieldsMetaRef = useRef<Record<string, any>>({});\n const [internalEmploymentId, setInternalEmploymentId] = useState<\n string | undefined\n >(employmentId);\n const { data: employment, isLoading: isLoadingEmployment } =\n useEmployment(employmentId);\n\n const { data: benefitOffers, isLoading: isLoadingBenefitOffers } =\n useBenefitOffers(internalEmploymentId);\n const {\n fieldValues,\n stepState,\n setFieldValues,\n previousStep,\n nextStep,\n goToStep,\n } = useStepState<keyof typeof STEPS>(STEPS);\n\n const createEmploymentMutation = useCreateEmployment();\n const updateEmploymentMutation = useUpdateEmployment();\n const updateBenefitsOffersMutation = useUpdateBenefitsOffers();\n const { mutateAsync: createEmploymentMutationAsync } = mutationToPromise(\n createEmploymentMutation,\n );\n const { mutateAsync: updateEmploymentMutationAsync } = mutationToPromise(\n updateEmploymentMutation,\n );\n const { mutateAsync: updateBenefitsOffersMutationAsync } = mutationToPromise(\n updateBenefitsOffersMutation,\n );\n\n const form: Record<keyof typeof STEPS, JSONSchemaFormType | null> = {\n basic_information: 'employment_basic_information',\n contract_details: 'contract_details',\n benefits: null,\n review: null,\n };\n\n const { data: onboardingForm, isLoading: isLoadingBasicInformation } =\n useJSONSchemaForm({\n countryCode: countryCode,\n form:\n form[stepState.currentStep.name as keyof typeof STEPS] ||\n 'employment_basic_information',\n fieldValues: {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n },\n options: options,\n employment: employment?.data?.data?.employment,\n });\n\n const {\n data: benefitOffersSchema,\n isLoading: isLoadingBenefitsOffersSchema,\n } = useBenefitOffersSchema(\n internalEmploymentId as string,\n fieldValues,\n options,\n );\n\n const benefitsFormValues = {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n };\n\n const initialValuesBenefitOffers =\n stepState.currentStep.name === 'benefits'\n ? mergeWith({}, benefitOffers, benefitsFormValues)\n : {};\n\n const stepFields: Record<keyof typeof STEPS, Fields> = {\n basic_information: onboardingForm?.fields || [],\n contract_details: onboardingForm?.fields || [],\n benefits: benefitOffersSchema?.fields || [],\n review: [],\n };\n\n const initialValues = {\n basic_information: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.data?.data.employment?.basic_information || {},\n ),\n contract_details: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.data?.data.employment?.contract_details || {},\n ),\n benefits: initialValuesBenefitOffers || {},\n };\n\n function parseFormValues(values: FieldValues) {\n if (onboardingForm) {\n return parseJSFToValidate(values, onboardingForm?.fields, {\n isPartialValidation: true,\n });\n }\n return {};\n }\n\n async function onSubmit(values: FieldValues) {\n // Prettify values for the current step\n fieldsMetaRef.current[stepState.currentStep.name] = prettifyFormValues(\n values,\n stepFields[stepState.currentStep.name],\n );\n\n const parsedValues = parseFormValues(values);\n switch (stepState.currentStep.name) {\n case 'basic_information': {\n if (!internalEmploymentId) {\n const payload: EmploymentCreateParams = {\n basic_information: parsedValues,\n type: type,\n country_code: countryCode,\n };\n try {\n const response = await createEmploymentMutationAsync(payload);\n setInternalEmploymentId(\n // @ts-expect-error the types from the response are not matching\n response.data?.data?.employment?.id,\n );\n return response;\n } catch (error) {\n console.error('Error creating onboarding:', error);\n throw error;\n }\n } else {\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId,\n basic_information: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n });\n }\n }\n\n case 'contract_details': {\n const payload: EmploymentFullParams = {\n contract_details: parsedValues,\n };\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId as string,\n ...payload,\n });\n }\n\n case 'benefits': {\n return updateBenefitsOffersMutationAsync({\n employmentId: internalEmploymentId as string,\n ...values,\n });\n }\n }\n return;\n }\n\n function back() {\n previousStep();\n }\n\n function next() {\n nextStep();\n }\n\n function goTo(step: keyof typeof STEPS) {\n goToStep(step);\n }\n\n return {\n /**\n * Employment id passed useful to be used between components\n */\n employmentId,\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n /**\n * Array of form fields from the onboarding schema\n */\n fields: stepFields[stepState.currentStep.name],\n /**\n * Loading state indicating if the onboarding schema is being fetched\n */\n isLoading:\n isLoadingBasicInformation ||\n isLoadingEmployment ||\n isLoadingBenefitsOffersSchema ||\n isLoadingBenefitOffers,\n /**\n * Loading state indicating if the onboarding mutation is in progress\n */\n isSubmitting:\n createEmploymentMutation.isPending ||\n updateEmploymentMutation.isPending ||\n updateBenefitsOffersMutation.isPending,\n /**\n * Initial form values\n */\n initialValues,\n /**\n * Function to validate form values against the onboarding schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation: (values: FieldValues) => {\n if (stepState.currentStep.name === 'benefits' && benefitOffersSchema) {\n const parsedValues = parseJSFToValidate(\n values,\n benefitOffersSchema?.fields,\n );\n\n return benefitOffersSchema?.handleValidation(parsedValues);\n }\n if (onboardingForm) {\n const parsedValues = parseJSFToValidate(values, onboardingForm?.fields);\n\n return onboardingForm?.handleValidation(parsedValues);\n }\n return null;\n },\n /**\n * Function to update the current form field values\n * @param values - New form values to set\n */\n checkFieldUpdates: setFieldValues,\n\n /**\n * Function to parse form values before submission\n * @param values - Form values to parse\n * @returns Parsed form values\n */\n parseFormValues,\n\n /**\n * Function to handle form submission\n * @param values - Form values to submit\n * @returns Promise resolving to the mutation result\n */\n onSubmit,\n\n /**\n * Function to handle going back to the previous step\n * @returns {void}\n */\n back,\n\n /**\n * Function to handle going to the next step\n * @returns {void}\n */\n next,\n\n /**\n * Function to handle going to a specific step\n * @param step The step to go to.\n * @returns {void}\n */\n goTo,\n\n /**\n * Fields metadata for each step\n */\n meta: {\n fields: fieldsMetaRef.current,\n },\n };\n};\n"],"mappings":"uVAgBA,OACE,sBAAAA,EAEA,UAAAC,MACK,8BACP,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBAatC,OAAS,UAAAC,GAAQ,YAAAC,OAAgB,QACjC,OAAOC,OAAe,mBAItB,IAAMC,GAEF,CACF,6BAA8B,oBAC9B,iBAAkB,kBACpB,EAEMC,GAAgBC,EAACC,GAAqC,CAC1D,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAE7B,OAAOC,EAAS,CACd,SAAU,CAAC,aAAcH,CAAY,EACrC,MAAO,GACP,QAAS,CAAC,C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B,EAEEvC,EAAS,MAAM,MAAM,YAAY,EACnC,EACOA,CACT,OAAS0E,EAAO,CACd,cAAQ,MAAM,6BAA8BA,CAAK,EAC3CA,CACR,CACF,CASF,CAEA,IAAK,mBAIH,OAAOlB,EAA8B,CACnC,aAAclB,EACd,GALoC,CACpC,iBAAkBmC,CACpB,CAIA,CAAC,EAGH,IAAK,WACH,OAAOhB,EAAkC,CACvC,aAAcnB,EACd,GAAG+B,CACL,CAAC,CAEL,CAEF,CAxDe1E,EAAA4E,GAAA,YA0Df,SAASI,IAAO,CACd7B,EAAa,CACf,CAFSnD,EAAAgF,GAAA,QAIT,SAASC,IAAO,CACd7B,EAAS,CACX,CAFSpD,EAAAiF,GAAA,QAIT,SAASC,GAAKC,EAA0B,CACtC9B,EAAS8B,CAAI,CACf,CAFS,OAAAnF,EAAAkF,GAAA,QAIF,CAIL,aAAAjF,EAIA,UAAAgD,EAIA,OAAQqB,EAAWrB,EAAU,YAAY,IAAI,EAI7C,UACEe,GACAlB,GACAoB,GACAlB,EAIF,aACEQ,EAAyB,WACzBC,EAAyB,WACzBC,EAA6B,UAI/B,cAAAa,GAMA,iBAAkBvE,EAAC0E,GAAwB,CACzC,GAAIzB,EAAU,YAAY,OAAS,YAAcgB,EAAqB,CACpE,IAAMa,EAAeH,EACnBD,EACAT,GAAqB,MACvB,EAEA,OAAOA,GAAqB,iBAAiBa,CAAY,CAC3D,CACA,GAAIf,EAAgB,CAClB,IAAMe,EAAeH,EAAmBD,EAAQX,GAAgB,MAAM,EAEtE,OAAOA,GAAgB,iBAAiBe,CAAY,CACtD,CACA,OAAO,IACT,EAfkB,oBAoBlB,kBAAmB5B,EAOnB,gBAAAuB,EAOA,SAAAG,GAMA,KAAAI,GAMA,KAAAC,GAOA,KAAAC,GAKA,KAAM,CACJ,OAAQzC,EAAc,OACxB,CACF,CACF,EAnR6B","names":["createHeadlessForm","modify","useMutation","useQuery","useRef","useState","mergeWith","jsonSchemaToEmployment","useEmployment","__name","employmentId","client","useClient","useQuery","response","getShowEmployment","useBenefitOffers","getIndexBenefitOffer","data","acc","item","useEmploymentInvite","useMutation","payload","postInviteEmploymentInvitation","useJSONSchemaForm","countryCode","form","fieldValues","options","employment","jsonSchemaQueryParam","getShowFormCountry","jsfSchema","schema","modify","hasFieldValues","employmentField","employmentFieldData","createHeadlessForm","useBenefitOffersSchema","getShowSchema","useCreateEmployment","postCreateEmployment2","useUpdateEmployment","patchUpdateEmployment2","useUpdateBenefitsOffers","putUpdateBenefitOffer","useOnboarding","type","fieldsMetaRef","useRef","internalEmploymentId","setInternalEmploymentId","useState","isLoadingEmployment","benefitOffers","isLoadingBenefitOffers","stepState","setFieldValues","previousStep","nextStep","goToStep","useStepState","STEPS","createEmploymentMutation","updateEmploymentMutation","updateBenefitsOffersMutation","createEmploymentMutationAsync","mutationToPromise","updateEmploymentMutationAsync","updateBenefitsOffersMutationAsync","onboardingForm","isLoadingBasicInformation","benefitOffersSchema","isLoadingBenefitsOffersSchema","benefitsFormValues","initialValuesBenefitOffers","mergeWith","stepFields","initialValues","getInitialValues","parseFormValues","values","parseJSFToValidate","onSubmit","prettifyFormValues","parsedValues","error","back","next","goTo","step"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as h}from"./chunk-HSW5HMHH.js";import{a as S}from"./chunk-XFD3ULUF.js";import{a as P}from"./chunk-WWANHPT7.js";import{a as F}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as h}from"./chunk-HSW5HMHH.js";import{a as S}from"./chunk-XFD3ULUF.js";import{a as P}from"./chunk-WWANHPT7.js";import{a as F}from"./chunk-S4XU4SE7.js";import{b as T}from"./chunk-36UPHOJS.js";import{a as y}from"./chunk-JRQSZHUU.js";import{b as p}from"./chunk-DHRIURRT.js";import{a as V}from"./chunk-2URGWNSM.js";import{d as _}from"./chunk-WRDKLT4N.js";import{c as s}from"./chunk-N25EBX6R.js";import{a as e}from"./chunk-AYDF3IFZ.js";import{createHeadlessForm as g,modify as x}from"@remoteoss/json-schema-form";import{useMutation as A,useQuery as K}from"@tanstack/react-query";import L from"lodash/omitBy";import q from"lodash/isNull";import z from"lodash/omit";function R(o){return{confidential:"",customer_informed_employee:"",customer_informed_employee_date:"",customer_informed_employee_description:"",personal_email:"",termination_reason:void 0,reason_description:"",termination_reason_files:[],will_challenge_termination:"",will_challenge_termination_description:null,agrees_to_pto_amount:"",agrees_to_pto_amount_notes:null,acknowledge_termination_procedure:!1,additional_comments:"",proposed_termination_date:"",risk_assessment_reasons:[],timesheet_file:void 0,...o}}e(R,"buildInitialValues");var B=e(()=>{let{client:o}=_();return A({mutationFn:e(n=>p({client:o,headers:{Authorization:""},body:n}),"mutationFn")})},"useCreateTermination"),I=e(({formValues:o,jsfModify:n,step:m})=>K({queryKey:["rmt-flows-termination-schema",m],queryFn:e(()=>h[m]??S,"queryFn"),select:e(({data:u})=>{let i=u?.schema||{};if(n){let{schema:d}=x(i,n);i=d}return g(i||{},{initialValues:o||{}})},"select")}),"useTerminationSchema"),ue=e(({employmentId:o,options:n})=>{let{fieldValues:m,setFieldValues:u,stepState:i,previousStep:f,nextStep:d}=V(F),k={...i.values?.[i.currentStep.name],...m},{data:r,isLoading:w}=I({formValues:k,jsfModify:n?.jsfModify,step:i.currentStep.name}),l=g(P.data.schema),c=B(),{mutateAsync:b}=y(c);async function C(a){if(!o)throw new Error("Employment id is missing");if(r){let t=s(a,l.fields,{isPartialValidation:!0}),{customer_informed_employee:j}=t,D=j==="yes"?{employee_awareness:{date:t.customer_informed_employee_date,note:t.customer_informed_employee_description}}:void 0,H=T(t,["agrees_to_pto_amount","confidential","customer_informed_employee","will_challenge_termination"]),J=z(H,"customer_informed_employee_date","customer_informed_employee_description"),O=L({...J,...D},q);return b({employment_id:o,termination_details:O,type:"termination"})}}e(C,"onSubmit");function M(){f()}e(M,"back");function v(){d()}e(v,"next");let E=R({...i.values?.employee_communication,...i.values?.termination_details,...i.values?.paid_time_off,...i.values?.additional_information});return{employmentId:o,stepState:i,fields:r?.fields||[],isLoading:w,isSubmitting:c.isPending,initialValues:E,handleValidation:e(a=>{if(r){let t=s(a,r?.fields);return r?.handleValidation(t)}return null},"handleValidation"),checkFieldUpdates:e(a=>{if(l){let t=s(a,l?.fields,{isPartialValidation:!0});u(t)}},"checkFieldUpdates"),parseFormValues:e(a=>s(a,l.fields,{isPartialValidation:!0}),"parseFormValues"),onSubmit:C,back:M,next:v}},"useTermination");export{ue as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4N3CYS6F.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as l}from"./chunk-WS3C3WIJ.js";import{a as d}from"./chunk-U3I3TJKB.js";import{b as s}from"./chunk-A4RX3KRZ.js";import{a}from"./chunk-IDSJI7KQ.js";import{a as t}from"./chunk-AYDF3IFZ.js";import e,{useEffect as f}from"react";import{useForm as b}from"react-hook-form";function w({defaultValues:i,onSubmit:c,components:p}){let{formId:F,onboardingBag:o}=l(),u=s(o.handleValidation),r=b({resolver:u,defaultValues:i,shouldUnregister:!1,mode:"onBlur"});return f(()=>{o.employmentId&&o?.checkFieldUpdates(r.getValues())},[]),f(()=>{let y=r?.watch(n=>{Object.keys(n).some(m=>n[m]!==i[m])&&o?.checkFieldUpdates(n)});return()=>y?.unsubscribe()},[]),e.createElement(a,{...r},e.createElement("form",{id:F,onSubmit:r.handleSubmit(c),className:"space-y-4 RemoteFlows__OnboardingForm"},e.createElement(d,{components:p,fields:o.fields})))}t(w,"OnboardingForm");export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-76JJOA3E.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/OnboardingForm.tsx"],"sourcesContent":["import { JSONSchemaFormFields } from '@/src/components/form/JSONSchemaForm';\nimport { Form } from '@/src/components/ui/form';\nimport React, { useEffect } from 'react';\nimport { useOnboardingContext } from './context';\nimport { useForm } from 'react-hook-form';\nimport { useJsonSchemasValidationFormResolver } from '@/src/components/form/yupValidationResolver';\nimport { Fields } from '@remoteoss/json-schema-form';\nimport {\n BasicInformationFormPayload,\n BenefitsFormPayload,\n ContractDetailsFormPayload,\n} from '@/src/flows/Onboarding/types';\nimport { Components } from '@/src/types/remoteFlows';\n\ntype OnboardingFormProps = {\n onSubmit: (\n payload:\n | BasicInformationFormPayload\n | BenefitsFormPayload\n | ContractDetailsFormPayload,\n ) => void;\n components?: Components;\n fields?: Fields;\n defaultValues: Record<string, unknown>;\n};\n\nexport function OnboardingForm({\n defaultValues,\n onSubmit,\n components,\n}: OnboardingFormProps) {\n const { formId, onboardingBag } = useOnboardingContext();\n\n const resolver = useJsonSchemasValidationFormResolver(\n // @ts-expect-error no matching type\n onboardingBag.handleValidation,\n );\n\n const form = useForm({\n resolver,\n defaultValues,\n shouldUnregister: false,\n mode: 'onBlur',\n });\n\n useEffect(() => {\n // When the employmentId is set,\n // we need to run the checkFieldUpdates to update fieldValues in useStepState\n if (onboardingBag.employmentId) {\n onboardingBag?.checkFieldUpdates(form.getValues());\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const subscription = form?.watch((values) => {\n const isAnyFieldDirty = Object.keys(values).some(\n (key) =>\n values[key as keyof unknown]
|
|
1
|
+
{"version":3,"sources":["../src/flows/Onboarding/OnboardingForm.tsx"],"sourcesContent":["import { JSONSchemaFormFields } from '@/src/components/form/JSONSchemaForm';\nimport { Form } from '@/src/components/ui/form';\nimport React, { useEffect } from 'react';\nimport { useOnboardingContext } from './context';\nimport { useForm } from 'react-hook-form';\nimport { useJsonSchemasValidationFormResolver } from '@/src/components/form/yupValidationResolver';\nimport { Fields } from '@remoteoss/json-schema-form';\nimport {\n BasicInformationFormPayload,\n BenefitsFormPayload,\n ContractDetailsFormPayload,\n} from '@/src/flows/Onboarding/types';\nimport { Components } from '@/src/types/remoteFlows';\n\ntype OnboardingFormProps = {\n onSubmit: (\n payload:\n | BasicInformationFormPayload\n | BenefitsFormPayload\n | ContractDetailsFormPayload,\n ) => void;\n components?: Components;\n fields?: Fields;\n defaultValues: Record<string, unknown>;\n};\n\nexport function OnboardingForm({\n defaultValues,\n onSubmit,\n components,\n}: OnboardingFormProps) {\n const { formId, onboardingBag } = useOnboardingContext();\n\n const resolver = useJsonSchemasValidationFormResolver(\n // @ts-expect-error no matching type\n onboardingBag.handleValidation,\n );\n\n const form = useForm({\n resolver,\n defaultValues,\n shouldUnregister: false,\n mode: 'onBlur',\n });\n\n useEffect(() => {\n // When the employmentId is set,\n // we need to run the checkFieldUpdates to update fieldValues in useStepState\n if (onboardingBag.employmentId) {\n onboardingBag?.checkFieldUpdates(form.getValues());\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const subscription = form?.watch((values) => {\n const isAnyFieldDirty = Object.keys(values).some(\n (key) =>\n values[key as keyof unknown] !== defaultValues[key as keyof unknown],\n );\n if (isAnyFieldDirty) {\n onboardingBag?.checkFieldUpdates(values);\n }\n });\n return () => subscription?.unsubscribe();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <Form {...form}>\n <form\n id={formId}\n onSubmit={form.handleSubmit(onSubmit)}\n className=\"space-y-4 RemoteFlows__OnboardingForm\"\n >\n <JSONSchemaFormFields\n components={components}\n fields={onboardingBag.fields}\n />\n </form>\n </Form>\n );\n}\n"],"mappings":"mMAEA,OAAOA,GAAS,aAAAC,MAAiB,QAEjC,OAAS,WAAAC,MAAe,kBAsBjB,SAASC,EAAe,CAC7B,cAAAC,EACA,SAAAC,EACA,WAAAC,CACF,EAAwB,CACtB,GAAM,CAAE,OAAAC,EAAQ,cAAAC,CAAc,EAAIC,EAAqB,EAEjDC,EAAWC,EAEfH,EAAc,gBAChB,EAEMI,EAAOC,EAAQ,CACnB,SAAAH,EACA,cAAAN,EACA,iBAAkB,GAClB,KAAM,QACR,CAAC,EAED,OAAAU,EAAU,IAAM,CAGVN,EAAc,cAChBA,GAAe,kBAAkBI,EAAK,UAAU,CAAC,CAGrD,EAAG,CAAC,CAAC,EAELE,EAAU,IAAM,CACd,IAAMC,EAAeH,GAAM,MAAOI,GAAW,CACnB,OAAO,KAAKA,CAAM,EAAE,KACzCC,GACCD,EAAOC,CAAoB,IAAMb,EAAca,CAAoB,CACvE,GAEET,GAAe,kBAAkBQ,CAAM,CAE3C,CAAC,EACD,MAAO,IAAMD,GAAc,YAAY,CAEzC,EAAG,CAAC,CAAC,EAGHG,EAAA,cAACC,EAAA,CAAM,GAAGP,GACRM,EAAA,cAAC,QACC,GAAIX,EACJ,SAAUK,EAAK,aAAaP,CAAQ,EACpC,UAAU,yCAEVa,EAAA,cAACE,EAAA,CACC,WAAYd,EACZ,OAAQE,EAAc,OACxB,CACF,CACF,CAEJ,CAxDgBa,EAAAlB,EAAA","names":["React","useEffect","useForm","OnboardingForm","defaultValues","onSubmit","components","formId","onboardingBag","useOnboardingContext","resolver","useJsonSchemasValidationFormResolver","form","useForm","useEffect","subscription","values","key","React","Form","JSONSchemaFormFields","__name"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as l}from"./chunk-AYDF3IFZ.js";var d={basic_information:{index:0,name:"basic_information"},contract_details:{index:1,name:"contract_details"},benefits:{index:2,name:"benefits"},review:{index:3,name:"review"}};function o(s,a){return a?Object.fromEntries(Object.entries(s).map(([t,r])=>{if(r===void 0)return[t,void 0];let e=a.find(n=>n.name===t);if(e?.isVisible===!1||e?.deprecated)return[t,void 0];if(e?.type==="radio"||e?.type==="select"){let n=e.options.find(i=>i.value===r);return n?[t,{prettyValue:n?.label,label:e?.label}]:void 0}if(e?.type==="checkbox"&&e?.const)return[t,{prettyValue:!0,label:e.label}];if(e?.type==="countries"&&Array.isArray(r))return[t,{prettyValue:r.join(),label:e.label}];if(e?.type==="fieldset"){let n=o(r,e.fields);if(!n.label&&n.value){let i={...n.value,label:e.label};return[t,i]}return[t,n]}if(e)return[t,{prettyValue:r,label:e.label}]}).filter(Boolean)):{}}l(o,"prettifyFormValues");export{d as a,o as b};
|
|
2
|
+
//# sourceMappingURL=chunk-7B32RZXH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/Onboarding/utils.ts"],"sourcesContent":["import { Step } from '@/src/flows/useStepState';\nimport { Fields } from '@remoteoss/json-schema-form';\n\ntype StepKeys =\n | 'basic_information'\n | 'contract_details'\n | 'benefits'\n | 'review';\n\nexport const STEPS: Record<StepKeys, Step<StepKeys>> = {\n basic_information: { index: 0, name: 'basic_information' },\n contract_details: { index: 1, name: 'contract_details' },\n benefits: { index: 2, name: 'benefits' },\n review: { index: 3, name: 'review' },\n} as const;\n\n/**\n * Function to prettify form values. Returns a pretty value and label for each field.\n * @param values - Form values to prettify\n * @param fields - Form fields\n * @returns Prettified form values\n */\n// @ts-expect-error need to check function return type\nexport function prettifyFormValues(\n values: Record<string, unknown>,\n fields: Fields | undefined,\n) {\n if (!fields) {\n return {};\n }\n return Object.fromEntries(\n Object.entries(values)\n // @ts-expect-error need to check function return type\n .map(([key, value]) => {\n if (value === undefined) {\n return [key, undefined];\n }\n\n const field = fields.find((field) => field.name === key);\n\n if (field?.isVisible === false || field?.deprecated) {\n return [key, undefined];\n }\n\n if (field?.type === 'radio' || field?.type === 'select') {\n const option = (\n field.options as Array<{ value: string; label: string }>\n ).find((option) => option.value === value);\n\n if (option) {\n return [key, { prettyValue: option?.label, label: field?.label }];\n }\n return;\n }\n\n if (field?.type === 'checkbox' && field?.const) {\n return [key, { prettyValue: true, label: field.label }];\n }\n\n if (field?.type === 'countries' && Array.isArray(value)) {\n return [key, { prettyValue: value.join(), label: field.label }];\n }\n\n if (field?.type === 'fieldset') {\n // @ts-expect-error need to check function return type\n const prettiedFieldset = prettifyFormValues(\n value as Record<string, unknown>,\n field.fields as Fields,\n );\n\n // Handles benefits fieldset in specific\n if (!prettiedFieldset.label && prettiedFieldset.value) {\n const prettyValue: Record<string, unknown> = {\n ...prettiedFieldset.value,\n label: field.label,\n };\n return [key, prettyValue];\n }\n\n return [key, prettiedFieldset];\n }\n\n if (field) {\n return [key, { prettyValue: value, label: field.label }];\n }\n })\n .filter(Boolean),\n );\n}\n"],"mappings":"wCASO,IAAMA,EAA0C,CACrD,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,EACzD,iBAAkB,CAAE,MAAO,EAAG,KAAM,kBAAmB,EACvD,SAAU,CAAE,MAAO,EAAG,KAAM,UAAW,EACvC,OAAQ,CAAE,MAAO,EAAG,KAAM,QAAS,CACrC,EASO,SAASC,EACdC,EACAC,EACA,CACA,OAAKA,EAGE,OAAO,YACZ,OAAO,QAAQD,CAAM,EAElB,IAAI,CAAC,CAACE,EAAKC,CAAK,IAAM,CACrB,GAAIA,IAAU,OACZ,MAAO,CAACD,EAAK,MAAS,EAGxB,IAAME,EAAQH,EAAO,KAAMG,GAAUA,EAAM,OAASF,CAAG,EAEvD,GAAIE,GAAO,YAAc,IAASA,GAAO,WACvC,MAAO,CAACF,EAAK,MAAS,EAGxB,GAAIE,GAAO,OAAS,SAAWA,GAAO,OAAS,SAAU,CACvD,IAAMC,EACJD,EAAM,QACN,KAAMC,GAAWA,EAAO,QAAUF,CAAK,EAEzC,OAAIE,EACK,CAACH,EAAK,CAAE,YAAaG,GAAQ,MAAO,MAAOD,GAAO,KAAM,CAAC,EAElE,MACF,CAEA,GAAIA,GAAO,OAAS,YAAcA,GAAO,MACvC,MAAO,CAACF,EAAK,CAAE,YAAa,GAAM,MAAOE,EAAM,KAAM,CAAC,EAGxD,GAAIA,GAAO,OAAS,aAAe,MAAM,QAAQD,CAAK,EACpD,MAAO,CAACD,EAAK,CAAE,YAAaC,EAAM,KAAK,EAAG,MAAOC,EAAM,KAAM,CAAC,EAGhE,GAAIA,GAAO,OAAS,WAAY,CAE9B,IAAME,EAAmBP,EACvBI,EACAC,EAAM,MACR,EAGA,GAAI,CAACE,EAAiB,OAASA,EAAiB,MAAO,CACrD,IAAMC,EAAuC,CAC3C,GAAGD,EAAiB,MACpB,MAAOF,EAAM,KACf,EACA,MAAO,CAACF,EAAKK,CAAW,CAC1B,CAEA,MAAO,CAACL,EAAKI,CAAgB,CAC/B,CAEA,GAAIF,EACF,MAAO,CAACF,EAAK,CAAE,YAAaC,EAAO,MAAOC,EAAM,KAAM,CAAC,CAE3D,CAAC,EACA,OAAO,OAAO,CACnB,EA3DS,CAAC,CA4DZ,CAjEgBI,EAAAT,EAAA","names":["STEPS","prettifyFormValues","values","fields","key","value","field","option","prettiedFieldset","prettyValue","__name"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-XLFHHYVS.js";import{a as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a}from"./chunk-XLFHHYVS.js";import{a as c}from"./chunk-TGB3TV3K.js";import{a as e}from"./chunk-FMT2OTOL.js";import{a as m}from"./chunk-BLPOQIGB.js";import{a as r}from"./chunk-JT5XHQEY.js";import{a as o}from"./chunk-6HGUGIYJ.js";import{a as n}from"./chunk-AYDF3IFZ.js";import f,{useId as s}from"react";function k({employmentId:d,countryCode:C,options:p,render:A}){let t=c({employmentId:d,countryCode:C,options:p}),i=s();return f.createElement(o.Provider,{value:{formId:i,contractAmendmentBag:t}},A({contractAmendmentBag:t,components:{Form:r,SubmitButton:a,ConfirmationForm:m,BackButton:e}}))}n(k,"ContractAmendmentFlow");export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-C4E24DUG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as p}from"./chunk-SYWI4UB6.js";import{a as i}from"./chunk-MHKNAQLP.js";import{b as t}from"./chunk-3KAYKVK5.js";import{a as e}from"./chunk-YIBRPAR3.js";import{a as d}from"./chunk-FNTHWOZU.js";import{a as m}from"./chunk-OXOB35EA.js";import{a}from"./chunk-M7WCW7WD.js";import{a as r}from"./chunk-WS3C3WIJ.js";import{a as n}from"./chunk-AYDF3IFZ.js";import O,{useId as S}from"react";var R=n(({employmentId:f,countryCode:s,type:b="employee",render:g,options:c})=>{let B=S(),o=t({employmentId:f,countryCode:s,type:b,options:c});return O.createElement(r.Provider,{value:{formId:B,onboardingBag:o}},g({onboardingBag:o,components:{BasicInformationStep:e,ContractDetailsStep:m,BenefitsStep:d,SubmitButton:i,BackButton:a,OnboardingInvite:p}}))},"OnboardingFlow");export{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-DQM4AWYT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a}from"./chunk-76JJOA3E.js";import{b as s}from"./chunk-WS3C3WIJ.js";import{d as i}from"./chunk-N25EBX6R.js";import{a as t}from"./chunk-AYDF3IFZ.js";import d from"react";function v({components:m,onSubmit:p,onError:r,onSuccess:f}){let{onboardingBag:e}=s(),u=e.fields??[],c=i(u,e.initialValues.benefits);return d.createElement(a,{defaultValues:c,components:m,onSubmit:t(async n=>{try{await p?.(n);let o=await e.onSubmit(n);if(o?.data){await f?.(o.data),e?.next();return}o?.error&&r?.(o.error)}catch(o){r?.(o)}},"handleSubmit")})}t(v,"BenefitsStep");export{v as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FNTHWOZU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as p}from"./chunk-U3I3TJKB.js";import{b as l}from"./chunk-A4RX3KRZ.js";import{a as f}from"./chunk-IDSJI7KQ.js";import{c as u}from"./chunk-N25EBX6R.js";import{b as F}from"./chunk-6HGUGIYJ.js";import{a as r}from"./chunk-AYDF3IFZ.js";import a,{useEffect as P}from"react";import{useForm as w}from"react-hook-form";var k=["effective_date","reason_for_change","reason_for_change_description","additional_comments","additional_comments_toggle"];function U({onSubmit:_,onError:m,onSuccess:b}){let{formId:A,contractAmendment:{checkFieldUpdates:C,fields:s,onSubmit:h,stepState:S,initialValues:i,handleValidation:g}}=F(),y=l(g),e=w({resolver:y,defaultValues:S.values?.form||i,shouldUnregister:!0,mode:"onBlur"});P(()=>{let t=e?.watch(o=>{(Object.keys(e.formState.dirtyFields).length>0||e.formState.isDirty)&&C(o)});return()=>t?.unsubscribe()},[]);let V=r(async t=>{let o=!1;for(let[c,v]of Object.entries(t))if(!k.includes(c)&&i[c]!==v){o=!0;break}if(!o)return m?.({message:"no_changes_detected_contract_details"});let d=u(t,s,{isPartialValidation:!1});await _?.(d);let n=await h(t);n.error?m?.(n.error):await b?.(n.data)},"handleSubmit");return a.createElement(f,{...e},a.createElement("form",{id:A,"data-testid":"contract-amendment-form",onSubmit:e.handleSubmit(V),className:"space-y-4 RemoteFlows__ContractAmendmentForm"},a.createElement(p,{fields:s})))}r(U,"ContractAmendmentForm");export{U as a};
|
|
2
|
+
//# sourceMappingURL=chunk-JT5XHQEY.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as r}from"./chunk-MI3HDT5D.js";import{b as m}from"./chunk-DZYFSFZ7.js";import{a as o}from"./chunk-AYDF3IFZ.js";import a from"react";function p({onSubmit:n}){let{terminationBag:i}=m();return a.createElement(r,{onSubmit:o(async t=>{await n?.(i?.parseFormValues(t)),i?.next()},"handleSubmit")})}o(p,"PaidTimeOffForm");export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-KGUR7YMA.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as f}from"./chunk-DZYFSFZ7.js";import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as f}from"./chunk-DZYFSFZ7.js";import{a as l}from"./chunk-U3I3TJKB.js";import{b as s}from"./chunk-A4RX3KRZ.js";import{a}from"./chunk-IDSJI7KQ.js";import{a as t}from"./chunk-AYDF3IFZ.js";import e,{useEffect as y}from"react";import{useForm as T}from"react-hook-form";function w({fields:m,onSubmit:d}){let{formId:u,terminationBag:o}=f(),F=s(o.handleValidation),i=T({resolver:F,defaultValues:o?.initialValues,shouldUnregister:!1,mode:"onBlur"});y(()=>{let p=i?.watch(r=>{Object.keys(r).some(n=>r[n]!==o?.initialValues?.[n])&&o?.checkFieldUpdates(r)});return()=>p?.unsubscribe()},[]);let c=m||(o?.fields??[]);return e.createElement(a,{...i},e.createElement("form",{id:u,onSubmit:i.handleSubmit(d),className:"space-y-4 RemoteFlows__TerminationForm"},e.createElement(l,{fields:c})))}t(w,"TerminationForm");export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-MI3HDT5D.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as a}from"./chunk-N25EBX6R.js";import{a as r}from"./chunk-AYDF3IFZ.js";var m={form:{index:0,name:"form"},confirmation_form:{index:1,name:"confirmation_form"}};function _(t,o){if(!t)return{};if(!o)return{...t.data.employment?.contract_details,effective_date:"",reason_for_change:"",job_title:t.data.employment?.job_title,additional_comments:"",annual_gross_salary:a(t.data.employment?.contract_details?.annual_gross_salary)};let s=o.map(n=>n.name),i=Object.keys(t?.data?.employment?.contract_details||{});return{...s.reduce((n,e)=>{if(i.includes(e)){let c=t?.data?.employment?.contract_details;n[e]=c[e]}return n},{}),effective_date:"",reason_for_change:"",job_title:t.data.employment?.job_title,additional_comments:"",annual_gross_salary:a(t.data.employment?.contract_details?.annual_gross_salary),additional_comments_toggle:!1}}r(_,"buildInitialValues");export{m as a,_ as b};
|
|
2
|
+
//# sourceMappingURL=chunk-NVMRRBRE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/ContractAmendment/utils.ts"],"sourcesContent":["import { EmploymentShowResponse } from '@/src/client';\nimport { convertFromCents } from '@/src/components/form/utils';\nimport { Fields } from '@remoteoss/json-schema-form';\nimport { Step } from '../useStepState';\n\ntype StepKeys = 'form' | 'confirmation_form';\n\nexport const STEPS: Record<StepKeys, Step<StepKeys>> = {\n form: { index: 0, name: 'form' },\n confirmation_form: { index: 1, name: 'confirmation_form' },\n} as const;\n\nexport function buildInitialValues(\n employment: EmploymentShowResponse | undefined,\n fields?: Fields | undefined,\n) {\n if (!employment) {\n return {};\n }\n\n if (!fields) {\n return {\n ...employment.data.employment?.contract_details,\n effective_date: '',\n reason_for_change: '',\n job_title: employment.data.employment?.job_title,\n additional_comments: '',\n annual_gross_salary: convertFromCents(\n employment.data.employment?.contract_details\n ?.annual_gross_salary as string,\n ),\n };\n }\n\n const allFields = fields.map((field) => field.name);\n const employmentFields = Object.keys(\n employment?.data?.employment?.contract_details || {},\n );\n const initialValues = allFields.reduce<Record<string, unknown>>(\n (initialValuesAcc, field) => {\n // @ts-expect-error error\n if (employmentFields.includes(field)) {\n const contractDetails = employment?.data?.employment\n ?.contract_details as Record<string, unknown>;\n // @ts-expect-error error\n initialValuesAcc[field] = contractDetails[field];\n }\n return initialValuesAcc;\n },\n {} as Record<string, unknown>,\n );\n\n return {\n ...initialValues,\n effective_date: '',\n reason_for_change: '',\n job_title: employment.data.employment?.job_title,\n additional_comments: '',\n annual_gross_salary: convertFromCents(\n employment.data.employment?.contract_details\n ?.annual_gross_salary as string,\n ),\n additional_comments_toggle: false,\n };\n}\n"],"mappings":"gFAOO,IAAMA,EAA0C,CACrD,KAAM,CAAE,MAAO,EAAG,KAAM,MAAO,EAC/B,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,CAC3D,EAEO,SAASC,EACdC,EACAC,EACA,CACA,GAAI,CAACD,EACH,MAAO,CAAC,EAGV,GAAI,CAACC,EACH,MAAO,CACL,GAAGD,EAAW,KAAK,YAAY,iBAC/B,eAAgB,GAChB,kBAAmB,GACnB,UAAWA,EAAW,KAAK,YAAY,UACvC,oBAAqB,GACrB,oBAAqBE,EACnBF,EAAW,KAAK,YAAY,kBACxB,mBACN,CACF,EAGF,IAAMG,EAAYF,EAAO,IAAKG,GAAUA,EAAM,IAAI,EAC5CC,EAAmB,OAAO,KAC9BL,GAAY,MAAM,YAAY,kBAAoB,CAAC,CACrD,EAeA,MAAO,CACL,GAfoBG,EAAU,OAC9B,CAACG,EAAkBF,IAAU,CAE3B,GAAIC,EAAiB,SAASD,CAAK,EAAG,CACpC,IAAMG,EAAkBP,GAAY,MAAM,YACtC,iBAEJM,EAAiBF,CAAK,EAAIG,EAAgBH,CAAK,CACjD,CACA,OAAOE,CACT,EACA,CAAC,CACH,EAIE,eAAgB,GAChB,kBAAmB,GACnB,UAAWN,EAAW,KAAK,YAAY,UACvC,oBAAqB,GACrB,oBAAqBE,EACnBF,EAAW,KAAK,YAAY,kBACxB,mBACN,EACA,2BAA4B,EAC9B,CACF,CApDgBQ,EAAAT,EAAA","names":["STEPS","buildInitialValues","employment","fields","convertFromCents","allFields","field","employmentFields","initialValuesAcc","contractDetails","__name"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i}from"./chunk-76JJOA3E.js";import{b as n}from"./chunk-WS3C3WIJ.js";import{a as r}from"./chunk-AYDF3IFZ.js";import l from"react";function S({onSubmit:s,onError:a,onSuccess:m}){let{onboardingBag:t}=n(),p=r(async e=>{try{await s?.(t.parseFormValues(e));let o=await t.onSubmit(e);if(o?.data){await m?.(o.data),t?.next();return}o?.error&&a?.(o.error)}catch(o){a?.(o)}},"handleSubmit");return l.createElement(i,{defaultValues:t.stepState.values?.contract_details||t.initialValues.contract_details,onSubmit:p})}r(S,"ContractDetailsStep");export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-OXOB35EA.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-MI3HDT5D.js";import{b as r}from"./chunk-DZYFSFZ7.js";import{a as o}from"./chunk-AYDF3IFZ.js";import a from"react";function p({onSubmit:n}){let{terminationBag:i}=r();return a.createElement(m,{onSubmit:o(async t=>{await n?.(i?.parseFormValues(t)),i?.next()},"handleSubmit")})}o(p,"TerminationDetailsForm");export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-QOXOAPGX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var i={employee_communication:{index:0,name:"employee_communication"},termination_details:{index:1,name:"termination_details"},paid_time_off:{index:2,name:"paid_time_off"},additional_information:{index:3,name:"additional_information"}};export{i as a};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-S4XU4SE7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/Termination/utils.ts"],"sourcesContent":["import { Step } from '@/src/flows/useStepState';\n\nexport type StepTerminationKeys =\n | 'employee_communication'\n | 'termination_details'\n | 'paid_time_off'\n | 'additional_information';\n\nexport const STEPS: Record<StepTerminationKeys, Step<StepTerminationKeys>> = {\n employee_communication: { index: 0, name: 'employee_communication' },\n termination_details: { index: 1, name: 'termination_details' },\n paid_time_off: { index: 2, name: 'paid_time_off' },\n additional_information: { index: 3, name: 'additional_information' },\n} as const;\n"],"mappings":"AAQO,IAAMA,EAAgE,CAC3E,uBAAwB,CAAE,MAAO,EAAG,KAAM,wBAAyB,EACnE,oBAAqB,CAAE,MAAO,EAAG,KAAM,qBAAsB,EAC7D,cAAe,CAAE,MAAO,EAAG,KAAM,eAAgB,EACjD,uBAAwB,CAAE,MAAO,EAAG,KAAM,wBAAyB,CACrE","names":["STEPS"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-3KAYKVK5.js";import{b as a}from"./chunk-WS3C3WIJ.js";import{a as s}from"./chunk-JRQSZHUU.js";import{b as i}from"./chunk-56BNVYTD.js";import{a as o}from"./chunk-AYDF3IFZ.js";import y from"react";function w({onSubmit:u,onSuccess:c,onError:n,...e}){let{onboardingBag:r}=a(),d=m(),{mutateAsync:p}=s(d),l=o(async()=>{try{if(await u?.(),!r.employmentId)throw new Error("Employment ID is required");let t=await p({employment_id:r.employmentId});if(t.data){await c?.(t.data);return}t.error&&n?.(t.error)}catch(t){n?.(t)}},"handleSubmit");return y.createElement(i,{...e,onClick:()=>{l()}},e.children)}o(w,"OnboardingInvite");export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-SYWI4UB6.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as n}from"./chunk-MI3HDT5D.js";import{b as i}from"./chunk-DZYFSFZ7.js";import{a as o}from"./chunk-AYDF3IFZ.js";import e from"react";function l({onSubmit:r}){let{terminationBag:m}=i();return e.createElement(n,{onSubmit:o(async t=>{await r?.(m?.parseFormValues(t)),m?.next()},"handleSubmit")})}o(l,"EmployeeCommunicationForm");export{l as a};
|
|
2
|
+
//# sourceMappingURL=chunk-T3PTQ4QM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as v}from"./chunk-QOMUXX6W.js";import{a as S}from"./chunk-JRQSZHUU.js";import{a as l,b as V}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as v}from"./chunk-QOMUXX6W.js";import{a as S}from"./chunk-JRQSZHUU.js";import{a as l,b as V}from"./chunk-NVMRRBRE.js";import{c as P,i as b,p as w}from"./chunk-DHRIURRT.js";import{a as M}from"./chunk-2URGWNSM.js";import{d}from"./chunk-WRDKLT4N.js";import{a as j,c as A}from"./chunk-N25EBX6R.js";import{a as e}from"./chunk-AYDF3IFZ.js";import{createHeadlessForm as R,modify as B}from"@remoteoss/json-schema-form";import{useMutation as L,useQuery as J}from"@tanstack/react-query";var K=e(({countryCode:a,employment:t,fieldValues:i,options:n})=>{let{client:u}=d(),s=n?.jsonSchemaVersion?.contract_amendments?{json_schema_version:n.jsonSchemaVersion.contract_amendments}:{};return J({queryKey:["contract-amendment-schema"],retry:!1,queryFn:e(async()=>{let r=await P({client:u,headers:{Authorization:""},query:{employment_id:t?.data?.employment?.id,country_code:a,...s}});if(r.error||!r.data)throw new Error("Failed to fetch contract amendment schema");return r},"queryFn"),enabled:!!t,select:e(({data:r})=>{let c=r?.data||{};if(n&&n.jsfModify){let{schema:f}=B(c,n.jsfModify);c=f}let o={...i,annual_gross_salary:i?.annual_gross_salary?j(i?.annual_gross_salary):void 0},p=Object.keys(o).length>0;return R(c,{initialValues:p?o:V(t)})},"select")})},"useContractAmendmentSchemaQuery"),O=e(()=>{let{client:a}=d();return L({mutationFn:e(t=>b({client:a,headers:{Authorization:""},body:t}),"mutationFn")})},"useCreateContractAmendmentMutation"),U=e(()=>{let{client:a}=d();return L({mutationFn:e(t=>w({client:a,headers:{Authorization:""},body:t}),"mutationFn")})},"useAutomatableContractAmendmentMutation"),ae=e(({employmentId:a,countryCode:t,options:i})=>{let{fieldValues:n,setFieldValues:u,stepState:s,nextStep:r,previousStep:c}=M(l),{data:o,isLoading:p,isError:_,error:f}=v({employmentId:a}),{data:m,isLoading:T,isError:k,error:Q}=K({employment:o,countryCode:t,fieldValues:{...s.values?.[s.currentStep.name],...n},options:i}),q=V(o,m?.fields),g=O(),E=U();async function z(y){let C=A(y,m?.fields||[],{isPartialValidation:!1}),F={employment_id:o?.data.employment?.id,amendment_contract_id:o?.data.employment?.active_contract_id,contract_amendment:{...C}};switch(s.currentStep.name){case l.form.name:{let{mutateAsync:h}=S(E),I=await h(F);return r(),I}case l.confirmation_form.name:{let{mutateAsync:h}=S(g);return h(F)}default:throw new Error("Invalid step state")}}e(z,"onSubmit");function x(y){if(m){let C=A(y,m?.fields);return m?.handleValidation(C)}return null}e(x,"handleValidation");function H(){c()}return e(H,"back"),{stepState:s,fields:m?.fields||[],isLoading:p||T,isError:_||k,error:f||Q,isSubmitting:E.isPending||g.isPending,initialValues:q,values:n,handleValidation:x,checkFieldUpdates:u,onSubmit:z,back:H}},"useContractAmendment");export{ae as a};
|
|
2
|
+
//# sourceMappingURL=chunk-TGB3TV3K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/ContractAmendment/hooks.ts"],"sourcesContent":["import {\n CreateContractAmendmentParams,\n EmploymentShowResponse,\n getShowContractAmendmentSchema,\n postAutomatableContractAmendment,\n postCreateContractAmendment,\n} from '@/src/client';\n\nimport {\n convertToCents,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { mutationToPromise } from '@/src/lib/mutations';\n\nimport { Client } from '@hey-api/client-fetch';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { ContractAmendmentParams } from './types';\n\nimport { useEmploymentQuery } from '@/src/common/hooks';\nimport { useClient } from '@/src/context';\nimport { FieldValues } from 'react-hook-form';\nimport { useStepState } from '../useStepState';\nimport { buildInitialValues, STEPS } from './utils';\n\ntype ContractAmendmentSchemaParams = {\n countryCode: string;\n employment: EmploymentShowResponse | undefined;\n fieldValues: FieldValues | undefined;\n options?: ContractAmendmentParams['options'];\n};\n\nconst useContractAmendmentSchemaQuery = ({\n countryCode,\n employment,\n fieldValues,\n options,\n}: ContractAmendmentSchemaParams) => {\n const { client } = useClient();\n const jsonSchemaQueryParam = options?.jsonSchemaVersion?.contract_amendments\n ? {\n json_schema_version: options.jsonSchemaVersion.contract_amendments,\n }\n : {};\n return useQuery({\n queryKey: ['contract-amendment-schema'],\n retry: false,\n queryFn: async () => {\n const response = await getShowContractAmendmentSchema({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n query: {\n employment_id: employment?.data?.employment?.id as string,\n country_code: countryCode,\n ...jsonSchemaQueryParam,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch contract amendment schema');\n }\n\n return response;\n },\n enabled: Boolean(employment),\n select: ({ data }) => {\n let jsfSchema = data?.data || {};\n\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n\n const copyFieldValues = {\n ...fieldValues,\n annual_gross_salary: fieldValues?.annual_gross_salary\n ? convertToCents(fieldValues?.annual_gross_salary)\n : undefined,\n };\n\n const hasFieldValues = Object.keys(copyFieldValues).length > 0;\n\n const result = createHeadlessForm(jsfSchema, {\n initialValues: hasFieldValues\n ? copyFieldValues\n : buildInitialValues(employment),\n });\n return result;\n },\n });\n};\n\nconst useCreateContractAmendmentMutation = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: CreateContractAmendmentParams) => {\n return postCreateContractAmendment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\nconst useAutomatableContractAmendmentMutation = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: CreateContractAmendmentParams) => {\n return postAutomatableContractAmendment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\nexport const useContractAmendment = ({\n employmentId,\n countryCode,\n options,\n}: ContractAmendmentParams) => {\n const { fieldValues, setFieldValues, stepState, nextStep, previousStep } =\n useStepState<keyof typeof STEPS>(STEPS);\n\n const {\n data: employment,\n isLoading: isLoadingEmployment,\n isError: isErrorEmployment,\n error: errorEmployment,\n } = useEmploymentQuery({\n employmentId,\n });\n\n const {\n data: contractAmendmentHeadlessForm,\n isLoading: isLoadingContractAmendments,\n isError: isErrorContractAmendmentSchema,\n error: errorContractAmendmentSchema,\n } = useContractAmendmentSchemaQuery({\n employment,\n countryCode,\n // In case the user is navigating back to the form step, we need to\n // pass the previous field values, so that the schema can be\n // generated with the correct values.\n fieldValues: {\n ...stepState.values?.[stepState.currentStep.name], // Restore values for the current step\n ...fieldValues,\n },\n options,\n });\n\n const initialValues = buildInitialValues(\n employment,\n contractAmendmentHeadlessForm?.fields,\n );\n\n const createContractAmendmentMutation = useCreateContractAmendmentMutation();\n const automatableContractAmendmentMutation =\n useAutomatableContractAmendmentMutation();\n\n async function onSubmit(values: FieldValues) {\n const parsedValues = parseJSFToValidate(\n values,\n contractAmendmentHeadlessForm?.fields || [],\n {\n isPartialValidation: false,\n },\n );\n\n const payload = {\n employment_id: employment?.data.employment?.id as string,\n amendment_contract_id: employment?.data.employment\n ?.active_contract_id as string,\n contract_amendment: {\n ...parsedValues,\n },\n };\n\n switch (stepState.currentStep.name) {\n case STEPS.form.name: {\n const { mutateAsync } = mutationToPromise(\n automatableContractAmendmentMutation,\n );\n\n const automatableContractAmendment = await mutateAsync(payload);\n\n nextStep();\n\n return automatableContractAmendment;\n }\n case STEPS.confirmation_form.name: {\n const { mutateAsync } = mutationToPromise(\n createContractAmendmentMutation,\n );\n\n return mutateAsync(payload);\n }\n\n default:\n throw new Error('Invalid step state');\n }\n }\n\n function handleValidation(values: FieldValues) {\n if (contractAmendmentHeadlessForm) {\n const parsedValues = parseJSFToValidate(\n values,\n contractAmendmentHeadlessForm?.fields,\n );\n\n return contractAmendmentHeadlessForm?.handleValidation(parsedValues);\n }\n return null;\n }\n\n function back() {\n previousStep();\n }\n\n return {\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n /**\n * Array of form fields from the contract amendment schema\n */\n fields: contractAmendmentHeadlessForm?.fields || [],\n /**\n * Loading state indicating if either employment or contract amendment data is being fetched\n */\n isLoading: isLoadingEmployment || isLoadingContractAmendments,\n /**\n * Error state indicating if there was an error fetching either employment or contract amendment data\n */\n isError: isErrorEmployment || isErrorContractAmendmentSchema,\n /**\n * Error object containing details about any errors that occurred during data fetching\n */\n error: errorEmployment || errorContractAmendmentSchema,\n /**\n * Loading state indicating if a contract amendment mutation is in progress\n */\n isSubmitting:\n automatableContractAmendmentMutation.isPending ||\n createContractAmendmentMutation.isPending,\n /**\n * Initial form values built from employment data and contract amendment fields\n */\n initialValues,\n /**\n * Current form field values\n */\n values: fieldValues,\n /**\n * Function to validate form values against the contract amendment schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation,\n /**\n * Function to update the current form field values\n * @param values - New form values to set\n */\n checkFieldUpdates: setFieldValues,\n /**\n * Function to handle form submission\n * @param values - Form values to submit\n * @returns Promise resolving to the mutation result\n */\n onSubmit,\n /**\n * Function to handle going back to the previous step\n * @returns {void}\n */\n back,\n };\n};\n"],"mappings":"uVAeA,OAAS,sBAAAA,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBAgBtC,IAAMC,EAAkCC,EAAA,CAAC,CACvC,YAAAC,EACA,WAAAC,EACA,YAAAC,EACA,QAAAC,CACF,IAAqC,CACnC,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EACvBC,EAAuBH,GAAS,mBAAmB,oBACrD,CACE,oBAAqBA,EAAQ,kBAAkB,mBACjD,EACA,CAAC,EACL,OAAOI,EAAS,CACd,SAAU,CAAC,2BAA2B,EACtC,MAAO,GACP,QAASR,EAAA,SAAY,CACnB,IAAMS,EAAW,MAAMC,EAA+B,CACpD,OAAQL,EACR,QAAS,CACP,cAAe,EACjB,EACA,MAAO,CACL,cAAeH,GAAY,MAAM,YAAY,GAC7C,aAAcD,EACd,GAAGM,CACL,CACF,CAAC,EAGD,GAAIE,EAAS,OAAS,CAACA,EAAS,KAC9B,MAAM,IAAI,MAAM,2CAA2C,EAG7D,OAAOA,CACT,EAnBS,WAoBT,QAAS,EAAQP,EACjB,OAAQF,EAAA,CAAC,CAAE,KAAAW,CAAK,IAAM,CACpB,IAAIC,EAAYD,GAAM,MAAQ,CAAC,EAE/B,GAAIP,GAAWA,EAAQ,UAAW,CAChC,GAAM,CAAE,OAAAS,CAAO,EAAIC,EAAOF,EAAWR,EAAQ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adlessForm","modify","useMutation","useQuery","useContractAmendmentSchemaQuery","__name","countryCode","employment","fieldValues","options","client","useClient","jsonSchemaQueryParam","useQuery","response","getShowContractAmendmentSchema","data","jsfSchema","schema","modify","copyFieldValues","convertToCents","hasFieldValues","createHeadlessForm","buildInitialValues","useCreateContractAmendmentMutation","useMutation","payload","postCreateContractAmendment","useAutomatableContractAmendmentMutation","postAutomatableContractAmendment","useContractAmendment","employmentId","setFieldValues","stepState","nextStep","previousStep","useStepState","STEPS","isLoadingEmployment","isErrorEmployment","errorEmployment","useEmploymentQuery","contractAmendmentHeadlessForm","isLoadingContractAmendments","isErrorContractAmendmentSchema","errorContractAmendmentSchema","initialValues","createContractAmendmentMutation","automatableContractAmendmentMutation","onSubmit","values","parsedValues","parseJSFToValidate","mutateAsync","mutationToPromise","automatableContractAmendment","handleValidation","back"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as e}from"./chunk-4N3CYS6F.js";import{a}from"./chunk-T3PTQ4QM.js";import{a as f}from"./chunk-KGUR7YMA.js";import{a as r}from"./chunk-YOC3VDC7.js";import{a as p}from"./chunk-QOXOAPGX.js";import{a as m}from"./chunk-KSGPQCSG.js";import{a as n}from"./chunk-D3SD6MMV.js";import{a as T}from"./chunk-WZ5AXHQT.js";import{a as t}from"./chunk-DZYFSFZ7.js";import{a as i}from"./chunk-AYDF3IFZ.js";import c,{useId as u}from"react";var k=i(({employmentId:d,render:s,options:l})=>{let y=u(),o=e({employmentId:d,options:l});return c.createElement(t.Provider,{value:{formId:y,terminationBag:o}},s({terminationBag:o,components:{SubmitButton:m,TimeOff:n,Back:r,EmployeeComunicationStep:a,TerminationDetailsStep:p,PaidTimeOffStep:f,AdditionalDetailsStep:T}}))},"TerminationFlow");export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-TXLTMGOU.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as Fe}from"./chunk-GFBF55NR.js";import{b as v}from"./chunk-WRDKLT4N.js";import{a as ce,b as H}from"./chunk-56BNVYTD.js";import{b as x,c as N,d as h,e as w,f as R,g as k}from"./chunk-IDSJI7KQ.js";import{a as s}from"./chunk-5ETXP2QF.js";import{a as r}from"./chunk-AYDF3IFZ.js";import U,{Fragment as Vt}from"react";import*as $ from"react";import*as Y from"@radix-ui/react-checkbox";import{Check as tt}from"lucide-react";var oe=$.forwardRef(({className:e,...t},o)=>$.createElement(Y.Root,{ref:o,className:s("peer h-4 w-4 shrink-0 rounded-sm border border-input ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-checkbox data-[state=checked]:text-primary",e),...t},$.createElement(Y.Indicator,{className:s("flex items-center justify-center text-current")},$.createElement(tt,{className:"h-4 w-4"}))));oe.displayName=Y.Root.displayName;import*as D from"react";import{useFormContext as ot}from"react-hook-form";function ve({name:e,defaultValue:t,description:o,label:a,onChange:i,multiple:c,options:p,component:F,..._}){let{components:n}=v(),{control:d}=ot(),u=r((m,l,g)=>{let y=g.value?[...g.value]:[];l?y.includes(m)||g.onChange([...y,m]):g.onChange(y.filter(z=>z!==m))},"handleCheckboxChange");return D.createElement(x,{control:d,name:e,defaultValue:t,render:({field:m,fieldState:l})=>{let g=F||n?.checkbox;if(g){let y={name:e,description:o,label:a,defaultValue:t,multiple:c,options:p,..._};return D.createElement(g,{field:{...m,onChange:r(z=>{if(c){let{checked:te,value:I}=z.target;u(I,te,m),i?.(te);return}m.onChange(z),i?.(z)},"onChange")},fieldState:l,fieldData:y})}return D.createElement(N,{"data-field":e,className:s(`RemoteFlows__CheckBoxField__Item__${e}`)},D.createElement(w,null,D.createElement(D.Fragment,null,p&&c?D.createElement(h,null,a):null,p&&c?p.map(y=>D.createElement("div",{key:y.value,className:"flex space-x-2"},D.createElement(oe,{id:y.value,onCheckedChange:z=>{u(y.value,z===!0,m),i?.(z,y.value)},checked:m.value?.includes(y.value),className:"RemoteFlows__CheckBox__Input"}),D.createElement(h,{htmlFor:y.value,className:"mb-0 RemoteFlows__CheckBox__Label"},y.label))):D.createElement("div",{className:"flex space-x-2"},D.createElement(oe,{id:e,onCheckedChange:y=>{m.onChange(y),i?.(y)},checked:m.value,className:"RemoteFlows__CheckBox__Input"}),D.createElement(h,{htmlFor:e,className:"mb-0 RemoteFlows__CheckBox__Label"},a)))),o&&D.createElement(R,null,o),l.error&&D.createElement(k,null))}})}r(ve,"CheckBoxField");import{CalendarIcon as it}from"lucide-react";import*as P from"react";import{useFormContext as st}from"react-hook-form";import*as re from"react";import{ChevronLeft as rt,ChevronRight as at}from"lucide-react";import{DayPicker as nt}from"react-day-picker";function xe({className:e,classNames:t,showOutsideDays:o=!0,...a}){return re.createElement(nt,{showOutsideDays:o,className:s("p-3",e),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:s(ce({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:s("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",a.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:s(ce({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:r(({className:i,...c})=>re.createElement(rt,{className:s("size-4",i),...c}),"IconLeft"),IconRight:r(({className:i,...c})=>re.createElement(at,{className:s("size-4",i),...c}),"IconRight")},...a})}r(xe,"Calendar");import*as Q from"react";import*as B from"@radix-ui/react-popover";function ae({...e}){return Q.createElement(B.Root,{"data-slot":"popover",...e})}r(ae,"Popover");function ne({...e}){return Q.createElement(B.Trigger,{"data-slot":"popover-trigger",...e})}r(ne,"PopoverTrigger");function ie({className:e,align:t="center",sideOffset:o=4,...a}){return Q.createElement(B.Portal,null,Q.createElement(B.Content,{"data-slot":"popover-content",align:t,sideOffset:o,className:s("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...a}))}r(ie,"PopoverContent");import{PopoverClose as lt}from"@radix-ui/react-popover";import{format as Ce}from"date-fns";function _e({description:e,label:t,name:o,minDate:a,onChange:i,component:c,...p}){let{components:F}=v(),{control:_}=st();return P.createElement(x,{control:_,name:o,render:({field:n,fieldState:d})=>{let u=c||F?.date;if(u){let m={description:e,label:t,name:o,minDate:a,onChange:i,...p};return P.createElement(u,{field:{...n,onChange:r(l=>{n.onChange(l),i?.(l)},"onChange")},fieldState:d,fieldData:m})}return P.createElement(N,{"data-field":o,className:`flex flex-col RemoteFlows__DatePickerField__Item__${o}`},P.createElement(h,{className:"RemoteFlows__DatePickerField__Label"},t),P.createElement(ae,null,P.createElement(ne,{asChild:!0},P.createElement(w,null,P.createElement("div",null,P.createElement(H,{type:"button",variant:"outline",className:s("w-full pl-3 text-left font-normal",!n.value&&"text-muted-foreground"),"data-testid":`date-picker-button-${o}`},n.value&&P.createElement(P.Fragment,null,Ce(n.value,"yyyy-MM-dd")),P.createElement(it,{className:"ml-auto h-4 w-4 opacity-50"}))))),P.createElement(ie,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start"},P.createElement(xe,{mode:"single",className:"RemoteFlows__DatepickerField__Calendar",selected:n.value?new Date(n.value):void 0,onSelect:m=>{n.onChange(m?Ce(m,"yyyy-MM-dd"):null),i?.(m)},defaultMonth:a?new Date(a):void 0,components:{DayContent:r(m=>P.createElement(lt,null,m.date.getDate()),"DayContent")},...a&&{disabled:r(m=>m<new Date(a),"disabled")}}))),e?P.createElement(R,null,e):null,d.error&&P.createElement(k,{className:"RemoteFlows__DatePickerField__Error"}))}})}r(_e,"DatePickerField");import*as J from"react";import{cva as mt}from"class-variance-authority";import*as se from"react";var dt=mt("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-card bg-warning border-warning-border [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function ye({className:e,variant:t,...o}){return se.createElement("div",{"data-slot":"alert",role:"alert",className:s(dt({variant:t}),e),...o})}r(ye,"Alert");function he({className:e,...t}){return se.createElement("div",{"data-slot":"alert-title",className:s("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}r(he,"AlertTitle");function Pe({className:e,...t}){return se.createElement("div",{"data-slot":"alert-description",className:s("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}r(Pe,"AlertDescription");import{AlertCircle as ct}from"lucide-react";import Z from"react";function le({title:e,description:t,severity:o}){let{components:a}=v();if(a?.statement){let i=a?.statement;return Z.createElement(i,{data:{title:e,description:t,severity:o}})}return Z.createElement(ye,{variant:"warning"},Z.createElement(ct,{className:"h-4 w-4"}),e&&Z.createElement(he,null,e),Z.createElement(Pe,null,t))}r(le,"Statement");function be({label:e,name:t,fields:o,description:a,components:i,statement:c}){return J.createElement("fieldset",{className:s("border-1 border-input p-4 rounded-xl",`RemoteFlows__FieldSetField__${t}`)},J.createElement("legend",{className:"text-sm font-semibold px-2"},e),a?J.createElement("div",{className:"mb-5 RemoteFlows__FieldSetField__Description",dangerouslySetInnerHTML:{__html:a}}):null,J.createElement("div",{className:"grid gap-4"},o.map(p=>{let F=me[p.type];return p.isVisible===!1||p.deprecated?null:J.createElement(F,{...p,key:p.name,name:`${t}.${p.name}`,component:i?.[p.type]})}),c?J.createElement(le,{...c}):null))}r(be,"FieldSetField");import*as E from"react";import{useFormContext as Ft}from"react-hook-form";import L,{useState as pt,useRef as ut}from"react";import{Upload as ft,X as gt}from"lucide-react";function Se({onChange:e,className:t,multiple:o}){let[a,i]=pt([]),c=ut(null),p=r(n=>{n.preventDefault(),c.current?.click()},"handleClick"),F=r(n=>{if(n.target.files&&n.target.files.length>0){let d=Array.from(n.target.files);i(d),e(n)}},"handleChange"),_=r(n=>{i(d=>d.filter(u=>u!==n))},"onRemoveFile");return L.createElement("div",{className:s("flex flex-col items-start gap-4",t)},L.createElement("input",{type:"file",ref:c,onChange:F,className:"hidden","aria-label":"File upload",multiple:o}),L.createElement(H,{type:"button",onClick:p,className:"gap-2"},L.createElement(ft,{className:"h-4 w-4"}),"Choose File"),a.length===0&&L.createElement("div",{className:"text-sm"},o?L.createElement("span",{className:"font-medium"},"No files selected. You can select multiple files"):L.createElement("span",{className:"font-medium"},"No file selected.")),a.length>0&&a.map((n,d)=>L.createElement("div",{key:d,className:"text-sm flex items-center gap-2"},"Selected file: ",L.createElement("span",{className:"font-medium"},n.name)," (",Math.round(n.size/1024)," KB)",L.createElement(H,{variant:"ghost",onClick:()=>_(n)},L.createElement(gt,null)))))}r(Se,"FileUploader");var vt=r(e=>new Promise((t,o)=>{let a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(a.result),a.onerror=i=>o(i)}),"toBase64"),Ne=r(async e=>{let t=e.target.files?Array.from(e.target.files):[];return await Promise.all(t.map(async a=>{let i=await vt(a);return{name:a.name,content:i.split(",")[1]}}))},"convertFilesToBase64");function we({name:e,description:t,label:o,multiple:a,onChange:i,component:c,...p}){let{components:F}=v(),{control:_}=Ft();return E.createElement(x,{control:_,name:e,render:({field:n,fieldState:d})=>{let u=c||F?.file;if(u){let m={name:e,description:t,label:o,multiple:a,...p};return E.createElement(u,{field:{...n,value:null,onChange:r(async l=>{let g=await Ne(l);n.onChange(g),i?.(g)},"onChange")},fieldState:d,fieldData:m})}return E.createElement(N,{"data-field":e,className:`RemoteFlows__FileUpload__Item__${e}`},E.createElement(h,{className:"RemoteFlows__FileUpload__Label"},o),E.createElement(w,null,E.createElement(Se,{onChange:async m=>{let l=await Ne(m);n.onChange(l),i?.(l)},multiple:a,className:s("RemoteFlows__FileUpload__Input")})),t&&E.createElement("div",{className:"flex items-center justify-between"},E.createElement(R,{className:"RemoteFlows__FileUpload__Description"},t)),d.error&&E.createElement(k,{className:"RemoteFlows__FileUpload__Error"}))}})}r(we,"FileUploadField");import pe from"react";import{useFormContext as Ct}from"react-hook-form";import*as G from"react";import{useFormContext as xt}from"react-hook-form";import*as Re from"react";function De({className:e,type:t,...o}){return Re.createElement("input",{type:t,"data-slot":"input",className:s("shadow-xs border-input file:text-foreground placeholder:text-muted-foreground flex h-9 w-full min-w-0 rounded-xl border bg-transparent px-4 py-7 text-sm transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-focused","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...o})}r(De,"Input");function W({name:e,description:t,label:o,type:a,onChange:i,component:c,...p}){let{components:F}=v(),{control:_}=xt();return G.createElement(x,{control:_,name:e,render:({field:n,fieldState:d})=>{let u=c||F?.text;if(u){let m={name:e,description:t,label:o,type:a,onChange:i,...p};return G.createElement(u,{field:{...n,onChange:r(l=>{n.onChange(l),i?.(l)},"onChange")},fieldState:d,fieldData:m})}return G.createElement(N,{"data-field":e,className:`RemoteFlows__TextField__Item__${e}`},G.createElement(h,{className:"RemoteFlows__TextField__Label"},o),G.createElement(w,null,G.createElement(De,{...n,value:n.value??"",onChange:m=>{n.onChange(m),i?.(m)},className:"RemoteFlows__TextField__Input",placeholder:o})),t&&G.createElement(R,{className:"RemoteFlows__TextField__Description"},t),d.error&&G.createElement(k,{className:"RemoteFlows__TextField__Error"}))}})}r(W,"TextField");function ue(e){let{components:t}=v(),{control:o}=Ct(),a=e.component||t?.number;return a?pe.createElement(x,{control:o,name:e.name,render:({field:i,fieldState:c})=>pe.createElement(a,{field:{...i,onChange:r(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:c,fieldData:e})}):pe.createElement(W,{...e,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$"})}r(ue,"NumberField");import*as X from"@radix-ui/react-radio-group";import{CircleIcon as _t}from"lucide-react";import*as ee from"react";function ke({className:e,...t}){return ee.createElement(X.Root,{"data-slot":"radio-group",className:s("grid gap-3",e),...t})}r(ke,"RadioGroup");function Te({className:e,...t}){return ee.createElement(X.Item,{"data-slot":"radio-group-item",className:s("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t},ee.createElement(X.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center"},ee.createElement(_t,{className:"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})))}r(Te,"RadioGroupItem");import*as b from"react";import{useFormContext as yt}from"react-hook-form";function Ie({name:e,defaultValue:t,description:o,label:a,options:i,onChange:c,component:p,...F}){let{components:_}=v(),{control:n}=yt();return b.createElement(x,{control:n,name:e,defaultValue:t,render:({field:d,fieldState:u})=>{let m=p||_?.radio;if(m){let l={name:e,defaultValue:t,description:o,label:a,options:i,...F};return b.createElement(m,{field:{...d,onChange:r(g=>{d.onChange(g),c?.(g)},"onChange")},fieldState:u,fieldData:l})}return b.createElement(N,{className:s("space-y-3",`RemoteFlows__RadioGroupField__Item__${e}`),"data-field":e},b.createElement(h,null,a),b.createElement(w,null,b.createElement(ke,{"aria-label":a||e,onValueChange:l=>{d.onChange(l),c?.(l)},value:d.value,className:"flex flex-col space-y-3"},i?.map(l=>b.createElement(b.Fragment,null,b.createElement(N,{key:l.value,"data-field":e,className:"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item"},b.createElement(w,null,b.createElement(Te,{value:l.value,className:"RemoteFlows__RadioField__Input"})),b.createElement("div",null,b.createElement(h,{className:"font-normal mb-0 RemoteFlows__RadioField__Label"},l.label),l.description&&b.createElement(R,{className:"mt-2"},l.description))))))),o&&b.createElement(R,null,o),u.error&&b.createElement(k,null))}})}r(Ie,"RadioGroupField");import*as T from"react";import*as C from"react";import*as f from"@radix-ui/react-select";import{CheckIcon as ht,ChevronDownIcon as Le,ChevronUpIcon as Pt}from"lucide-react";function Me({...e}){return C.createElement(f.Root,{"data-slot":"select",...e})}r(Me,"Select");function ze({...e}){return C.createElement(f.Group,{"data-slot":"select-group",...e})}r(ze,"SelectGroup");function Ee({...e}){return C.createElement(f.Value,{"data-slot":"select-value",...e})}r(Ee,"SelectValue");function Ae({className:e,children:t,...o}){return C.createElement(f.Trigger,{"data-slot":"select-trigger",className:s("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-full items-center justify-between rounded-xl border bg-transparent px-4 py-7 text-sm whitespace-nowrap transition-[color] outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","focus-visible:border-focused",e),...o},t,C.createElement(f.Icon,{asChild:!0,className:"absolute right-4"},C.createElement(Le,{className:"size-4"})))}r(Ae,"SelectTrigger");function Be({className:e,children:t,position:o="popper",...a}){return C.createElement(f.Portal,null,C.createElement(f.Content,{"data-slot":"select-content",className:s("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:o,...a},C.createElement(bt,null),C.createElement(f.Viewport,{className:s(o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")},t),C.createElement(St,null)))}r(Be,"SelectContent");function Ge({className:e,children:t,...o}){return C.createElement(f.Item,{"data-slot":"select-item",className:s("focus:bg-accent focus:text-accent-foreground min-h-11 justify-between [&_svg:not([class*='text-'])]:text-muted-foreground flex w-full cursor-default items-center gap-2 py-2 px-4 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...o},C.createElement(f.ItemText,null,t),C.createElement("span",{className:"flex size-3.5 items-center justify-center"},C.createElement(f.ItemIndicator,null,C.createElement(ht,{className:"size-4"}))))}r(Ge,"SelectItem");function bt({className:e,...t}){return C.createElement(f.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:s("flex cursor-default items-center justify-center py-1",e),...t},C.createElement(Pt,{className:"size-4"}))}r(bt,"SelectScrollUpButton");function St({className:e,...t}){return C.createElement(f.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:s("flex cursor-default items-center justify-center py-1",e),...t},C.createElement(Le,{className:"size-4"}))}r(St,"SelectScrollDownButton");import{useFormContext as Nt}from"react-hook-form";function Ve({label:e,name:t,options:o,defaultValue:a,description:i,onChange:c,component:p,...F}){let{control:_}=Nt(),{components:n}=v();return T.createElement(x,{defaultValue:a,control:_,name:t,render:({field:d,fieldState:u})=>{let m=p||n?.select;if(m){let l={label:e,name:t,options:o,defaultValue:a,description:i,onChange:c,...F};return T.createElement(m,{field:{...d,onChange:r(g=>{d.onChange(g),c?.(g)},"onChange")},fieldState:u,fieldData:l})}return T.createElement(N,{"data-field":t,className:`RemoteFlows__SelectField__Item__${t}`},T.createElement(h,{className:"RemoteFlows__SelectField__Label"},e),T.createElement(w,null,T.createElement("div",{className:"relative"},T.createElement(Me,{value:d.value||"",onValueChange:l=>{d.onChange(l),c?.(l)}},T.createElement(Ae,{className:"RemoteFlows__SelectField__Trigger","aria-invalid":!!u.error,"aria-label":e},T.createElement("span",{className:"absolute"},T.createElement(Ee,{placeholder:e}))),T.createElement(Be,{className:"RemoteFlows__SelectField__Content"},T.createElement(ze,{className:"RemoteFlows__SelectField__Group"},o.map(l=>T.createElement(Ge,{key:l.value,value:l.value,className:"RemoteFlows__SelectField__SelectItem"},l.label))))))),i&&T.createElement(R,null,i),u.error&&T.createElement(k,null))}})}r(Ve,"SelectField");import O,{useState as Lt}from"react";import{useFormContext as Mt}from"react-hook-form";import S,{Fragment as Rt,useState as Dt}from"react";import{Check as kt,ChevronDownIcon as Tt,X as It}from"lucide-react";import*as j from"react";import{Command as K}from"cmdk";import{SearchIcon as Wr}from"lucide-react";import*as wt from"react";import*as V from"@radix-ui/react-dialog";import{XIcon as Er}from"lucide-react";function Oe({className:e,...t}){return j.createElement(K,{"data-slot":"command",className:s("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}r(Oe,"Command");function Ue({className:e,...t}){return j.createElement(K.List,{"data-slot":"command-list",className:s("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}r(Ue,"CommandList");function He({...e}){return j.createElement(K.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}r(He,"CommandEmpty");function Je({className:e,...t}){return j.createElement(K.Group,{"data-slot":"command-group",className:s("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}r(Je,"CommandGroup");function je({className:e,...t}){return j.createElement(K.Separator,{"data-slot":"command-separator",className:s("bg-border -mx-1 h-px",e),...t})}r(je,"CommandSeparator");function $e({className:e,...t}){return j.createElement(K.Item,{"data-slot":"command-item",className:s("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}r($e,"CommandItem");function We({options:e,selected:t,onChange:o,placeholder:a,...i}){let[c,p]=Dt(!1),F=r(n=>{o(t.filter(d=>d.value!==n.value))},"handleUnselect"),_=e.reduce((n,d)=>{let u=d.category||"Uncategorized";return n[u]||(n[u]=[]),n[u].push(d),n},{});return S.createElement(ae,{open:c,onOpenChange:p,...i},S.createElement(ne,null,S.createElement(H,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",type:"button"},S.createElement("div",{className:"flex gap-1 flex-wrap overflow-x-auto max-h-[2.5rem] items-center"},t.length>0?t.map(n=>S.createElement(Fe,{key:n.label,variant:"secondary",className:"mr-1 mb-1"},n.label,S.createElement("div",{role:"button",tabIndex:0,"aria-label":`remove ${n.label}`,className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",onKeyDown:d=>{d.key==="Enter"&&F(n)},onMouseDown:d=>{d.preventDefault(),d.stopPropagation()},onClick:()=>F(n)},S.createElement(It,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})))):S.createElement("span",{className:"text-foreground"},a)),S.createElement(Tt,{className:"size-4"}))),S.createElement(ie,{align:"start",className:"w-full p-0"},S.createElement(Oe,null,S.createElement(Ue,null,S.createElement(He,null,"No item found."),Object.entries(_).map(([n,d],u)=>S.createElement(Rt,{key:n},u>0&&S.createElement(je,null),S.createElement(Je,{heading:n},d.map(m=>{let l=t.some(g=>g.value===m.value);return S.createElement($e,{key:m.label,onSelect:()=>{o(l?t.filter(g=>g.value!==m.value):[...t,m])}},S.createElement(kt,{className:s("mr-2 h-4 w-4",l?"opacity-100":"opacity-0")}),m.label)}))))))))}r(We,"MultiSelect");function Xe({label:e,name:t,options:o,defaultValue:a,description:i,onChange:c,$meta:p,component:F,..._}){let{control:n}=Mt(),{components:d}=v(),[u,m]=Lt([]);return O.createElement(x,{defaultValue:a,control:n,name:t,render:({field:l,fieldState:g})=>{let y=F||d?.countries;if(y){let I={label:e,name:t,options:o,defaultValue:a,description:i,onChange:c,$meta:p,..._};return O.createElement(y,{field:{...l,onChange:r(A=>{l.onChange(A),c?.(A)},"onChange")},fieldState:g,fieldData:I})}let z=[...Object.entries(p?.regions||{}).map(([I,A])=>({value:A,label:I,category:"Regions"})),...Object.entries(p?.subregions||{}).map(([I,A])=>({value:A,label:I,category:"Subregions"})),...o.map(I=>({...I,value:I.value,label:I.label,category:"Countries"}))],te=r(I=>{let A=I.map(({value:et})=>et);l.onChange(A),c?.(A),m(I)},"handleChange");return O.createElement(N,{"data-field":t,className:`RemoteFlows__CountryField__Item__${t}`},O.createElement(h,{className:"RemoteFlows__CountryField__Label"},e),O.createElement(w,null,O.createElement(We,{options:z,selected:u,onChange:te,..._})),i&&O.createElement(R,null,i),g.error&&O.createElement(k,null))}})}r(Xe,"CountryField");import*as M from"react";import{useFormContext as zt}from"react-hook-form";import*as de from"react";var fe=de.forwardRef(({className:e,...t},o)=>de.createElement("textarea",{className:s("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:o,...t}));fe.displayName="Textarea";function Ke({name:e,description:t,label:o,onChange:a,maxLength:i,component:c,...p}){let{components:F}=v(),{control:_}=zt();return M.createElement(x,{control:_,name:e,render:({field:n,fieldState:d})=>{let u=c||F?.textarea;if(u){let l={name:e,description:t,label:o,maxLength:i,...p};return M.createElement(u,{field:{...n,onChange:r(g=>{n.onChange(g),a?.(g)},"onChange")},fieldState:d,fieldData:l})}let m=n.value?.length??0;return M.createElement(N,{"data-field":e,className:`RemoteFlows__TextArea__Item__${e}`},M.createElement(h,{className:"RemoteFlows__TextArea__Label"},o),M.createElement(w,null,M.createElement(fe,{...n,value:n.value??"",onChange:l=>{n.onChange(l),a?.(l)},className:s(d.error&&"border-red-500 focus-visible:ring-red-500","RemoteFlows__TextArea__Input"),placeholder:o})),(t||i)&&M.createElement("div",{className:"flex items-center justify-between"},t&&M.createElement(R,{className:"RemoteFlows__TextArea__Description"},t),i&&M.createElement("span",{className:"text-sm ml-auto RemoteFlows__TextArea__MaxLength"},m,"/",i)),d.error&&M.createElement(k,{className:"RemoteFlows__TextArea__Error"}))}})}r(Ke,"TextAreaField");import ge from"react";import{useFormContext as Et}from"react-hook-form";function qe(e){let{components:t}=v(),{control:o}=Et(),a=e.component||t?.email;return a?ge.createElement(x,{control:o,name:e.name,render:({field:i,fieldState:c})=>ge.createElement(a,{field:{...i,onChange:r(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:c,fieldData:e})}):ge.createElement(W,{...e,type:"email"})}r(qe,"EmailField");import Ye from"react";import{useFormContext as At}from"react-hook-form";function Qe(e){let{control:t}=At();return Ye.createElement(x,{control:t,name:e.name,render:({field:o})=>Ye.createElement("input",{...o,type:"hidden"})})}r(Qe,"HiddenField");var me={checkbox:ve,text:W,email:qe,money:ue,select:Ve,radio:Ie,number:ue,file:we,fieldset:be,date:_e,textarea:Ke,countries:Xe,hidden:Qe};import q,{useEffect as Bt}from"react";import{useFormContext as Gt}from"react-hook-form";function Ze({name:e,value:t,description:o,statement:a}){let{setValue:i}=Gt();return Bt(()=>{i(e,t)},[]),q.createElement("div",null,a?q.createElement(q.Fragment,null,q.createElement("p",{className:`text-sm RemoteFlows__ForcedValue__Title__${e}`,dangerouslySetInnerHTML:{__html:a?.title}}),q.createElement("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:a?.description}})):q.createElement("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:o}}))}r(Ze,"ForcedValueField");function Ot(e){return e.const!==void 0&&e.const===e.default&&e.inputType!=="checkbox"&&e.inputType!=="hidden"}r(Ot,"checkFieldHasForcedValue");var an=r(({fields:e,components:t})=>!e||e.length===0?null:U.createElement(U.Fragment,null,e.map(o=>{if(o.isVisible===!1||o.deprecated)return null;if(Ot(o))return U.createElement(Ze,{key:o.name,name:o.name,description:o.description,value:o.const,statement:o.statement});let a=me[o.inputType];return o.inputType==="fieldset"?U.createElement(a,{...o,components:t}):a?U.createElement(Vt,{key:o.name},U.createElement(a,{...o,component:t&&t[o.inputType]}),o.statement?U.createElement(le,{...o.statement}):null):U.createElement("p",{className:"error"},"Field type ",o.inputType," not supported")})),"JSONSchemaFormFields");export{an as a};
|
|
2
|
+
//# sourceMappingURL=chunk-U3I3TJKB.js.map
|