{"version":3,"sources":["../src/components/FormField/index.tsx","../src/components/FormField/FormFieldDescription/index.tsx","../src/components/FormField/FormFieldError/index.tsx","../src/components/FormField/FormFieldLabel/index.tsx"],"names":["React","styles","jsx","FormFieldDescription","className","style","description","descriptionId","useFormFieldContext","clsx_m_default","FormFieldError","error","errorId","FormFieldLabel","id","label","labelId","jsxs","FormField","_id","custom","fill","children","useIdValue","ctxValue","content","FormFieldContext","FormFieldContainer"],"mappings":"yFACA,OAAOA,MAAW,QCIlB,OAAOC,MAAY,sDAaf,cAAAC,MAAA,oBATG,SAASC,EAAqB,CACnC,UAAAC,EACA,MAAAC,CACF,EAAwB,CACtB,GAAM,CAAE,YAAAC,EAAa,cAAAC,CAAc,EAAIC,EAAoB,EAE3D,MAAI,CAACF,GAAe,CAACC,EAAsB,KAGzCL,EAAC,QACC,GAAIK,EACJ,UAAWE,EAAKR,EAAO,MAAUG,CAAS,EAC1C,MAAOC,EAEN,SAAAC,EACH,CAEJ,CCrBA,OAAOL,MAAY,gDAUf,cAAAC,MAAA,oBANG,SAASQ,EAAe,CAAE,UAAAN,EAAW,MAAAC,CAAM,EAAwB,CACxE,GAAM,CAAE,MAAAM,EAAO,QAAAC,CAAQ,EAAIJ,EAAoB,EAE/C,MAAI,CAACG,GAAS,CAACC,EAAgB,KAG7BV,EAAC,QACC,GAAIU,EACJ,UAAWH,EAAKR,EAAO,MAAUG,CAAS,EAC1C,MAAOC,EAEN,SAAAM,EACH,CAEJ,CClBA,OAAOV,MAAY,gDAQf,cAAAC,MAAA,oBAJG,SAASW,EAAe,CAAE,UAAAT,EAAW,MAAAC,CAAM,EAAmB,CACnE,GAAM,CAAE,GAAAS,EAAI,MAAAC,EAAO,QAAAC,CAAQ,EAAIR,EAAoB,EAEnD,OACEN,EAAC,SACC,QAASY,EACT,GAAIE,EACJ,UAAWP,EAAKR,EAAO,MAAUG,CAAS,EAC1C,MAAOC,EAEN,SAAAU,EACH,CAEJ,CHbA,OAAOd,MAAY,iCAoDf,OACc,OAAAC,EADd,QAAAe,MAAA,oBA5BG,IAAMC,EAAa,CAAC,CACzB,MAAAH,EACA,YAAAT,EACA,MAAAK,EAAQ,GACR,GAAIQ,EACJ,OAAAC,EAAS,GACT,KAAAC,EAAO,GACP,SAAAC,EACA,UAAAlB,EACA,MAAAC,CACF,IAAsB,CACpB,IAAMkB,EAAavB,EAAM,MAAM,EACzBc,EAAKK,GAAOI,EACZP,EAAU,GAAGF,WACbP,EAAgBD,EAAc,GAAGQ,iBAAoB,OACrDF,EAAU,OAAOD,GAAU,SAAW,GAAGG,WAAc,OACvDU,EAAW,CACf,GAAAV,EACA,MAAAC,EACA,QAAAC,EACA,YAAAV,EACA,cAAAC,EACA,MAAAI,EACA,QAAAC,EACA,QAAS,CAAC,CAACD,CACb,EAEMc,EACJR,EAACS,EAAiB,SAAjB,CAA0B,MAAOF,EAC/B,WAACJ,GAAUlB,EAACW,EAAA,EAAe,EAC3B,CAACO,GAAUlB,EAACC,EAAA,EAAqB,EACjC,OAAOmB,GAAa,WAAaA,EAASE,CAAQ,EAAIF,EACtD,CAACF,GAAUlB,EAACQ,EAAA,EAAe,GAC9B,EAGF,OAAOU,EACLK,EAEAvB,EAACyB,EAAA,CAAmB,KAAMN,EAAM,UAAWjB,EAAW,MAAOC,EAC1D,SAAAoB,EACH,CAEJ,EAEA,SAASE,EAAmB,CAC1B,KAAAN,EACA,SAAAC,EACA,UAAAlB,EACA,MAAAC,CACF,EAGe,CACb,OACEH,EAAC,OACC,UAAWO,EAAKR,EAAO,MAAOoB,GAAQpB,EAAO,aAAa,EAAGG,CAAS,EACtE,MAAOC,EAEN,SAAAiB,EACH,CAEJ,CAEAJ,EAAU,UAAYS,EACtBT,EAAU,MAAQL,EAClBK,EAAU,YAAcf,EACxBe,EAAU,MAAQR","sourcesContent":["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 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"]}