import type { ChangeEvent } from 'react'; import type { FC } from '../../lib/teact/teact'; import React, { memo, useCallback } from '../../lib/teact/teact'; import buildClassName from '../../util/buildClassName'; import './Switcher.scss'; type OwnProps = { id?: string; name?: string; value?: string; label: string; checked?: boolean; disabled?: boolean; inactive?: boolean; noAnimation?: boolean; onChange?: (e: ChangeEvent) => void; onCheck?: (isChecked: boolean) => void; }; const Switcher: FC = ({ id, name, value, label, checked = false, disabled, inactive, noAnimation, onChange, onCheck, }) => { const handleChange = useCallback((e: ChangeEvent) => { if (onChange) { onChange(e); } if (onCheck) { onCheck(e.currentTarget.checked); } }, [onChange, onCheck]); const className = buildClassName( 'Switcher', disabled && 'disabled', inactive && 'inactive', noAnimation && 'no-animation', ); return ( ); }; export default memo(Switcher);