UNPKG

ldx-widgets

Version:

widgets

73 lines (65 loc) 2.01 kB
(function() { var CheckboxInput, PropTypes, React, createClass, input, label, ref, span; React = require('react'); createClass = require('create-react-class'); PropTypes = require('prop-types'); ref = React.DOM, input = ref.input, label = ref.label, span = ref.span; CheckboxInput = createClass({ displayName: 'CheckboxInput', propTypes: { name: PropTypes.string, className: PropTypes.string, wrapperLabel: PropTypes.string, disabled: PropTypes.bool, onChange: PropTypes.func, tabIndex: PropTypes.number, id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) }, getDefaultProps: function() { return { className: 'checkbox-input', disabled: false, wrapperLabel: null, name: null }; }, render: function() { var checked, className, disabled, id, inputProps, name, onChange, ref1, tabIndex, wrapperLabel; ref1 = this.props, className = ref1.className, onChange = ref1.onChange, wrapperLabel = ref1.wrapperLabel, checked = ref1.checked, disabled = ref1.disabled, id = ref1.id, name = ref1.name, tabIndex = ref1.tabIndex; inputProps = { key: 'input', ref: 'input', name: name, type: 'checkbox', onChange: onChange, checked: checked, disabled: disabled }; if (tabIndex != null) { inputProps.tabIndex = tabIndex; } if (id != null) { inputProps.id = id; } if (className != null) { inputProps.className = className; } if (wrapperLabel != null) { return label({ className: 'checkbox-input-label', htmlFor: id }, [ input(inputProps), span({ key: 'label' }, wrapperLabel) ]); } else { return input(inputProps); } }, getValue: function() { return this.refs.input.checked; } }); module.exports = CheckboxInput; }).call(this);