{"version":3,"sources":["../../../../node_modules/.pnpm/clsx@1.2.1/node_modules/clsx/dist/clsx.m.js","../../src/utils/joinLabelIds.ts","../../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","../../src/components/RadioGroup/index.tsx"],"names":["r","t","f","n","clsx","clsx_m_default","joinLabelIds","ids","id","React","Fragment","jsx","FormFieldContext","useFormFieldContext","styles","FormFieldDescription","className","style","description","descriptionId","FormFieldError","error","errorId","FormFieldLabel","label","labelId","jsxs","FormField","_id","custom","fill","children","useIdValue","ctxValue","content","FormFieldContainer","RadioGroup","orientation","props"],"mappings":"AAAA,SAASA,EAAE,EAAE,CAAC,IAAIC,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAO,GAAjB,UAA8B,OAAO,GAAjB,SAAmBA,GAAG,UAAoB,OAAO,GAAjB,SAAmB,GAAG,MAAM,QAAQ,CAAC,EAAE,IAAIF,EAAE,EAAEA,EAAE,EAAE,OAAOA,IAAI,EAAEA,CAAC,IAAIC,EAAEF,EAAE,EAAEC,CAAC,CAAC,KAAKE,IAAIA,GAAG,KAAKA,GAAGD,OAAQ,KAAID,KAAK,EAAE,EAAEA,CAAC,IAAIE,IAAIA,GAAG,KAAKA,GAAGF,GAAG,OAAOE,CAAC,CAAQ,SAASC,GAAM,CAAC,QAAQ,EAAEH,EAAEC,EAAE,EAAEC,EAAE,GAAGD,EAAE,UAAU,SAAS,EAAE,UAAUA,GAAG,KAAKD,EAAED,EAAE,CAAC,KAAKG,IAAIA,GAAG,KAAKA,GAAGF,GAAG,OAAOE,CAAC,CAAC,IAAOE,EAAQD,ECA1W,SAASE,KAAgBC,EAA6B,CAC3D,OAAOA,EAAI,OAAQC,GAAO,CAAC,CAACA,CAAE,EAAE,KAAK,GAAG,GAAK,MAC/C,CCDA,OAAOC,MAA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B,EACA,YAAAN,EACA,MAAAG,EACA,SAAAU,EACA,GAAGO,CACL,EAAoB,CAClB,OACE3B,EAACgB,EAAA,CACC,GAAInB,EACJ,MAAOgB,EACP,YAAaN,EACb,MAAOG,EACP,OAAM,GAEL,UAAC,CAAE,QAAAI,EAAS,cAAAN,EAAe,QAAAG,CAAQ,IAClCI,EAAC,OACC,KAAK,aACL,mBAAkBpB,EAAaa,EAAeG,CAAO,EACrD,kBAAiBG,EACjB,UAAWpB,EACTS,EAAO,MACPuB,IAAgB,YAAcvB,EAAO,KAAKuB,GAAa,CACzD,EACC,GAAGC,EAEJ,UAAA3B,EAACgB,EAAU,MAAV,EAAgB,EACjBhB,EAACgB,EAAU,YAAV,EAAsB,EACvBhB,EAAC,OAAI,UAAWG,EAAO,MAAQ,SAAAiB,EAAS,EACxCpB,EAACgB,EAAU,MAAV,EAAgB,GACnB,EAEJ,CAEJ","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;","export function joinLabelIds(...ids: (string | undefined)[]) {\n  return ids.filter((id) => !!id).join(\" \") || undefined;\n}\n","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","import clsx from \"clsx\";\n\nimport type { Orientation } from \"@camome/system\";\n\nimport { joinLabelIds } from \"../../utils/joinLabelIds\";\nimport { FormField, type FormFieldProps } from \"../FormField\";\n\nimport styles from \"./styles.module.scss\";\n\ntype NativeProps = JSX.IntrinsicElements[\"div\"];\n\nexport type RadioGroupProps = {\n  orientation?: Orientation;\n} & FormFieldProps &\n  NativeProps;\n\nexport function RadioGroup({\n  orientation = \"vertical\",\n  id,\n  label,\n  description,\n  error,\n  children,\n  ...props\n}: RadioGroupProps) {\n  return (\n    <FormField\n      id={id}\n      label={label}\n      description={description}\n      error={error}\n      custom\n    >\n      {({ labelId, descriptionId, errorId }) => (\n        <div\n          role=\"radiogroup\"\n          aria-describedby={joinLabelIds(descriptionId, errorId)}\n          aria-labelledby={labelId}\n          className={clsx(\n            styles.Block,\n            orientation !== \"vertical\" && styles[`--${orientation}`]\n          )}\n          {...props}\n        >\n          <FormField.Label />\n          <FormField.Description />\n          <div className={styles.items}>{children}</div>\n          <FormField.Error />\n        </div>\n      )}\n    </FormField>\n  );\n}\n"]}