{"version":3,"sources":["../../src/components/Switch/index.tsx"],"names":["forwardRef","styles","jsx","jsxs","Switch","on","off","size","style","className","props","ref","clsx_m_default","UnstyledInput"],"mappings":"8KACA,OAAS,cAAAA,MAAkB,QAM3B,OAAOC,MAAY,uBAYb,OAIE,OAAAC,EAJF,QAAAC,MAAA,oBAHC,IAAMC,EAASJ,EACpB,CAAC,CAAE,GAAAK,EAAI,IAAAC,EAAK,KAAAC,EAAO,KAAM,MAAAC,EAAO,UAAAC,EAAW,GAAGC,CAAM,EAAGC,IAEnDR,EAAC,QACC,UAAWS,EAAKX,EAAO,MAAOA,EAAO,KAAKM,GAAM,EAAGE,CAAS,EAC5D,MAAOD,EAEP,UAAAN,EAACW,EAAA,CACC,KAAK,WACJ,GAAGH,EACJ,IAAKC,EACL,UAAWV,EAAO,MAClB,KAAK,SACP,EACAC,EAAC,OAAI,UAAWD,EAAO,MAAO,EAC9BC,EAAC,OAAI,UAAWD,EAAO,WAAY,EAEnCC,EAAC,OAAI,UAAWD,EAAO,GAAI,cAAW,GACnC,SAAAI,EACH,EACAH,EAAC,OAAI,UAAWD,EAAO,IAAK,cAAW,GACpC,SAAAK,EACH,GACF,CAGN,EAEAF,EAAO,YAAc","sourcesContent":["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"]}