{"version":3,"sources":["../../../../node_modules/.pnpm/clsx@1.2.1/node_modules/clsx/dist/clsx.m.js","../../src/components/Switch/index.tsx","../../src/components/UnstyledInput/index.tsx","../../src/utils/joinLabelIds.ts","../../src/components/Box/index.tsx","../../src/components/FormField/useFormFieldContext.ts","../../src/components/FormField/FormFieldContext.tsx"],"names":["r","t","f","n","clsx","clsx_m_default","forwardRef","React","joinLabelIds","ids","id","jsx","_Box","className","component","style","props","ref","Box","Fragment","FormFieldContext","useFormFieldContext","_UnstyledInput","inputProps","forwardedRef","descriptionId","errorId","isError","UnstyledInput","styles","jsxs","Switch","on","off","size"],"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,ECCjX,OAAS,cAAAE,MAAkB,QCD3B,OAAOC,MAAW,QCAX,SAASC,KAAgBC,EAA6B,CAC3D,OAAOA,EAAI,OAAQC,GAAO,CAAC,CAACA,CAAE,EAAE,KAAK,GAAG,GAAK,MAC/C,CCFA,OAAOH,MAAW,QAgBT,cAAAI,MAAA,oBALF,IAAMC,EAAOL,EAAM,W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ACJ,GAAGZ,EACJ,IAAKC,EACL,UAAWY,EAAO,MAClB,KAAK,SACP,EACAlB,EAAC,OAAI,UAAWkB,EAAO,MAAO,EAC9BlB,EAAC,OAAI,UAAWkB,EAAO,WAAY,EAEnClB,EAAC,OAAI,UAAWkB,EAAO,GAAI,cAAW,GACnC,SAAAG,EACH,EACArB,EAAC,OAAI,UAAWkB,EAAO,IAAK,cAAW,GACpC,SAAAI,EACH,GACF,CAGN,EAEAF,EAAO,YAAc","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 { forwardRef } from \"react\";\n\nimport type { Size } from \"@camome/system\";\n\nimport { UnstyledInput } from \"../UnstyledInput\";\n\nimport styles from \"./styles.module.scss\";\n\nexport type SwitchProps = {\n  on?: React.ReactNode;\n  off?: React.ReactNode;\n  size?: Size;\n} & Omit<JSX.IntrinsicElements[\"input\"], \"size\">;\n\n// Reference: https://www.w3.org/WAI/ARIA/apg/patterns/switch/\nexport const Switch = forwardRef<HTMLInputElement, SwitchProps>(\n  ({ on, off, size = \"md\", style, className, ...props }, ref) => {\n    return (\n      <span\n        className={clsx(styles.Block, styles[`--${size}`], className)}\n        style={style}\n      >\n        <UnstyledInput\n          type=\"checkbox\"\n          {...props}\n          ref={ref}\n          className={styles.input}\n          role=\"switch\"\n        />\n        <div className={styles.label} />\n        <div className={styles.background} />\n        {/* aria-hidden: https://www.w3.org/WAI/ARIA/apg/example-index/switch/switch-checkbox.html#:~:text=NOTE%3A%20To%20prevent%20redundant%20announcement%20of%20the%20state%20by%20screen%20readers%2C%20the%20text%20indicators%20of%20state%20are%20hidden%20from%20assistive%20technologies%20with%20aria%2Dhidden. */}\n        <div className={styles.on} aria-hidden>\n          {on}\n        </div>\n        <div className={styles.off} aria-hidden>\n          {off}\n        </div>\n      </span>\n    );\n  }\n);\n\nSwitch.displayName = \"Switch\";\n","import React from \"react\";\n\nimport { BaseProps, PolymorphicProps } from \"../../types\";\nimport { createPolymorphicComponent } from \"../../utils/createPolymorphicComponent\";\nimport { joinLabelIds } from \"../../utils/joinLabelIds\";\nimport { Box } from \"../Box\";\nimport { useFormFieldContext } from \"../FormField/useFormFieldContext\";\n\nconst _UnstyledInput = React.forwardRef<\n  HTMLInputElement,\n  BaseProps & PolymorphicProps\n>(({ component = \"input\", ...inputProps }, forwardedRef) => {\n  const { id, descriptionId, errorId, isError } = useFormFieldContext();\n  return (\n    <Box\n      component={component}\n      id={id}\n      aria-describedby={joinLabelIds(descriptionId, errorId)}\n      aria-invalid={isError}\n      ref={forwardedRef}\n      {...inputProps}\n    />\n  );\n});\n\n_UnstyledInput.displayName = \"Input\";\n\nexport const UnstyledInput = createPolymorphicComponent<\"input\", BaseProps>(\n  _UnstyledInput\n);\n","export function joinLabelIds(...ids: (string | undefined)[]) {\n  return ids.filter((id) => !!id).join(\" \") || undefined;\n}\n","import React from \"react\";\n\nimport { PolymorphicProps } from \"../../types\";\nimport { createPolymorphicComponent } from \"../../utils/createPolymorphicComponent\";\n\nexport type BoxProps = {\n  className?: string;\n  children?: React.ReactNode;\n  style?: React.CSSProperties;\n};\n\nexport const _Box = React.forwardRef<\n  HTMLDivElement,\n  BoxProps & PolymorphicProps\n>(({ className, component, style, ...props }, ref) => {\n  const Element = component || \"div\";\n  return <Element ref={ref} className={className} style={style} {...props} />;\n});\n\n_Box.displayName = \"Box\";\n\nexport const Box = createPolymorphicComponent<\"div\", BoxProps>(_Box);\n","import React from \"react\";\n\nimport { FormFieldContext } from \"./FormFieldContext\";\n\nexport function useFormFieldContext() {\n  return React.useContext(FormFieldContext);\n}\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"]}