UNPKG

2.29 kBJavaScriptView Raw
1import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2import _createClass from 'babel-runtime/helpers/createClass';
3import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4import _inherits from 'babel-runtime/helpers/inherits';
5var __rest = this && this.__rest || function (s, e) {
6 var t = {};
7 for (var p in s) {
8 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
9 }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10 if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
11 }return t;
12};
13import classnames from 'classnames';
14import RcCheckbox from 'rc-checkbox';
15import React from 'react';
16
17var Checkbox = function (_React$Component) {
18 _inherits(Checkbox, _React$Component);
19
20 function Checkbox() {
21 _classCallCheck(this, Checkbox);
22
23 return _possibleConstructorReturn(this, (Checkbox.__proto__ || Object.getPrototypeOf(Checkbox)).apply(this, arguments));
24 }
25
26 _createClass(Checkbox, [{
27 key: 'render',
28 value: function render() {
29 var _a = this.props,
30 className = _a.className,
31 style = _a.style,
32 restProps = __rest(_a, ["className", "style"]);var prefixCls = restProps.prefixCls,
33 children = restProps.children;
34
35 var wrapCls = classnames(prefixCls + '-wrapper', className);
36 // Todo: wait for https://github.com/developit/preact-compat/issues/422, then we can remove class below
37 if ('class' in restProps) {
38 /* tslint:disable:no-string-literal */
39 delete restProps['class'];
40 }
41 var mark = React.createElement(
42 'label',
43 { className: wrapCls, style: style },
44 React.createElement(RcCheckbox, restProps),
45 children
46 );
47 if (this.props.wrapLabel) {
48 return mark;
49 }
50 return React.createElement(RcCheckbox, this.props);
51 }
52 }]);
53
54 return Checkbox;
55}(React.Component);
56
57export default Checkbox;
58
59Checkbox.defaultProps = {
60 prefixCls: 'am-checkbox',
61 wrapLabel: true
62};
\No newline at end of file