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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 1× 9× 1× 1× 1× 1× 2× 5× 3× 2× 2× 1× 1× 1× 1× 2× 2× 1× 1× 1× 1× 1× 3× 3× 4× 1× 3× 3× 3× 3× 1× 1× 1× 1× 1× | 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { Eif (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames3 = require('classnames'); var _classnames4 = _interopRequireDefault(_classnames3); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); Iif (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _defineProperty(obj, key, value) { Iif (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { Iif (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } var CheckBox = function (_React$Component) { _inherits(CheckBox, _React$Component); function CheckBox() { _classCallCheck(this, CheckBox); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } CheckBox.prototype.getValue = function getValue() { return this.checkbox.checked; }; CheckBox.prototype.handleChange = function handleChange(e) { this.props.onChange(e); }; CheckBox.prototype.handleClick = function handleClick() { // simulate checkbox this.props.onChange({ target: { checked: true } }); }; CheckBox.prototype.renderHalfChecked = function renderHalfChecked() { return _react2['default'].createElement( 'span', { className: (0, _classnames4['default'])(_defineProperty({}, this.props.className, !!this.props.className)), onClick: this.handleClick.bind(this) }, _react2['default'].createElement('i', { className: (0, _classnames4['default'])({ 'half-checked': true }) }), this.props.children ); }; CheckBox.prototype.renderCheckBox = function renderCheckBox(renderProps) { var _this2 = this; return _react2['default'].createElement( 'label', { className: (0, _classnames4['default'])(_defineProperty({}, this.props.className, !!this.props.className)) }, _react2['default'].createElement('input', _extends({ type: 'checkbox', ref: function ref(c) { _this2.checkbox = c; } }, renderProps)), _react2['default'].createElement('s', null), this.props.children ); }; CheckBox.prototype.render = function render() { var props = this.props; Iif (props.halfChecked) { return this.renderHalfChecked(); } var renderProps = { className: 'kuma-checkbox', checked: this.props.checked, onChange: this.handleChange.bind(this) }; return this.renderCheckBox(renderProps); }; return CheckBox; }(_react2['default'].Component); CheckBox.propTypes = { onChange: _react2['default'].PropTypes.func, checked: _react2['default'].PropTypes.bool, className: _react2['default'].PropTypes.string, children: _react2['default'].PropTypes.any }; CheckBox.defaultProps = { onChange: function onChange() {} }; exports['default'] = CheckBox; module.exports = exports['default']; |