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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
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 _styles = require("@material-ui/core/styles");
|
23 |
|
24 | var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
|
25 |
|
26 | var _SuccessOutlined = _interopRequireDefault(require("../internal/svg-icons/SuccessOutlined"));
|
27 |
|
28 | var _ReportProblemOutlined = _interopRequireDefault(require("../internal/svg-icons/ReportProblemOutlined"));
|
29 |
|
30 | var _ErrorOutline = _interopRequireDefault(require("../internal/svg-icons/ErrorOutline"));
|
31 |
|
32 | var _InfoOutlined = _interopRequireDefault(require("../internal/svg-icons/InfoOutlined"));
|
33 |
|
34 | var _Close = _interopRequireDefault(require("../internal/svg-icons/Close"));
|
35 |
|
36 | var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
37 |
|
38 | var _utils = require("@material-ui/core/utils");
|
39 |
|
40 | var styles = function styles(theme) {
|
41 | var getColor = theme.palette.type === 'light' ? _styles.darken : _styles.lighten;
|
42 | var getBackgroundColor = theme.palette.type === 'light' ? _styles.lighten : _styles.darken;
|
43 | return {
|
44 |
|
45 | root: (0, _extends2.default)({}, theme.typography.body2, {
|
46 | borderRadius: theme.shape.borderRadius,
|
47 | backgroundColor: 'transparent',
|
48 | display: 'flex',
|
49 | padding: '6px 16px'
|
50 | }),
|
51 |
|
52 |
|
53 | standardSuccess: {
|
54 | color: getColor(theme.palette.success.main, 0.6),
|
55 | backgroundColor: getBackgroundColor(theme.palette.success.main, 0.9),
|
56 | '& $icon': {
|
57 | color: theme.palette.success.main
|
58 | }
|
59 | },
|
60 |
|
61 |
|
62 | standardInfo: {
|
63 | color: getColor(theme.palette.info.main, 0.6),
|
64 | backgroundColor: getBackgroundColor(theme.palette.info.main, 0.9),
|
65 | '& $icon': {
|
66 | color: theme.palette.info.main
|
67 | }
|
68 | },
|
69 |
|
70 |
|
71 | standardWarning: {
|
72 | color: getColor(theme.palette.warning.main, 0.6),
|
73 | backgroundColor: getBackgroundColor(theme.palette.warning.main, 0.9),
|
74 | '& $icon': {
|
75 | color: theme.palette.warning.main
|
76 | }
|
77 | },
|
78 |
|
79 |
|
80 | standardError: {
|
81 | color: getColor(theme.palette.error.main, 0.6),
|
82 | backgroundColor: getBackgroundColor(theme.palette.error.main, 0.9),
|
83 | '& $icon': {
|
84 | color: theme.palette.error.main
|
85 | }
|
86 | },
|
87 |
|
88 |
|
89 | outlinedSuccess: {
|
90 | color: getColor(theme.palette.success.main, 0.6),
|
91 | border: "1px solid ".concat(theme.palette.success.main),
|
92 | '& $icon': {
|
93 | color: theme.palette.success.main
|
94 | }
|
95 | },
|
96 |
|
97 |
|
98 | outlinedInfo: {
|
99 | color: getColor(theme.palette.info.main, 0.6),
|
100 | border: "1px solid ".concat(theme.palette.info.main),
|
101 | '& $icon': {
|
102 | color: theme.palette.info.main
|
103 | }
|
104 | },
|
105 |
|
106 |
|
107 | outlinedWarning: {
|
108 | color: getColor(theme.palette.warning.main, 0.6),
|
109 | border: "1px solid ".concat(theme.palette.warning.main),
|
110 | '& $icon': {
|
111 | color: theme.palette.warning.main
|
112 | }
|
113 | },
|
114 |
|
115 |
|
116 | outlinedError: {
|
117 | color: getColor(theme.palette.error.main, 0.6),
|
118 | border: "1px solid ".concat(theme.palette.error.main),
|
119 | '& $icon': {
|
120 | color: theme.palette.error.main
|
121 | }
|
122 | },
|
123 |
|
124 |
|
125 | filledSuccess: {
|
126 | color: '#fff',
|
127 | fontWeight: theme.typography.fontWeightMedium,
|
128 | backgroundColor: theme.palette.success.main
|
129 | },
|
130 |
|
131 |
|
132 | filledInfo: {
|
133 | color: '#fff',
|
134 | fontWeight: theme.typography.fontWeightMedium,
|
135 | backgroundColor: theme.palette.info.main
|
136 | },
|
137 |
|
138 |
|
139 | filledWarning: {
|
140 | color: '#fff',
|
141 | fontWeight: theme.typography.fontWeightMedium,
|
142 | backgroundColor: theme.palette.warning.main
|
143 | },
|
144 |
|
145 |
|
146 | filledError: {
|
147 | color: '#fff',
|
148 | fontWeight: theme.typography.fontWeightMedium,
|
149 | backgroundColor: theme.palette.error.main
|
150 | },
|
151 |
|
152 |
|
153 | icon: {
|
154 | marginRight: 12,
|
155 | padding: '7px 0',
|
156 | display: 'flex',
|
157 | fontSize: 22,
|
158 | opacity: 0.9
|
159 | },
|
160 |
|
161 |
|
162 | message: {
|
163 | padding: '8px 0'
|
164 | },
|
165 |
|
166 |
|
167 | action: {
|
168 | display: 'flex',
|
169 | alignItems: 'center',
|
170 | marginLeft: 'auto',
|
171 | paddingLeft: 16,
|
172 | marginRight: -8
|
173 | }
|
174 | };
|
175 | };
|
176 |
|
177 | exports.styles = styles;
|
178 | var defaultIconMapping = {
|
179 | success: React.createElement(_SuccessOutlined.default, {
|
180 | fontSize: "inherit"
|
181 | }),
|
182 | warning: React.createElement(_ReportProblemOutlined.default, {
|
183 | fontSize: "inherit"
|
184 | }),
|
185 | error: React.createElement(_ErrorOutline.default, {
|
186 | fontSize: "inherit"
|
187 | }),
|
188 | info: React.createElement(_InfoOutlined.default, {
|
189 | fontSize: "inherit"
|
190 | })
|
191 | };
|
192 |
|
193 | var _ref = React.createElement(_Close.default, {
|
194 | fontSize: "small"
|
195 | });
|
196 |
|
197 | var Alert = React.forwardRef(function Alert(props, ref) {
|
198 | var action = props.action,
|
199 | children = props.children,
|
200 | classes = props.classes,
|
201 | className = props.className,
|
202 | _props$closeText = props.closeText,
|
203 | closeText = _props$closeText === void 0 ? 'Close' : _props$closeText,
|
204 | color = props.color,
|
205 | icon = props.icon,
|
206 | _props$iconMapping = props.iconMapping,
|
207 | iconMapping = _props$iconMapping === void 0 ? defaultIconMapping : _props$iconMapping,
|
208 | onClose = props.onClose,
|
209 | _props$role = props.role,
|
210 | role = _props$role === void 0 ? 'alert' : _props$role,
|
211 | _props$severity = props.severity,
|
212 | severity = _props$severity === void 0 ? 'success' : _props$severity,
|
213 | _props$variant = props.variant,
|
214 | variant = _props$variant === void 0 ? 'standard' : _props$variant,
|
215 | other = (0, _objectWithoutProperties2.default)(props, ["action", "children", "classes", "className", "closeText", "color", "icon", "iconMapping", "onClose", "role", "severity", "variant"]);
|
216 | return React.createElement(_Paper.default, (0, _extends2.default)({
|
217 | role: role,
|
218 | square: true,
|
219 | elevation: 0,
|
220 | className: (0, _clsx.default)(classes.root, classes["".concat(variant).concat((0, _utils.capitalize)(color || severity))], className),
|
221 | ref: ref
|
222 | }, other), icon !== false ? React.createElement("div", {
|
223 | className: classes.icon
|
224 | }, icon || iconMapping[severity] || defaultIconMapping[severity]) : null, React.createElement("div", {
|
225 | className: classes.message
|
226 | }, children), action != null ? React.createElement("div", {
|
227 | className: classes.action
|
228 | }, action) : null, action == null && onClose ? React.createElement("div", {
|
229 | className: classes.action
|
230 | }, React.createElement(_IconButton.default, {
|
231 | size: "small",
|
232 | "aria-label": closeText,
|
233 | title: closeText,
|
234 | color: "inherit",
|
235 | onClick: onClose
|
236 | }, _ref)) : null);
|
237 | });
|
238 | process.env.NODE_ENV !== "production" ? Alert.propTypes = {
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | |
245 |
|
246 |
|
247 | action: _propTypes.default.node,
|
248 |
|
249 | |
250 |
|
251 |
|
252 | children: _propTypes.default.node,
|
253 |
|
254 | |
255 |
|
256 |
|
257 |
|
258 | classes: _propTypes.default.object,
|
259 |
|
260 | |
261 |
|
262 |
|
263 | className: _propTypes.default.string,
|
264 |
|
265 | |
266 |
|
267 |
|
268 |
|
269 |
|
270 | closeText: _propTypes.default.string,
|
271 |
|
272 | |
273 |
|
274 |
|
275 | color: _propTypes.default.oneOf(['error', 'info', 'success', 'warning']),
|
276 |
|
277 | |
278 |
|
279 |
|
280 |
|
281 | icon: _propTypes.default.node,
|
282 |
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 | iconMapping: _propTypes.default.shape({
|
290 | error: _propTypes.default.node,
|
291 | info: _propTypes.default.node,
|
292 | success: _propTypes.default.node,
|
293 | warning: _propTypes.default.node
|
294 | }),
|
295 |
|
296 | |
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | onClose: _propTypes.default.func,
|
303 |
|
304 | |
305 |
|
306 |
|
307 | role: _propTypes.default.string,
|
308 |
|
309 | |
310 |
|
311 |
|
312 | severity: _propTypes.default.oneOf(['error', 'info', 'success', 'warning']),
|
313 |
|
314 | |
315 |
|
316 |
|
317 | variant: _propTypes.default.oneOf(['filled', 'outlined', 'standard'])
|
318 | } : void 0;
|
319 |
|
320 | var _default = (0, _styles.withStyles)(styles, {
|
321 | name: 'MuiAlert'
|
322 | })(Alert);
|
323 |
|
324 | exports.default = _default; |
\ | No newline at end of file |