@remoteoss/remote-flows 0.0.6 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +52 -0
  2. package/dist/{chunk-BY2NZ5QF.js → chunk-4F7PYKUZ.js} +2 -2
  3. package/dist/chunk-4QHHDFB2.js +2 -0
  4. package/dist/chunk-4QHHDFB2.js.map +1 -0
  5. package/dist/chunk-5UXOVZY5.js +2 -0
  6. package/dist/chunk-5UXOVZY5.js.map +1 -0
  7. package/dist/chunk-A4RX3KRZ.js +2 -0
  8. package/dist/chunk-A4RX3KRZ.js.map +1 -0
  9. package/dist/{chunk-Z5SEXEAZ.js → chunk-AD7ZWPEI.js} +2 -2
  10. package/dist/chunk-ANPGCYMT.js +2 -0
  11. package/dist/chunk-ANPGCYMT.js.map +1 -0
  12. package/dist/{chunk-BIWKEH5R.js → chunk-DOA6BAUQ.js} +2 -2
  13. package/dist/{chunk-DE6ICD4X.js → chunk-FCRDQVTB.js} +2 -2
  14. package/dist/{chunk-HHNKZK2V.js → chunk-FI76EKUS.js} +2 -2
  15. package/dist/chunk-GCF5EF2A.js +2 -0
  16. package/dist/chunk-GCF5EF2A.js.map +1 -0
  17. package/dist/chunk-GKEURJR4.js +2 -0
  18. package/dist/chunk-GKEURJR4.js.map +1 -0
  19. package/dist/{chunk-P5PQMJ4T.js → chunk-IJWDAD54.js} +2 -2
  20. package/dist/{chunk-HGBJ3RNH.js → chunk-J2RINDSC.js} +2 -2
  21. package/dist/chunk-KQCZ2KSO.js +2 -0
  22. package/dist/chunk-KQCZ2KSO.js.map +1 -0
  23. package/dist/chunk-KY7BGW6H.js +2 -0
  24. package/dist/chunk-KY7BGW6H.js.map +1 -0
  25. package/dist/chunk-MKJHD77O.js +1 -0
  26. package/dist/chunk-MKJHD77O.js.map +1 -0
  27. package/dist/{chunk-ZEGD25G2.js → chunk-NZFES56Y.js} +2 -2
  28. package/dist/chunk-OCNLZSS7.js +2 -0
  29. package/dist/chunk-OCNLZSS7.js.map +1 -0
  30. package/dist/chunk-Q6GIPVSE.js +2 -0
  31. package/dist/chunk-Q6GIPVSE.js.map +1 -0
  32. package/dist/chunk-SJ56GVNV.js +2 -0
  33. package/dist/{chunk-ATKR5HCM.js.map → chunk-SJ56GVNV.js.map} +1 -1
  34. package/dist/{chunk-VWM3PP54.js → chunk-UPRUP24B.js} +2 -2
  35. package/dist/chunk-UPRUP24B.js.map +1 -0
  36. package/dist/chunk-UTCIIPYZ.js +2 -0
  37. package/dist/chunk-UTCIIPYZ.js.map +1 -0
  38. package/dist/chunk-VTAHQOKR.js +2 -0
  39. package/dist/chunk-VTAHQOKR.js.map +1 -0
  40. package/dist/{chunk-LT4TLUWZ.js → chunk-VV7RML2Q.js} +2 -2
  41. package/dist/chunk-WRDKLT4N.js +2 -0
  42. package/dist/chunk-WRDKLT4N.js.map +1 -0
  43. package/dist/{chunk-JEULWBZA.js → chunk-XEQTLVMV.js} +2 -2
  44. package/dist/chunk-YGP3O2VJ.js +2 -0
  45. package/dist/chunk-YGP3O2VJ.js.map +1 -0
  46. package/dist/chunk-YNLDKIE4.js +2 -0
  47. package/dist/chunk-YNLDKIE4.js.map +1 -0
  48. package/dist/{chunk-Q2ZB5MOF.js → chunk-YVC4OEFJ.js} +2 -2
  49. package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +24 -0
  50. package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +2 -0
  51. package/dist/flows/ContractAmendment/ContractAmendmentFlow.js.map +1 -0
  52. package/dist/flows/ContractAmendment/ContractAmendmentForm.d.ts +10 -0
  53. package/dist/flows/ContractAmendment/ContractAmendmentForm.js +2 -0
  54. package/dist/flows/ContractAmendment/ContractAmendmentForm.js.map +1 -0
  55. package/dist/flows/ContractAmendment/ContractAmendmentSubmit.d.ts +5 -0
  56. package/dist/flows/ContractAmendment/ContractAmendmentSubmit.js +2 -0
  57. package/dist/flows/ContractAmendment/ContractAmendmentSubmit.js.map +1 -0
  58. package/dist/flows/ContractAmendment/context.d.ts +58 -0
  59. package/dist/flows/ContractAmendment/context.js +2 -0
  60. package/dist/flows/ContractAmendment/context.js.map +1 -0
  61. package/dist/flows/ContractAmendment/hooks.d.ts +6 -0
  62. package/dist/flows/ContractAmendment/hooks.js +2 -0
  63. package/dist/flows/ContractAmendment/hooks.js.map +1 -0
  64. package/dist/flows/ContractAmendment/index.d.ts +10 -0
  65. package/dist/flows/ContractAmendment/index.js +2 -0
  66. package/dist/flows/ContractAmendment/index.js.map +1 -0
  67. package/dist/flows/ContractAmendment/types.d.ts +11 -0
  68. package/dist/flows/ContractAmendment/types.js +1 -0
  69. package/dist/flows/ContractAmendment/types.js.map +1 -0
  70. package/dist/flows/CostCalculator/CostCalculatorDisclaimer.js +1 -1
  71. package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +1 -1
  72. package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
  73. package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +1 -1
  74. package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
  75. package/dist/flows/CostCalculator/CostCalculatorResetButton.d.ts +1 -1
  76. package/dist/flows/CostCalculator/CostCalculatorResetButton.js +1 -1
  77. package/dist/flows/CostCalculator/CostCalculatorSubmitButton.js +1 -1
  78. package/dist/flows/CostCalculator/Results/CostCalculatorBenefitsBreakdown.js +1 -1
  79. package/dist/flows/CostCalculator/Results/CostCalculatorContributionsBreakdown.js +1 -1
  80. package/dist/flows/CostCalculator/Results/CostCalculatorGrossSalary.js +1 -1
  81. package/dist/flows/CostCalculator/Results/CostCalculatorResults.d.ts +1 -1
  82. package/dist/flows/CostCalculator/Results/CostCalculatorResults.js +1 -1
  83. package/dist/flows/CostCalculator/Results/CostCalculatorResultsChart.js +1 -1
  84. package/dist/flows/CostCalculator/Results/CostCalculatorTotalCost.js +1 -1
  85. package/dist/flows/CostCalculator/context.d.ts +6 -3
  86. package/dist/flows/CostCalculator/hooks.d.ts +5 -2
  87. package/dist/flows/CostCalculator/hooks.js +1 -1
  88. package/dist/flows/CostCalculator/index.d.ts +1 -1
  89. package/dist/flows/CostCalculator/index.js +1 -1
  90. package/dist/flows/CostCalculator/jsonSchema.d.ts +0 -1
  91. package/dist/flows/CostCalculator/jsonSchema.js +1 -1
  92. package/dist/flows/CostCalculator/types.d.ts +1 -1
  93. package/dist/flows/CostCalculator/utils.d.ts +2 -2
  94. package/dist/flows/CostCalculator/utils.js +1 -1
  95. package/dist/flows/types.d.ts +24 -1
  96. package/dist/flows/utils.d.ts +10 -0
  97. package/dist/flows/utils.js +2 -0
  98. package/dist/flows/utils.js.map +1 -0
  99. package/dist/hooks-BQWrl9Bj.d.ts +50 -0
  100. package/dist/index.css +1 -1
  101. package/dist/index.css.map +1 -1
  102. package/dist/index.d.ts +65 -3
  103. package/dist/index.js +1 -1
  104. package/dist/index.js.map +1 -1
  105. package/dist/{types.gen-dIMXHE0Y.d.ts → types.gen-DCJSPsGk.d.ts} +1 -1
  106. package/package.json +2 -1
  107. package/dist/chunk-A5W3QNYJ.js +0 -2
  108. package/dist/chunk-A5W3QNYJ.js.map +0 -1
  109. package/dist/chunk-ATKR5HCM.js +0 -2
  110. package/dist/chunk-DARQDP44.js +0 -2
  111. package/dist/chunk-DARQDP44.js.map +0 -1
  112. package/dist/chunk-EEWCEZ3D.js +0 -2
  113. package/dist/chunk-EEWCEZ3D.js.map +0 -1
  114. package/dist/chunk-NIDHTKHS.js +0 -2
  115. package/dist/chunk-NIDHTKHS.js.map +0 -1
  116. package/dist/chunk-VWM3PP54.js.map +0 -1
  117. /package/dist/{chunk-BY2NZ5QF.js.map → chunk-4F7PYKUZ.js.map} +0 -0
  118. /package/dist/{chunk-Z5SEXEAZ.js.map → chunk-AD7ZWPEI.js.map} +0 -0
  119. /package/dist/{chunk-BIWKEH5R.js.map → chunk-DOA6BAUQ.js.map} +0 -0
  120. /package/dist/{chunk-DE6ICD4X.js.map → chunk-FCRDQVTB.js.map} +0 -0
  121. /package/dist/{chunk-HHNKZK2V.js.map → chunk-FI76EKUS.js.map} +0 -0
  122. /package/dist/{chunk-P5PQMJ4T.js.map → chunk-IJWDAD54.js.map} +0 -0
  123. /package/dist/{chunk-HGBJ3RNH.js.map → chunk-J2RINDSC.js.map} +0 -0
  124. /package/dist/{chunk-ZEGD25G2.js.map → chunk-NZFES56Y.js.map} +0 -0
  125. /package/dist/{chunk-LT4TLUWZ.js.map → chunk-VV7RML2Q.js.map} +0 -0
  126. /package/dist/{chunk-JEULWBZA.js.map → chunk-XEQTLVMV.js.map} +0 -0
  127. /package/dist/{chunk-Q2ZB5MOF.js.map → chunk-YVC4OEFJ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/mutations.ts","../src/flows/ContractAmendment/hooks.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { UseMutationResult } from '@tanstack/react-query';\n\ntype MutationData<T> =\n T extends UseMutationResult<infer R, any, any, any> ? R : never;\ntype MutationVariables<T> =\n T extends UseMutationResult<any, any, infer V, any> ? V : never;\ntype MutationError<T> =\n T extends UseMutationResult<any, infer E, any, any> ? E : never;\n\nexport interface SuccessResponse<D> {\n data: D;\n error: null;\n}\n\nexport interface ErrorResponse<E> {\n data: null;\n error: E;\n}\n\ntype PromiseResult<D, E> = SuccessResponse<D> | ErrorResponse<E>;\n\n/**\n * Converts a mutation to a promise-based API. We avoid using the\n * `mutateAsync` method from react-query for 2 reasons:\n * 1. We lose the isPending state of the mutation\n * 2. We want to return the data and error in a consistent way\n * (either data or error is null)\n * @param mutation\n * @returns\n */\nexport function mutationToPromise<\n T extends UseMutationResult<any, any, any, any>,\n>(mutation: T) {\n type Data = MutationData<T>;\n type Variables = MutationVariables<T>;\n type Error = MutationError<T>;\n\n return {\n mutateAsync: (values: Variables): Promise<PromiseResult<Data, Error>> => {\n return new Promise((resolve, reject) => {\n mutation.mutate(values, {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data as Data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ) as unknown as Error,\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as Error,\n });\n },\n });\n });\n },\n };\n}\n","import {\n CreateContractAmendmentParams,\n EmploymentShowResponse,\n getShowContractAmendmentSchema,\n getShowEmployment,\n postCreateContractAmendment,\n} from '@/src/client';\n\nimport {\n convertFromCents,\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 { useState } from 'react';\nimport { ContractAmendmentParams } from './types';\n\nimport { useClient } from '@/src/context';\nimport { FieldValues } from 'react-hook-form';\nimport { buildValidationSchema } from '../utils';\n\ntype UseEmployment = Pick<ContractAmendmentParams, 'employmentId'>;\n\nfunction buildInitialValues(employment?: EmploymentShowResponse) {\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\nconst useEmployment = ({ employmentId }: UseEmployment) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['employment'],\n queryFn: () => {\n return getShowEmployment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: { employment_id: employmentId },\n });\n },\n select: ({ data }) => data,\n });\n};\n\ntype ContractAmendmentSchemaParams = {\n countryCode: string;\n employment: EmploymentShowResponse | undefined;\n fieldValues: FieldValues | undefined;\n options?: ContractAmendmentParams['options'];\n};\n\nconst useContractAmendmentSchema = ({\n countryCode,\n employment,\n fieldValues,\n options,\n}: ContractAmendmentSchemaParams) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['contract-amendment-schema'],\n queryFn: () => {\n return 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 },\n });\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 return createHeadlessForm(jsfSchema, {\n initialValues: fieldValues || buildInitialValues(employment),\n });\n },\n });\n};\n\nconst useCreateContractAmendment = () => {\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\nexport const useContractAmendment = ({\n employmentId,\n countryCode,\n options,\n}: ContractAmendmentParams) => {\n const [fieldValues, setFieldValues] = useState<FieldValues>();\n const { data: employment, isLoading: isLoadingEmployment } = useEmployment({\n employmentId,\n });\n\n const {\n data: contractAmendmentHeadlessForm,\n isLoading: isLoadingContractAmendments,\n } = useContractAmendmentSchema({\n employment,\n countryCode,\n fieldValues,\n options,\n });\n\n const createContractAmendment = useCreateContractAmendment();\n const { mutateAsync } = mutationToPromise(createContractAmendment);\n\n async function onSubmit(values: FieldValues) {\n if (\n !employment?.data?.employment?.id ||\n !employment?.data?.employment.active_contract_id\n ) {\n throw new Error('Employment id or active contract id is missing');\n }\n\n // const validation =\n // jsonSchemaContractAmendmentFields?.handleValidation(values);\n // if (validation?.formErrors && Object.keys(validation?.formErrors)) {\n // return {\n // data: null,\n // error: validation.formErrors,\n // };\n // }\n\n return mutateAsync({\n employment_id: employment?.data.employment?.id,\n amendment_contract_id: employment?.data.employment?.active_contract_id,\n contract_amendment: {\n ...values,\n },\n });\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: contractAmendmentHeadlessForm?.fields || [],\n isLoading: isLoadingEmployment || isLoadingContractAmendments,\n isSubmitting: createContractAmendment.isPending,\n initialValues: buildInitialValues(employment),\n validationSchema: buildValidationSchema(\n // @ts-expect-error error\n contractAmendmentHeadlessForm?.fields || [],\n ),\n handleValidation: (values: FieldValues) => {\n if (contractAmendmentHeadlessForm) {\n const parsedValues = parseJSFToValidate(\n values,\n contractAmendmentHeadlessForm?.fields,\n {\n isPartialValidation: false,\n },\n );\n return contractAmendmentHeadlessForm?.handleValidation(parsedValues);\n }\n return null;\n },\n checkFieldUpdates: (values: FieldValues) => {\n if (contractAmendmentHeadlessForm) {\n const parsedValues = parseJSFToValidate(\n values,\n contractAmendmentHeadlessForm?.fields,\n {\n isPartialValidation: false,\n },\n );\n setFieldValues(parsedValues);\n }\n },\n onSubmit,\n };\n};\n"],"mappings":"wNA+BO,SAASA,EAEdC,EAAa,CAKb,MAAO,CACL,YAAaC,EAACC,GACL,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtCJ,EAAS,OAAOE,EAAQ,CACtB,UAAWD,EAACI,GAAa,CACnBA,EAAS,KACXF,EAAQ,CACN,KAAME,EAAS,KACf,MAAO,IACT,CAAC,EAEDF,EAAQ,CACN,KAAM,KACN,MAAO,IAAI,MACT,+CACF,CACF,CAAC,CAEL,EAdW,aAeX,QAASF,EAACK,GAAU,CAClBF,EAAO,CACL,KAAM,KACN,MAAOE,CACT,CAAC,CACH,EALS,UAMX,CAAC,CACH,CAAC,EAzBU,cA2Bf,CACF,CApCgBL,EAAAF,EAAA,qBChBhB,OAAS,sBAAAQ,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBACtC,OAAS,YAAAC,MAAgB,QASzB,SAASC,EAAmBC,EAAqC,CAC/D,MAAO,CACL,GAAGA,GAAY,MAAM,YAAY,iBACjC,eAAgB,GAChB,kBAAmB,GACnB,UAAWA,GAAY,MAAM,YAAY,UACzC,oBAAqB,GACrB,oBAAqBC,EACnBD,GAAY,MAAM,YAAY,kBAC1B,mBACN,CACF,CACF,CAZSE,EA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ACE,oBAAqB,EACvB,CACF,EACAH,EAAeW,CAAY,CAC7B,CACF,EAXmB,qBAYnB,SAAAH,CACF,CACF,EA1FoC","names":["mutationToPromise","mutation","__name","values","resolve","reject","response","error","createHeadlessForm","modify","useMutation","useQuery","useState","buildInitialValues","employment","convertFromCents","__name","useEmployment","employmentId","client","useClient","useQuery","getShowEmployment","data","useContractAmendmentSchema","countryCode","fieldValues","options","getShowContractAmendmentSchema","jsfSchema","schema","modify","createHeadlessForm","useCreateContractAmendment","useMutation","payload","postCreateContractAmendment","useContractAmendment","setFieldValues","useState","isLoadingEmployment","contractAmendmentHeadlessForm","isLoadingContractAmendments","createContractAmendment","mutateAsync","mutationToPromise","onSubmit","values","buildValidationSchema","parsedValues","parseJSFToValidate"]}
@@ -1,2 +1,2 @@
1
- import{a as p}from"./chunk-DYB3RWP7.js";import{b as d}from"./chunk-HHNKZK2V.js";import{a as s}from"./chunk-ATKR5HCM.js";import{a as m}from"./chunk-AYDF3IFZ.js";import o from"react";import*as a from"react";import{Drawer as l}from"vaul";var f=m(({shouldScaleBackground:r=!0,...e})=>a.createElement(l.Root,{shouldScaleBackground:r,...e}),"Drawer");f.displayName="Drawer";var y=l.Trigger,h=l.Portal,P=l.Close,N=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Overlay,{ref:i,className:s("fixed inset-0 z-50 bg-black/80",r),...e}));N.displayName=l.Overlay.displayName;var D=a.forwardRef(({className:r,children:e,...i},c)=>a.createElement(h,null,a.createElement(N,null),a.createElement(l.Content,{ref:c,className:s("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",r),...i},a.createElement("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),e)));D.displayName="DrawerContent";var w=m(({className:r,...e})=>a.createElement("div",{className:s("grid gap-1.5 p-4 text-center sm:text-left",r),...e}),"DrawerHeader");w.displayName="DrawerHeader";var C=m(({className:r,...e})=>a.createElement("div",{className:s("mt-auto flex flex-col gap-2 p-4",r),...e}),"DrawerFooter");C.displayName="DrawerFooter";var u=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Title,{ref:i,className:s("text-lg font-semibold leading-none tracking-tight",r),...e}));u.displayName=l.Title.displayName;var v=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Description,{ref:i,className:s("text-sm text-muted-foreground",r),...e}));v.displayName=l.Description.displayName;import*as n from"react";import*as t from"@radix-ui/react-scroll-area";var g=n.forwardRef(({className:r,children:e,...i},c)=>n.createElement(t.Root,{ref:c,className:s("relative overflow-hidden",r),...i},n.createElement(t.Viewport,{className:"h-full w-full rounded-[inherit]"},e),n.createElement(b,null),n.createElement(t.Corner,null)));g.displayName=t.Root.displayName;var b=n.forwardRef(({className:r,orientation:e="vertical",...i},c)=>n.createElement(t.ScrollAreaScrollbar,{ref:c,orientation:e,className:s("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r),...i},n.createElement(t.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})));b.displayName=t.ScrollAreaScrollbar.displayName;import{X as S}from"lucide-react";var O=m(({label:r="Disclaimer"})=>o.createElement(f,null,o.createElement(y,{asChild:!0},o.createElement(d,{variant:"link",size:"link"},r)),o.createElement(D,null,o.createElement(w,null,o.createElement(P,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none"},o.createElement(S,{className:"h-4 w-4"}),o.createElement("span",{className:"sr-only"},"Close")),o.createElement(u,null,p?.data.title),o.createElement(v,null,"For more details read our"," ",o.createElement(d,{variant:"link",size:"link",asChild:!0},o.createElement("a",{href:p?.data.html_url,target:"_blank",rel:"noopener noreferrer"},"Disclaimer")))),o.createElement(g,{className:"px-4 pb-4 overflow-y-auto max-h-[calc(80vh-120px)] cost-calculator-disclaimer-drawer-scroll-area"},o.createElement("div",{className:"cost-calculator-disclaimer-drawer-body",dangerouslySetInnerHTML:{__html:p?.data.body??""}})))),"CostCalculatorDisclaimer");export{O as a};
2
- //# sourceMappingURL=chunk-P5PQMJ4T.js.map
1
+ import{a as p}from"./chunk-DYB3RWP7.js";import{b as d}from"./chunk-FI76EKUS.js";import{a as s}from"./chunk-SJ56GVNV.js";import{a as m}from"./chunk-AYDF3IFZ.js";import o from"react";import*as a from"react";import{Drawer as l}from"vaul";var f=m(({shouldScaleBackground:r=!0,...e})=>a.createElement(l.Root,{shouldScaleBackground:r,...e}),"Drawer");f.displayName="Drawer";var y=l.Trigger,h=l.Portal,P=l.Close,N=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Overlay,{ref:i,className:s("fixed inset-0 z-50 bg-black/80",r),...e}));N.displayName=l.Overlay.displayName;var D=a.forwardRef(({className:r,children:e,...i},c)=>a.createElement(h,null,a.createElement(N,null),a.createElement(l.Content,{ref:c,className:s("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",r),...i},a.createElement("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),e)));D.displayName="DrawerContent";var w=m(({className:r,...e})=>a.createElement("div",{className:s("grid gap-1.5 p-4 text-center sm:text-left",r),...e}),"DrawerHeader");w.displayName="DrawerHeader";var C=m(({className:r,...e})=>a.createElement("div",{className:s("mt-auto flex flex-col gap-2 p-4",r),...e}),"DrawerFooter");C.displayName="DrawerFooter";var u=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Title,{ref:i,className:s("text-lg font-semibold leading-none tracking-tight",r),...e}));u.displayName=l.Title.displayName;var v=a.forwardRef(({className:r,...e},i)=>a.createElement(l.Description,{ref:i,className:s("text-sm text-muted-foreground",r),...e}));v.displayName=l.Description.displayName;import*as n from"react";import*as t from"@radix-ui/react-scroll-area";var g=n.forwardRef(({className:r,children:e,...i},c)=>n.createElement(t.Root,{ref:c,className:s("relative overflow-hidden",r),...i},n.createElement(t.Viewport,{className:"h-full w-full rounded-[inherit]"},e),n.createElement(b,null),n.createElement(t.Corner,null)));g.displayName=t.Root.displayName;var b=n.forwardRef(({className:r,orientation:e="vertical",...i},c)=>n.createElement(t.ScrollAreaScrollbar,{ref:c,orientation:e,className:s("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r),...i},n.createElement(t.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})));b.displayName=t.ScrollAreaScrollbar.displayName;import{X as S}from"lucide-react";var O=m(({label:r="Disclaimer"})=>o.createElement(f,null,o.createElement(y,{asChild:!0},o.createElement(d,{variant:"link",size:"link"},r)),o.createElement(D,null,o.createElement(w,null,o.createElement(P,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none"},o.createElement(S,{className:"h-4 w-4"}),o.createElement("span",{className:"sr-only"},"Close")),o.createElement(u,null,p?.data.title),o.createElement(v,null,"For more details read our"," ",o.createElement(d,{variant:"link",size:"link",asChild:!0},o.createElement("a",{href:p?.data.html_url,target:"_blank",rel:"noopener noreferrer"},"Disclaimer")))),o.createElement(g,{className:"px-4 pb-4 overflow-y-auto max-h-[calc(80vh-120px)] cost-calculator-disclaimer-drawer-scroll-area"},o.createElement("div",{className:"cost-calculator-disclaimer-drawer-body",dangerouslySetInnerHTML:{__html:p?.data.body??""}})))),"CostCalculatorDisclaimer");export{O as a};
2
+ //# sourceMappingURL=chunk-IJWDAD54.js.map
@@ -1,2 +1,2 @@
1
- import{a,b as m,c as p,d as l}from"./chunk-Z5SEXEAZ.js";import{a as e}from"./chunk-DE6ICD4X.js";import{b as n}from"./chunk-HHNKZK2V.js";import{b as i}from"./chunk-ATKR5HCM.js";import{a as t}from"./chunk-AYDF3IFZ.js";import{Info as v}from"lucide-react";import o from"react";function w({benefitsTotal:d,benefitsBreakdown:f,currency:r}){return o.createElement("div",null,o.createElement("div",{className:"flex justify-between items-center mb-2"},o.createElement("h3",{className:"font-medium text-primary-foreground-800"},"Benefits"),o.createElement("span",{className:"font-semibold text-lg"},i(d,r))),o.createElement(e,{className:"mb-3"}),o.createElement("div",{className:"space-y-3 pl-2"},f.map((s,u)=>o.createElement("div",{key:u,className:"flex justify-between items-start text-sm"},o.createElement("div",{className:"flex items-start gap-2"},o.createElement("span",null,s.name),o.createElement(a,null,o.createElement(m,null,o.createElement(p,{asChild:!0},o.createElement(n,{variant:"ghost",size:"icon",className:"h-4 w-4 p-0"},o.createElement(v,{className:"h-3 w-3 text-gray-400"}),o.createElement("span",{className:"sr-only"},"Info"))),o.createElement(l,null,o.createElement("p",{className:"max-w-xs"},s.description))))),o.createElement("span",null,i(s.amount,r))))))}t(w,"CostCalculatorBenefitsBreakdown");export{w as a};
2
- //# sourceMappingURL=chunk-HGBJ3RNH.js.map
1
+ import{a,b as m,c as p,d as l}from"./chunk-AD7ZWPEI.js";import{a as e}from"./chunk-FCRDQVTB.js";import{b as n}from"./chunk-FI76EKUS.js";import{b as i}from"./chunk-SJ56GVNV.js";import{a as t}from"./chunk-AYDF3IFZ.js";import{Info as v}from"lucide-react";import o from"react";function w({benefitsTotal:d,benefitsBreakdown:f,currency:r}){return o.createElement("div",null,o.createElement("div",{className:"flex justify-between items-center mb-2"},o.createElement("h3",{className:"font-medium text-primary-foreground-800"},"Benefits"),o.createElement("span",{className:"font-semibold text-lg"},i(d,r))),o.createElement(e,{className:"mb-3"}),o.createElement("div",{className:"space-y-3 pl-2"},f.map((s,u)=>o.createElement("div",{key:u,className:"flex justify-between items-start text-sm"},o.createElement("div",{className:"flex items-start gap-2"},o.createElement("span",null,s.name),o.createElement(a,null,o.createElement(m,null,o.createElement(p,{asChild:!0},o.createElement(n,{variant:"ghost",size:"icon",className:"h-4 w-4 p-0"},o.createElement(v,{className:"h-3 w-3 text-gray-400"}),o.createElement("span",{className:"sr-only"},"Info"))),o.createElement(l,null,o.createElement("p",{className:"max-w-xs"},s.description))))),o.createElement("span",null,i(s.amount,r))))))}t(w,"CostCalculatorBenefitsBreakdown");export{w as a};
2
+ //# sourceMappingURL=chunk-J2RINDSC.js.map
@@ -0,0 +1,2 @@
1
+ import{a as x}from"./chunk-UPRUP24B.js";import{a as V}from"./chunk-A4RX3KRZ.js";import{c as j,d as M,f as w,h as B,i as O}from"./chunk-5UXOVZY5.js";import{a as y,d as A}from"./chunk-ANPGCYMT.js";import{d as f}from"./chunk-WRDKLT4N.js";import{a as r}from"./chunk-AYDF3IFZ.js";import{object as se}from"yup";import{createHeadlessForm as k,modify as I}from"@remoteoss/json-schema-form";import{useMutation as K,useQuery as p}from"@tanstack/react-query";import{useState as q}from"react";import{string as L,ValidationError as J}from"yup";var oe=r(({includePremiumBenefits:e})=>{let{client:o}=f();return p({queryKey:["cost-calculator-countries",e],queryFn:r(()=>w({client:o,headers:{Authorization:""},query:{include_premium_benefits:e}}),"queryFn"),select:r(n=>n.data?.data.map(a=>({value:a.region_slug,label:a.name,childRegions:a.child_regions,hasAdditionalFields:a.has_additional_fields,regionSlug:a.region_slug})),"select")})},"useCostCalculatorCountries"),ie=r(()=>{let{client:e}=f();return p({queryKey:["company-currencies"],queryFn:r(()=>O({client:e,headers:{Authorization:""}}),"queryFn"),select:r(o=>o.data?.data?.company_currencies.map(n=>({value:n.slug,label:n.code})),"select")})},"useCompanyCurrencies"),ne=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>j({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimation"),Fe=r(()=>{let{client:e}=f();return K({mutationFn:r(o=>M({client:e,headers:{Authorization:""},body:o}),"mutationFn")})},"useCostCalculatorEstimationPdf"),ae=r((e,{includePremiumBenefits:o,options:n})=>{let{client:a}=f();return p({queryKey:["cost-calculator-region-fields",e,o],queryFn:r(()=>B({client:a,headers:{Authorization:""},path:{slug:e},query:{include_premium_benefits:o}}),"queryFn"),enabled:!!e,select:r(({data:s})=>{let u=s?.data?.schema||{};if(n&&n.jsfModify){let{schema:c}=I(u,n.jsfModify);u=c}return k(u)},"select")})},"useRegionFields"),E={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1},Pe=r(({defaultRegion:e,estimationOptions:o,options:n}={estimationOptions:E})=>{let{schema:a}=I(x.data.schema,n?.jsfModify||{}),s=k(a),[u,c]=q(e),[h,b]=q(),{data:g,isLoading:G}=oe({includePremiumBenefits:o.includePremiumBenefits}),{data:_,isLoading:U}=ie(),$=u||h?.value,{data:S,isLoading:H}=ae($,{includePremiumBenefits:o.includePremiumBenefits,options:n}),F=ne();async function N(i){try{await C.validate(i,{abortEarly:!1})}catch(t){return{data:null,error:t}}return new Promise((t,d)=>{F.mutate(T(i,o),{onSuccess:r(l=>{l.data?t({data:l.data,error:null}):t({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:r(l=>{d({data:null,error:l})},"onError")})})}r(N,"onSubmit");function Q(i){let t=g?.find(({value:d})=>d===i);t&&t.childRegions.length===0&&t.hasAdditionalFields?c(t.regionSlug):c(void 0),b(t)}r(Q,"onCountryChange");function D(i){c(i)}r(D,"onRegionChange");let m=s.fields.find(i=>i.name==="region");if(m){let i=h?.childRegions.map(t=>({value:t.slug,label:t.name}))??[];m.options=i,m.isVisible=i.length>0,m.required=i.length>0,m.onChange=D,m.schema=i.length>0?L().transform(t=>typeof t=="string"?t:"").required("Region is required"):L()}if(_){let i=s.fields.find(t=>t.name==="currency");i&&(i.options=_)}if(g){let i=s.fields.find(t=>t.name==="country");i&&(i.options=g,i.onChange=Q)}let W=r(()=>{b(void 0),c(e)},"resetForm"),P=[...s.fields,...S?.fields||[]],C=z(s.fields);async function X(i){let t=null,d=A(i,P,{isPartialValidation:!1});try{await C.validate(d,{abortEarly:!1}),t={formErrors:{},yupError:new J([],i)}}catch(R){let v=V(R);t={formErrors:Object.entries(v).reduce((ee,[te,re])=>({...ee,[te]:re.message}),{}),yupError:R}}let l=S?.handleValidation(d),Y=[...t?.yupError.inner||[],...l?.yupError?.inner||[]],Z={...t?.yupError?.value||{},...l?.yupError?.value||{}};return{formErrors:{...t?.formErrors||{},...l?.formErrors||{}},yupError:new J(Y,Z)}}return r(X,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:P,validationSchema:C,handleValidation:X,isSubmitting:F.isPending,isLoading:G&&U&&H,onSubmit:N,resetForm:W}},"useCostCalculator");function z(e){let o=e.reduce((n,a)=>(n[a.name]=a.schema,n),{});return se(o)}r(z,"buildValidationSchema");function le(e){let o="benefit-";return Object.keys(e).reduce((n,a)=>{let u={benefit_group_slug:a.replace(o,""),benefit_tier_slug:e[a]};return[...n,u]},[])}r(le,"formatBenefits");function T(e,o=E){return{employer_currency_slug:e.currency,include_benefits:o.includeBenefits,include_cost_breakdowns:o.includeCostBreakdowns,include_premium_benefits:o.includePremiumBenefits,employments:[{region_slug:e.region||e.country,annual_gross_salary:y(e.salary),annual_gross_salary_in_employer_currency:y(e.salary),employment_term:e.contract_duration_type??"fixed",title:o.title,regional_to_employer_exchange_rate:"1",age:e.age??void 0,...e.benefits&&{benefits:le(e.benefits)}}]}}r(T,"buildPayload");export{z as a,T as b,Fe as c,E as d,Pe as e};
2
+ //# sourceMappingURL=chunk-KQCZ2KSO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/CostCalculator/utils.ts","../src/flows/CostCalculator/hooks.ts"],"sourcesContent":["import type { CostCalculatorEstimateParams } from '@/src/client';\n\nimport { convertToCents } from '@/src/components/form/utils';\nimport { $TSFixMe } from '@remoteoss/json-schema-form';\nimport { AnyObjectSchema, object } from 'yup';\nimport { defaultEstimationOptions } from './hooks';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n} from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: $TSFixMe[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n\n/**\n * Format the benefits to the expected format by the API.\n * @param benefits\n * @returns\n */\nfunction formatBenefits(benefits: Record<string, string>) {\n const needle = 'benefit-';\n return Object.keys(benefits).reduce<\n Array<{ benefit_group_slug: string; benefit_tier_slug: string }>\n >((acc, key) => {\n const benefitGroupSlug = key.replace(needle, '');\n const benefitEntry = {\n benefit_group_slug: benefitGroupSlug,\n benefit_tier_slug: benefits[key],\n };\n return [...acc, benefitEntry];\n }, []);\n}\n\n/**\n * Build the payload for the cost calculator estimation.\n * @param values\n * @param estimationOptions\n * @returns\n */\nexport function buildPayload(\n values: CostCalculatorEstimationFormValues,\n estimationOptions: CostCalculatorEstimationOptions = defaultEstimationOptions,\n): CostCalculatorEstimateParams {\n return {\n employer_currency_slug: values.currency,\n include_benefits: estimationOptions.includeBenefits,\n include_cost_breakdowns: estimationOptions.includeCostBreakdowns,\n include_premium_benefits: estimationOptions.includePremiumBenefits,\n employments: [\n {\n region_slug: values.region || values.country,\n annual_gross_salary: convertToCents(values.salary) as number,\n annual_gross_salary_in_employer_currency: convertToCents(\n values.salary,\n ) as number,\n employment_term: values.contract_duration_type ?? 'fixed',\n title: estimationOptions.title,\n regional_to_employer_exchange_rate: '1',\n age: values.age ?? undefined,\n ...(values.benefits && { benefits: formatBenefits(values.benefits) }),\n },\n ],\n };\n}\n","import {\n CostCalculatorEstimateParams,\n CostCalculatorEstimateResponse,\n getIndexCompanyCurrency,\n getIndexCountry,\n getShowRegionField,\n MinimalRegion,\n postCreateEstimation,\n PostCreateEstimationError,\n postCreateEstimationPdf,\n} from '@/src/client';\nimport { jsonSchema } from '@/src/flows/CostCalculator/jsonSchema';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n JSFModify,\n} from '@/src/flows/CostCalculator/types';\nimport type { Result } from '@/src/flows/types';\n\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { iterateErrors } from '@/src/components/form/yupValidationResolver';\nimport { useClient } from '@/src/context';\nimport { Client } from '@hey-api/client-fetch';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { useState } from 'react';\nimport { string, ValidationError } from 'yup';\nimport { buildPayload, buildValidationSchema } from './utils';\n\ntype CostCalculatorCountry = {\n value: string;\n label: string;\n childRegions: MinimalRegion[];\n hasAdditionalFields: boolean | undefined;\n regionSlug: string;\n};\n\ntype JSFValidationError = {\n formErrors: Record<\n string,\n {\n type: string;\n message: string;\n }\n >;\n yupError: ValidationError;\n};\n\n/**\n * Hook to fetch the countries for the cost calculator.\n * @returns\n */\nconst useCostCalculatorCountries = ({\n includePremiumBenefits,\n}: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n}) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['cost-calculator-countries', includePremiumBenefits],\n queryFn: () => {\n return getIndexCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n select: (data) =>\n data.data?.data.map((country) => ({\n value: country.region_slug,\n label: country.name,\n childRegions: country.child_regions,\n hasAdditionalFields: country.has_additional_fields,\n regionSlug: country.region_slug,\n })),\n });\n};\n\n/**\n * Hook to fetch the company currencies.\n * @returns\n */\nconst useCompanyCurrencies = () => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['company-currencies'],\n queryFn: () => {\n return getIndexCompanyCurrency({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n });\n },\n select: (data) =>\n data.data?.data?.company_currencies.map((currency) => ({\n value: currency.slug,\n label: currency.code,\n })),\n });\n};\n\n/**\n * Hook to create an estimation.\n * @returns\n */\nconst useCostCalculatorEstimation = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimation({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Custom hook to create a PDF estimation.\n *\n * @returns\n */\nexport const useCostCalculatorEstimationPdf = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: CostCalculatorEstimateParams) => {\n return postCreateEstimationPdf({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\n/**\n * Hook to fetch the region fields.\n * @param region\n * @returns\n */\nconst useRegionFields = (\n region: string | undefined,\n {\n includePremiumBenefits,\n options,\n }: {\n includePremiumBenefits: CostCalculatorEstimationOptions['includePremiumBenefits'];\n options?: {\n jsfModify?: JSFModify;\n };\n },\n) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['cost-calculator-region-fields', region, includePremiumBenefits],\n queryFn: () => {\n return getShowRegionField({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: { slug: region as string },\n query: {\n include_premium_benefits: includePremiumBenefits,\n },\n });\n },\n enabled: !!region,\n select: ({ data }) => {\n let jsfSchema = data?.data?.schema || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n return createHeadlessForm(jsfSchema);\n },\n });\n};\n\nexport const defaultEstimationOptions: CostCalculatorEstimationOptions = {\n title: 'Estimation',\n includeBenefits: false,\n includeCostBreakdowns: false,\n includePremiumBenefits: false,\n};\n\ntype UseCostCalculatorParams = {\n /**\n * The default region slug to preselect a country and a region.\n */\n defaultRegion?: string;\n /**\n * The estimation options.\n */\n estimationOptions: CostCalculatorEstimationOptions;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport type EstimationError = PostCreateEstimationError | ValidationError;\n\n/**\n * Hook to use the cost calculator.\n */\nexport const useCostCalculator = (\n { defaultRegion, estimationOptions, options }: UseCostCalculatorParams = {\n estimationOptions: defaultEstimationOptions,\n },\n) => {\n const { schema: jsonSchemaModified } = modify(\n jsonSchema.data.schema,\n options?.jsfModify || {},\n );\n\n const fieldsJSONSchema = createHeadlessForm(jsonSchemaModified);\n\n const [selectedRegion, setSelectedRegion] = useState<string | undefined>(\n defaultRegion,\n );\n const [selectedCountry, setSelectedCountry] =\n useState<CostCalculatorCountry>();\n const { data: countries, isLoading: isLoadingCountries } =\n useCostCalculatorCountries({\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n });\n const { data: currencies, isLoading: isLoadingCurrencies } =\n useCompanyCurrencies();\n\n const jsonSchemaRegionSlug = selectedRegion || selectedCountry?.value;\n\n const { data: jsonSchemaRegionFields, isLoading: isLoadingRegionFields } =\n useRegionFields(jsonSchemaRegionSlug, {\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n options,\n });\n const costCalculatorEstimationMutation = useCostCalculatorEstimation();\n\n /**\n * Submit the estimation form with the given values.\n * @param values\n */\n async function onSubmit(\n values: CostCalculatorEstimationFormValues,\n ): Promise<Result<CostCalculatorEstimateResponse, EstimationError>> {\n try {\n await validationSchema.validate(values, { abortEarly: false });\n } catch (err) {\n return {\n data: null,\n error: err as ValidationError,\n };\n }\n\n return new Promise((resolve, reject) => {\n costCalculatorEstimationMutation.mutate(\n buildPayload(values, estimationOptions),\n {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ),\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as PostCreateEstimationError,\n });\n },\n },\n );\n });\n }\n\n /**\n * If the selected country has no child regions and has additional fields,\n * set the current region to the country's region slug and fetch the region fields.\n * @param country\n */\n function onCountryChange(country: string) {\n const currentCountry = countries?.find(({ value }) => value === country);\n\n if (\n currentCountry &&\n currentCountry.childRegions.length === 0 &&\n currentCountry.hasAdditionalFields\n ) {\n setSelectedRegion(currentCountry.regionSlug);\n } else {\n setSelectedRegion(undefined);\n }\n setSelectedCountry(currentCountry);\n }\n\n /**\n * Update the selected region and fetch the region fields.\n * @param region\n */\n function onRegionChange(region: string) {\n setSelectedRegion(region);\n }\n\n const regionField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'region',\n );\n\n if (regionField) {\n const regions =\n selectedCountry?.childRegions.map((region) => ({\n value: region.slug,\n label: region.name,\n })) ?? [];\n regionField.options = regions;\n regionField.isVisible = regions.length > 0;\n regionField.required = regions.length > 0;\n regionField.onChange = onRegionChange;\n regionField.schema =\n regions.length > 0\n ? string()\n .transform((value) => (typeof value === 'string' ? value : ''))\n .required('Region is required')\n : string();\n }\n\n if (currencies) {\n const currencyField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'currency',\n );\n if (currencyField) {\n currencyField.options = currencies;\n }\n }\n\n if (countries) {\n const countryField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n countryField.onChange = onCountryChange;\n }\n }\n\n const resetForm = () => {\n setSelectedCountry(undefined);\n setSelectedRegion(defaultRegion);\n };\n\n const allFields = [\n ...fieldsJSONSchema.fields,\n ...(jsonSchemaRegionFields?.fields || []),\n ];\n\n const validationSchema = buildValidationSchema(fieldsJSONSchema.fields);\n\n async function handleValidation(values: CostCalculatorEstimationFormValues) {\n let errors: JSFValidationError | null = null;\n\n const parsedValues = parseJSFToValidate(values, allFields, {\n isPartialValidation: false,\n });\n\n // 1. validate static fields first using Yup validate function\n try {\n await validationSchema.validate(parsedValues, {\n abortEarly: false,\n });\n errors = {\n formErrors: {},\n yupError: new ValidationError([], values),\n };\n } catch (error) {\n const iterateResult = iterateErrors(error as ValidationError);\n\n errors = {\n // convert the errors to a format that can be used in the form\n formErrors: Object.entries(iterateResult).reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value.message }),\n {},\n ),\n yupError: error as ValidationError,\n };\n }\n\n // 2. validate json schema fields using the handleValidation (from json-schema-form)\n const handleValidationResult =\n jsonSchemaRegionFields?.handleValidation(parsedValues);\n\n // 3. combine the errors from both validations\n const combinedInnerErrors = [\n ...(errors?.yupError.inner || []),\n ...(handleValidationResult?.yupError?.inner || []),\n ];\n const combinedValues = {\n ...(errors?.yupError?.value || {}),\n ...(handleValidationResult?.yupError?.value || {}),\n };\n\n return {\n formErrors: {\n ...(errors?.formErrors || {}),\n ...(handleValidationResult?.formErrors || {}),\n },\n yupError: new ValidationError(combinedInnerErrors, combinedValues),\n };\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: allFields,\n validationSchema,\n handleValidation,\n isSubmitting: costCalculatorEstimationMutation.isPending,\n isLoading:\n isLoadingCountries && isLoadingCurrencies && isLoadingRegionFields,\n onSubmit,\n resetForm,\n };\n};\n"],"mappings":"mRAIA,OAA0B,UAAAA,OAAc,MCmBxC,OAAS,sBAAAC,EAAoB,UAAAC,MAAc,8BAC3C,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBACtC,OAAS,YAAAC,MAAgB,QACzB,OAAS,UAAAC,EAAQ,mBAAAC,MAAuB,MA0BxC,IAAMC,GAA6BC,EAAA,CAAC,CAClC,uBAAAC,CACF,IAEM,CACJ,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,4BAA6BH,CAAsB,EAC9D,QAASD,EAAA,IACAK,EAAgB,CACrB,OAAQH,EACR,QAAS,CACP,cAAe,EACjB,EACA,MAAO,CACL,yBAA0BD,CAC5B,CACF,CAAC,EATM,WAWT,OAAQD,EAACM,GACPA,EAAK,MAAM,KAAK,IAAKC,IAAa,CAChC,MAAOA,EAAQ,YACf,MAAOA,EAAQ,KACf,aAAcA,EAAQ,cACtB,oBAAqBA,EAAQ,sBAC7B,WAAYA,EAAQ,WACtB,EAAE,EAPI,SAQV,CAAC,CACH,EA5BmC,8BAkC7BC,GAAuBR,EAAA,IAAM,CACjC,GAAM,CAAE,OAAAE,CAAO,EA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AAY,EACd,EACA,OAAQF,EACR,iBAAAlB,EACA,iBAAAoB,EACA,aAAcvB,EAAiC,UAC/C,UACEN,GAAsBE,GAAuBG,EAC/C,SAAAE,EACA,UAAAmB,CACF,CACF,EAnOiC,qBD5M1B,SAASe,EAAsBC,EAAoB,CACxD,IAAMC,EAAeD,EAAO,OAC1B,CAACE,EAAiBC,KAChBD,EAAgBC,EAAM,IAAI,EAAIA,EAAM,OAC7BD,GAET,CAAC,CACH,EACA,OAAOE,GAAOH,CAAY,CAC5B,CATgBI,EAAAN,EAAA,yBAgBhB,SAASO,GAAeC,EAAkC,CACxD,IAAMC,EAAS,WACf,OAAO,OAAO,KAAKD,CAAQ,EAAE,OAE3B,CAACE,EAAKC,IAAQ,CAEd,IAAMC,EAAe,CACnB,mBAFuBD,EAAI,QAAQF,EAAQ,EAAE,EAG7C,kBAAmBD,EAASG,CAAG,CACjC,EACA,MAAO,CAAC,GAAGD,EAAKE,CAAY,CAC9B,EAAG,CAAC,CAAC,CACP,CAZSN,EAAAC,GAAA,kBAoBF,SAASM,EACdC,EACAC,EAAqDC,EACvB,CAC9B,MAAO,CACL,uBAAwBF,EAAO,SAC/B,iBAAkBC,EAAkB,gBACpC,wBAAyBA,EAAkB,sBAC3C,yBAA0BA,EAAkB,uBAC5C,YAAa,CACX,CACE,YAAaD,EAAO,QAAUA,EAAO,QACrC,oBAAqBG,EAAeH,EAAO,MAAM,EACjD,yCAA0CG,EACxCH,EAAO,MACT,EACA,gBAAiBA,EAAO,wBAA0B,QAClD,MAAOC,EAAkB,MACzB,mCAAoC,IACpC,IAAKD,EAAO,KAAO,OACnB,GAAIA,EAAO,UAAY,CAAE,SAAUP,GAAeO,EAAO,QAAQ,CAAE,CACrE,CACF,CACF,CACF,CAxBgBR,EAAAO,EAAA","names":["object","createHeadlessForm","modify","useMutation","useQuery","useState","string","ValidationError","useCostCalculatorCountries","__name","includePremiumBenefits","client","useClient","useQuery","getIndexCountry","data","country","useCompanyCurrencies","getIndexCompanyCurrency","currency","useCostCalculatorEstimation","useMutation","payload","postCreateEstimation","useCostCalculatorEstimationPdf","postCreateEstimationPdf","useRegionFields","region","options","getShowRegionField","jsfSchema","schema","modify","createHeadlessForm","defaultEstimationOptions","useCostCalculator","defaultRegion","estimationOptions","jsonSchemaModified","jsonSchema","fieldsJSONSchema","selectedRegion","setSelectedRegion","useState","selectedCountry","setSelectedCountry","countries","isLoadingCountries","currencies","isLoadingCurrencies","jsonSchemaRegionSlug","jsonSchemaRegionFields","isLoadingRegionFields","costCalculatorEstimationMutation","onSubmit","values","validationSchema","err","resolve","reject","buildPayload","response","error","onCountryChange","currentCountry","value","onRegionChange","regionField","field","regions","string","currencyField","countryField","resetForm","allFields","buildValidationSchema","handleValidation","errors","parsedValues","parseJSFToValidate","ValidationError","iterateResult","iterateErrors","acc","key","handleValidationResult","combinedInnerErrors","combinedValues","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","formatBenefits","benefits","needle","acc","key","benefitEntry","buildPayload","values","estimationOptions","defaultEstimationOptions","convertToCents"]}
@@ -0,0 +1,2 @@
1
+ import{a as s,b as a}from"./chunk-UTCIIPYZ.js";import{b as c}from"./chunk-GCF5EF2A.js";import{c as i}from"./chunk-ANPGCYMT.js";import{a as e}from"./chunk-AYDF3IFZ.js";import m,{useEffect as S}from"react";function P({onSubmit:d,onError:u,onSuccess:f}){let{form:r,formId:l,contractAmendment:{checkFieldUpdates:p,fields:n,onSubmit:F}}=c();S(()=>{let t=r?.watch(o=>{r.formState.isDirty&&p(o)});return()=>t?.unsubscribe()},[]);let b=e(async t=>{let o=await F(i(t,n));await d?.(t),o.error?u?.(o.error):f?.(o.data)},"handleSubmit");return m.createElement(s,{...r},m.createElement("form",{id:l,onSubmit:r.handleSubmit(b),className:"space-y-4 RemoteFlows__CostCalculatorForm"},m.createElement(a,{fields:n})))}e(P,"ContractAmendmentForm");export{P as a};
2
+ //# sourceMappingURL=chunk-KY7BGW6H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/ContractAmendment/ContractAmendmentForm.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { JSONSchemaFormFields } from '@/src/components/form/JSONSchemaForm';\nimport { parseFormValuesToAPI } from '@/src/components/form/utils';\nimport { Form } from '@/src/components/ui/form';\nimport React, { useEffect } from 'react';\nimport { FieldValues } from 'react-hook-form';\nimport { useContractAmendmentContext } from './context';\n\ntype ContractAmendmentFormProps = {\n onSubmit?: (values: any) => Promise<void>;\n onError?: (error: any) => void;\n onSuccess?: (data: any) => void;\n};\n\nexport function ContractAmendmentForm({\n onSubmit,\n onError,\n onSuccess,\n}: ContractAmendmentFormProps) {\n const {\n form,\n formId,\n contractAmendment: {\n checkFieldUpdates,\n fields,\n onSubmit: submitContractAmendment,\n },\n } = useContractAmendmentContext();\n\n useEffect(() => {\n const subscription = form?.watch((values) => {\n if (form.formState.isDirty) {\n checkFieldUpdates(values);\n }\n });\n return () => subscription?.unsubscribe();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleSubmit = async (values: FieldValues) => {\n const contractAmendmentResult = await submitContractAmendment(\n parseFormValuesToAPI(values, fields),\n );\n\n await onSubmit?.(values);\n if (contractAmendmentResult.error) {\n onError?.(contractAmendmentResult.error);\n } else {\n onSuccess?.(contractAmendmentResult.data);\n }\n };\n\n return (\n <Form {...form}>\n <form\n id={formId}\n onSubmit={form.handleSubmit(handleSubmit)}\n className=\"space-y-4 RemoteFlows__CostCalculatorForm\"\n >\n <JSONSchemaFormFields fields={fields} />\n </form>\n </Form>\n );\n}\n"],"mappings":"uKAIA,OAAOA,GAAS,aAAAC,MAAiB,QAU1B,SAASC,EAAsB,CACpC,SAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAA+B,CAC7B,GAAM,CACJ,KAAAC,EACA,OAAAC,EACA,kBAAmB,CACjB,kBAAAC,EACA,OAAAC,EACA,SAAUC,CACZ,CACF,EAAIC,EAA4B,EAEhCC,EAAU,IAAM,CACd,IAAMC,EAAeP,GAAM,MAAOQ,GAAW,CACvCR,EAAK,UAAU,SACjBE,EAAkBM,CAAM,CAE5B,CAAC,EACD,MAAO,IAAMD,GAAc,YAAY,CAEzC,EAAG,CAAC,CAAC,EAEL,IAAME,EAAeC,EAAA,MAAOF,GAAwB,CAClD,IAAMG,EAA0B,MAAMP,EACpCQ,EAAqBJ,EAAQL,CAAM,CACrC,EAEA,MAAMN,IAAWW,CAAM,EACnBG,EAAwB,MAC1Bb,IAAUa,EAAwB,KAAK,EAEvCZ,IAAYY,EAAwB,IAAI,CAE5C,EAXqB,gBAarB,OACEE,EAAA,cAACC,EAAA,CAAM,GAAGd,GACRa,EAAA,cAAC,QACC,GAAIZ,EACJ,SAAUD,EAAK,aAAaS,CAAY,EACxC,UAAU,6CAEVI,EAAA,cAACE,EAAA,CAAqB,OAAQZ,EAAQ,CACxC,CACF,CAEJ,CAjDgBO,EAAAd,EAAA","names":["React","useEffect","ContractAmendmentForm","onSubmit","onError","onSuccess","form","formId","checkFieldUpdates","fields","submitContractAmendment","useContractAmendmentContext","useEffect","subscription","values","handleSubmit","__name","contractAmendmentResult","parseFormValuesToAPI","React","Form","JSONSchemaFormFields"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-MKJHD77O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +1,2 @@
1
- import{b as u}from"./chunk-HHNKZK2V.js";import{a as m}from"./chunk-ATKR5HCM.js";import{b as r}from"./chunk-OLJ2S6A6.js";import{a as o}from"./chunk-AYDF3IFZ.js";import e from"react";function f(t){let{formId:n}=r();return e.createElement(u,{type:"submit",className:m("RemoteFlows__CostCalculatorForm__SubmitButton",t.className),form:n,...t},t.children)}o(f,"CostCalculatorSubmitButton");export{f as a};
2
- //# sourceMappingURL=chunk-ZEGD25G2.js.map
1
+ import{b as r}from"./chunk-OLJ2S6A6.js";import{b as u}from"./chunk-FI76EKUS.js";import{a as m}from"./chunk-SJ56GVNV.js";import{a as o}from"./chunk-AYDF3IFZ.js";import e from"react";function f(t){let{formId:n}=r();return e.createElement(u,{type:"submit",className:m("RemoteFlows__CostCalculatorForm__SubmitButton",t.className),form:n,...t},t.children)}o(f,"CostCalculatorSubmitButton");export{f as a};
2
+ //# sourceMappingURL=chunk-NZFES56Y.js.map
@@ -0,0 +1,2 @@
1
+ import{b as r}from"./chunk-OLJ2S6A6.js";import{b as n}from"./chunk-FI76EKUS.js";import{a as e}from"./chunk-SJ56GVNV.js";import{a as o}from"./chunk-AYDF3IFZ.js";import i from"react";function _({children:s,...t}){let{form:m,formId:l,costCalculatorBag:u}=r();return i.createElement(n,{...t,type:"reset",className:e("RemoteFlows__CostCalculatorForm__ResetButton",t.className),form:l,onClick:a=>{u?.resetForm(),m.reset(),t.onClick?.(a)}},s)}o(_,"CostCalculatorResetButton");export{_ as a};
2
+ //# sourceMappingURL=chunk-OCNLZSS7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/CostCalculator/CostCalculatorResetButton.tsx"],"sourcesContent":["import { Button } from '@/src/components/ui/button';\nimport React, { ButtonHTMLAttributes, PropsWithChildren } from 'react';\nimport { useCostCalculatorContext } from './context';\nimport { cn } from '@/src/lib/utils';\n\nexport function CostCalculatorResetButton({\n children,\n ...props\n}: PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>) {\n const { form, formId, costCalculatorBag } = useCostCalculatorContext();\n return (\n <Button\n {...props}\n type=\"reset\"\n className={cn(\n 'RemoteFlows__CostCalculatorForm__ResetButton',\n props.className,\n )}\n form={formId}\n onClick={(evt) => {\n costCalculatorBag?.resetForm();\n form.reset();\n props.onClick?.(evt);\n }}\n >\n {children}\n </Button>\n );\n}\n"],"mappings":"gKACA,OAAOA,MAAwD,QAIxD,SAASC,EAA0B,CACxC,SAAAC,EACA,GAAGC,CACL,EAA+D,CAC7D,GAAM,CAAE,KAAAC,EAAM,OAAAC,EAAQ,kBAAAC,CAAkB,EAAIC,EAAyB,EACrE,OACEC,EAAA,cAACC,EAAA,CACE,GAAGN,EACJ,KAAK,QACL,UAAWO,EACT,+CACAP,EAAM,SACR,EACA,KAAME,EACN,QAAUM,GAAQ,CAChBL,GAAmB,UAAU,EAC7BF,EAAK,MAAM,EACXD,EAAM,UAAUQ,CAAG,CACrB,GAECT,CACH,CAEJ,CAvBgBU,EAAAX,EAAA","names":["React","CostCalculatorResetButton","children","props","form","formId","costCalculatorBag","useCostCalculatorContext","React","Button","cn","evt","__name"]}
@@ -0,0 +1,2 @@
1
+ import{d as u,e as i}from"./chunk-KQCZ2KSO.js";import{a as n}from"./chunk-OLJ2S6A6.js";import{b as s}from"./chunk-A4RX3KRZ.js";import{a as l}from"./chunk-AYDF3IFZ.js";import c,{useId as g}from"react";import{useForm as y}from"react-hook-form";function d({costCalculatorBag:t,defaultValues:o,render:e}){let a=g(),r=s(t.handleValidation),C=y({resolver:r,defaultValues:{country:o?.countryRegionSlug,currency:o?.currencySlug,region:"",salary:o?.salary},shouldUnregister:!0,mode:"onBlur"});return c.createElement(n.Provider,{value:{form:C,formId:a,costCalculatorBag:t}},e(t))}l(d,"CostCalculatorFlowProvider");var F=l(({estimationOptions:t=u,defaultValues:o={countryRegionSlug:"",currencySlug:"",salary:""},options:e,render:a})=>{let r=i({defaultRegion:o.countryRegionSlug,estimationOptions:t,options:e});return r.isLoading?a(r):c.createElement(d,{costCalculatorBag:r,defaultValues:o,render:a})},"CostCalculatorFlow");export{F as a};
2
+ //# sourceMappingURL=chunk-Q6GIPVSE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/CostCalculator/CostCalculatorFlow.tsx"],"sourcesContent":["import { useJsonSchemasValidationFormResolver } from '@/src/components/form/yupValidationResolver';\nimport { CostCalculatorContext } from '@/src/flows/CostCalculator/context';\nimport {\n defaultEstimationOptions,\n useCostCalculator,\n} from '@/src/flows/CostCalculator/hooks';\nimport {\n CostCalculatorEstimationOptions,\n JSFModify,\n} from '@/src/flows/CostCalculator/types';\nimport React, { PropsWithChildren, useId } from 'react';\nimport { useForm } from 'react-hook-form';\n\nfunction CostCalculatorFlowProvider({\n costCalculatorBag,\n defaultValues,\n render,\n}: PropsWithChildren<{\n costCalculatorBag: ReturnType<typeof useCostCalculator>;\n defaultValues: Partial<{\n countryRegionSlug: string;\n currencySlug: string;\n salary: string;\n }>;\n render: (\n costCalculatorBag: ReturnType<typeof useCostCalculator>,\n ) => React.ReactNode;\n}>) {\n const formId = useId();\n const resolver = useJsonSchemasValidationFormResolver(\n // @ts-expect-error no matching type\n costCalculatorBag.handleValidation,\n );\n\n const form = useForm({\n resolver,\n defaultValues: {\n country: defaultValues?.countryRegionSlug,\n currency: defaultValues?.currencySlug,\n region: '',\n salary: defaultValues?.salary,\n },\n shouldUnregister: true,\n mode: 'onBlur',\n });\n\n return (\n <CostCalculatorContext.Provider\n value={{\n form,\n formId: formId,\n costCalculatorBag,\n }}\n >\n {render(costCalculatorBag)}\n </CostCalculatorContext.Provider>\n );\n}\n\nexport type CostCalculatorFlowProps = {\n /**\n * Estimation params allows you to customize the parameters sent to the /cost-calculator/estimation endpoint.\n */\n estimationOptions?: CostCalculatorEstimationOptions;\n /**\n * Default values for the form fields.\n */\n defaultValues?: Partial<{\n /**\n * Default value for the country field.\n */\n countryRegionSlug: string;\n /**\n * Default value for the currency field.\n */\n currencySlug: string;\n /**\n * Default value for the salary field.\n */\n salary: string;\n }>;\n options?: {\n jsfModify?: JSFModify;\n };\n render: (\n costCalculatorBag: ReturnType<typeof useCostCalculator>,\n ) => React.ReactNode;\n};\n\nexport const CostCalculatorFlow = ({\n estimationOptions = defaultEstimationOptions,\n defaultValues = {\n countryRegionSlug: '',\n currencySlug: '',\n salary: '',\n },\n options,\n render,\n}: CostCalculatorFlowProps) => {\n const costCalculatorBag = useCostCalculator({\n defaultRegion: defaultValues.countryRegionSlug,\n estimationOptions,\n options,\n });\n\n if (costCalculatorBag.isLoading) {\n return render(costCalculatorBag);\n }\n\n return (\n <CostCalculatorFlowProvider\n costCalculatorBag={costCalculatorBag}\n defaultValues={defaultValues}\n render={render}\n />\n );\n};\n"],"mappings":"uKAUA,OAAOA,GAA4B,SAAAC,MAAa,QAChD,OAAS,WAAAC,MAAe,kBAExB,SAASC,EAA2B,CAClC,kBAAAC,EACA,cAAAC,EACA,OAAAC,CACF,EAUI,CACF,IAAMC,EAASC,EAAM,EACfC,EAAWC,EAEfN,EAAkB,gBACpB,EAEMO,EAAOC,EAAQ,CACnB,SAAAH,EACA,cAAe,CACb,QAASJ,GAAe,kBACxB,SAAUA,GAAe,aACzB,OAAQ,GACR,OAAQA,GAAe,MACzB,EACA,iBAAkB,GAClB,KAAM,QACR,CAAC,EAED,OACEQ,EAAA,cAACC,EAAsB,SAAtB,CACC,MAAO,CACL,KAAAH,EACA,OAAQJ,EACR,kBAAAH,CACF,GAECE,EAAOF,CAAiB,CAC3B,CAEJ,CA5CSW,EAAAZ,EAAA,8BA4EF,IAAMa,EAAqBD,EAAA,CAAC,CACjC,kBAAAE,EAAoBC,EACpB,cAAAb,EAAgB,CACd,kBAAmB,GACnB,aAAc,GACd,OAAQ,EACV,EACA,QAAAc,EACA,OAAAb,CACF,IAA+B,CAC7B,IAAMF,EAAoBgB,EAAkB,CAC1C,cAAef,EAAc,kBAC7B,kBAAAY,EACA,QAAAE,CACF,CAAC,EAED,OAAIf,EAAkB,UACbE,EAAOF,CAAiB,EAI/BS,EAAA,cAACV,EAAA,CACC,kBAAmBC,EACnB,cAAeC,EACf,OAAQC,EACV,CAEJ,EA3BkC","names":["React","useId","useForm","CostCalculatorFlowProvider","costCalculatorBag","defaultValues","render","formId","useId","resolver","useJsonSchemasValidationFormResolver","form","useForm","React","CostCalculatorContext","__name","CostCalculatorFlow","estimationOptions","defaultEstimationOptions","options","useCostCalculator"]}
@@ -0,0 +1,2 @@
1
+ import{a as o}from"./chunk-AYDF3IFZ.js";import{clsx as i}from"clsx";import{twMerge as u}from"tailwind-merge";function p(...n){return u(i(n))}o(p,"cn");function m(n,t="\u20AC"){if(!n)return"-";let r=n/100;return`${t}${r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}o(m,"formatCurrency");var a=o(n=>{let t={};return n.inner.forEach(r=>{r.path!==void 0&&(t[r.path]={type:r.type,errors:r.errors,inner:r.inner.map(e=>a(e))})}),t},"transformYupErrorsIntoObject");export{p as a,m as b,a as c};
2
+ //# sourceMappingURL=chunk-SJ56GVNV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport { ValidationError } from 'yup';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function formatCurrency(\n amount: number | undefined,\n symbol = '€',\n): string {\n if (!amount) {\n return '-';\n }\n\n const value = amount / 100;\n\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`;\n}\n\nfunction round(value: number): number {\n return Number(value.toFixed(2));\n}\n\nfunction convertToValidCost(value: string) {\n return parseFloat(value.replace(/,/g, ''));\n}\n\n/**\n * Converts a string amount to cents.\n *\n * This function takes a string representing a monetary amount, converts it to a valid number,\n * and then multiplies it by 100 to get the value in cents. The result is rounded to two decimal places.\n *\n * @param {string} amount - The string representation of the monetary amount.\n * @returns {number} - The amount in cents, rounded to two decimal places.\n */\nexport function convertToCents(amount: string): number {\n const validAmount = convertToValidCost(amount);\n\n return round(validAmount * 100);\n}\n\ntype YupError = Pick<ValidationError, 'type' | 'errors'> & {\n inner: Record<string, YupError>[];\n};\n\n/**\n * Transforms a Yup ValidationError object into a more readable object. The format is as follows:\n * {\n * [fieldName]: {\n * type: string,\n * errors: string[],\n * inner: YupError[],\n * },\n * }\n * @param errors\n * @returns\n */\nexport const transformYupErrorsIntoObject = (errors: ValidationError) => {\n const validationErrors: Record<string, YupError> = {};\n\n errors.inner.forEach((error: ValidationError) => {\n if (error.path !== undefined) {\n validationErrors[error.path] = {\n type: error.type,\n errors: error.errors,\n inner: error.inner.map((innerError) =>\n transformYupErrorsIntoObject(innerError),\n ),\n };\n }\n });\n\n return validationErrors;\n};\n"],"mappings":"wCAAA,OAAS,QAAAA,MAA6B,OACtC,OAAS,WAAAC,MAAe,iBAGjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOC,EAAQC,EAAKF,CAAM,CAAC,CAC7B,CAFgBG,EAAAJ,EAAA,MAIT,SAASK,EACdC,EACAC,EAAS,SACD,CACR,GAAI,CAACD,EACH,MAAO,IAGT,IAAME,EAAQF,EAAS,IAEvB,MAAO,GAAGC,CAAM,GAAGC,EAAM,eAAe,QAAS,CAC/C,sBAAuB,EACvB,sBAAuB,CACzB,CAAC,CAAC,EACJ,CAdgBJ,EAAAC,EAAA,kBAgBhB,SAASI,EAAMD,EAAuB,CACpC,OAAO,OAAOA,EAAM,QAAQ,CAAC,CAAC,CAChC,CAFSJ,EAAAK,EAAA,SAIT,SAASC,EAAmBF,EAAe,CACzC,OAAO,WAAWA,EAAM,QAAQ,KAAM,EAAE,CAAC,CAC3C,CAFSJ,EAAAM,EAAA,sBAaF,SAASC,EAAeL,EAAwB,CACrD,IAAMM,EAAcF,EAAmBJ,CAAM,EAE7C,OAAOG,EAAMG,EAAc,GAAG,CAChC,CAJgBR,EAAAO,EAAA,kBAsBT,IAAME,EAA+BT,EAACU,GAA4B,CACvE,IAAMC,EAA6C,CAAC,EAEpD,OAAAD,EAAO,MAAM,QAASE,GAA2B,CAC3CA,EAAM,OAAS,SACjBD,EAAiBC,EAAM,IAAI,EAAI,CAC7B,KAAMA,EAAM,KACZ,OAAQA,EAAM,OACd,MAAOA,EAAM,MAAM,IAAKC,GACtBJ,EAA6BI,CAAU,CACzC,CACF,EAEJ,CAAC,EAEMF,CACT,EAhB4C","names":["clsx","twMerge","cn","inputs","twMerge","clsx","__name","formatCurrency","amount","symbol","value","round","convertToValidCost","convertToCents","validAmount","transformYupErrorsIntoObject","errors","validationErrors","error","innerError"]}
1
+ {"version":3,"sources":["../src/lib/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport { ValidationError } from 'yup';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function formatCurrency(\n amount: number | undefined,\n symbol = '€',\n): string {\n if (!amount) {\n return '-';\n }\n\n const value = amount / 100;\n\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`;\n}\n\nfunction round(value: number): number {\n return Number(value.toFixed(2));\n}\n\nfunction convertToValidCost(value: string) {\n return parseFloat(value.replace(/,/g, ''));\n}\n\n/**\n * Converts a string amount to cents.\n *\n * This function takes a string representing a monetary amount, converts it to a valid number,\n * and then multiplies it by 100 to get the value in cents. The result is rounded to two decimal places.\n *\n * @param {string} amount - The string representation of the monetary amount.\n * @returns {number} - The amount in cents, rounded to two decimal places.\n */\nexport function convertToCents(amount: string): number {\n const validAmount = convertToValidCost(amount);\n\n return round(validAmount * 100);\n}\n\ntype YupError = Pick<ValidationError, 'type' | 'errors'> & {\n inner: Record<string, YupError>[];\n};\n\n/**\n * Transforms a Yup ValidationError object into a more readable object. The format is as follows:\n * {\n * [fieldName]: {\n * type: string,\n * errors: string[],\n * inner: YupError[],\n * },\n * }\n * @param errors\n * @returns\n */\nexport const transformYupErrorsIntoObject = (errors: ValidationError) => {\n const validationErrors: Record<string, YupError> = {};\n\n errors.inner.forEach((error: ValidationError) => {\n if (error.path !== undefined) {\n validationErrors[error.path] = {\n type: error.type,\n errors: error.errors,\n inner: error.inner.map((innerError) =>\n transformYupErrorsIntoObject(innerError),\n ),\n };\n }\n });\n\n return validationErrors;\n};\n"],"mappings":"wCAAA,OAAS,QAAAA,MAA6B,OACtC,OAAS,WAAAC,MAAe,iBAGjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOC,EAAQC,EAAKF,CAAM,CAAC,CAC7B,CAFgBG,EAAAJ,EAAA,MAIT,SAASK,EACdC,EACAC,EAAS,SACD,CACR,GAAI,CAACD,EACH,MAAO,IAGT,IAAME,EAAQF,EAAS,IAEvB,MAAO,GAAGC,CAAM,GAAGC,EAAM,eAAe,QAAS,CAC/C,sBAAuB,EACvB,sBAAuB,CACzB,CAAC,CAAC,EACJ,CAdgBJ,EAAAC,EAAA,kBAuDT,IAAMI,EAA+BC,EAACC,GAA4B,CACvE,IAAMC,EAA6C,CAAC,EAEpD,OAAAD,EAAO,MAAM,QAASE,GAA2B,CAC3CA,EAAM,OAAS,SACjBD,EAAiBC,EAAM,IAAI,EAAI,CAC7B,KAAMA,EAAM,KACZ,OAAQA,EAAM,OACd,MAAOA,EAAM,MAAM,IAAKC,GACtBL,EAA6BK,CAAU,CACzC,CACF,EAEJ,CAAC,EAEMF,CACT,EAhB4C","names":["clsx","twMerge","cn","inputs","twMerge","clsx","__name","formatCurrency","amount","symbol","value","transformYupErrorsIntoObject","__name","errors","validationErrors","error","innerError"]}
@@ -1,2 +1,2 @@
1
- var e={data:{version:7,schema:{additionalProperties:!1,properties:{country:{title:"Country",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},region:{title:"Region",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},currency:{title:"Currency",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},salary:{description:"",maxLength:255,title:"Salary",type:"string","x-jsf-presentation":{inputType:"text"},"x-jsf-errorMessage":{required:"Salary is required"}}},required:["country","currency","salary"],type:"object","x-jsf-order":["country","region","currency","salary"]}}};export{e as a};
2
- //# sourceMappingURL=chunk-VWM3PP54.js.map
1
+ var e={data:{version:7,schema:{additionalProperties:!1,properties:{country:{title:"Country",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},region:{title:"Region",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},currency:{title:"Currency",description:"",type:"string",oneOf:[],"x-jsf-presentation":{inputType:"select"}},salary:{description:"",title:"Salary",type:"integer","x-jsf-presentation":{inputType:"money"},"x-jsf-errorMessage":{required:"Salary is required"}}},required:["country","currency","salary"],type:"object","x-jsf-order":["country","region","currency","salary"]}}};export{e as a};
2
+ //# sourceMappingURL=chunk-UPRUP24B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/CostCalculator/jsonSchema.ts"],"sourcesContent":["export const jsonSchema = {\n data: {\n version: 7,\n schema: {\n additionalProperties: false,\n properties: {\n country: {\n title: 'Country',\n description: '',\n type: 'string',\n oneOf: [],\n 'x-jsf-presentation': {\n inputType: 'select',\n },\n },\n region: {\n title: 'Region',\n description: '',\n type: 'string',\n oneOf: [],\n 'x-jsf-presentation': {\n inputType: 'select',\n },\n },\n currency: {\n title: 'Currency',\n description: '',\n type: 'string',\n oneOf: [],\n 'x-jsf-presentation': {\n inputType: 'select',\n },\n },\n salary: {\n description: '',\n title: 'Salary',\n type: 'integer',\n 'x-jsf-presentation': {\n inputType: 'money',\n },\n 'x-jsf-errorMessage': {\n required: 'Salary is required',\n },\n },\n },\n required: ['country', 'currency', 'salary'],\n type: 'object',\n 'x-jsf-order': ['country', 'region', 'currency', 'salary'],\n },\n },\n};\n"],"mappings":"AAAO,IAAMA,EAAa,CACxB,KAAM,CACJ,QAAS,EACT,OAAQ,CACN,qBAAsB,GACtB,WAAY,CACV,QAAS,CACP,MAAO,UACP,YAAa,GACb,KAAM,SACN,MAAO,CAAC,EACR,qBAAsB,CACpB,UAAW,QACb,CACF,EACA,OAAQ,CACN,MAAO,SACP,YAAa,GACb,KAAM,SACN,MAAO,CAAC,EACR,qBAAsB,CACpB,UAAW,QACb,CACF,EACA,SAAU,CACR,MAAO,WACP,YAAa,GACb,KAAM,SACN,MAAO,CAAC,EACR,qBAAsB,CACpB,UAAW,QACb,CACF,EACA,OAAQ,CACN,YAAa,GACb,MAAO,SACP,KAAM,UACN,qBAAsB,CACpB,UAAW,OACb,EACA,qBAAsB,CACpB,SAAU,oBACZ,CACF,CACF,EACA,SAAU,CAAC,UAAW,WAAY,QAAQ,EAC1C,KAAM,SACN,cAAe,CAAC,UAAW,SAAU,WAAY,QAAQ,CAC3D,CACF,CACF","names":["jsonSchema"]}
@@ -0,0 +1,2 @@
1
+ import{a as K,b as A}from"./chunk-FI76EKUS.js";import{a}from"./chunk-SJ56GVNV.js";import{b as D}from"./chunk-WRDKLT4N.js";import{a as o}from"./chunk-AYDF3IFZ.js";import{Slot as Ee}from"@radix-ui/react-slot";import*as p from"react";import{Controller as Ae,FormProvider as Be,useFormContext as ze,useFormState as Ge}from"react-hook-form";import*as oe from"react";import*as re from"@radix-ui/react-label";function ae({className:e,...t}){return oe.createElement(re.Root,{"data-slot":"label",className:a("flex items-center gap-2 text-sm leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",e),...t})}o(ae,"Label");var Nt=Be,ie=p.createContext({}),g=o(({...e})=>p.createElement(ie.Provider,{value:{name:e.name}},p.createElement(Ae,{...e})),"FormField"),$=o(()=>{let e=p.useContext(ie),t=p.useContext(ne),{getFieldState:r}=ze(),i=Ge({name:e.name}),n=r(e.name,i);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return{id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...n}},"useFormField"),ne=p.createContext({});function b({className:e,...t}){let r=p.useId();return p.createElement(ne.Provider,{value:{id:r}},p.createElement("div",{"data-slot":"form-item",className:a("grid gap-2",e),...t}))}o(b,"FormItem");function h({className:e,...t}){let{error:r,formItemId:i}=$();return p.createElement(ae,{"data-slot":"form-label","data-error":!!r,className:a("text-base-color mb-1 data-[error=true]:text-destructive",e),htmlFor:i,...t})}o(h,"FormLabel");var v=p.forwardRef(({...e},t)=>{let{error:r,formItemId:i,formDescriptionId:n,formMessageId:s}=$();return p.createElement(Ee,{"data-slot":"form-control",ref:t,id:i,"aria-describedby":r?`${n} ${s}`:`${n}`,"aria-invalid":!!r,...e})});v.displayName="FormControl";function P({className:e,...t}){let{formDescriptionId:r}=$();return p.createElement("p",{"data-slot":"form-description",id:r,className:a("text-base-color text-xs",e),...t})}o(P,"FormDescription");function C({className:e,...t}){let{error:r,formMessageId:i}=$(),n=r?String(r?.message??""):t.children;return n?p.createElement("p",{"data-slot":"form-message",id:i,className:a("text-destructive text-sm",e),...t},n):null}o(C,"FormMessage");import*as V from"react";import*as B from"@radix-ui/react-checkbox";import{Check as Ue}from"lucide-react";var X=V.forwardRef(({className:e,...t},r)=>V.createElement(B.Root,{ref:r,className:a("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},V.createElement(B.Indicator,{className:a("flex items-center justify-center text-current")},V.createElement(Ue,{className:"h-4 w-4"}))));X.displayName=B.Root.displayName;import*as w from"react";import{useFormContext as $e}from"react-hook-form";function se({name:e,defaultValue:t,description:r,label:i}){let{control:n}=$e();return w.createElement(g,{control:n,name:e,defaultValue:t,render:({field:s,fieldState:m})=>w.createElement(b,{className:a(`RemoteFlows__CheckBoxField__Item__${e}`)},w.createElement(v,null,w.createElement("div",{className:"flex space-x-2"},w.createElement(X,{id:e,onCheckedChange:s.onChange,checked:s.value,className:"RemoteFlows__CheckBox__Input"}),w.createElement(h,{htmlFor:e,className:"mb-0 RemoteFlows__CheckBox__Label"},i))),r&&w.createElement(P,null,r),m.error&&w.createElement(C,null))})}o(se,"CheckBoxField");import{CalendarIcon as Je}from"lucide-react";import*as u from"react";import{useFormContext as We}from"react-hook-form";import*as H from"react";import{ChevronLeft as He,ChevronRight as je}from"lucide-react";import{DayPicker as Oe}from"react-day-picker";function le({className:e,classNames:t,showOutsideDays:r=!0,...i}){return H.createElement(Oe,{showOutsideDays:r,className:a("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:a(K({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:a("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",i.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:a(K({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:o(({className:n,...s})=>H.createElement(He,{className:a("size-4",n),...s}),"IconLeft"),IconRight:o(({className:n,...s})=>H.createElement(je,{className:a("size-4",n),...s}),"IconRight")},...i})}o(le,"Calendar");import*as z from"react";import*as I from"@radix-ui/react-popover";function me({...e}){return z.createElement(I.Root,{"data-slot":"popover",...e})}o(me,"Popover");function ce({...e}){return z.createElement(I.Trigger,{"data-slot":"popover-trigger",...e})}o(ce,"PopoverTrigger");function de({className:e,align:t="center",sideOffset:r=4,...i}){return z.createElement(I.Portal,null,z.createElement(I.Content,{"data-slot":"popover-content",align:t,sideOffset:r,className:a("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),...i}))}o(de,"PopoverContent");import{PopoverClose as qe}from"@radix-ui/react-popover";import{format as pe}from"date-fns";function ue({description:e,label:t,name:r,minDate:i}){let{control:n}=We();return u.createElement(g,{control:n,name:r,render:({field:s})=>u.createElement(b,{className:`flex flex-col RemoteFlows__DatePickerField__Item__${r}`},u.createElement(h,{className:"RemoteFlows__DatePickerField__Label"},t),u.createElement(me,null,u.createElement(ce,{asChild:!0},u.createElement(v,null,u.createElement("div",null,u.createElement(A,{type:"button",variant:"outline",className:a("w-full pl-3 text-left font-normal",!s.value&&"text-muted-foreground")},s.value&&u.createElement(u.Fragment,null,pe(s.value,"yyyy-MM-dd")),u.createElement(Je,{className:"ml-auto h-4 w-4 opacity-50"}))))),u.createElement(de,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start"},u.createElement(le,{mode:"single",className:"RemoteFlows__DatepickerField__Calendar",selected:s.value?new Date(s.value):void 0,onSelect:m=>s.onChange(m?pe(m,"yyyy-MM-dd"):null),defaultMonth:i?new Date(i):void 0,components:{DayContent:o(m=>u.createElement(qe,null,m.date.getDate()),"DayContent")},...i&&{disabled:o(m=>m<new Date(i),"disabled")}}))),e?u.createElement(P,null,e):null,u.createElement(C,null))})}o(ue,"DatePickerField");import*as M from"react";function fe({label:e,name:t,fields:r,description:i}){return M.createElement("fieldset",{className:a("border-1 border-input p-4 rounded-xl",`RemoteFlows__FieldSetField__${t}`)},M.createElement("legend",{className:"text-sm font-semibold px-2"},e),i?M.createElement("div",{className:"mb-5 RemoteFlows__FieldSetField__Description",dangerouslySetInnerHTML:{__html:i}}):null,M.createElement("div",{className:"grid gap-4"},r.map(n=>{let s=j[n.type];return M.createElement(s,{...n,key:n.name,name:`${t}.${n.name}`})})))}o(fe,"FieldSetField");import*as T from"react";import{useFormContext as Ze}from"react-hook-form";import S,{useState as Ke,useRef as Xe}from"react";import{Upload as Ye,X as Qe}from"lucide-react";function Fe({onChange:e,className:t,multiple:r}){let[i,n]=Ke([]),s=Xe(null),m=o(()=>{s.current?.click()},"handleClick"),y=o(l=>{if(l.target.files&&l.target.files.length>0){let _=Array.from(l.target.files);n(_),e(l)}},"handleChange"),f=o(l=>{n(_=>_.filter(R=>R!==l))},"onRemoveFile");return S.createElement("div",{className:a("flex flex-col items-start gap-4",t)},S.createElement("input",{type:"file",ref:s,onChange:y,className:"hidden","aria-label":"File upload",multiple:r}),S.createElement(A,{onClick:m,className:"gap-2"},S.createElement(Ye,{className:"h-4 w-4"}),"Choose File"),i.length===0&&S.createElement("div",{className:"text-sm"},r?S.createElement("span",{className:"font-medium"},"No files selected. You can select multiple files"):S.createElement("span",{className:"font-medium"},"No file selected.")),i.length>0&&i.map((l,_)=>S.createElement("div",{key:_,className:"text-sm flex items-center gap-2"},"Selected file: ",S.createElement("span",{className:"font-medium"},l.name)," (",Math.round(l.size/1024)," KB)",S.createElement(A,{variant:"ghost",onClick:()=>f(l)},S.createElement(Qe,null)))))}o(Fe,"FileUploader");function ge({name:e,description:t,label:r,multiple:i,onChange:n}){let{control:s}=Ze();return T.createElement(g,{control:s,name:e,render:({field:m,fieldState:y})=>T.createElement(b,{className:`RemoteFlows__FileUpload__Item__${e}`},T.createElement(h,{className:"RemoteFlows__FileUpload__Label"},r),T.createElement(v,null,T.createElement(Fe,{...m,onChange:f=>{m.onChange(f),n?.(f)},multiple:i,className:a("RemoteFlows__FileUpload__Input")})),t&&T.createElement("div",{className:"flex items-center justify-between"},T.createElement(P,{className:"RemoteFlows__FileUpload__Description"},t)),y.error&&T.createElement(C,{className:"RemoteFlows__FileUpload__Error"}))})}o(ge,"FileUploadField");import Y from"react";import{useFormContext as tt}from"react-hook-form";import*as k from"react";import{useFormContext as et}from"react-hook-form";import*as ve from"react";function xe({className:e,type:t,...r}){return ve.createElement("input",{type:t,"data-slot":"input",className:a("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),...r})}o(xe,"Input");function O({name:e,description:t,label:r,type:i,onChange:n,...s}){let{components:m}=D(),{control:y}=et();return k.createElement(g,{control:y,name:e,render:({field:f,fieldState:l})=>{if(m?.text){let _=m?.text,R={name:e,description:t,label:r,type:i,onChange:n,...s};return k.createElement(_,{field:{...f,onChange:o(U=>{f.onChange(U),n?.(U)},"onChange")},fieldState:l,fieldData:R})}return k.createElement(b,{className:`RemoteFlows__TextField__Item__${e}`},k.createElement(h,{className:"RemoteFlows__TextField__Label"},r),k.createElement(v,null,k.createElement(xe,{...f,value:f.value??"",onChange:_=>{console.log("EVENT",_),f.onChange(_),n?.(_)},className:"RemoteFlows__TextField__Input",placeholder:r})),t&&k.createElement(P,{className:"RemoteFlows__TextField__Description"},t),l.error&&k.createElement(C,{className:"RemoteFlows__TextField__Error"}))}})}o(O,"TextField");function Q(e){let{components:t}=D(),{control:r}=tt();return t?.number?Y.createElement(g,{control:r,name:e.name,render:({field:i,fieldState:n})=>{let s=t.number;return Y.createElement(s,{field:{...i,onChange:o(m=>{i.onChange(m),e.onChange?.(m)},"onChange")},fieldState:n,fieldData:e})}}):Y.createElement(O,{...e,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$"})}o(Q,"NumberField");import*as E from"@radix-ui/react-radio-group";import{CircleIcon as ot}from"lucide-react";import*as G from"react";function _e({className:e,...t}){return G.createElement(E.Root,{"data-slot":"radio-group",className:a("grid gap-3",e),...t})}o(_e,"RadioGroup");function be({className:e,...t}){return G.createElement(E.Item,{"data-slot":"radio-group-item",className:a("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},G.createElement(E.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center"},G.createElement(ot,{className:"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})))}o(be,"RadioGroupItem");import*as F from"react";import{useFormContext as rt}from"react-hook-form";function he({name:e,defaultValue:t,description:r,label:i,options:n,onChange:s}){let{control:m}=rt();return F.createElement(g,{control:m,name:e,defaultValue:t,render:({field:y,fieldState:f})=>F.createElement(b,{className:a("space-y-3",`RemoteFlows__RadioGroupField__Item__${e}`)},F.createElement(h,null,i),F.createElement(v,null,F.createElement(_e,{onValueChange:l=>{y.onChange(l),s?.(l)},defaultValue:y.value,className:"flex flex-col space-y-3"},n.map(l=>F.createElement(F.Fragment,null,F.createElement(b,{key:l.value,className:"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item"},F.createElement(v,null,F.createElement(be,{value:l.value,className:"RemoteFlows__RadioField__Input"})),F.createElement("div",null,F.createElement(h,{className:"font-normal mb-0 RemoteFlows__RadioField__Label"},l.label),l.description&&F.createElement(P,{className:"mt-2"},l.description))))))),r&&F.createElement(P,null,r),f.error&&F.createElement(C,null))})}o(he,"RadioGroupField");import*as x from"react";import*as d from"react";import*as c from"@radix-ui/react-select";import{CheckIcon as at,ChevronDownIcon as Pe,ChevronUpIcon as it}from"lucide-react";function Ce({...e}){return d.createElement(c.Root,{"data-slot":"select",...e})}o(Ce,"Select");function ye({...e}){return d.createElement(c.Group,{"data-slot":"select-group",...e})}o(ye,"SelectGroup");function Re({...e}){return d.createElement(c.Value,{"data-slot":"select-value",...e})}o(Re,"SelectValue");function Se({className:e,children:t,...r}){return d.createElement(c.Trigger,{"data-slot":"select-trigger",className:a("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),...r},t,d.createElement(c.Icon,{asChild:!0,className:"absolute right-4"},d.createElement(Pe,{className:"size-4"})))}o(Se,"SelectTrigger");function Ne({className:e,children:t,position:r="popper",...i}){return d.createElement(c.Portal,null,d.createElement(c.Content,{"data-slot":"select-content",className:a("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",r==="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:r,...i},d.createElement(nt,null),d.createElement(c.Viewport,{className:a(r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")},t),d.createElement(st,null)))}o(Ne,"SelectContent");function we({className:e,children:t,...r}){return d.createElement(c.Item,{"data-slot":"select-item",className:a("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),...r},d.createElement(c.ItemText,null,t),d.createElement("span",{className:"flex size-3.5 items-center justify-center"},d.createElement(c.ItemIndicator,null,d.createElement(at,{className:"size-4"}))))}o(we,"SelectItem");function nt({className:e,...t}){return d.createElement(c.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:a("flex cursor-default items-center justify-center py-1",e),...t},d.createElement(it,{className:"size-4"}))}o(nt,"SelectScrollUpButton");function st({className:e,...t}){return d.createElement(c.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:a("flex cursor-default items-center justify-center py-1",e),...t},d.createElement(Pe,{className:"size-4"}))}o(st,"SelectScrollDownButton");import{useFormContext as lt}from"react-hook-form";function Ie({label:e,name:t,options:r,defaultValue:i,description:n,onChange:s,...m}){let{control:y}=lt(),{components:f}=D();return x.createElement(g,{defaultValue:i,control:y,name:t,render:({field:l,fieldState:_})=>{if(f?.select){let R=f?.select,U={label:e,name:t,options:r,defaultValue:i,description:n,onChange:s,...m};return x.createElement(R,{field:{...l,onChange:o(te=>{l.onChange(te),s?.(te)},"onChange")},fieldState:_,fieldData:U})}return x.createElement(b,{className:`RemoteFlows__SelectField__Item__${t}`},x.createElement(h,{className:"RemoteFlows__SelectField__Label"},e),x.createElement(v,{"aria-label":e},x.createElement("div",{className:"relative"},x.createElement(Ce,{value:l.value||"",onValueChange:R=>{l.onChange(R),s?.(R)}},x.createElement(Se,{className:"RemoteFlows__SelectField__Trigger","aria-invalid":!!_.error},x.createElement("span",{className:"absolute"},x.createElement(Re,{placeholder:e}))),x.createElement(Ne,{className:"RemoteFlows__SelectField__Content"},x.createElement(ye,{className:"RemoteFlows__SelectField__Group"},r.map(R=>x.createElement(we,{key:R.value,value:R.value,className:"RemoteFlows__SelectField__SelectItem"},R.label))))))),n&&x.createElement(P,null,n),_.error&&x.createElement(C,null))}})}o(Ie,"SelectField");import*as N from"react";import{useFormContext as mt}from"react-hook-form";import*as J from"react";var Z=J.forwardRef(({className:e,...t},r)=>J.createElement("textarea",{className:a("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:r,...t}));Z.displayName="Textarea";function Te({name:e,description:t,label:r,onChange:i,maxLength:n}){let{control:s}=mt();return N.createElement(g,{control:s,name:e,render:({field:m,fieldState:y})=>{let f=m.value?.length??0;return N.createElement(b,{className:`RemoteFlows__TextArea__Item__${e}`},N.createElement(h,{className:"RemoteFlows__TextArea__Label"},r),N.createElement(v,null,N.createElement(Z,{...m,value:m.value??"",onChange:l=>{m.onChange(l),i?.(l)},className:a(y.error&&"border-red-500 focus-visible:ring-red-500","RemoteFlows__TextArea__Input"),placeholder:r})),(t||n)&&N.createElement("div",{className:"flex items-center justify-between"},t&&N.createElement(P,{className:"RemoteFlows__TextArea__Description"},t),n&&N.createElement("span",{className:"text-sm ml-auto RemoteFlows__TextArea__MaxLength"},f,"/",n)),y.error&&N.createElement(C,{className:"RemoteFlows__TextArea__Error"}))}})}o(Te,"TextAreaField");var j={checkbox:se,text:O,money:Q,select:Ie,radio:he,number:Q,file:ge,fieldset:fe,date:ue,textarea:Te};import L,{Fragment as Ft}from"react";import{cva as ct}from"class-variance-authority";import*as W from"react";var dt=ct("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 ke({className:e,variant:t,...r}){return W.createElement("div",{"data-slot":"alert",role:"alert",className:a(dt({variant:t}),e),...r})}o(ke,"Alert");function Le({className:e,...t}){return W.createElement("div",{"data-slot":"alert-title",className:a("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}o(Le,"AlertTitle");function De({className:e,...t}){return W.createElement("div",{"data-slot":"alert-description",className:a("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}o(De,"AlertDescription");import{AlertCircle as pt}from"lucide-react";import q from"react";function Ve({title:e,description:t}){return q.createElement(ke,{variant:"warning"},q.createElement(pt,{className:"h-4 w-4"}),q.createElement(Le,null,e),q.createElement(De,null,t))}o(Ve,"Statement");import ee,{useEffect as ut}from"react";import{useFormContext as ft}from"react-hook-form";function Me({name:e,value:t,description:r,statement:i}){let{setValue:n}=ft();return ut(()=>{n(e,t)},[]),ee.createElement("div",null,ee.createElement("p",{className:`text-sm RemoteFlows__ForcedValue__Title__${e}`,dangerouslySetInnerHTML:{__html:i.title}}),ee.createElement("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:i.description||r}}))}o(Me,"ForcedValueField");function gt(e){return e.const!==void 0&&e.const===e.default&&e.inputType!=="checkbox"&&e.inputType!=="hidden"}o(gt,"checkFieldHasForcedValue");var Ur=o(({fields:e})=>!e||e.length===0?null:L.createElement(L.Fragment,null,e.map(t=>{if(t.isVisible===!1||t.deprecated)return null;if(gt(t))return L.createElement(Me,{key:t.name,name:t.name,description:t.description,value:t.const,statement:t.statement});let r=j[t.inputType];return r?L.createElement(Ft,{key:t.name},L.createElement(r,{...t}),t.statement?L.createElement(Ve,{...t.statement}):null):L.createElement("p",{className:"error"},"Field type ",t.inputType," not supported")})),"JSONSchemaFormFields");export{Nt as a,Ur as b};
2
+ //# sourceMappingURL=chunk-UTCIIPYZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ui/form.tsx","../src/components/ui/label.tsx","../src/components/ui/checkbox.tsx","../src/components/form/fields/CheckBoxField.tsx","../src/components/form/fields/DatePickerField.tsx","../src/components/ui/calendar.tsx","../src/components/ui/popover.tsx","../src/components/form/fields/FieldSetField.tsx","../src/components/form/fields/FileUploadField.tsx","../src/components/ui/file-uploader.tsx","../src/components/form/fields/NumberField.tsx","../src/components/form/fields/TextField.tsx","../src/components/ui/input.tsx","../src/components/ui/radio-group.tsx","../src/components/form/fields/RadioGroupField.tsx","../src/components/form/fields/SelectField.tsx","../src/components/ui/select.tsx","../src/components/form/fields/TextAreaField.tsx","../src/components/ui/textarea.tsx","../src/components/form/fields/fieldsMapping.tsx","../src/components/form/JSONSchemaForm.tsx","../src/components/ui/alert.tsx","../src/components/form/Statement.tsx","../src/components/form/fields/ForcedValueField.tsx"],"sourcesContent":["import * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport {\n Controller,\n ControllerProps,\n FieldPath,\n FieldValues,\n FormProvider,\n useFormContext,\n useFormState,\n} from 'react-hook-form';\n\nimport { Label } from '@/src/components/ui/label';\nimport { cn } from '@/src/lib/utils';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n className={cn('grid gap-2', className)}\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\n 'text-base-color mb-1 data-[error=true]:text-destructive',\n className,\n )}\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\nconst FormControl = React.forwardRef<\n React.ComponentRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n data-slot=\"form-control\"\n ref={ref}\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\n\nFormControl.displayName = 'FormControl';\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn('text-base-color text-xs', className)}\n {...props}\n />\n );\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? '') : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn('text-destructive text-sm', className)}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n};\n","'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n 'flex items-center gap-2 text-sm leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Label };\n","'use client';\n\nimport * as React from 'react';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { Check } from 'lucide-react';\n\nimport { cn } from '@/src/lib/utils';\n\nconst Checkbox = React.forwardRef<\n React.ComponentRef<typeof CheckboxPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <CheckboxPrimitive.Root\n ref={ref}\n className={cn(\n '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',\n className,\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator\n className={cn('flex items-center justify-center text-current')}\n >\n <Check className=\"h-4 w-4\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n));\nCheckbox.displayName = CheckboxPrimitive.Root.displayName;\n\nexport { Checkbox };\n","import { Checkbox } from '@/src/components/ui/checkbox';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/src/components/ui/form';\nimport { cn } from '@/src/lib/utils';\nimport * as React from 'react';\nimport { useFormContext } from 'react-hook-form';\n\ntype CheckBoxFieldProps = {\n name: string;\n label: string;\n description?: string;\n defaultValue?: string;\n};\n\nexport function CheckBoxField({\n name,\n defaultValue,\n description,\n label,\n}: CheckBoxFieldProps) {\n const { control } = useFormContext();\n return (\n <FormField\n control={control}\n name={name}\n defaultValue={defaultValue}\n render={({ field, fieldState }) => {\n return (\n <FormItem className={cn(`RemoteFlows__CheckBoxField__Item__${name}`)}>\n <FormControl>\n <div className=\"flex space-x-2\">\n <Checkbox\n id={name}\n onCheckedChange={field.onChange}\n checked={field.value}\n className=\"RemoteFlows__CheckBox__Input\"\n />\n <FormLabel\n htmlFor={name}\n className=\"mb-0 RemoteFlows__CheckBox__Label\"\n >\n {label}\n </FormLabel>\n </div>\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {fieldState.error && <FormMessage />}\n </FormItem>\n );\n }}\n />\n );\n}\n","import { CalendarIcon } from 'lucide-react';\nimport * as React from 'react';\nimport { useFormContext } from 'react-hook-form';\n\nimport { Button } from '@/src/components/ui/button';\nimport { Calendar } from '@/src/components/ui/calendar';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/src/components/ui/form';\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@/src/components/ui/popover';\nimport { cn } from '@/src/lib/utils';\nimport { PopoverClose } from '@radix-ui/react-popover';\nimport { format } from 'date-fns';\n\ntype DatePickerFieldProps = {\n description?: string;\n label: string;\n name: string;\n minDate?: string;\n};\n\nexport function DatePickerField({\n description,\n label,\n name,\n minDate,\n}: DatePickerFieldProps) {\n const { control } = useFormContext();\n return (\n <FormField\n control={control}\n name={name}\n render={({ field }) => (\n <FormItem\n className={`flex flex-col RemoteFlows__DatePickerField__Item__${name}`}\n >\n <FormLabel className=\"RemoteFlows__DatePickerField__Label\">\n {label}\n </FormLabel>\n <Popover>\n <PopoverTrigger asChild>\n <FormControl>\n <div>\n <Button\n type=\"button\"\n variant={'outline'}\n className={cn(\n 'w-full pl-3 text-left font-normal',\n !field.value && 'text-muted-foreground',\n )}\n >\n {field.value && <>{format(field.value, 'yyyy-MM-dd')}</>}\n <CalendarIcon className=\"ml-auto h-4 w-4 opacity-50\" />\n </Button>\n </div>\n </FormControl>\n </PopoverTrigger>\n <PopoverContent\n className={`w-auto p-0 RemoteFlows__DatepickerField__PopoverContent`}\n align=\"start\"\n >\n <Calendar\n mode=\"single\"\n className=\"RemoteFlows__DatepickerField__Calendar\"\n selected={field.value ? new Date(field.value) : undefined}\n onSelect={(date) =>\n field.onChange(date ? format(date, 'yyyy-MM-dd') : null)\n }\n defaultMonth={minDate ? new Date(minDate) : undefined}\n components={{\n DayContent: (props) => {\n return <PopoverClose>{props.date.getDate()}</PopoverClose>;\n },\n }}\n {...(minDate && {\n disabled: (date: Date) => date < new Date(minDate),\n })}\n />\n </PopoverContent>\n </Popover>\n {description ? (\n <FormDescription>{description}</FormDescription>\n ) : null}\n <FormMessage />\n </FormItem>\n )}\n />\n );\n}\n","import * as React from 'react';\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\nimport { DayPicker } from 'react-day-picker';\n\nimport { cn } from '@/src/lib/utils';\nimport { buttonVariants } from '@/src/components/ui/button';\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: React.ComponentProps<typeof DayPicker>) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn('p-3', className)}\n classNames={{\n months: 'flex flex-col sm:flex-row gap-2',\n month: 'flex flex-col gap-4',\n caption: 'flex justify-center pt-1 relative items-center w-full',\n caption_label: 'text-sm font-medium',\n nav: 'flex items-center gap-1',\n nav_button: cn(\n buttonVariants({ variant: 'outline' }),\n 'size-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n ),\n nav_button_previous: 'absolute left-1',\n nav_button_next: 'absolute right-1',\n table: 'w-full border-collapse space-x-1',\n head_row: 'flex',\n head_cell:\n 'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',\n row: 'flex w-full mt-2',\n cell: cn(\n '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',\n props.mode === 'range'\n ? '[&: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'\n : '[&:has([aria-selected])]:rounded-md',\n ),\n day: cn(\n buttonVariants({ variant: 'ghost' }),\n 'size-8 p-0 font-normal aria-selected:opacity-100',\n ),\n day_range_start:\n 'day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground',\n day_range_end:\n 'day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground',\n day_selected:\n 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',\n day_today: 'bg-accent text-accent-foreground',\n day_outside:\n 'day-outside text-muted-foreground aria-selected:text-muted-foreground',\n day_disabled: 'text-muted-foreground opacity-50',\n day_range_middle:\n 'aria-selected:bg-accent aria-selected:text-accent-foreground',\n day_hidden: 'invisible',\n ...classNames,\n }}\n components={{\n IconLeft: ({ className, ...props }) => (\n <ChevronLeft className={cn('size-4', className)} {...props} />\n ),\n IconRight: ({ className, ...props }) => (\n <ChevronRight className={cn('size-4', className)} {...props} />\n ),\n }}\n {...props}\n />\n );\n}\n\nexport { Calendar };\n","import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Popover({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nfunction PopoverTrigger({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\n}\n\nfunction PopoverContent({\n className,\n align = 'center',\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n data-slot=\"popover-content\"\n align={align}\n sideOffset={sideOffset}\n className={cn(\n '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',\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Portal>\n );\n}\n\nfunction PopoverAnchor({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {\n return <PopoverPrimitive.Anchor data-slot=\"popover-anchor\" {...props} />;\n}\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };\n","import { fieldsMap } from '@/src/components/form/fields/fieldsMapping';\nimport { cn } from '@/src/lib/utils';\nimport * as React from 'react';\nimport { SupportedTypes } from './types';\n\ntype FieldBase = {\n label: string;\n name: string;\n description: string;\n};\n\ntype FieldWithOptions = FieldBase & {\n type: 'select' | 'radio';\n options: Array<{ value: string; label: string }>;\n};\n\ntype FieldWithoutOptions = FieldBase & {\n type: Exclude<SupportedTypes, 'select' | 'radio'>;\n options?: never;\n};\n\ntype Field = FieldWithOptions | FieldWithoutOptions;\n\ntype FieldSetProps = {\n label: string;\n name: string;\n description: string;\n fields: Field[];\n};\n\nexport function FieldSetField({\n label,\n name,\n fields,\n description,\n}: FieldSetProps) {\n return (\n <fieldset\n className={cn(\n 'border-1 border-input p-4 rounded-xl',\n `RemoteFlows__FieldSetField__${name}`,\n )}\n >\n <legend className=\"text-sm font-semibold px-2\">{label}</legend>\n {description ? (\n <div\n className=\"mb-5 RemoteFlows__FieldSetField__Description\"\n dangerouslySetInnerHTML={{ __html: description }}\n />\n ) : null}\n <div className=\"grid gap-4\">\n {fields.map((field) => {\n const FieldComponent = fieldsMap[field.type];\n return (\n <FieldComponent\n {...field}\n key={field.name}\n name={`${name}.${field.name}`}\n />\n );\n })}\n </div>\n </fieldset>\n );\n}\n","import * as React from 'react';\n\nimport { useFormContext } from 'react-hook-form';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '../../ui/form';\nimport { FileUploader } from '../../ui/file-uploader';\nimport { cn } from '@/src/lib/utils';\n\ntype FileUploadFieldProps = {\n label: string;\n description?: string;\n name: string;\n multiple?: boolean;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n};\n\nexport function FileUploadField({\n name,\n description,\n label,\n multiple,\n onChange,\n}: FileUploadFieldProps) {\n const { control } = useFormContext();\n return (\n <FormField\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n return (\n <FormItem className={`RemoteFlows__FileUpload__Item__${name}`}>\n <FormLabel className=\"RemoteFlows__FileUpload__Label\">\n {label}\n </FormLabel>\n <FormControl>\n <FileUploader\n {...field}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n field.onChange(event);\n onChange?.(event);\n }}\n multiple={multiple}\n className={cn('RemoteFlows__FileUpload__Input')}\n />\n </FormControl>\n {description && (\n <div className=\"flex items-center justify-between\">\n <FormDescription className=\"RemoteFlows__FileUpload__Description\">\n {description}\n </FormDescription>\n </div>\n )}\n {fieldState.error && (\n <FormMessage className=\"RemoteFlows__FileUpload__Error\" />\n )}\n </FormItem>\n );\n }}\n />\n );\n}\n","import React, { useState, useRef } from 'react';\nimport { Button } from '@/src/components/ui/button';\nimport { Upload, X } from 'lucide-react';\nimport { cn } from '@/src/lib/utils';\n\ntype FileUploaderProps = {\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n className?: string;\n multiple?: boolean;\n};\n\nexport function FileUploader({\n onChange,\n className,\n multiple,\n}: FileUploaderProps) {\n const [files, setFiles] = useState<File[]>([]);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleClick = () => {\n inputRef.current?.click();\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.files && e.target.files.length > 0) {\n const newFiles = Array.from(e.target.files);\n\n setFiles(newFiles);\n onChange(e);\n }\n };\n\n const onRemoveFile = (file: File) => {\n setFiles((prevFiles) => prevFiles.filter((f) => f !== file));\n };\n\n return (\n <div className={cn('flex flex-col items-start gap-4', className)}>\n <input\n type=\"file\"\n ref={inputRef}\n onChange={handleChange}\n className=\"hidden\"\n aria-label=\"File upload\"\n multiple={multiple}\n />\n <Button onClick={handleClick} className=\"gap-2\">\n <Upload className=\"h-4 w-4\" />\n Choose File\n </Button>\n {files.length === 0 && (\n <div className=\"text-sm\">\n {!multiple ? (\n <span className=\"font-medium\">No file selected.</span>\n ) : (\n <span className=\"font-medium\">\n No files selected. You can select multiple files\n </span>\n )}\n </div>\n )}\n {files.length > 0 &&\n files.map((file, index) => (\n <div key={index} className=\"text-sm flex items-center gap-2\">\n Selected file: <span className=\"font-medium\">{file.name}</span> (\n {Math.round(file.size / 1024)} KB)\n <Button variant=\"ghost\" onClick={() => onRemoveFile(file)}>\n <X />\n </Button>\n </div>\n ))}\n </div>\n );\n}\n","import { useFormFields } from '@/src/context';\nimport React from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { FormField } from '../../ui/form';\nimport { TextField, TextFieldProps } from './TextField';\n\nexport function NumberField(props: TextFieldProps) {\n const { components } = useFormFields();\n const { control } = useFormContext();\n\n if (components?.number) {\n return (\n <FormField\n control={control}\n name={props.name}\n render={({ field, fieldState }) => {\n const CustomNumberField =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components.number as React.ComponentType<any>;\n return (\n <CustomNumberField\n field={{\n ...field,\n onChange: (value: React.ChangeEvent<HTMLInputElement>) => {\n field.onChange(value);\n props.onChange?.(value);\n },\n }}\n fieldState={fieldState}\n fieldData={props}\n />\n );\n }}\n />\n );\n }\n\n return (\n <TextField {...props} type=\"text\" inputMode=\"decimal\" pattern=\"^[0-9.]*$\" />\n );\n}\n","import * as React from 'react';\n\nimport { useFormFields } from '@/src/context';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { useFormContext } from 'react-hook-form';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '../../ui/form';\nimport { Input } from '../../ui/input';\n\nexport type TextFieldProps = React.ComponentProps<'input'> &\n JSFField & {\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n };\n\nexport function TextField({\n name,\n description,\n label,\n type,\n onChange,\n ...rest\n}: TextFieldProps) {\n const { components } = useFormFields();\n const { control } = useFormContext();\n\n return (\n <FormField\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n if (components?.text) {\n const CustomTextField = components?.text;\n const customTextFieldProps = {\n name,\n description,\n label,\n type,\n onChange,\n ...rest,\n };\n return (\n <CustomTextField\n field={{\n ...field,\n onChange: (value: React.ChangeEvent<HTMLInputElement>) => {\n field.onChange(value);\n onChange?.(value);\n },\n }}\n fieldState={fieldState}\n fieldData={customTextFieldProps}\n />\n );\n }\n\n return (\n <FormItem className={`RemoteFlows__TextField__Item__${name}`}>\n <FormLabel className=\"RemoteFlows__TextField__Label\">\n {label}\n </FormLabel>\n <FormControl>\n <Input\n {...field}\n // {...rest}\n value={field.value ?? ''}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) => {\n console.log('EVENT', event);\n field.onChange(event);\n onChange?.(event);\n }}\n className=\"RemoteFlows__TextField__Input\"\n placeholder={label}\n />\n </FormControl>\n {description && (\n <FormDescription className=\"RemoteFlows__TextField__Description\">\n {description}\n </FormDescription>\n )}\n {fieldState.error && (\n <FormMessage className=\"RemoteFlows__TextField__Error\" />\n )}\n </FormItem>\n );\n }}\n />\n );\n}\n","import * as React from 'react';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n type={type}\n data-slot=\"input\"\n className={cn(\n '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',\n 'focus-visible:border-focused',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Input };\n","import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { CircleIcon } from 'lucide-react';\nimport * as React from 'react';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction RadioGroup({\n className,\n ...props\n}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {\n return (\n <RadioGroupPrimitive.Root\n data-slot=\"radio-group\"\n className={cn('grid gap-3', className)}\n {...props}\n />\n );\n}\n\nfunction RadioGroupItem({\n className,\n ...props\n}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {\n return (\n <RadioGroupPrimitive.Item\n data-slot=\"radio-group-item\"\n className={cn(\n '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',\n className,\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator\n data-slot=\"radio-group-indicator\"\n className=\"relative flex items-center justify-center\"\n >\n <CircleIcon className=\"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n );\n}\n\nexport { RadioGroup, RadioGroupItem };\n","import {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/src/components/ui/form';\nimport { RadioGroup, RadioGroupItem } from '@/src/components/ui/radio-group';\nimport { cn } from '@/src/lib/utils';\nimport * as React from 'react';\nimport { useFormContext } from 'react-hook-form';\n\ntype RadioGroupFieldProps = {\n name: string;\n label: string;\n description?: string;\n defaultValue?: string;\n options: Array<{ value: string; label: string; description?: string }>;\n onChange?: (value: string) => void;\n};\n\nexport function RadioGroupField({\n name,\n defaultValue,\n description,\n label,\n options,\n onChange,\n}: RadioGroupFieldProps) {\n const { control } = useFormContext();\n return (\n <FormField\n control={control}\n name={name}\n defaultValue={defaultValue}\n render={({ field, fieldState }) => (\n <FormItem\n className={cn(\n 'space-y-3',\n `RemoteFlows__RadioGroupField__Item__${name}`,\n )}\n >\n <FormLabel>{label}</FormLabel>\n <FormControl>\n <RadioGroup\n // onValueChange={field.onChange}\n onValueChange={(value: string) => {\n field.onChange(value);\n onChange?.(value);\n }}\n defaultValue={field.value}\n className=\"flex flex-col space-y-3\"\n >\n {options.map((option) => (\n <>\n <FormItem\n key={option.value}\n className=\"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item\"\n >\n <FormControl>\n <RadioGroupItem\n value={option.value}\n className=\"RemoteFlows__RadioField__Input\"\n />\n </FormControl>\n <div>\n <FormLabel className=\"font-normal mb-0 RemoteFlows__RadioField__Label\">\n {option.label}\n </FormLabel>\n {option.description && (\n <FormDescription className=\"mt-2\">\n {option.description}\n </FormDescription>\n )}\n </div>\n </FormItem>\n </>\n ))}\n </RadioGroup>\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {fieldState.error && <FormMessage />}\n </FormItem>\n )}\n />\n );\n}\n","import * as React from 'react';\n\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@/src/components/ui/select';\nimport { useFormFields } from '@/src/context';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { useFormContext } from 'react-hook-form';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '../../ui/form';\n\ntype SelectFieldProps = JSFField & {\n placeholder?: string;\n options: Array<{ value: string; label: string }>;\n className?: string;\n onChange?: (value: React.ChangeEvent<HTMLInputElement> | string) => void;\n};\n\nexport function SelectField({\n label,\n name,\n options,\n defaultValue,\n description,\n onChange,\n ...rest\n}: SelectFieldProps) {\n const { control } = useFormContext();\n const { components } = useFormFields();\n\n return (\n <FormField\n defaultValue={defaultValue}\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n if (components?.select) {\n const CustomSelectField = components?.select;\n const customSelectFieldProps = {\n label,\n name,\n options,\n defaultValue,\n description,\n onChange,\n ...rest,\n };\n return (\n <CustomSelectField\n field={{\n ...field,\n onChange: (value: React.ChangeEvent<HTMLInputElement>) => {\n field.onChange(value);\n onChange?.(value);\n },\n }}\n fieldState={fieldState}\n fieldData={customSelectFieldProps}\n />\n );\n }\n\n return (\n <FormItem className={`RemoteFlows__SelectField__Item__${name}`}>\n <FormLabel className=\"RemoteFlows__SelectField__Label\">\n {label}\n </FormLabel>\n <FormControl aria-label={label}>\n <div className=\"relative\">\n <Select\n value={field.value || ''}\n onValueChange={(value: string) => {\n field.onChange(value);\n onChange?.(value);\n }}\n >\n <SelectTrigger\n className=\"RemoteFlows__SelectField__Trigger\"\n aria-invalid={Boolean(fieldState.error)}\n >\n <span className=\"absolute\">\n <SelectValue placeholder={label} />\n </span>\n </SelectTrigger>\n <SelectContent className=\"RemoteFlows__SelectField__Content\">\n <SelectGroup className=\"RemoteFlows__SelectField__Group\">\n {options.map((option) => (\n <SelectItem\n key={option.value}\n value={option.value}\n className=\"RemoteFlows__SelectField__SelectItem\"\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </Select>\n </div>\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {fieldState.error && <FormMessage />}\n </FormItem>\n );\n }}\n />\n );\n}\n","import * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react';\n\nimport { cn } from '@/src/lib/utils';\n\nfunction Select({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Root>) {\n return <SelectPrimitive.Root data-slot=\"select\" {...props} />;\n}\n\nfunction SelectGroup({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return <SelectPrimitive.Group data-slot=\"select-group\" {...props} />;\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />;\n}\n\nfunction SelectTrigger({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger>) {\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n className={cn(\n \"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\",\n 'focus-visible:border-focused',\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild className=\"absolute right-4\">\n <ChevronDownIcon className=\"size-4\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n );\n}\n\nfunction SelectContent({\n className,\n children,\n position = 'popper',\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Content>) {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n data-slot=\"select-content\"\n className={cn(\n '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',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n );\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Label>) {\n return (\n <SelectPrimitive.Label\n data-slot=\"select-label\"\n className={cn('px-2 py-1.5 text-sm font-medium', className)}\n {...props}\n />\n );\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n <span className=\"flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n </SelectPrimitive.Item>\n );\n}\n\nfunction SelectSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Separator>) {\n return (\n <SelectPrimitive.Separator\n data-slot=\"select-separator\"\n className={cn('bg-border pointer-events-none -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {\n return (\n <SelectPrimitive.ScrollUpButton\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronUpIcon className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n );\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {\n return (\n <SelectPrimitive.ScrollDownButton\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronDownIcon className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n );\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n};\n","import * as React from 'react';\n\nimport { useFormContext } from 'react-hook-form';\nimport {\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '../../ui/form';\nimport { Textarea } from '../../ui/textarea';\nimport { cn } from '@/src/lib/utils';\n\ntype TextAreaFieldProps = {\n label: string;\n description?: string;\n name: string;\n maxLength?: number;\n onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n};\n\nexport function TextAreaField({\n name,\n description,\n label,\n onChange,\n maxLength,\n}: TextAreaFieldProps) {\n const { control } = useFormContext();\n return (\n <FormField\n control={control}\n name={name}\n render={({ field, fieldState }) => {\n const valueLength = field.value?.length ?? 0;\n return (\n <FormItem className={`RemoteFlows__TextArea__Item__${name}`}>\n <FormLabel className=\"RemoteFlows__TextArea__Label\">\n {label}\n </FormLabel>\n <FormControl>\n <Textarea\n {...field}\n value={field.value ?? ''}\n onChange={(event: React.ChangeEvent<HTMLTextAreaElement>) => {\n field.onChange(event);\n onChange?.(event);\n }}\n className={cn(\n fieldState.error &&\n 'border-red-500 focus-visible:ring-red-500',\n 'RemoteFlows__TextArea__Input',\n )}\n placeholder={label}\n />\n </FormControl>\n {(description || maxLength) && (\n <div className=\"flex items-center justify-between\">\n {description && (\n <FormDescription className=\"RemoteFlows__TextArea__Description\">\n {description}\n </FormDescription>\n )}\n {maxLength && (\n <span className=\"text-sm ml-auto RemoteFlows__TextArea__MaxLength\">\n {valueLength}/{maxLength}\n </span>\n )}\n </div>\n )}\n {fieldState.error && (\n <FormMessage className=\"RemoteFlows__TextArea__Error\" />\n )}\n </FormItem>\n );\n }}\n />\n );\n}\n","import * as React from 'react';\n\nimport { cn } from '@/src/lib/utils';\n\nconst Textarea = React.forwardRef<\n HTMLTextAreaElement,\n React.ComponentProps<'textarea'>\n>(({ className, ...props }, ref) => {\n return (\n <textarea\n className={cn(\n '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',\n className,\n )}\n ref={ref}\n {...props}\n />\n );\n});\nTextarea.displayName = 'Textarea';\n\nexport { Textarea };\n","import { CheckBoxField } from '@/src/components/form/fields/CheckBoxField';\nimport { DatePickerField } from '@/src/components/form/fields/DatePickerField';\nimport { FieldSetField } from '@/src/components/form/fields/FieldSetField';\nimport { FileUploadField } from '@/src/components/form/fields/FileUploadField';\nimport { NumberField } from '@/src/components/form/fields/NumberField';\nimport { RadioGroupField } from '@/src/components/form/fields/RadioGroupField';\nimport { SelectField } from '@/src/components/form/fields/SelectField';\nimport { TextAreaField } from '@/src/components/form/fields/TextAreaField';\nimport { TextField } from '@/src/components/form/fields/TextField';\nimport { SupportedTypes } from '@/src/components/form/fields/types';\nimport React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const fieldsMap: Record<SupportedTypes, React.ComponentType<any>> = {\n checkbox: CheckBoxField,\n text: TextField,\n money: NumberField,\n select: SelectField,\n radio: RadioGroupField,\n number: NumberField,\n file: FileUploadField,\n fieldset: FieldSetField,\n date: DatePickerField,\n textarea: TextAreaField,\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { fieldsMap } from '@/src/components/form/fields/fieldsMapping';\nimport { SupportedTypes } from '@/src/components/form/fields/types';\nimport { Fields } from '@remoteoss/json-schema-form';\nimport React, { Fragment } from 'react';\nimport { Statement, StatementProps } from './Statement';\nimport { ForcedValueField } from './fields/ForcedValueField';\n\ntype JSONSchemaFormFieldsProps = {\n fields: Fields;\n};\n\nfunction checkFieldHasForcedValue(field: any) {\n // A field to be considered \"forced value\" must:\n return (\n field.const !== undefined && // Only accepts a specific value\n field.const === field.default && // It can be prefilled, meaning it's not critical\n field.inputType !== 'checkbox' && // Because checkbox must always be visible\n field.inputType !== 'hidden' // Because hidden inputs shouldn't be visible\n );\n}\n\nexport const JSONSchemaFormFields = ({ fields }: JSONSchemaFormFieldsProps) => {\n if (!fields || fields.length === 0) return null;\n\n return (\n <>\n {fields.map((field) => {\n if (field.isVisible === false || field.deprecated) {\n return null; // Skip hidden or deprecated fields\n }\n\n if (checkFieldHasForcedValue(field)) {\n return (\n <ForcedValueField\n key={field.name as string}\n name={field.name as string}\n description={field.description as string}\n value={field.const as string}\n statement={field.statement as any}\n />\n );\n }\n\n const FieldComponent = fieldsMap[field.inputType as SupportedTypes];\n return FieldComponent ? (\n <Fragment key={field.name as string}>\n <FieldComponent {...field} />\n {field.statement ? (\n <Statement {...(field.statement as StatementProps)} />\n ) : null}\n </Fragment>\n ) : (\n <p className=\"error\">\n Field type {field.inputType as string} not supported\n </p>\n );\n })}\n </>\n );\n};\n","import { cva, type VariantProps } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { cn } from '@/src/lib/utils';\n\nconst alertVariants = cva(\n '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',\n {\n variants: {\n variant: {\n default: 'bg-card text-card-foreground',\n destructive:\n 'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',\n warning:\n 'bg-card bg-warning border-warning-border [&>svg]:text-current',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nfunction Alert({\n className,\n variant,\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {\n return (\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-title\"\n className={cn(\n 'col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDescription({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-description\"\n className={cn(\n 'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Alert, AlertDescription, AlertTitle };\n","import { Alert, AlertDescription, AlertTitle } from '@/src/components/ui/alert';\nimport { AlertCircle } from 'lucide-react';\nimport React from 'react';\n\nexport type StatementProps = {\n title: string;\n description: string;\n severity: 'warning' | 'error' | 'success' | 'info' | 'neutral' | 'time';\n};\n\nexport function Statement({ title, description }: StatementProps) {\n return (\n <Alert variant=\"warning\">\n <AlertCircle className=\"h-4 w-4\" />\n <AlertTitle>{title}</AlertTitle>\n <AlertDescription>{description}</AlertDescription>\n </Alert>\n );\n}\n","import React, { useEffect } from 'react';\nimport { useFormContext } from 'react-hook-form';\n\ntype ForcedValueFieldProps = {\n name: string;\n value: string;\n description: string;\n statement: {\n title: string;\n description: string;\n };\n};\n\nexport function ForcedValueField({\n name,\n value,\n description,\n statement,\n}: ForcedValueFieldProps) {\n const { setValue } = useFormContext();\n\n useEffect(() => {\n setValue(name, value);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <p\n className={`text-sm RemoteFlows__ForcedValue__Title__${name}`}\n dangerouslySetInnerHTML={{ __html: statement.title }}\n />\n <p\n className={`text-xs RemoteFlows__ForcedValue__Description__${name}`}\n dangerouslySetInnerHTML={{\n __html: statement.description || description,\n }}\n />\n </div>\n );\n}\n"],"mappings":"kKACA,OAAS,QAAAA,OAAY,uBACrB,UAAYC,MAAW,QACvB,OACE,cAAAC,GAIA,gBAAAC,GACA,kBAAAC,GACA,gBAAAC,OACK,kBCTP,UAAYC,OAAW,QACvB,UAAYC,OAAoB,wBAIhC,SAASC,GAAM,CACb,UAAAC,EACA,GAAGC,CACL,EAAqD,CACnD,OACE,iBAAgB,QAAf,CACC,YAAU,QACV,UAAWC,EACT,gJACAF,CACF,EACC,GAAGC,EACN,CAEJ,CAdSE,EAAAJ,GAAA,SDST,IAAMK,GAAOC,GASPC,GAAyB,gBAC7B,CAAC,CACH,EAEMC,EAAYC,EAAA,CAGhB,CACA,GAAGC,CACL,IAEI,gBAACH,GAAiB,SAAjB,CAA0B,MAAO,CAA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EAAU,KAGzCC,EAAA,cAAAA,EAAA,cACGD,EAAO,IAAKH,GAAU,CACrB,GAAIA,EAAM,YAAc,IAASA,EAAM,WACrC,OAAO,KAGT,GAAID,GAAyBC,CAAK,EAChC,OACEI,EAAA,cAACC,GAAA,CACC,IAAKL,EAAM,KACX,KAAMA,EAAM,KACZ,YAAaA,EAAM,YACnB,MAAOA,EAAM,MACb,UAAWA,EAAM,UACnB,EAIJ,IAAMM,EAAiBC,EAAUP,EAAM,SAA2B,EAClE,OAAOM,EACLF,EAAA,cAACI,GAAA,CAAS,IAAKR,EAAM,MACnBI,EAAA,cAACE,EAAA,CAAgB,GAAGN,EAAO,EAC1BA,EAAM,UACLI,EAAA,cAACK,GAAA,CAAW,GAAIT,EAAM,UAA8B,EAClD,IACN,EAEAI,EAAA,cAAC,KAAE,UAAU,SAAQ,cACPJ,EAAM,UAAoB,gBACxC,CAEJ,CAAC,CACH,EApCgC","names":["Slot","React","Controller","FormProvider","useFormContext","useFormState","React","LabelPrimitive","Label","className","props","cn","__name","Form","FormProvider","FormFieldContext","FormField","__name","props","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","ref","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body","React","CheckboxPrimitive","Check","Checkbox","className","props","ref","cn","Check","React","useFormContext","CheckBoxField","name","defaultValue","description","label","control","useFormContext","FormField","field","fieldState","FormItem","cn","FormControl","Checkbox","FormLabel","FormDescription","FormMessage","__name","CalendarIcon","React","useFormContext","React","ChevronLeft","ChevronRight","DayPicker","Calendar","className","classNames","showOutsideDays","props","DayPicker","cn","buttonVariants","__name","ChevronLeft","ChevronRight","React","PopoverPrimitive","Popover","props","__name","PopoverTrigger","PopoverContent","className","align","sideOffset","cn","PopoverClose","format","DatePickerField","description","label","name","minDate","control","useFormContext","FormField","field","FormItem","FormLabel","Popover","PopoverTrigger","FormControl","Button","cn","format","CalendarIcon","PopoverContent","Calendar","date","__name","props","PopoverClose","FormDescription","FormMessage","React","FieldSetField","label","name","fields","description","cn","field","FieldComponent","fieldsMap","__name","React","useFormContext","React","useState","useRef","Upload","X","FileUploader","onChange","className","multiple","files","setFiles","useState","inputRef","useRef","handleClick","__name","handleChange","e","newFiles","onRemoveFile","file","prevFiles","f","React","cn","Button","Upload","index","X","FileUploadField","name","description","label","multiple","onChange","control","useFormContext","FormField","field","fieldState","FormItem","FormLabel","FormControl","FileUploader","event","cn","FormDescription","FormMessage","__name","React","useFormContext","React","useFormContext","React","Input","className","type","props","cn","__name","TextField","name","description","label","type","onChange","rest","components","useFormFields","control","useFormContext","FormField","field","fieldState","CustomTextField","customTextFieldProps","__name","value","FormItem","FormLabel","FormControl","Input","event","FormDescription","FormMessage","NumberField","props","components","useFormFields","control","useFormContext","React","FormField","field","fieldState","CustomNumberField","__name","value","TextField","RadioGroupPrimitive","CircleIcon","React","RadioGroup","className","props","cn","__name","RadioGroupItem","CircleIcon","React","useFormContext","RadioGroupField","name","defaultValue","description","label","options","onChange","control","useFormContext","FormField","field","fieldState","FormItem","cn","FormLabel","FormControl","RadioGroup","value","option","RadioGroupItem","FormDescription","FormMessage","__name","React","React","SelectPrimitive","CheckIcon","ChevronDownIcon","ChevronUpIcon","Select","props","__name","SelectGroup","SelectValue","SelectTrigger","className","children","cn","ChevronDownIcon","SelectContent","position","SelectScrollUpButton","SelectScrollDownButton","SelectItem","className","children","props","cn","CheckIcon","__name","SelectScrollUpButton","className","props","cn","ChevronUpIcon","__name","SelectScrollDownButton","ChevronDownIcon","useFormContext","SelectField","label","name","options","defaultValue","description","onChange","rest","control","useFormContext","components","useFormFields","FormField","field","fieldState","CustomSelectField","customSelectFieldProps","__name","value","FormItem","FormLabel","FormControl","Select","SelectTrigger","SelectValue","SelectContent","SelectGroup","option","SelectItem","FormDescription","FormMessage","React","useFormContext","React","Textarea","className","props","ref","cn","TextAreaField","name","description","label","onChange","maxLength","control","useFormContext","FormField","field","fieldState","valueLength","FormItem","FormLabel","FormControl","Textarea","event","cn","FormDescription","FormMessage","__name","fieldsMap","CheckBoxField","TextField","NumberField","SelectField","RadioGroupField","FileUploadField","FieldSetField","DatePickerField","TextAreaField","React","Fragment","cva","React","alertVariants","cva","Alert","className","variant","props","cn","__name","AlertTitle","AlertDescription","AlertCircle","React","Statement","title","description","React","Alert","AlertCircle","AlertTitle","AlertDescription","__name","React","useEffect","useFormContext","ForcedValueField","name","value","description","statement","setValue","useFormContext","useEffect","React","__name","checkFieldHasForcedValue","field","__name","JSONSchemaFormFields","fields","React","ForcedValueField","FieldComponent","fieldsMap","Fragment","Statement"]}
@@ -0,0 +1,2 @@
1
+ import{a as c}from"./chunk-AYDF3IFZ.js";import{object as a}from"yup";function i(n){let r=n.reduce((e,t)=>(e[t.name]=t.schema,e),{});return a(r)}c(i,"buildValidationSchema");export{i as a};
2
+ //# sourceMappingURL=chunk-VTAHQOKR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flows/utils.ts"],"sourcesContent":["import { AnyObjectSchema, object } from 'yup';\nimport { Field } from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: Field[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n"],"mappings":"wCAAA,OAA0B,UAAAA,MAAc,MAOjC,SAASC,EAAsBC,EAAiB,CACrD,IAAMC,EAAeD,EAAO,OAC1B,CAACE,EAAiBC,KAChBD,EAAgBC,EAAM,IAAI,EAAIA,EAAM,OAC7BD,GAET,CAAC,CACH,EACA,OAAOE,EAAOH,CAAY,CAC5B,CATgBI,EAAAN,EAAA","names":["object","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name"]}
@@ -1,2 +1,2 @@
1
- import{a as P}from"./chunk-Q2ZB5MOF.js";import{a as y,b as v,c as h,d as _,e as w}from"./chunk-JEULWBZA.js";import{a as k}from"./chunk-BIWKEH5R.js";import{a as x}from"./chunk-HGBJ3RNH.js";import{a as T}from"./chunk-BY2NZ5QF.js";import{a as n}from"./chunk-ATKR5HCM.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{Euro as H}from"lucide-react";import t,{lazy as G,useState as A}from"react";import*as N from"react";import{Slot as z}from"@radix-ui/react-slot";import{cva as F}from"class-variance-authority";var E=F("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-badge text-badge-foreground rounded-full [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground rounded-full [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white rounded-full [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",outline:"text-foreground rounded-full [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function B({className:a,variant:o,asChild:r=!1,...u}){return N.createElement(r?z:"span",{"data-slot":"badge",className:n(E({variant:o}),a),...u})}s(B,"Badge");import*as m from"react";import*as i from"@radix-ui/react-tabs";function S({className:a,...o}){return m.createElement(i.Root,{"data-slot":"tabs",className:n("flex flex-col gap-2",a),...o})}s(S,"Tabs");function V({className:a,...o}){return m.createElement(i.List,{"data-slot":"tabs-list",className:n("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",a),...o})}s(V,"TabsList");function b({className:a,...o}){return m.createElement(i.Trigger,{"data-slot":"tabs-trigger",className:n("data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a),...o})}s(b,"TabsTrigger");var M=G(()=>import("./flows/CostCalculator/Results/CostCalculatorResultsChart.js"));function st({employmentData:a,options:o}){let[r,u]=A("monthly"),l=a.employments?.[0];if(!l)return null;let e=l.employer_currency_costs,c=e.currency.symbol,f=r==="monthly"?e.monthly_gross_salary:e.annual_gross_salary,p=r==="monthly"?e.monthly_benefits_total:e.annual_benefits_total,g=r==="monthly"?e.monthly_contributions_total:e.annual_contributions_total,D=r==="monthly"?e.monthly_total:e.annual_total,d=r==="monthly"?e.monthly_benefits_breakdown:e.annual_benefits_breakdown,L=r==="monthly"?e.monthly_contributions_breakdown:e.annual_contributions_breakdown,C=[{name:"Gross Salary",value:f,color:o?.chartColors?.grossSalary??"#3b82f6"},{name:"Contributions",value:g,color:o?.chartColors?.contributions??"#f59e0b"}];return d&&C.push({name:"Benefits",value:p??0,color:o?.chartColors?.benefits??"#10b981"}),t.createElement(t.Fragment,null,t.createElement("div",{className:"flex flex-col md:flex-row gap-4 md:items-center justify-between mb-6 RemoteFlows__CostCalculatorResults"},t.createElement("div",{className:"RemoteFlows__CostCalculatorResults__Header"},t.createElement("h2",{className:"text-xl font-semibold flex items-center gap-2"},t.createElement("span",{className:"flex items-center gap-1"},t.createElement(H,{className:"h-5 w-5 text-gray-600"}),o?.title??"Cost Calculator"),t.createElement(B,{className:"ml-2"},l.country.name)),t.createElement("p",{className:"text-primary-foreground font-medium mt-1"},o?.description??`Total cost of employment in ${l.country.name}`)),t.createElement(S,{value:r,onValueChange:j=>u(j),className:"w-full md:w-auto RemoteFlows__CostCalculatorResults__Tabs"},t.createElement(V,{className:"grid w-full md:w-[200px] grid-cols-2"},t.createElement(b,{value:"monthly"},"Monthly"),t.createElement(b,{value:"annual"},"Annual")))),t.createElement("div",{className:n("grid grid-cols-1 gap-6",o?.showChart?"md:grid-cols-3":"","RemoteFlows__CostCalculatorResults_CostBreakdown")},t.createElement(y,{className:"md:col-span-2 rounded-lg"},t.createElement(v,{className:"pb-2"},t.createElement(h,null,"Cost Breakdown"),t.createElement(_,null,"Detailed breakdown of all employer costs")),t.createElement(w,null,t.createElement("div",{className:"space-y-6"},t.createElement(P,{grossSalary:f,currency:c}),d?t.createElement(x,{benefitsBreakdown:d,benefitsTotal:p,currency:c}):null,t.createElement(T,{contributionsBreakdown:L,contributionsTotal:g,currency:c}),t.createElement(k,{totalCost:D,currency:c})))),o?.showChart&&t.createElement(M,{chartData:C,currency:c})))}s(st,"CostCalculatorResults");export{st as a};
2
- //# sourceMappingURL=chunk-LT4TLUWZ.js.map
1
+ import{a as P}from"./chunk-YVC4OEFJ.js";import{a as y,b as v,c as h,d as _,e as w}from"./chunk-XEQTLVMV.js";import{a as k}from"./chunk-DOA6BAUQ.js";import{a as x}from"./chunk-J2RINDSC.js";import{a as T}from"./chunk-4F7PYKUZ.js";import{a as n}from"./chunk-SJ56GVNV.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{Euro as H}from"lucide-react";import t,{lazy as G,useState as A}from"react";import*as N from"react";import{Slot as z}from"@radix-ui/react-slot";import{cva as F}from"class-variance-authority";var E=F("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-badge text-badge-foreground rounded-full [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground rounded-full [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white rounded-full [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",outline:"text-foreground rounded-full [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function B({className:a,variant:o,asChild:r=!1,...u}){return N.createElement(r?z:"span",{"data-slot":"badge",className:n(E({variant:o}),a),...u})}s(B,"Badge");import*as m from"react";import*as i from"@radix-ui/react-tabs";function S({className:a,...o}){return m.createElement(i.Root,{"data-slot":"tabs",className:n("flex flex-col gap-2",a),...o})}s(S,"Tabs");function V({className:a,...o}){return m.createElement(i.List,{"data-slot":"tabs-list",className:n("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",a),...o})}s(V,"TabsList");function b({className:a,...o}){return m.createElement(i.Trigger,{"data-slot":"tabs-trigger",className:n("data-[state=active]:bg-background data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring inline-flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",a),...o})}s(b,"TabsTrigger");var M=G(()=>import("./flows/CostCalculator/Results/CostCalculatorResultsChart.js"));function st({employmentData:a,options:o}){let[r,u]=A("monthly"),l=a.employments?.[0];if(!l)return null;let e=l.employer_currency_costs,c=e.currency.symbol,f=r==="monthly"?e.monthly_gross_salary:e.annual_gross_salary,p=r==="monthly"?e.monthly_benefits_total:e.annual_benefits_total,g=r==="monthly"?e.monthly_contributions_total:e.annual_contributions_total,D=r==="monthly"?e.monthly_total:e.annual_total,d=r==="monthly"?e.monthly_benefits_breakdown:e.annual_benefits_breakdown,L=r==="monthly"?e.monthly_contributions_breakdown:e.annual_contributions_breakdown,C=[{name:"Gross Salary",value:f,color:o?.chartColors?.grossSalary??"#3b82f6"},{name:"Contributions",value:g,color:o?.chartColors?.contributions??"#f59e0b"}];return d&&C.push({name:"Benefits",value:p??0,color:o?.chartColors?.benefits??"#10b981"}),t.createElement(t.Fragment,null,t.createElement("div",{className:"flex flex-col md:flex-row gap-4 md:items-center justify-between mb-6 RemoteFlows__CostCalculatorResults"},t.createElement("div",{className:"RemoteFlows__CostCalculatorResults__Header"},t.createElement("h2",{className:"text-xl font-semibold flex items-center gap-2"},t.createElement("span",{className:"flex items-center gap-1"},t.createElement(H,{className:"h-5 w-5 text-gray-600"}),o?.title??"Cost Calculator"),t.createElement(B,{className:"ml-2"},l.country.name)),t.createElement("p",{className:"text-primary-foreground font-medium mt-1"},o?.description??`Total cost of employment in ${l.country.name}`)),t.createElement(S,{value:r,onValueChange:j=>u(j),className:"w-full md:w-auto RemoteFlows__CostCalculatorResults__Tabs"},t.createElement(V,{className:"grid w-full md:w-[200px] grid-cols-2"},t.createElement(b,{value:"monthly"},"Monthly"),t.createElement(b,{value:"annual"},"Annual")))),t.createElement("div",{className:n("grid grid-cols-1 gap-6",o?.showChart?"md:grid-cols-3":"","RemoteFlows__CostCalculatorResults_CostBreakdown")},t.createElement(y,{className:"md:col-span-2 rounded-lg"},t.createElement(v,{className:"pb-2"},t.createElement(h,null,"Cost Breakdown"),t.createElement(_,null,"Detailed breakdown of all employer costs")),t.createElement(w,null,t.createElement("div",{className:"space-y-6"},t.createElement(P,{grossSalary:f,currency:c}),d?t.createElement(x,{benefitsBreakdown:d,benefitsTotal:p,currency:c}):null,t.createElement(T,{contributionsBreakdown:L,contributionsTotal:g,currency:c}),t.createElement(k,{totalCost:D,currency:c})))),o?.showChart&&t.createElement(M,{chartData:C,currency:c})))}s(st,"CostCalculatorResults");export{st as a};
2
+ //# sourceMappingURL=chunk-VV7RML2Q.js.map
@@ -0,0 +1,2 @@
1
+ import{a as o}from"./chunk-AYDF3IFZ.js";import{createContext as e,useContext as n}from"react";var r=e(null),m=o(()=>{let t=n(r);if(!t?.components)throw new Error("useFormFields must be used within a FormFieldsProvider");return{components:t.components}},"useFormFields"),s=e({client:null}),i=o(()=>n(s),"useClient");export{r as a,m as b,s as c,i as d};
2
+ //# sourceMappingURL=chunk-WRDKLT4N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts"],"sourcesContent":["import { Client } from '@hey-api/client-fetch';\nimport { createContext, useContext } from 'react';\nimport { Components } from './types/remoteFlows';\n\nexport const FormFieldsContext = createContext<{\n components: Components;\n} | null>(null);\n\nexport const useFormFields = () => {\n const context = useContext(FormFieldsContext);\n if (!context?.components) {\n throw new Error('useFormFields must be used within a FormFieldsProvider');\n }\n\n return {\n components: context.components,\n };\n};\n\nexport const RemoteFlowContext = createContext<{ client: Client | null }>({\n client: null,\n});\n\nexport const useClient = () => useContext(RemoteFlowContext);\n"],"mappings":"wCACA,OAAS,iBAAAA,EAAe,cAAAC,MAAkB,QAGnC,IAAMC,EAAoBC,EAEvB,IAAI,EAEDC,EAAgBC,EAAA,IAAM,CACjC,IAAMC,EAAUC,EAAWL,CAAiB,EAC5C,GAAI,CAACI,GAAS,WACZ,MAAM,IAAI,MAAM,wDAAwD,EAG1E,MAAO,CACL,WAAYA,EAAQ,UACtB,CACF,EAT6B,iBAWhBE,EAAoBL,EAAyC,CACxE,OAAQ,IACV,CAAC,EAEYM,EAAYJ,EAAA,IAAME,EAAWC,CAAiB,EAAlC","names":["createContext","useContext","FormFieldsContext","createContext","useFormFields","__name","context","useContext","RemoteFlowContext","useClient"]}