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 _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
23 |
|
24 | var _colorManipulator = require("../styles/colorManipulator");
|
25 |
|
26 | var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
27 |
|
28 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
29 |
|
30 | var styles = function styles(theme) {
|
31 | return {
|
32 |
|
33 | root: {
|
34 | textAlign: 'center',
|
35 | flex: '0 0 auto',
|
36 | fontSize: theme.typography.pxToRem(24),
|
37 | padding: 12,
|
38 | borderRadius: '50%',
|
39 | overflow: 'visible',
|
40 |
|
41 | color: theme.palette.action.active,
|
42 | transition: theme.transitions.create('background-color', {
|
43 | duration: theme.transitions.duration.shortest
|
44 | }),
|
45 | '&:hover': {
|
46 | backgroundColor: (0, _colorManipulator.fade)(theme.palette.action.active, theme.palette.action.hoverOpacity),
|
47 |
|
48 | '@media (hover: none)': {
|
49 | backgroundColor: 'transparent'
|
50 | }
|
51 | },
|
52 | '&$disabled': {
|
53 | backgroundColor: 'transparent',
|
54 | color: theme.palette.action.disabled
|
55 | }
|
56 | },
|
57 |
|
58 |
|
59 | edgeStart: {
|
60 | marginLeft: -12,
|
61 | '$sizeSmall&': {
|
62 | marginLeft: -3
|
63 | }
|
64 | },
|
65 |
|
66 |
|
67 | edgeEnd: {
|
68 | marginRight: -12,
|
69 | '$sizeSmall&': {
|
70 | marginRight: -3
|
71 | }
|
72 | },
|
73 |
|
74 |
|
75 | colorInherit: {
|
76 | color: 'inherit'
|
77 | },
|
78 |
|
79 |
|
80 | colorPrimary: {
|
81 | color: theme.palette.primary.main,
|
82 | '&:hover': {
|
83 | backgroundColor: (0, _colorManipulator.fade)(theme.palette.primary.main, theme.palette.action.hoverOpacity),
|
84 |
|
85 | '@media (hover: none)': {
|
86 | backgroundColor: 'transparent'
|
87 | }
|
88 | }
|
89 | },
|
90 |
|
91 |
|
92 | colorSecondary: {
|
93 | color: theme.palette.secondary.main,
|
94 | '&:hover': {
|
95 | backgroundColor: (0, _colorManipulator.fade)(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
|
96 |
|
97 | '@media (hover: none)': {
|
98 | backgroundColor: 'transparent'
|
99 | }
|
100 | }
|
101 | },
|
102 |
|
103 |
|
104 | disabled: {},
|
105 |
|
106 |
|
107 | sizeSmall: {
|
108 | padding: 3,
|
109 | fontSize: theme.typography.pxToRem(18)
|
110 | },
|
111 |
|
112 |
|
113 | label: {
|
114 | width: '100%',
|
115 | display: 'flex',
|
116 | alignItems: 'inherit',
|
117 | justifyContent: 'inherit'
|
118 | }
|
119 | };
|
120 | };
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | exports.styles = styles;
|
128 |
|
129 | var IconButton = _react.default.forwardRef(function IconButton(props, ref) {
|
130 | var _props$edge = props.edge,
|
131 | edge = _props$edge === void 0 ? false : _props$edge,
|
132 | children = props.children,
|
133 | classes = props.classes,
|
134 | className = props.className,
|
135 | _props$color = props.color,
|
136 | color = _props$color === void 0 ? 'default' : _props$color,
|
137 | _props$disabled = props.disabled,
|
138 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
139 | _props$disableFocusRi = props.disableFocusRipple,
|
140 | disableFocusRipple = _props$disableFocusRi === void 0 ? false : _props$disableFocusRi,
|
141 | _props$size = props.size,
|
142 | size = _props$size === void 0 ? 'medium' : _props$size,
|
143 | other = (0, _objectWithoutProperties2.default)(props, ["edge", "children", "classes", "className", "color", "disabled", "disableFocusRipple", "size"]);
|
144 | return _react.default.createElement(_ButtonBase.default, (0, _extends2.default)({
|
145 | className: (0, _clsx.default)(classes.root, className, color !== 'default' && classes["color".concat((0, _capitalize.default)(color))], disabled && classes.disabled, {
|
146 | small: classes["size".concat((0, _capitalize.default)(size))]
|
147 | }[size], {
|
148 | start: classes.edgeStart,
|
149 | end: classes.edgeEnd
|
150 | }[edge]),
|
151 | centerRipple: true,
|
152 | focusRipple: !disableFocusRipple,
|
153 | disabled: disabled,
|
154 | ref: ref
|
155 | }, other), _react.default.createElement("span", {
|
156 | className: classes.label
|
157 | }, children));
|
158 | });
|
159 |
|
160 | process.env.NODE_ENV !== "production" ? IconButton.propTypes = {
|
161 | |
162 |
|
163 |
|
164 | children: (0, _utils.chainPropTypes)(_propTypes.default.node, function (props) {
|
165 | var found = _react.default.Children.toArray(props.children).some(function (child) {
|
166 | return _react.default.isValidElement(child) && child.props.onClick;
|
167 | });
|
168 |
|
169 | if (found) {
|
170 | return new Error(['Material-UI: you are providing an onClick event listener ' + 'to a child of a button element.', 'Firefox will never trigger the event.', 'You should move the onClick listener to the parent button element.', 'https://github.com/mui-org/material-ui/issues/13957'].join('\n'));
|
171 | }
|
172 |
|
173 | return null;
|
174 | }),
|
175 |
|
176 | |
177 |
|
178 |
|
179 |
|
180 | classes: _propTypes.default.object.isRequired,
|
181 |
|
182 | |
183 |
|
184 |
|
185 | className: _propTypes.default.string,
|
186 |
|
187 | |
188 |
|
189 |
|
190 | color: _propTypes.default.oneOf(['default', 'inherit', 'primary', 'secondary']),
|
191 |
|
192 | |
193 |
|
194 |
|
195 | disabled: _propTypes.default.bool,
|
196 |
|
197 | |
198 |
|
199 |
|
200 |
|
201 | disableFocusRipple: _propTypes.default.bool,
|
202 |
|
203 | |
204 |
|
205 |
|
206 | disableRipple: _propTypes.default.bool,
|
207 |
|
208 | |
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | edge: _propTypes.default.oneOf(['start', 'end', false]),
|
215 |
|
216 | |
217 |
|
218 |
|
219 |
|
220 | size: _propTypes.default.oneOf(['small', 'medium'])
|
221 | } : void 0;
|
222 |
|
223 | var _default = (0, _withStyles.default)(styles, {
|
224 | name: 'MuiIconButton'
|
225 | })(IconButton);
|
226 |
|
227 | exports.default = _default; |
\ | No newline at end of file |