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