| 1 |
import { arrayToClassName } from 'elementor-app/utils/utils.js'; |
| 2 |
|
| 3 |
import './checkbox.scss'; |
| 4 |
|
| 5 |
export default function Checkbox( { className, checked, rounded, indeterminate, error, disabled, onChange } ) { |
| 6 |
const baseClassName = 'eps-checkbox', |
| 7 |
classes = [ baseClassName, className ]; |
| 8 |
|
| 9 |
if ( rounded ) { |
| 10 |
classes.push( baseClassName + '--rounded' ); |
| 11 |
} |
| 12 |
|
| 13 |
if ( indeterminate ) { |
| 14 |
classes.push( baseClassName + '--indeterminate' ); |
| 15 |
} |
| 16 |
|
| 17 |
if ( error ) { |
| 18 |
classes.push( baseClassName + '--error' ); |
| 19 |
} |
| 20 |
|
| 21 |
return ( |
| 22 |
<input |
| 23 |
className={ arrayToClassName( classes ) } |
| 24 |
type="checkbox" |
| 25 |
checked={ checked } |
| 26 |
disabled={ disabled } |
| 27 |
onChange={ onChange } |
| 28 |
/> |
| 29 |
); |
| 30 |
} |
| 31 |
|
| 32 |
Checkbox.propTypes = { |
| 33 |
className: PropTypes.string, |
| 34 |
checked: PropTypes.bool, |
| 35 |
disabled: PropTypes.bool, |
| 36 |
indeterminate: PropTypes.bool, |
| 37 |
rounded: PropTypes.bool, |
| 38 |
error: PropTypes.bool, |
| 39 |
onChange: PropTypes.func, |
| 40 |
}; |
| 41 |
|
| 42 |
Checkbox.defaultProps = { |
| 43 |
className: '', |
| 44 |
checked: null, |
| 45 |
disabled: false, |
| 46 |
indeterminate: false, |
| 47 |
error: false, |
| 48 |
onChange: () => {}, |
| 49 |
}; |
| 50 |
|