{"version":3,"sources":["../../../../node_modules/.pnpm/clsx@1.2.1/node_modules/clsx/dist/clsx.m.js","../../src/components/FormField/index.tsx","../../src/components/FormField/FormFieldContext.tsx","../../src/components/FormField/useFormFieldContext.ts","../../src/components/FormField/FormFieldDescription/index.tsx","../../src/components/FormField/FormFieldError/index.tsx","../../src/components/FormField/FormFieldLabel/index.tsx"],"names":["r","e","t","f","n","clsx","clsx_m_default","React","Fragment","jsx","FormFieldContext","useFormFieldContext","styles","FormFieldDescription","className","style","description","descriptionId","FormFieldError","error","errorId","FormFieldLabel","id","label","labelId","jsxs","FormField","_id","custom","fill","children","useIdValue","ctxValue","content","FormFieldContainer"],"mappings":"AAAA,SAASA,EAAEC,EAAE,CAAC,IAAIC,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAOH,GAAjB,UAA8B,OAAOA,GAAjB,SAAmBG,GAAGH,UAAoB,OAAOA,GAAjB,SAAmB,GAAG,MAAM,QAAQA,CAAC,EAAE,IAAIC,EAAE,EAAEA,EAAED,EAAE,OAAOC,IAAID,EAAEC,CAAC,IAAIC,EAAEH,EAAEC,EAAEC,CAAC,CAAC,KAAKE,IAAIA,GAAG,KAAKA,GAAGD,OAAQ,KAAID,KAAKD,EAAEA,EAAEC,CAAC,IAAIE,IAAIA,GAAG,KAAKA,GAAGF,GAAG,OAAOE,CAAC,CAAQ,SAASC,GAAM,CAAC,QAAQJ,EAAEC,EAAEC,EAAE,EAAEC,EAAE,GAAGD,EAAE,UAAU,SAASF,EAAE,UAAUE,GAAG,KAAKD,EAAEF,EAAEC,CAAC,KAAKG,IAAIA,GAAG,KAAKA,GAAGF,GAAG,OAAOE,CAAC,CAAC,IAAOE,EAAQD,ECCjX,OAAOE,MAAW,QCDlB,OAAOA,MAAW,QAeT,mBAAAC,EAAA,OAAAC,MAAA,oBAFF,IAAMC,EAAmBH,EAAM,cAAqC,CACzE,GAAI,OACJ,MAAOE,EAAAD,EAAA,EAAE,EACT,QAAS,GACT,YAAa,OACb,cAAe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AhB,EACA,MAAAC,CACF,IAAsB,CACpB,IAAMgB,EAAaxB,EAAM,MAAM,EACzBe,EAAKK,GAAOI,EACZP,EAAU,GAAGF,WACbL,EAAgBD,EAAc,GAAGM,iBAAoB,OACrDF,EAAU,OAAOD,GAAU,SAAW,GAAGG,WAAc,OACvDU,EAAW,CACf,GAAAV,EACA,MAAAC,EACA,QAAAC,EACA,YAAAR,EACA,cAAAC,EACA,MAAAE,EACA,QAAAC,EACA,QAAS,CAAC,CAACD,CACb,EAEMc,EACJR,EAACf,EAAiB,SAAjB,CAA0B,MAAOsB,EAC/B,WAACJ,GAAUnB,EAACY,EAAA,EAAe,EAC3B,CAACO,GAAUnB,EAACI,EAAA,EAAqB,EACjC,OAAOiB,GAAa,WAAaA,EAASE,CAAQ,EAAIF,EACtD,CAACF,GAAUnB,EAACS,EAAA,EAAe,GAC9B,EAGF,OAAOU,EACLK,EAEAxB,EAACyB,EAAA,CAAmB,KAAML,EAAM,UAAWf,EAAW,MAAOC,EAC1D,SAAAkB,EACH,CAEJ,EAEA,SAASC,EAAmB,CAC1B,KAAAL,EACA,SAAAC,EACA,UAAAhB,EACA,MAAAC,CACF,EAGe,CACb,OACEN,EAAC,OACC,UAAWH,EAAKM,EAAO,MAAOiB,GAAQjB,EAAO,aAAa,EAAGE,CAAS,EACtE,MAAOC,EAEN,SAAAe,EACH,CAEJ,CAEAJ,EAAU,UAAYQ,EACtBR,EAAU,MAAQL,EAClBK,EAAU,YAAcb,EACxBa,EAAU,MAAQR","sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f);else for(t in e)e[t]&&(n&&(n+=\" \"),n+=t);return n}export function clsx(){for(var e,t,f=0,n=\"\";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import clsx from \"clsx\";\nimport React from \"react\";\n\nimport { BaseProps } from \"src/types\";\n\nimport { FormFieldContext, FormFieldContextValue } from \"./FormFieldContext\";\nimport { FormFieldDescription } from \"./FormFieldDescription\";\nimport { FormFieldError } from \"./FormFieldError\";\nimport { FormFieldLabel } from \"./FormFieldLabel\";\nimport styles from \"./styles.module.scss\";\n\nexport type FormFieldProps = {\n  label: React.ReactNode;\n  description?: React.ReactNode;\n  error?: boolean | string;\n  id?: string;\n  custom?: boolean;\n  fill?: boolean;\n  children:\n    | React.ReactNode\n    | ((props: FormFieldContextValue) => React.ReactNode);\n  // using `& BaseProps` breaks react-docgen somehow\n  className?: string;\n  style?: React.CSSProperties;\n};\n\ntype FormFieldApi = React.FC<FormFieldProps> & {\n  Container: typeof FormFieldContainer;\n  Label: typeof FormFieldLabel;\n  Description: typeof FormFieldDescription;\n  Error: typeof FormFieldError;\n};\n\nexport const FormField = (({\n  label,\n  description,\n  error = false,\n  id: _id,\n  custom = false,\n  fill = false,\n  children,\n  className,\n  style,\n}: FormFieldProps) => {\n  const useIdValue = React.useId();\n  const id = _id || useIdValue;\n  const labelId = `${id}--label`;\n  const descriptionId = description ? `${id}--description` : undefined;\n  const errorId = typeof error === \"string\" ? `${id}--error` : undefined;\n  const ctxValue = {\n    id,\n    label,\n    labelId,\n    description,\n    descriptionId,\n    error,\n    errorId,\n    isError: !!error,\n  };\n\n  const content = (\n    <FormFieldContext.Provider value={ctxValue}>\n      {!custom && <FormFieldLabel />}\n      {!custom && <FormFieldDescription />}\n      {typeof children === \"function\" ? children(ctxValue) : children}\n      {!custom && <FormFieldError />}\n    </FormFieldContext.Provider>\n  );\n\n  return custom ? (\n    content\n  ) : (\n    <FormFieldContainer fill={fill} className={className} style={style}>\n      {content}\n    </FormFieldContainer>\n  );\n}) as FormFieldApi;\n\nfunction FormFieldContainer({\n  fill,\n  children,\n  className,\n  style,\n}: {\n  fill: boolean;\n  children: React.ReactNode;\n} & BaseProps) {\n  return (\n    <div\n      className={clsx(styles.Block, fill && styles[\"Block--fill\"], className)}\n      style={style}\n    >\n      {children}\n    </div>\n  );\n}\n\nFormField.Container = FormFieldContainer;\nFormField.Label = FormFieldLabel;\nFormField.Description = FormFieldDescription;\nFormField.Error = FormFieldError;\n","import React from \"react\";\n\nexport type FormFieldContextValue = {\n  id: string | undefined;\n  label: React.ReactNode;\n  labelId: string;\n  description: React.ReactNode | undefined;\n  descriptionId: string | undefined;\n  error: React.ReactNode | undefined;\n  errorId: string | undefined;\n  isError: boolean;\n};\n\nexport const FormFieldContext = React.createContext<FormFieldContextValue>({\n  id: undefined,\n  label: <></>,\n  labelId: \"\",\n  description: undefined,\n  descriptionId: undefined,\n  error: undefined,\n  errorId: undefined,\n  isError: false,\n});\n","import React from \"react\";\n\nimport { FormFieldContext } from \"./FormFieldContext\";\n\nexport function useFormFieldContext() {\n  return React.useContext(FormFieldContext);\n}\n","import clsx from \"clsx\";\n\nimport { BaseProps } from \"../../../types\";\nimport { useFormFieldContext } from \"../useFormFieldContext\";\n\nimport styles from \"./styles.module.scss\";\n\nexport type FormHelperTextProps = BaseProps;\n\nexport function FormFieldDescription({\n  className,\n  style,\n}: FormHelperTextProps) {\n  const { description, descriptionId } = useFormFieldContext();\n\n  if (!description || !descriptionId) return null;\n\n  return (\n    <span\n      id={descriptionId}\n      className={clsx(styles[\"Block\"], className)}\n      style={style}\n    >\n      {description}\n    </span>\n  );\n}\n","import clsx from \"clsx\";\n\nimport { BaseProps } from \"../../../types\";\nimport { useFormFieldContext } from \"../useFormFieldContext\";\n\nimport styles from \"./styles.module.scss\";\n\nexport type FormHelperTextProps = BaseProps;\n\nexport function FormFieldError({ className, style }: FormHelperTextProps) {\n  const { error, errorId } = useFormFieldContext();\n\n  if (!error || !errorId) return null;\n\n  return (\n    <span\n      id={errorId}\n      className={clsx(styles[\"Block\"], className)}\n      style={style}\n    >\n      {error}\n    </span>\n  );\n}\n","import clsx from \"clsx\";\n\nimport { BaseProps } from \"../../../types\";\nimport { useFormFieldContext } from \"../useFormFieldContext\";\n\nimport styles from \"./styles.module.scss\";\n\nexport type FormLabelProps = BaseProps;\n\nexport function FormFieldLabel({ className, style }: FormLabelProps) {\n  const { id, label, labelId } = useFormFieldContext();\n\n  return (\n    <label\n      htmlFor={id}\n      id={labelId}\n      className={clsx(styles[\"Block\"], className)}\n      style={style}\n    >\n      {label}\n    </label>\n  );\n}\n"]}