All files / components/checkbox index.js

0% Statements 0/37
0% Branches 0/14
0% Functions 0/4
0% Lines 0/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                                               
import React from 'react'
import PropTypes from 'prop-types'
import StyledCheckbox from './styled-checkbox'
 
const CheckBox = ({ name, label, text, disabled, active, onChange, clearable, ...rest }) => (
  <StyledCheckbox clearable={clearable}>
    {label && <div className='Input-label'>{label}</div>}
    <div className='checkbox-items-list'>
      <div className='checkbox-item'>
        <input
          {...rest}
          type='checkbox'
          id={name}
          name={name}
          disabled={disabled}
          defaultChecked={active}
          onChange={onChange}
        />
        <label htmlFor={name}>{text}</label>
      </div>
    </div>
  </StyledCheckbox>
)
 
CheckBox.propTypes = {
  name: PropTypes.string.isRequired,
  label: PropTypes.string,
  text: PropTypes.string.isRequired,
  disabled: PropTypes.bool,
  active: PropTypes.bool,
  onChange: PropTypes.func,
  clearable: PropTypes.bool
}
 
CheckBox.defaultProps = {
  clearable: false
}
 
export { CheckBox }