import React, { InputHTMLAttributes, ReactNode, Ref } from "react"; import "./Switch.css"; import { getClassName, getCN, randomId, renderProps } from "../utils"; import ButtonTouch from "../ButtonTouch/ButtonTouch"; export type ISwitch = { label?: boolean, stopPropagation?: boolean, checked?: boolean, onChange?: InputHTMLAttributes["onChange"], className?: string | undefined, } function Switch({ label, stopPropagation = true, checked, onChange, className, ...props }: { [x: string]: any; }) { const [props_id,] = React.useState(randomId(props.id, `switch`)); const [is_checked, setChecked] = React.useState(checked || false) const handlerChange = (e: React.ChangeEvent) => { setChecked(e.target.checked); if (onChange) onChange(e) } return ( ); } export default Switch;