UNPKG

@bigfishtv/cockpit

Version:

35 lines (31 loc) 946 B
import PropTypes from 'prop-types' import React, { Component } from 'react' import classNames from 'classnames' export default class Checkbox extends Component { static propTypes = { text: PropTypes.node, value: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]), onChange: PropTypes.func, } static defaultProps = { value: false, onChange: () => console.warn('No onChange provided for Checkbox'), } render() { const { text, value, inline, onChange, readOnly, labelWidth, invalid, formValue, ...props } = this.props return ( <label className={classNames('control checkbox', { 'control-inline': inline, disabled: readOnly })}> <input {...props} type="checkbox" checked={value} disabled={readOnly} onClick={event => onChange(!value)} onChange={() => {}} /> <span className="control-indicator" /> {text && <span className="control-label">{text}</span>} </label> ) } }