import React from 'react'; import Toggle from 'react-toggle'; import { defineMessages, injectIntl } from 'react-intl'; import Settings from '/imports/ui/services/settings'; import Styled from './styles'; const intlMessages = defineMessages({ on: { id: 'app.switch.onLabel', description: 'label for toggle switch on state', }, off: { id: 'app.switch.offLabel', description: 'label for toggle switch off state', }, }); const defaultProps = { showToggleLabel: true, invertColors: false, }; class Switch extends Toggle { render() { const { intl, icons: _icons, ariaLabelledBy, ariaDescribedBy, ariaLabel, ariaDesc, showToggleLabel, invertColors, disabled, ...inputProps } = this.props; const { animations } = Settings.application; const { checked, hasFocus, } = this.state; return ( { this.input = ref; }} onFocus={this.handleFocus} onBlur={this.handleBlur} type="checkbox" tabIndex="0" disabled={disabled} aria-label={ariaLabel} aria-describedby={ariaDescribedBy} /> ); } } Switch.defaultProps = defaultProps; export default injectIntl(Switch);