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 }
|