1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
4 |
|
5 | exports.__esModule = true;
|
6 | exports.default = void 0;
|
7 |
|
8 | var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/extends"));
|
9 |
|
10 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectWithoutPropertiesLoose"));
|
11 |
|
12 | var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inheritsLoose"));
|
13 |
|
14 | var _classnames = _interopRequireDefault(require("classnames"));
|
15 |
|
16 | var _react = _interopRequireDefault(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _warning = _interopRequireDefault(require("warning"));
|
21 |
|
22 | var _bootstrapUtils = require("./utils/bootstrapUtils");
|
23 |
|
24 |
|
25 | var propTypes = {
|
26 | inline: _propTypes.default.bool,
|
27 | disabled: _propTypes.default.bool,
|
28 | title: _propTypes.default.string,
|
29 |
|
30 | |
31 |
|
32 |
|
33 | validationState: _propTypes.default.oneOf(['success', 'warning', 'error', null]),
|
34 |
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | inputRef: _propTypes.default.func
|
43 | };
|
44 | var defaultProps = {
|
45 | inline: false,
|
46 | disabled: false,
|
47 | title: ''
|
48 | };
|
49 |
|
50 | var Checkbox =
|
51 |
|
52 | function (_React$Component) {
|
53 | (0, _inheritsLoose2.default)(Checkbox, _React$Component);
|
54 |
|
55 | function Checkbox() {
|
56 | return _React$Component.apply(this, arguments) || this;
|
57 | }
|
58 |
|
59 | var _proto = Checkbox.prototype;
|
60 |
|
61 | _proto.render = function render() {
|
62 | var _this$props = this.props,
|
63 | inline = _this$props.inline,
|
64 | disabled = _this$props.disabled,
|
65 | validationState = _this$props.validationState,
|
66 | inputRef = _this$props.inputRef,
|
67 | className = _this$props.className,
|
68 | style = _this$props.style,
|
69 | title = _this$props.title,
|
70 | children = _this$props.children,
|
71 | props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["inline", "disabled", "validationState", "inputRef", "className", "style", "title", "children"]);
|
72 |
|
73 | var _splitBsProps = (0, _bootstrapUtils.splitBsProps)(props),
|
74 | bsProps = _splitBsProps[0],
|
75 | elementProps = _splitBsProps[1];
|
76 |
|
77 | var input = _react.default.createElement("input", (0, _extends2.default)({}, elementProps, {
|
78 | ref: inputRef,
|
79 | type: "checkbox",
|
80 | disabled: disabled
|
81 | }));
|
82 |
|
83 | if (inline) {
|
84 | var _classes2;
|
85 |
|
86 | var _classes = (_classes2 = {}, _classes2[(0, _bootstrapUtils.prefix)(bsProps, 'inline')] = true, _classes2.disabled = disabled, _classes2);
|
87 |
|
88 |
|
89 |
|
90 | process.env.NODE_ENV !== "production" ? (0, _warning.default)(!validationState, '`validationState` is ignored on `<Checkbox inline>`. To display ' + 'validation state on an inline checkbox, set `validationState` on a ' + 'parent `<FormGroup>` or other element instead.') : void 0;
|
91 | return _react.default.createElement("label", {
|
92 | className: (0, _classnames.default)(className, _classes),
|
93 | style: style,
|
94 | title: title
|
95 | }, input, children);
|
96 | }
|
97 |
|
98 | var classes = (0, _extends2.default)({}, (0, _bootstrapUtils.getClassSet)(bsProps), {
|
99 | disabled: disabled
|
100 | });
|
101 |
|
102 | if (validationState) {
|
103 | classes["has-" + validationState] = true;
|
104 | }
|
105 |
|
106 | return _react.default.createElement("div", {
|
107 | className: (0, _classnames.default)(className, classes),
|
108 | style: style
|
109 | }, _react.default.createElement("label", {
|
110 | title: title
|
111 | }, input, children));
|
112 | };
|
113 |
|
114 | return Checkbox;
|
115 | }(_react.default.Component);
|
116 |
|
117 | Checkbox.propTypes = propTypes;
|
118 | Checkbox.defaultProps = defaultProps;
|
119 |
|
120 | var _default = (0, _bootstrapUtils.bsClass)('checkbox', Checkbox);
|
121 |
|
122 | exports.default = _default;
|
123 | module.exports = exports["default"]; |
\ | No newline at end of file |