UNPKG

ldx-widgets

Version:

widgets

57 lines (51 loc) 1.51 kB
(function() { var CheckboxInput, React, input, label, ref, span; React = require('react'); ref = React.DOM, input = ref.input, label = ref.label, span = ref.span; CheckboxInput = React.createClass({ displayName: 'CheckboxInput', getDefaultProps: function() { return { className: 'checkbox-input', disabled: false }; }, render: function() { var checked, className, disabled, id, inputProps, 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, tabIndex = ref1.tabIndex; inputProps = { key: 'input', ref: 'input', 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) { 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);