1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = exports.styles = void 0;
|
9 |
|
10 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11 |
|
12 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _react = _interopRequireDefault(require("react"));
|
15 |
|
16 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
17 |
|
18 | var _clsx = _interopRequireDefault(require("clsx"));
|
19 |
|
20 | var _utils = require("@material-ui/utils");
|
21 |
|
22 | var _SwitchBase = _interopRequireDefault(require("../internal/SwitchBase"));
|
23 |
|
24 | var _CheckBoxOutlineBlank = _interopRequireDefault(require("../internal/svg-icons/CheckBoxOutlineBlank"));
|
25 |
|
26 | var _CheckBox = _interopRequireDefault(require("../internal/svg-icons/CheckBox"));
|
27 |
|
28 | var _colorManipulator = require("../styles/colorManipulator");
|
29 |
|
30 | var _IndeterminateCheckBox = _interopRequireDefault(require("../internal/svg-icons/IndeterminateCheckBox"));
|
31 |
|
32 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
33 |
|
34 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
35 |
|
36 | var styles = function styles(theme) {
|
37 | return {
|
38 |
|
39 | root: {
|
40 | color: theme.palette.text.secondary
|
41 | },
|
42 |
|
43 |
|
44 | checked: {},
|
45 |
|
46 |
|
47 | disabled: {},
|
48 |
|
49 |
|
50 | indeterminate: {},
|
51 |
|
52 |
|
53 | colorPrimary: {
|
54 | '&$checked': {
|
55 | color: theme.palette.primary.main,
|
56 | '&:hover': {
|
57 | backgroundColor: (0, _colorManipulator.fade)(theme.palette.primary.main, theme.palette.action.hoverOpacity),
|
58 |
|
59 | '@media (hover: none)': {
|
60 | backgroundColor: 'transparent'
|
61 | }
|
62 | }
|
63 | },
|
64 | '&$disabled': {
|
65 | color: theme.palette.action.disabled
|
66 | }
|
67 | },
|
68 |
|
69 |
|
70 | colorSecondary: {
|
71 | '&$checked': {
|
72 | color: theme.palette.secondary.main,
|
73 | '&:hover': {
|
74 | backgroundColor: (0, _colorManipulator.fade)(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
|
75 |
|
76 | '@media (hover: none)': {
|
77 | backgroundColor: 'transparent'
|
78 | }
|
79 | }
|
80 | },
|
81 | '&$disabled': {
|
82 | color: theme.palette.action.disabled
|
83 | }
|
84 | }
|
85 | };
|
86 | };
|
87 |
|
88 | exports.styles = styles;
|
89 |
|
90 | var defaultCheckedIcon = _react.default.createElement(_CheckBox.default, null);
|
91 |
|
92 | var defaultIcon = _react.default.createElement(_CheckBoxOutlineBlank.default, null);
|
93 |
|
94 | var defaultIndeterminateIcon = _react.default.createElement(_IndeterminateCheckBox.default, null);
|
95 |
|
96 | var Checkbox = _react.default.forwardRef(function Checkbox(props, ref) {
|
97 | var _props$checkedIcon = props.checkedIcon,
|
98 | checkedIcon = _props$checkedIcon === void 0 ? defaultCheckedIcon : _props$checkedIcon,
|
99 | classes = props.classes,
|
100 | _props$color = props.color,
|
101 | color = _props$color === void 0 ? 'secondary' : _props$color,
|
102 | _props$disabled = props.disabled,
|
103 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
104 | _props$icon = props.icon,
|
105 | icon = _props$icon === void 0 ? defaultIcon : _props$icon,
|
106 | _props$indeterminate = props.indeterminate,
|
107 | indeterminate = _props$indeterminate === void 0 ? false : _props$indeterminate,
|
108 | _props$indeterminateI = props.indeterminateIcon,
|
109 | indeterminateIcon = _props$indeterminateI === void 0 ? defaultIndeterminateIcon : _props$indeterminateI,
|
110 | inputProps = props.inputProps,
|
111 | _props$size = props.size,
|
112 | size = _props$size === void 0 ? 'medium' : _props$size,
|
113 | other = (0, _objectWithoutProperties2.default)(props, ["checkedIcon", "classes", "color", "disabled", "icon", "indeterminate", "indeterminateIcon", "inputProps", "size"]);
|
114 | return _react.default.createElement(_SwitchBase.default, (0, _extends2.default)({
|
115 | type: "checkbox",
|
116 | classes: {
|
117 | root: (0, _clsx.default)(classes.root, classes["color".concat((0, _capitalize.default)(color))], indeterminate && classes.indeterminate),
|
118 | checked: classes.checked,
|
119 | disabled: classes.disabled
|
120 | },
|
121 | color: color,
|
122 | inputProps: (0, _extends2.default)({
|
123 | 'data-indeterminate': indeterminate
|
124 | }, inputProps),
|
125 | icon: _react.default.cloneElement(indeterminate ? indeterminateIcon : icon, {
|
126 | fontSize: size === 'small' ? 'small' : 'default'
|
127 | }),
|
128 | checkedIcon: _react.default.cloneElement(indeterminate ? indeterminateIcon : checkedIcon, {
|
129 | fontSize: size === 'small' ? 'small' : 'default'
|
130 | }),
|
131 | ref: ref,
|
132 | disabled: disabled
|
133 | }, other));
|
134 | });
|
135 |
|
136 | process.env.NODE_ENV !== "production" ? Checkbox.propTypes = {
|
137 | |
138 |
|
139 |
|
140 | checked: _propTypes.default.bool,
|
141 |
|
142 | |
143 |
|
144 |
|
145 | checkedIcon: _propTypes.default.node,
|
146 |
|
147 | |
148 |
|
149 |
|
150 |
|
151 | classes: _propTypes.default.object.isRequired,
|
152 |
|
153 | |
154 |
|
155 |
|
156 | color: _propTypes.default.oneOf(['primary', 'secondary', 'default']),
|
157 |
|
158 | |
159 |
|
160 |
|
161 | disabled: _propTypes.default.bool,
|
162 |
|
163 | |
164 |
|
165 |
|
166 | disableRipple: _propTypes.default.bool,
|
167 |
|
168 | |
169 |
|
170 |
|
171 | icon: _propTypes.default.node,
|
172 |
|
173 | |
174 |
|
175 |
|
176 | id: _propTypes.default.string,
|
177 |
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | indeterminate: _propTypes.default.bool,
|
185 |
|
186 | |
187 |
|
188 |
|
189 | indeterminateIcon: _propTypes.default.node,
|
190 |
|
191 | |
192 |
|
193 |
|
194 | inputProps: _propTypes.default.object,
|
195 |
|
196 | |
197 |
|
198 |
|
199 | inputRef: _utils.refType,
|
200 |
|
201 | |
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | onChange: _propTypes.default.func,
|
208 |
|
209 | |
210 |
|
211 |
|
212 | required: _propTypes.default.bool,
|
213 |
|
214 | |
215 |
|
216 |
|
217 |
|
218 | size: _propTypes.default.oneOf(['small', 'medium']),
|
219 |
|
220 | |
221 |
|
222 |
|
223 | type: _propTypes.default.string,
|
224 |
|
225 | |
226 |
|
227 |
|
228 | value: _propTypes.default.any
|
229 | } : void 0;
|
230 |
|
231 | var _default = (0, _withStyles.default)(styles, {
|
232 | name: 'MuiCheckbox'
|
233 | })(Checkbox);
|
234 |
|
235 | exports.default = _default; |
\ | No newline at end of file |