@daoyi/nmtl-ui 2.0.1-beta.7 → 2.0.1-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Autocomplete-e62927dc.js +334 -0
- package/lib/components/Autocomplete.js +13 -1
- package/lib/components/Avatar.js +53 -1
- package/lib/components/BackTop.js +109 -1
- package/lib/components/BarChart.js +762 -1
- package/lib/components/Breadcrumbs.js +122 -1
- package/lib/components/Button-4fddcd2f.js +92 -0
- package/lib/components/Button.js +6 -1
- package/lib/components/Carousel.js +4654 -1
- package/lib/components/Checkbox.js +37 -1
- package/lib/components/CollapseContent.js +179 -1
- package/lib/components/ContactModal-33f4e605.js +12020 -0
- package/lib/components/ContactModal.js +22 -3
- package/lib/components/Drawer-fb5bc1ec.js +157 -0
- package/lib/components/Drawer.js +11 -1
- package/lib/components/Dropdown.js +134 -1
- package/lib/components/Empty-e50b760e.js +45 -0
- package/lib/components/Empty.js +5 -1
- package/lib/components/ExportButton.js +112 -1
- package/lib/components/ExtraTools-a49a1d2f.js +3537 -0
- package/lib/components/ExtraTools.js +10 -22
- package/lib/components/Filter.js +782 -12
- package/lib/components/Footer.js +271 -1
- package/lib/components/ForwardLink-6a82c19d.js +106 -0
- package/lib/components/ForwardLink.js +8 -0
- package/lib/components/Header.js +187 -1
- package/lib/components/Image.js +61 -1
- package/lib/components/Input.js +82 -1
- package/lib/components/InputMethod.js +33949 -12
- package/lib/components/KeywordSearch-3af0c402.js +140 -0
- package/lib/components/KeywordSearch.js +15 -1
- package/lib/components/KeywordTicker.js +190 -1
- package/lib/components/Keywords.js +317 -1
- package/lib/components/Loading.js +28 -1
- package/lib/components/MUITheme.js +2624 -1
- package/lib/components/Modal-2c39d5b8.js +108 -0
- package/lib/components/Modal.js +9 -1
- package/lib/components/MoreButton-6b323fe4.js +110 -0
- package/lib/components/MoreButton.js +6 -1
- package/lib/components/Pagination.js +3706 -0
- package/lib/components/Radio.js +78 -1
- package/lib/components/SNA.js +1691 -22
- package/lib/components/Select-0f131640.js +115 -0
- package/lib/components/Select.js +8 -1
- package/lib/components/Spin-1741f625.js +75 -0
- package/lib/components/Spin.js +6 -1
- package/lib/components/Table.js +51 -1
- package/lib/components/Tooltip-65a21a86.js +70 -0
- package/lib/components/Tooltip.js +7 -1
- package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
- package/lib/components/_rollupPluginBabelHelpers-a52356f6.js +142 -0
- package/lib/components/createSvgIcon-d9801fb7.js +576 -0
- package/lib/components/dataExport-d55d6fa3.js +92 -0
- package/lib/components/debounce-127da66c.js +355 -0
- package/lib/components/defaultTheme-5839b9b3.js +1505 -0
- package/lib/components/globalConfig.js +175 -0
- package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
- package/lib/components/index-0be0afec.js +481 -0
- package/lib/components/index-ef96775f.js +61 -0
- package/lib/components/isObjectLike-e111475d.js +190 -0
- package/lib/components/style-inject.es-1f59c1d0.js +28 -1
- package/lib/components/transform-3a04288b.js +5475 -0
- package/lib/components/withTheme-4417822c.js +6 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/utils/_rollupPluginBabelHelpers-8dd26e1a.js +121 -0
- package/lib/utils/arrayMerge.js +4953 -1
- package/lib/utils/chunkArray.js +15 -1
- package/lib/utils/convert2HtmlEntities.js +42 -1
- package/lib/utils/domToImage.js +802 -1
- package/lib/utils/downloadGephi.js +106 -1
- package/lib/utils/exportXlsx.js +219 -1
- package/lib/utils/historyAppendSearch.js +502 -1
- package/lib/utils/isDevelopMode.js +5 -1
- package/lib/utils/parseYMD.js +36 -1
- package/lib/utils/removeDuplicateItem.js +11 -1
- package/lib/utils/sendEmail.js +39 -1
- package/lib/utils/snaDefine-6a2bcd94.js +5 -0
- package/lib/utils/snaDefine.js +1 -1
- package/lib/utils/snaPreProcess.js +84 -1
- package/package.json +17 -21
- package/lib/components/Empty-54b79907.js +0 -1
- package/lib/components/KeywordSearch-5a393f12.js +0 -1
- package/lib/components/Select-f2441b83.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-1b8c042f.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-ec4e2a53.js +0 -1
- package/lib/components/createSvgIcon-62b64929.js +0 -1
- package/lib/components/createSvgIcon-e24792d4.js +0 -1
- package/lib/components/createTheme-7fffa109.js +0 -1
- package/lib/components/dataExport-9fccd4f0.js +0 -1
- package/lib/components/debounce-c993109b.js +0 -1
- package/lib/components/hoist-non-react-statics.cjs-d6a9befd.js +0 -1
- package/lib/components/index-11391ca3.js +0 -7
- package/lib/components/index-b2745105.js +0 -7
- package/lib/components/isObjectLike-2f1983fe.js +0 -1
- package/lib/components/style-inject.es-c875d022.js +0 -1
- package/lib/components/transform-0eb2d36e.js +0 -1
- package/lib/utils/_commonjsHelpers-e2cda605.js +0 -1
- package/lib/utils/_rollupPluginBabelHelpers-928a52ce.js +0 -1
|
@@ -0,0 +1,1505 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import 'react-is';
|
|
3
|
+
|
|
4
|
+
function chainPropTypes(propType1, propType2) {
|
|
5
|
+
{
|
|
6
|
+
return function () {
|
|
7
|
+
return null;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _extends() {
|
|
13
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
14
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15
|
+
var source = arguments[i];
|
|
16
|
+
for (var key in source) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
return _extends.apply(this, arguments);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _typeof(obj) {
|
|
28
|
+
"@babel/helpers - typeof";
|
|
29
|
+
|
|
30
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
31
|
+
return typeof obj;
|
|
32
|
+
} : function (obj) {
|
|
33
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
34
|
+
}, _typeof(obj);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isPlainObject(item) {
|
|
38
|
+
return item && _typeof(item) === 'object' && item.constructor === Object;
|
|
39
|
+
}
|
|
40
|
+
function deepmerge(target, source) {
|
|
41
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
42
|
+
clone: true
|
|
43
|
+
};
|
|
44
|
+
var output = options.clone ? _extends({}, target) : target;
|
|
45
|
+
|
|
46
|
+
if (isPlainObject(target) && isPlainObject(source)) {
|
|
47
|
+
Object.keys(source).forEach(function (key) {
|
|
48
|
+
// Avoid prototype pollution
|
|
49
|
+
if (key === '__proto__') {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (isPlainObject(source[key]) && key in target) {
|
|
54
|
+
output[key] = deepmerge(target[key], source[key], options);
|
|
55
|
+
} else {
|
|
56
|
+
output[key] = source[key];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return output;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var elementAcceptingRef = chainPropTypes(PropTypes.element);
|
|
65
|
+
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired);
|
|
66
|
+
|
|
67
|
+
function _defineProperty(obj, key, value) {
|
|
68
|
+
if (key in obj) {
|
|
69
|
+
Object.defineProperty(obj, key, {
|
|
70
|
+
value: value,
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
obj[key] = value;
|
|
77
|
+
}
|
|
78
|
+
return obj;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* WARNING: Don't import this directly.
|
|
83
|
+
* Use `MuiError` from `@material-ui/utils/macros/MuiError.macro` instead.
|
|
84
|
+
* @param {number} code
|
|
85
|
+
*/
|
|
86
|
+
function formatMuiErrorMessage(code) {
|
|
87
|
+
// Apply babel-plugin-transform-template-literals in loose mode
|
|
88
|
+
// loose mode is safe iff we're concatenating primitives
|
|
89
|
+
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose
|
|
90
|
+
|
|
91
|
+
/* eslint-disable prefer-template */
|
|
92
|
+
var url = 'https://mui.com/production-error/?code=' + code;
|
|
93
|
+
|
|
94
|
+
for (var i = 1; i < arguments.length; i += 1) {
|
|
95
|
+
// rest params over-transpile for this case
|
|
96
|
+
// eslint-disable-next-line prefer-rest-params
|
|
97
|
+
url += '&args[]=' + encodeURIComponent(arguments[i]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return 'Minified Material-UI error #' + code + '; visit ' + url + ' for the full message.';
|
|
101
|
+
/* eslint-enable prefer-template */
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* eslint-disable */
|
|
105
|
+
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
106
|
+
typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
|
|
107
|
+
|
|
108
|
+
PropTypes.oneOfType([PropTypes.func, PropTypes.object]);
|
|
109
|
+
|
|
110
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
111
|
+
if (source == null) return {};
|
|
112
|
+
var target = {};
|
|
113
|
+
var sourceKeys = Object.keys(source);
|
|
114
|
+
var key, i;
|
|
115
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
116
|
+
key = sourceKeys[i];
|
|
117
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
118
|
+
target[key] = source[key];
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function _objectWithoutProperties(source, excluded) {
|
|
124
|
+
if (source == null) return {};
|
|
125
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
126
|
+
var key, i;
|
|
127
|
+
if (Object.getOwnPropertySymbols) {
|
|
128
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
129
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
130
|
+
key = sourceSymbolKeys[i];
|
|
131
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
132
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
133
|
+
target[key] = source[key];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return target;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Sorted ASC by size. That's important.
|
|
140
|
+
// It can't be configured as it's used statically for propTypes.
|
|
141
|
+
var keys = ['xs', 'sm', 'md', 'lg', 'xl']; // Keep in mind that @media is inclusive by the CSS specification.
|
|
142
|
+
|
|
143
|
+
function createBreakpoints(breakpoints) {
|
|
144
|
+
var _breakpoints$values = breakpoints.values,
|
|
145
|
+
values = _breakpoints$values === void 0 ? {
|
|
146
|
+
xs: 0,
|
|
147
|
+
sm: 600,
|
|
148
|
+
md: 960,
|
|
149
|
+
lg: 1280,
|
|
150
|
+
xl: 1920
|
|
151
|
+
} : _breakpoints$values,
|
|
152
|
+
_breakpoints$unit = breakpoints.unit,
|
|
153
|
+
unit = _breakpoints$unit === void 0 ? 'px' : _breakpoints$unit,
|
|
154
|
+
_breakpoints$step = breakpoints.step,
|
|
155
|
+
step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
|
|
156
|
+
other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
|
|
157
|
+
|
|
158
|
+
function up(key) {
|
|
159
|
+
var value = typeof values[key] === 'number' ? values[key] : key;
|
|
160
|
+
return "@media (min-width:".concat(value).concat(unit, ")");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function down(key) {
|
|
164
|
+
var endIndex = keys.indexOf(key) + 1;
|
|
165
|
+
var upperbound = values[keys[endIndex]];
|
|
166
|
+
|
|
167
|
+
if (endIndex === keys.length) {
|
|
168
|
+
// xl down applies to all sizes
|
|
169
|
+
return up('xs');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var value = typeof upperbound === 'number' && endIndex > 0 ? upperbound : key;
|
|
173
|
+
return "@media (max-width:".concat(value - step / 100).concat(unit, ")");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function between(start, end) {
|
|
177
|
+
var endIndex = keys.indexOf(end);
|
|
178
|
+
|
|
179
|
+
if (endIndex === keys.length - 1) {
|
|
180
|
+
return up(start);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return "@media (min-width:".concat(typeof values[start] === 'number' ? values[start] : start).concat(unit, ") and ") + "(max-width:".concat((endIndex !== -1 && typeof values[keys[endIndex + 1]] === 'number' ? values[keys[endIndex + 1]] : end) - step / 100).concat(unit, ")");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function only(key) {
|
|
187
|
+
return between(key, key);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function width(key) {
|
|
191
|
+
|
|
192
|
+
return values[key];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return _extends({
|
|
196
|
+
keys: keys,
|
|
197
|
+
values: values,
|
|
198
|
+
up: up,
|
|
199
|
+
down: down,
|
|
200
|
+
between: between,
|
|
201
|
+
only: only,
|
|
202
|
+
width: width
|
|
203
|
+
}, other);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function createMixins(breakpoints, spacing, mixins) {
|
|
207
|
+
var _toolbar;
|
|
208
|
+
|
|
209
|
+
return _extends({
|
|
210
|
+
gutters: function gutters() {
|
|
211
|
+
var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
212
|
+
console.warn(['Material-UI: theme.mixins.gutters() is deprecated.', 'You can use the source of the mixin directly:', "\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n [theme.breakpoints.up('sm')]: {\n paddingLeft: theme.spacing(3),\n paddingRight: theme.spacing(3),\n },\n "].join('\n'));
|
|
213
|
+
return _extends({
|
|
214
|
+
paddingLeft: spacing(2),
|
|
215
|
+
paddingRight: spacing(2)
|
|
216
|
+
}, styles, _defineProperty({}, breakpoints.up('sm'), _extends({
|
|
217
|
+
paddingLeft: spacing(3),
|
|
218
|
+
paddingRight: spacing(3)
|
|
219
|
+
}, styles[breakpoints.up('sm')])));
|
|
220
|
+
},
|
|
221
|
+
toolbar: (_toolbar = {
|
|
222
|
+
minHeight: 56
|
|
223
|
+
}, _defineProperty(_toolbar, "".concat(breakpoints.up('xs'), " and (orientation: landscape)"), {
|
|
224
|
+
minHeight: 48
|
|
225
|
+
}), _defineProperty(_toolbar, breakpoints.up('sm'), {
|
|
226
|
+
minHeight: 64
|
|
227
|
+
}), _toolbar)
|
|
228
|
+
}, mixins);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
var common = {
|
|
232
|
+
black: '#000',
|
|
233
|
+
white: '#fff'
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
var grey = {
|
|
237
|
+
50: '#fafafa',
|
|
238
|
+
100: '#f5f5f5',
|
|
239
|
+
200: '#eeeeee',
|
|
240
|
+
300: '#e0e0e0',
|
|
241
|
+
400: '#bdbdbd',
|
|
242
|
+
500: '#9e9e9e',
|
|
243
|
+
600: '#757575',
|
|
244
|
+
700: '#616161',
|
|
245
|
+
800: '#424242',
|
|
246
|
+
900: '#212121',
|
|
247
|
+
A100: '#d5d5d5',
|
|
248
|
+
A200: '#aaaaaa',
|
|
249
|
+
A400: '#303030',
|
|
250
|
+
A700: '#616161'
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
var indigo = {
|
|
254
|
+
50: '#e8eaf6',
|
|
255
|
+
100: '#c5cae9',
|
|
256
|
+
200: '#9fa8da',
|
|
257
|
+
300: '#7986cb',
|
|
258
|
+
400: '#5c6bc0',
|
|
259
|
+
500: '#3f51b5',
|
|
260
|
+
600: '#3949ab',
|
|
261
|
+
700: '#303f9f',
|
|
262
|
+
800: '#283593',
|
|
263
|
+
900: '#1a237e',
|
|
264
|
+
A100: '#8c9eff',
|
|
265
|
+
A200: '#536dfe',
|
|
266
|
+
A400: '#3d5afe',
|
|
267
|
+
A700: '#304ffe'
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
var pink = {
|
|
271
|
+
50: '#fce4ec',
|
|
272
|
+
100: '#f8bbd0',
|
|
273
|
+
200: '#f48fb1',
|
|
274
|
+
300: '#f06292',
|
|
275
|
+
400: '#ec407a',
|
|
276
|
+
500: '#e91e63',
|
|
277
|
+
600: '#d81b60',
|
|
278
|
+
700: '#c2185b',
|
|
279
|
+
800: '#ad1457',
|
|
280
|
+
900: '#880e4f',
|
|
281
|
+
A100: '#ff80ab',
|
|
282
|
+
A200: '#ff4081',
|
|
283
|
+
A400: '#f50057',
|
|
284
|
+
A700: '#c51162'
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
var red = {
|
|
288
|
+
50: '#ffebee',
|
|
289
|
+
100: '#ffcdd2',
|
|
290
|
+
200: '#ef9a9a',
|
|
291
|
+
300: '#e57373',
|
|
292
|
+
400: '#ef5350',
|
|
293
|
+
500: '#f44336',
|
|
294
|
+
600: '#e53935',
|
|
295
|
+
700: '#d32f2f',
|
|
296
|
+
800: '#c62828',
|
|
297
|
+
900: '#b71c1c',
|
|
298
|
+
A100: '#ff8a80',
|
|
299
|
+
A200: '#ff5252',
|
|
300
|
+
A400: '#ff1744',
|
|
301
|
+
A700: '#d50000'
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
var orange = {
|
|
305
|
+
50: '#fff3e0',
|
|
306
|
+
100: '#ffe0b2',
|
|
307
|
+
200: '#ffcc80',
|
|
308
|
+
300: '#ffb74d',
|
|
309
|
+
400: '#ffa726',
|
|
310
|
+
500: '#ff9800',
|
|
311
|
+
600: '#fb8c00',
|
|
312
|
+
700: '#f57c00',
|
|
313
|
+
800: '#ef6c00',
|
|
314
|
+
900: '#e65100',
|
|
315
|
+
A100: '#ffd180',
|
|
316
|
+
A200: '#ffab40',
|
|
317
|
+
A400: '#ff9100',
|
|
318
|
+
A700: '#ff6d00'
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
var blue = {
|
|
322
|
+
50: '#e3f2fd',
|
|
323
|
+
100: '#bbdefb',
|
|
324
|
+
200: '#90caf9',
|
|
325
|
+
300: '#64b5f6',
|
|
326
|
+
400: '#42a5f5',
|
|
327
|
+
500: '#2196f3',
|
|
328
|
+
600: '#1e88e5',
|
|
329
|
+
700: '#1976d2',
|
|
330
|
+
800: '#1565c0',
|
|
331
|
+
900: '#0d47a1',
|
|
332
|
+
A100: '#82b1ff',
|
|
333
|
+
A200: '#448aff',
|
|
334
|
+
A400: '#2979ff',
|
|
335
|
+
A700: '#2962ff'
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
var green = {
|
|
339
|
+
50: '#e8f5e9',
|
|
340
|
+
100: '#c8e6c9',
|
|
341
|
+
200: '#a5d6a7',
|
|
342
|
+
300: '#81c784',
|
|
343
|
+
400: '#66bb6a',
|
|
344
|
+
500: '#4caf50',
|
|
345
|
+
600: '#43a047',
|
|
346
|
+
700: '#388e3c',
|
|
347
|
+
800: '#2e7d32',
|
|
348
|
+
900: '#1b5e20',
|
|
349
|
+
A100: '#b9f6ca',
|
|
350
|
+
A200: '#69f0ae',
|
|
351
|
+
A400: '#00e676',
|
|
352
|
+
A700: '#00c853'
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/* eslint-disable no-use-before-define */
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Returns a number whose value is limited to the given range.
|
|
359
|
+
*
|
|
360
|
+
* @param {number} value The value to be clamped
|
|
361
|
+
* @param {number} min The lower boundary of the output range
|
|
362
|
+
* @param {number} max The upper boundary of the output range
|
|
363
|
+
* @returns {number} A number in the range [min, max]
|
|
364
|
+
*/
|
|
365
|
+
function clamp(value) {
|
|
366
|
+
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
367
|
+
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
368
|
+
|
|
369
|
+
return Math.min(Math.max(min, value), max);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Converts a color from CSS hex format to CSS rgb format.
|
|
373
|
+
*
|
|
374
|
+
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
375
|
+
* @returns {string} A CSS rgb color string
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
function hexToRgb(color) {
|
|
380
|
+
color = color.substr(1);
|
|
381
|
+
var re = new RegExp(".{1,".concat(color.length >= 6 ? 2 : 1, "}"), 'g');
|
|
382
|
+
var colors = color.match(re);
|
|
383
|
+
|
|
384
|
+
if (colors && colors[0].length === 1) {
|
|
385
|
+
colors = colors.map(function (n) {
|
|
386
|
+
return n + n;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return colors ? "rgb".concat(colors.length === 4 ? 'a' : '', "(").concat(colors.map(function (n, index) {
|
|
391
|
+
return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
|
|
392
|
+
}).join(', '), ")") : '';
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Converts a color from hsl format to rgb format.
|
|
396
|
+
*
|
|
397
|
+
* @param {string} color - HSL color values
|
|
398
|
+
* @returns {string} rgb color values
|
|
399
|
+
*/
|
|
400
|
+
|
|
401
|
+
function hslToRgb(color) {
|
|
402
|
+
color = decomposeColor(color);
|
|
403
|
+
var _color = color,
|
|
404
|
+
values = _color.values;
|
|
405
|
+
var h = values[0];
|
|
406
|
+
var s = values[1] / 100;
|
|
407
|
+
var l = values[2] / 100;
|
|
408
|
+
var a = s * Math.min(l, 1 - l);
|
|
409
|
+
|
|
410
|
+
var f = function f(n) {
|
|
411
|
+
var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12;
|
|
412
|
+
return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
var type = 'rgb';
|
|
416
|
+
var rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
|
|
417
|
+
|
|
418
|
+
if (color.type === 'hsla') {
|
|
419
|
+
type += 'a';
|
|
420
|
+
rgb.push(values[3]);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return recomposeColor({
|
|
424
|
+
type: type,
|
|
425
|
+
values: rgb
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Returns an object with the type and values of a color.
|
|
430
|
+
*
|
|
431
|
+
* Note: Does not support rgb % values.
|
|
432
|
+
*
|
|
433
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
434
|
+
* @returns {object} - A MUI color object: {type: string, values: number[]}
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
function decomposeColor(color) {
|
|
438
|
+
// Idempotent
|
|
439
|
+
if (color.type) {
|
|
440
|
+
return color;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (color.charAt(0) === '#') {
|
|
444
|
+
return decomposeColor(hexToRgb(color));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
var marker = color.indexOf('(');
|
|
448
|
+
var type = color.substring(0, marker);
|
|
449
|
+
|
|
450
|
+
if (['rgb', 'rgba', 'hsl', 'hsla'].indexOf(type) === -1) {
|
|
451
|
+
throw new Error(formatMuiErrorMessage(3, color));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
var values = color.substring(marker + 1, color.length - 1).split(',');
|
|
455
|
+
values = values.map(function (value) {
|
|
456
|
+
return parseFloat(value);
|
|
457
|
+
});
|
|
458
|
+
return {
|
|
459
|
+
type: type,
|
|
460
|
+
values: values
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Converts a color object with type and values to a string.
|
|
465
|
+
*
|
|
466
|
+
* @param {object} color - Decomposed color
|
|
467
|
+
* @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
|
|
468
|
+
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
469
|
+
* @returns {string} A CSS color string
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
function recomposeColor(color) {
|
|
473
|
+
var type = color.type;
|
|
474
|
+
var values = color.values;
|
|
475
|
+
|
|
476
|
+
if (type.indexOf('rgb') !== -1) {
|
|
477
|
+
// Only convert the first 3 values to int (i.e. not alpha)
|
|
478
|
+
values = values.map(function (n, i) {
|
|
479
|
+
return i < 3 ? parseInt(n, 10) : n;
|
|
480
|
+
});
|
|
481
|
+
} else if (type.indexOf('hsl') !== -1) {
|
|
482
|
+
values[1] = "".concat(values[1], "%");
|
|
483
|
+
values[2] = "".concat(values[2], "%");
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return "".concat(type, "(").concat(values.join(', '), ")");
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Calculates the contrast ratio between two colors.
|
|
490
|
+
*
|
|
491
|
+
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
492
|
+
*
|
|
493
|
+
* @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
494
|
+
* @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
495
|
+
* @returns {number} A contrast ratio value in the range 0 - 21.
|
|
496
|
+
*/
|
|
497
|
+
|
|
498
|
+
function getContrastRatio(foreground, background) {
|
|
499
|
+
var lumA = getLuminance(foreground);
|
|
500
|
+
var lumB = getLuminance(background);
|
|
501
|
+
return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* The relative brightness of any point in a color space,
|
|
505
|
+
* normalized to 0 for darkest black and 1 for lightest white.
|
|
506
|
+
*
|
|
507
|
+
* Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
508
|
+
*
|
|
509
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
510
|
+
* @returns {number} The relative brightness of the color in the range 0 - 1
|
|
511
|
+
*/
|
|
512
|
+
|
|
513
|
+
function getLuminance(color) {
|
|
514
|
+
color = decomposeColor(color);
|
|
515
|
+
var rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
516
|
+
rgb = rgb.map(function (val) {
|
|
517
|
+
val /= 255; // normalized
|
|
518
|
+
|
|
519
|
+
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
|
|
520
|
+
}); // Truncate at 3 digits
|
|
521
|
+
|
|
522
|
+
return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Set the absolute transparency of a color.
|
|
526
|
+
* Any existing alpha value is overwritten.
|
|
527
|
+
*
|
|
528
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
529
|
+
* @param {number} value - value to set the alpha channel to in the range 0-1
|
|
530
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
function alpha(color, value) {
|
|
534
|
+
color = decomposeColor(color);
|
|
535
|
+
value = clamp(value);
|
|
536
|
+
|
|
537
|
+
if (color.type === 'rgb' || color.type === 'hsl') {
|
|
538
|
+
color.type += 'a';
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
color.values[3] = value;
|
|
542
|
+
return recomposeColor(color);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Darkens a color.
|
|
546
|
+
*
|
|
547
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
548
|
+
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
549
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
function darken(color, coefficient) {
|
|
553
|
+
color = decomposeColor(color);
|
|
554
|
+
coefficient = clamp(coefficient);
|
|
555
|
+
|
|
556
|
+
if (color.type.indexOf('hsl') !== -1) {
|
|
557
|
+
color.values[2] *= 1 - coefficient;
|
|
558
|
+
} else if (color.type.indexOf('rgb') !== -1) {
|
|
559
|
+
for (var i = 0; i < 3; i += 1) {
|
|
560
|
+
color.values[i] *= 1 - coefficient;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
return recomposeColor(color);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Lightens a color.
|
|
568
|
+
*
|
|
569
|
+
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
570
|
+
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
571
|
+
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
function lighten(color, coefficient) {
|
|
575
|
+
color = decomposeColor(color);
|
|
576
|
+
coefficient = clamp(coefficient);
|
|
577
|
+
|
|
578
|
+
if (color.type.indexOf('hsl') !== -1) {
|
|
579
|
+
color.values[2] += (100 - color.values[2]) * coefficient;
|
|
580
|
+
} else if (color.type.indexOf('rgb') !== -1) {
|
|
581
|
+
for (var i = 0; i < 3; i += 1) {
|
|
582
|
+
color.values[i] += (255 - color.values[i]) * coefficient;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return recomposeColor(color);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
var light = {
|
|
590
|
+
// The colors used to style the text.
|
|
591
|
+
text: {
|
|
592
|
+
// The most important text.
|
|
593
|
+
primary: 'rgba(0, 0, 0, 0.87)',
|
|
594
|
+
// Secondary text.
|
|
595
|
+
secondary: 'rgba(0, 0, 0, 0.54)',
|
|
596
|
+
// Disabled text have even lower visual prominence.
|
|
597
|
+
disabled: 'rgba(0, 0, 0, 0.38)',
|
|
598
|
+
// Text hints.
|
|
599
|
+
hint: 'rgba(0, 0, 0, 0.38)'
|
|
600
|
+
},
|
|
601
|
+
// The color used to divide different elements.
|
|
602
|
+
divider: 'rgba(0, 0, 0, 0.12)',
|
|
603
|
+
// The background colors used to style the surfaces.
|
|
604
|
+
// Consistency between these values is important.
|
|
605
|
+
background: {
|
|
606
|
+
paper: common.white,
|
|
607
|
+
default: grey[50]
|
|
608
|
+
},
|
|
609
|
+
// The colors used to style the action elements.
|
|
610
|
+
action: {
|
|
611
|
+
// The color of an active action like an icon button.
|
|
612
|
+
active: 'rgba(0, 0, 0, 0.54)',
|
|
613
|
+
// The color of an hovered action.
|
|
614
|
+
hover: 'rgba(0, 0, 0, 0.04)',
|
|
615
|
+
hoverOpacity: 0.04,
|
|
616
|
+
// The color of a selected action.
|
|
617
|
+
selected: 'rgba(0, 0, 0, 0.08)',
|
|
618
|
+
selectedOpacity: 0.08,
|
|
619
|
+
// The color of a disabled action.
|
|
620
|
+
disabled: 'rgba(0, 0, 0, 0.26)',
|
|
621
|
+
// The background color of a disabled action.
|
|
622
|
+
disabledBackground: 'rgba(0, 0, 0, 0.12)',
|
|
623
|
+
disabledOpacity: 0.38,
|
|
624
|
+
focus: 'rgba(0, 0, 0, 0.12)',
|
|
625
|
+
focusOpacity: 0.12,
|
|
626
|
+
activatedOpacity: 0.12
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var dark = {
|
|
630
|
+
text: {
|
|
631
|
+
primary: common.white,
|
|
632
|
+
secondary: 'rgba(255, 255, 255, 0.7)',
|
|
633
|
+
disabled: 'rgba(255, 255, 255, 0.5)',
|
|
634
|
+
hint: 'rgba(255, 255, 255, 0.5)',
|
|
635
|
+
icon: 'rgba(255, 255, 255, 0.5)'
|
|
636
|
+
},
|
|
637
|
+
divider: 'rgba(255, 255, 255, 0.12)',
|
|
638
|
+
background: {
|
|
639
|
+
paper: grey[800],
|
|
640
|
+
default: '#303030'
|
|
641
|
+
},
|
|
642
|
+
action: {
|
|
643
|
+
active: common.white,
|
|
644
|
+
hover: 'rgba(255, 255, 255, 0.08)',
|
|
645
|
+
hoverOpacity: 0.08,
|
|
646
|
+
selected: 'rgba(255, 255, 255, 0.16)',
|
|
647
|
+
selectedOpacity: 0.16,
|
|
648
|
+
disabled: 'rgba(255, 255, 255, 0.3)',
|
|
649
|
+
disabledBackground: 'rgba(255, 255, 255, 0.12)',
|
|
650
|
+
disabledOpacity: 0.38,
|
|
651
|
+
focus: 'rgba(255, 255, 255, 0.12)',
|
|
652
|
+
focusOpacity: 0.12,
|
|
653
|
+
activatedOpacity: 0.24
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
function addLightOrDark(intent, direction, shade, tonalOffset) {
|
|
658
|
+
var tonalOffsetLight = tonalOffset.light || tonalOffset;
|
|
659
|
+
var tonalOffsetDark = tonalOffset.dark || tonalOffset * 1.5;
|
|
660
|
+
|
|
661
|
+
if (!intent[direction]) {
|
|
662
|
+
if (intent.hasOwnProperty(shade)) {
|
|
663
|
+
intent[direction] = intent[shade];
|
|
664
|
+
} else if (direction === 'light') {
|
|
665
|
+
intent.light = lighten(intent.main, tonalOffsetLight);
|
|
666
|
+
} else if (direction === 'dark') {
|
|
667
|
+
intent.dark = darken(intent.main, tonalOffsetDark);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function createPalette(palette) {
|
|
673
|
+
var _palette$primary = palette.primary,
|
|
674
|
+
primary = _palette$primary === void 0 ? {
|
|
675
|
+
light: indigo[300],
|
|
676
|
+
main: indigo[500],
|
|
677
|
+
dark: indigo[700]
|
|
678
|
+
} : _palette$primary,
|
|
679
|
+
_palette$secondary = palette.secondary,
|
|
680
|
+
secondary = _palette$secondary === void 0 ? {
|
|
681
|
+
light: pink.A200,
|
|
682
|
+
main: pink.A400,
|
|
683
|
+
dark: pink.A700
|
|
684
|
+
} : _palette$secondary,
|
|
685
|
+
_palette$error = palette.error,
|
|
686
|
+
error = _palette$error === void 0 ? {
|
|
687
|
+
light: red[300],
|
|
688
|
+
main: red[500],
|
|
689
|
+
dark: red[700]
|
|
690
|
+
} : _palette$error,
|
|
691
|
+
_palette$warning = palette.warning,
|
|
692
|
+
warning = _palette$warning === void 0 ? {
|
|
693
|
+
light: orange[300],
|
|
694
|
+
main: orange[500],
|
|
695
|
+
dark: orange[700]
|
|
696
|
+
} : _palette$warning,
|
|
697
|
+
_palette$info = palette.info,
|
|
698
|
+
info = _palette$info === void 0 ? {
|
|
699
|
+
light: blue[300],
|
|
700
|
+
main: blue[500],
|
|
701
|
+
dark: blue[700]
|
|
702
|
+
} : _palette$info,
|
|
703
|
+
_palette$success = palette.success,
|
|
704
|
+
success = _palette$success === void 0 ? {
|
|
705
|
+
light: green[300],
|
|
706
|
+
main: green[500],
|
|
707
|
+
dark: green[700]
|
|
708
|
+
} : _palette$success,
|
|
709
|
+
_palette$type = palette.type,
|
|
710
|
+
type = _palette$type === void 0 ? 'light' : _palette$type,
|
|
711
|
+
_palette$contrastThre = palette.contrastThreshold,
|
|
712
|
+
contrastThreshold = _palette$contrastThre === void 0 ? 3 : _palette$contrastThre,
|
|
713
|
+
_palette$tonalOffset = palette.tonalOffset,
|
|
714
|
+
tonalOffset = _palette$tonalOffset === void 0 ? 0.2 : _palette$tonalOffset,
|
|
715
|
+
other = _objectWithoutProperties(palette, ["primary", "secondary", "error", "warning", "info", "success", "type", "contrastThreshold", "tonalOffset"]); // Use the same logic as
|
|
716
|
+
// Bootstrap: https://github.com/twbs/bootstrap/blob/1d6e3710dd447de1a200f29e8fa521f8a0908f70/scss/_functions.scss#L59
|
|
717
|
+
// and material-components-web https://github.com/material-components/material-components-web/blob/ac46b8863c4dab9fc22c4c662dc6bd1b65dd652f/packages/mdc-theme/_functions.scss#L54
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
function getContrastText(background) {
|
|
721
|
+
var contrastText = getContrastRatio(background, dark.text.primary) >= contrastThreshold ? dark.text.primary : light.text.primary;
|
|
722
|
+
|
|
723
|
+
return contrastText;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
var augmentColor = function augmentColor(color) {
|
|
727
|
+
var mainShade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
|
728
|
+
var lightShade = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 300;
|
|
729
|
+
var darkShade = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 700;
|
|
730
|
+
color = _extends({}, color);
|
|
731
|
+
|
|
732
|
+
if (!color.main && color[mainShade]) {
|
|
733
|
+
color.main = color[mainShade];
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
if (!color.main) {
|
|
737
|
+
throw new Error(formatMuiErrorMessage(4, mainShade));
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (typeof color.main !== 'string') {
|
|
741
|
+
throw new Error(formatMuiErrorMessage(5, JSON.stringify(color.main)));
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
addLightOrDark(color, 'light', lightShade, tonalOffset);
|
|
745
|
+
addLightOrDark(color, 'dark', darkShade, tonalOffset);
|
|
746
|
+
|
|
747
|
+
if (!color.contrastText) {
|
|
748
|
+
color.contrastText = getContrastText(color.main);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return color;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
var types = {
|
|
755
|
+
dark: dark,
|
|
756
|
+
light: light
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
var paletteOutput = deepmerge(_extends({
|
|
760
|
+
// A collection of common colors.
|
|
761
|
+
common: common,
|
|
762
|
+
// The palette type, can be light or dark.
|
|
763
|
+
type: type,
|
|
764
|
+
// The colors used to represent primary interface elements for a user.
|
|
765
|
+
primary: augmentColor(primary),
|
|
766
|
+
// The colors used to represent secondary interface elements for a user.
|
|
767
|
+
secondary: augmentColor(secondary, 'A400', 'A200', 'A700'),
|
|
768
|
+
// The colors used to represent interface elements that the user should be made aware of.
|
|
769
|
+
error: augmentColor(error),
|
|
770
|
+
// The colors used to represent potentially dangerous actions or important messages.
|
|
771
|
+
warning: augmentColor(warning),
|
|
772
|
+
// The colors used to present information to the user that is neutral and not necessarily important.
|
|
773
|
+
info: augmentColor(info),
|
|
774
|
+
// The colors used to indicate the successful completion of an action that user triggered.
|
|
775
|
+
success: augmentColor(success),
|
|
776
|
+
// The grey colors.
|
|
777
|
+
grey: grey,
|
|
778
|
+
// Used by `getContrastText()` to maximize the contrast between
|
|
779
|
+
// the background and the text.
|
|
780
|
+
contrastThreshold: contrastThreshold,
|
|
781
|
+
// Takes a background color and returns the text color that maximizes the contrast.
|
|
782
|
+
getContrastText: getContrastText,
|
|
783
|
+
// Generate a rich color object.
|
|
784
|
+
augmentColor: augmentColor,
|
|
785
|
+
// Used by the functions below to shift a color's luminance by approximately
|
|
786
|
+
// two indexes within its tonal palette.
|
|
787
|
+
// E.g., shift from Red 500 to Red 300 or Red 700.
|
|
788
|
+
tonalOffset: tonalOffset
|
|
789
|
+
}, types[type]), other);
|
|
790
|
+
return paletteOutput;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function round(value) {
|
|
794
|
+
return Math.round(value * 1e5) / 1e5;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function roundWithDeprecationWarning(value) {
|
|
798
|
+
|
|
799
|
+
return round(value);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
var caseAllCaps = {
|
|
803
|
+
textTransform: 'uppercase'
|
|
804
|
+
};
|
|
805
|
+
var defaultFontFamily = '"Roboto", "Helvetica", "Arial", sans-serif';
|
|
806
|
+
/**
|
|
807
|
+
* @see @link{https://material.io/design/typography/the-type-system.html}
|
|
808
|
+
* @see @link{https://material.io/design/typography/understanding-typography.html}
|
|
809
|
+
*/
|
|
810
|
+
|
|
811
|
+
function createTypography(palette, typography) {
|
|
812
|
+
var _ref = typeof typography === 'function' ? typography(palette) : typography,
|
|
813
|
+
_ref$fontFamily = _ref.fontFamily,
|
|
814
|
+
fontFamily = _ref$fontFamily === void 0 ? defaultFontFamily : _ref$fontFamily,
|
|
815
|
+
_ref$fontSize = _ref.fontSize,
|
|
816
|
+
fontSize = _ref$fontSize === void 0 ? 14 : _ref$fontSize,
|
|
817
|
+
_ref$fontWeightLight = _ref.fontWeightLight,
|
|
818
|
+
fontWeightLight = _ref$fontWeightLight === void 0 ? 300 : _ref$fontWeightLight,
|
|
819
|
+
_ref$fontWeightRegula = _ref.fontWeightRegular,
|
|
820
|
+
fontWeightRegular = _ref$fontWeightRegula === void 0 ? 400 : _ref$fontWeightRegula,
|
|
821
|
+
_ref$fontWeightMedium = _ref.fontWeightMedium,
|
|
822
|
+
fontWeightMedium = _ref$fontWeightMedium === void 0 ? 500 : _ref$fontWeightMedium,
|
|
823
|
+
_ref$fontWeightBold = _ref.fontWeightBold,
|
|
824
|
+
fontWeightBold = _ref$fontWeightBold === void 0 ? 700 : _ref$fontWeightBold,
|
|
825
|
+
_ref$htmlFontSize = _ref.htmlFontSize,
|
|
826
|
+
htmlFontSize = _ref$htmlFontSize === void 0 ? 16 : _ref$htmlFontSize,
|
|
827
|
+
allVariants = _ref.allVariants,
|
|
828
|
+
pxToRem2 = _ref.pxToRem,
|
|
829
|
+
other = _objectWithoutProperties(_ref, ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"]);
|
|
830
|
+
|
|
831
|
+
var coef = fontSize / 14;
|
|
832
|
+
|
|
833
|
+
var pxToRem = pxToRem2 || function (size) {
|
|
834
|
+
return "".concat(size / htmlFontSize * coef, "rem");
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
var buildVariant = function buildVariant(fontWeight, size, lineHeight, letterSpacing, casing) {
|
|
838
|
+
return _extends({
|
|
839
|
+
fontFamily: fontFamily,
|
|
840
|
+
fontWeight: fontWeight,
|
|
841
|
+
fontSize: pxToRem(size),
|
|
842
|
+
// Unitless following https://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/
|
|
843
|
+
lineHeight: lineHeight
|
|
844
|
+
}, fontFamily === defaultFontFamily ? {
|
|
845
|
+
letterSpacing: "".concat(round(letterSpacing / size), "em")
|
|
846
|
+
} : {}, casing, allVariants);
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
var variants = {
|
|
850
|
+
h1: buildVariant(fontWeightLight, 96, 1.167, -1.5),
|
|
851
|
+
h2: buildVariant(fontWeightLight, 60, 1.2, -0.5),
|
|
852
|
+
h3: buildVariant(fontWeightRegular, 48, 1.167, 0),
|
|
853
|
+
h4: buildVariant(fontWeightRegular, 34, 1.235, 0.25),
|
|
854
|
+
h5: buildVariant(fontWeightRegular, 24, 1.334, 0),
|
|
855
|
+
h6: buildVariant(fontWeightMedium, 20, 1.6, 0.15),
|
|
856
|
+
subtitle1: buildVariant(fontWeightRegular, 16, 1.75, 0.15),
|
|
857
|
+
subtitle2: buildVariant(fontWeightMedium, 14, 1.57, 0.1),
|
|
858
|
+
body1: buildVariant(fontWeightRegular, 16, 1.5, 0.15),
|
|
859
|
+
body2: buildVariant(fontWeightRegular, 14, 1.43, 0.15),
|
|
860
|
+
button: buildVariant(fontWeightMedium, 14, 1.75, 0.4, caseAllCaps),
|
|
861
|
+
caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
|
|
862
|
+
overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps)
|
|
863
|
+
};
|
|
864
|
+
return deepmerge(_extends({
|
|
865
|
+
htmlFontSize: htmlFontSize,
|
|
866
|
+
pxToRem: pxToRem,
|
|
867
|
+
round: roundWithDeprecationWarning,
|
|
868
|
+
// TODO v5: remove
|
|
869
|
+
fontFamily: fontFamily,
|
|
870
|
+
fontSize: fontSize,
|
|
871
|
+
fontWeightLight: fontWeightLight,
|
|
872
|
+
fontWeightRegular: fontWeightRegular,
|
|
873
|
+
fontWeightMedium: fontWeightMedium,
|
|
874
|
+
fontWeightBold: fontWeightBold
|
|
875
|
+
}, variants), other, {
|
|
876
|
+
clone: false // No need to clone deep
|
|
877
|
+
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
var shadowKeyUmbraOpacity = 0.2;
|
|
882
|
+
var shadowKeyPenumbraOpacity = 0.14;
|
|
883
|
+
var shadowAmbientShadowOpacity = 0.12;
|
|
884
|
+
|
|
885
|
+
function createShadow() {
|
|
886
|
+
return ["".concat(arguments.length <= 0 ? undefined : arguments[0], "px ").concat(arguments.length <= 1 ? undefined : arguments[1], "px ").concat(arguments.length <= 2 ? undefined : arguments[2], "px ").concat(arguments.length <= 3 ? undefined : arguments[3], "px rgba(0,0,0,").concat(shadowKeyUmbraOpacity, ")"), "".concat(arguments.length <= 4 ? undefined : arguments[4], "px ").concat(arguments.length <= 5 ? undefined : arguments[5], "px ").concat(arguments.length <= 6 ? undefined : arguments[6], "px ").concat(arguments.length <= 7 ? undefined : arguments[7], "px rgba(0,0,0,").concat(shadowKeyPenumbraOpacity, ")"), "".concat(arguments.length <= 8 ? undefined : arguments[8], "px ").concat(arguments.length <= 9 ? undefined : arguments[9], "px ").concat(arguments.length <= 10 ? undefined : arguments[10], "px ").concat(arguments.length <= 11 ? undefined : arguments[11], "px rgba(0,0,0,").concat(shadowAmbientShadowOpacity, ")")].join(',');
|
|
887
|
+
} // Values from https://github.com/material-components/material-components-web/blob/be8747f94574669cb5e7add1a7c54fa41a89cec7/packages/mdc-elevation/_variables.scss
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
var shadows = ['none', createShadow(0, 2, 1, -1, 0, 1, 1, 0, 0, 1, 3, 0), createShadow(0, 3, 1, -2, 0, 2, 2, 0, 0, 1, 5, 0), createShadow(0, 3, 3, -2, 0, 3, 4, 0, 0, 1, 8, 0), createShadow(0, 2, 4, -1, 0, 4, 5, 0, 0, 1, 10, 0), createShadow(0, 3, 5, -1, 0, 5, 8, 0, 0, 1, 14, 0), createShadow(0, 3, 5, -1, 0, 6, 10, 0, 0, 1, 18, 0), createShadow(0, 4, 5, -2, 0, 7, 10, 1, 0, 2, 16, 1), createShadow(0, 5, 5, -3, 0, 8, 10, 1, 0, 3, 14, 2), createShadow(0, 5, 6, -3, 0, 9, 12, 1, 0, 3, 16, 2), createShadow(0, 6, 6, -3, 0, 10, 14, 1, 0, 4, 18, 3), createShadow(0, 6, 7, -4, 0, 11, 15, 1, 0, 4, 20, 3), createShadow(0, 7, 8, -4, 0, 12, 17, 2, 0, 5, 22, 4), createShadow(0, 7, 8, -4, 0, 13, 19, 2, 0, 5, 24, 4), createShadow(0, 7, 9, -4, 0, 14, 21, 2, 0, 5, 26, 4), createShadow(0, 8, 9, -5, 0, 15, 22, 2, 0, 6, 28, 5), createShadow(0, 8, 10, -5, 0, 16, 24, 2, 0, 6, 30, 5), createShadow(0, 8, 11, -5, 0, 17, 26, 2, 0, 6, 32, 5), createShadow(0, 9, 11, -5, 0, 18, 28, 2, 0, 7, 34, 6), createShadow(0, 9, 12, -6, 0, 19, 29, 2, 0, 7, 36, 6), createShadow(0, 10, 13, -6, 0, 20, 31, 3, 0, 8, 38, 7), createShadow(0, 10, 13, -6, 0, 21, 33, 3, 0, 8, 40, 7), createShadow(0, 10, 14, -6, 0, 22, 35, 3, 0, 8, 42, 7), createShadow(0, 11, 14, -7, 0, 23, 36, 3, 0, 9, 44, 8), createShadow(0, 11, 15, -7, 0, 24, 38, 3, 0, 9, 46, 8)];
|
|
891
|
+
|
|
892
|
+
var shape = {
|
|
893
|
+
borderRadius: 4
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
function merge(acc, item) {
|
|
897
|
+
if (!item) {
|
|
898
|
+
return acc;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return deepmerge(acc, item, {
|
|
902
|
+
clone: false // No need to clone deep, it's way faster.
|
|
903
|
+
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// For instance with the first breakpoint xs: [xs, sm[.
|
|
908
|
+
|
|
909
|
+
var values = {
|
|
910
|
+
xs: 0,
|
|
911
|
+
sm: 600,
|
|
912
|
+
md: 960,
|
|
913
|
+
lg: 1280,
|
|
914
|
+
xl: 1920
|
|
915
|
+
};
|
|
916
|
+
var defaultBreakpoints = {
|
|
917
|
+
// Sorted ASC by size. That's important.
|
|
918
|
+
// It can't be configured as it's used statically for propTypes.
|
|
919
|
+
keys: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
920
|
+
up: function up(key) {
|
|
921
|
+
return "@media (min-width:".concat(values[key], "px)");
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
function handleBreakpoints(props, propValue, styleFromPropValue) {
|
|
925
|
+
|
|
926
|
+
if (Array.isArray(propValue)) {
|
|
927
|
+
var themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
|
|
928
|
+
return propValue.reduce(function (acc, item, index) {
|
|
929
|
+
acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
|
|
930
|
+
return acc;
|
|
931
|
+
}, {});
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (_typeof(propValue) === 'object') {
|
|
935
|
+
var _themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
|
|
936
|
+
|
|
937
|
+
return Object.keys(propValue).reduce(function (acc, breakpoint) {
|
|
938
|
+
acc[_themeBreakpoints.up(breakpoint)] = styleFromPropValue(propValue[breakpoint]);
|
|
939
|
+
return acc;
|
|
940
|
+
}, {});
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
var output = styleFromPropValue(propValue);
|
|
944
|
+
return output;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function getPath(obj, path) {
|
|
948
|
+
if (!path || typeof path !== 'string') {
|
|
949
|
+
return null;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
return path.split('.').reduce(function (acc, item) {
|
|
953
|
+
return acc && acc[item] ? acc[item] : null;
|
|
954
|
+
}, obj);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function style(options) {
|
|
958
|
+
var prop = options.prop,
|
|
959
|
+
_options$cssProperty = options.cssProperty,
|
|
960
|
+
cssProperty = _options$cssProperty === void 0 ? options.prop : _options$cssProperty,
|
|
961
|
+
themeKey = options.themeKey,
|
|
962
|
+
transform = options.transform;
|
|
963
|
+
|
|
964
|
+
var fn = function fn(props) {
|
|
965
|
+
if (props[prop] == null) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
var propValue = props[prop];
|
|
970
|
+
var theme = props.theme;
|
|
971
|
+
var themeMapping = getPath(theme, themeKey) || {};
|
|
972
|
+
|
|
973
|
+
var styleFromPropValue = function styleFromPropValue(propValueFinal) {
|
|
974
|
+
var value;
|
|
975
|
+
|
|
976
|
+
if (typeof themeMapping === 'function') {
|
|
977
|
+
value = themeMapping(propValueFinal);
|
|
978
|
+
} else if (Array.isArray(themeMapping)) {
|
|
979
|
+
value = themeMapping[propValueFinal] || propValueFinal;
|
|
980
|
+
} else {
|
|
981
|
+
value = getPath(themeMapping, propValueFinal) || propValueFinal;
|
|
982
|
+
|
|
983
|
+
if (transform) {
|
|
984
|
+
value = transform(value);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
if (cssProperty === false) {
|
|
989
|
+
return value;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
return _defineProperty({}, cssProperty, value);
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
return handleBreakpoints(props, propValue, styleFromPropValue);
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
fn.propTypes = {};
|
|
999
|
+
fn.filterProps = [prop];
|
|
1000
|
+
return fn;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
function compose() {
|
|
1004
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1005
|
+
styles[_key] = arguments[_key];
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
var fn = function fn(props) {
|
|
1009
|
+
return styles.reduce(function (acc, style) {
|
|
1010
|
+
var output = style(props);
|
|
1011
|
+
|
|
1012
|
+
if (output) {
|
|
1013
|
+
return merge(acc, output);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return acc;
|
|
1017
|
+
}, {});
|
|
1018
|
+
}; // Alternative approach that doesn't yield any performance gain.
|
|
1019
|
+
// const handlers = styles.reduce((acc, style) => {
|
|
1020
|
+
// style.filterProps.forEach(prop => {
|
|
1021
|
+
// acc[prop] = style;
|
|
1022
|
+
// });
|
|
1023
|
+
// return acc;
|
|
1024
|
+
// }, {});
|
|
1025
|
+
// const fn = props => {
|
|
1026
|
+
// return Object.keys(props).reduce((acc, prop) => {
|
|
1027
|
+
// if (handlers[prop]) {
|
|
1028
|
+
// return merge(acc, handlers[prop](props));
|
|
1029
|
+
// }
|
|
1030
|
+
// return acc;
|
|
1031
|
+
// }, {});
|
|
1032
|
+
// };
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
fn.propTypes = {};
|
|
1036
|
+
fn.filterProps = styles.reduce(function (acc, style) {
|
|
1037
|
+
return acc.concat(style.filterProps);
|
|
1038
|
+
}, []);
|
|
1039
|
+
return fn;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function getBorder(value) {
|
|
1043
|
+
if (typeof value !== 'number') {
|
|
1044
|
+
return value;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
return "".concat(value, "px solid");
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
var border = style({
|
|
1051
|
+
prop: 'border',
|
|
1052
|
+
themeKey: 'borders',
|
|
1053
|
+
transform: getBorder
|
|
1054
|
+
});
|
|
1055
|
+
var borderTop = style({
|
|
1056
|
+
prop: 'borderTop',
|
|
1057
|
+
themeKey: 'borders',
|
|
1058
|
+
transform: getBorder
|
|
1059
|
+
});
|
|
1060
|
+
var borderRight = style({
|
|
1061
|
+
prop: 'borderRight',
|
|
1062
|
+
themeKey: 'borders',
|
|
1063
|
+
transform: getBorder
|
|
1064
|
+
});
|
|
1065
|
+
var borderBottom = style({
|
|
1066
|
+
prop: 'borderBottom',
|
|
1067
|
+
themeKey: 'borders',
|
|
1068
|
+
transform: getBorder
|
|
1069
|
+
});
|
|
1070
|
+
var borderLeft = style({
|
|
1071
|
+
prop: 'borderLeft',
|
|
1072
|
+
themeKey: 'borders',
|
|
1073
|
+
transform: getBorder
|
|
1074
|
+
});
|
|
1075
|
+
var borderColor = style({
|
|
1076
|
+
prop: 'borderColor',
|
|
1077
|
+
themeKey: 'palette'
|
|
1078
|
+
});
|
|
1079
|
+
var borderRadius = style({
|
|
1080
|
+
prop: 'borderRadius',
|
|
1081
|
+
themeKey: 'shape'
|
|
1082
|
+
});
|
|
1083
|
+
compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderRadius);
|
|
1084
|
+
|
|
1085
|
+
var displayPrint = style({
|
|
1086
|
+
prop: 'displayPrint',
|
|
1087
|
+
cssProperty: false,
|
|
1088
|
+
transform: function transform(value) {
|
|
1089
|
+
return {
|
|
1090
|
+
'@media print': {
|
|
1091
|
+
display: value
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
var displayRaw = style({
|
|
1097
|
+
prop: 'display'
|
|
1098
|
+
});
|
|
1099
|
+
var overflow = style({
|
|
1100
|
+
prop: 'overflow'
|
|
1101
|
+
});
|
|
1102
|
+
var textOverflow = style({
|
|
1103
|
+
prop: 'textOverflow'
|
|
1104
|
+
});
|
|
1105
|
+
var visibility = style({
|
|
1106
|
+
prop: 'visibility'
|
|
1107
|
+
});
|
|
1108
|
+
var whiteSpace = style({
|
|
1109
|
+
prop: 'whiteSpace'
|
|
1110
|
+
});
|
|
1111
|
+
compose(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
|
|
1112
|
+
|
|
1113
|
+
var flexBasis = style({
|
|
1114
|
+
prop: 'flexBasis'
|
|
1115
|
+
});
|
|
1116
|
+
var flexDirection = style({
|
|
1117
|
+
prop: 'flexDirection'
|
|
1118
|
+
});
|
|
1119
|
+
var flexWrap = style({
|
|
1120
|
+
prop: 'flexWrap'
|
|
1121
|
+
});
|
|
1122
|
+
var justifyContent = style({
|
|
1123
|
+
prop: 'justifyContent'
|
|
1124
|
+
});
|
|
1125
|
+
var alignItems = style({
|
|
1126
|
+
prop: 'alignItems'
|
|
1127
|
+
});
|
|
1128
|
+
var alignContent = style({
|
|
1129
|
+
prop: 'alignContent'
|
|
1130
|
+
});
|
|
1131
|
+
var order = style({
|
|
1132
|
+
prop: 'order'
|
|
1133
|
+
});
|
|
1134
|
+
var flex = style({
|
|
1135
|
+
prop: 'flex'
|
|
1136
|
+
});
|
|
1137
|
+
var flexGrow = style({
|
|
1138
|
+
prop: 'flexGrow'
|
|
1139
|
+
});
|
|
1140
|
+
var flexShrink = style({
|
|
1141
|
+
prop: 'flexShrink'
|
|
1142
|
+
});
|
|
1143
|
+
var alignSelf = style({
|
|
1144
|
+
prop: 'alignSelf'
|
|
1145
|
+
});
|
|
1146
|
+
var justifyItems = style({
|
|
1147
|
+
prop: 'justifyItems'
|
|
1148
|
+
});
|
|
1149
|
+
var justifySelf = style({
|
|
1150
|
+
prop: 'justifySelf'
|
|
1151
|
+
});
|
|
1152
|
+
compose(flexBasis, flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf, justifyItems, justifySelf);
|
|
1153
|
+
|
|
1154
|
+
var gridGap = style({
|
|
1155
|
+
prop: 'gridGap'
|
|
1156
|
+
});
|
|
1157
|
+
var gridColumnGap = style({
|
|
1158
|
+
prop: 'gridColumnGap'
|
|
1159
|
+
});
|
|
1160
|
+
var gridRowGap = style({
|
|
1161
|
+
prop: 'gridRowGap'
|
|
1162
|
+
});
|
|
1163
|
+
var gridColumn = style({
|
|
1164
|
+
prop: 'gridColumn'
|
|
1165
|
+
});
|
|
1166
|
+
var gridRow = style({
|
|
1167
|
+
prop: 'gridRow'
|
|
1168
|
+
});
|
|
1169
|
+
var gridAutoFlow = style({
|
|
1170
|
+
prop: 'gridAutoFlow'
|
|
1171
|
+
});
|
|
1172
|
+
var gridAutoColumns = style({
|
|
1173
|
+
prop: 'gridAutoColumns'
|
|
1174
|
+
});
|
|
1175
|
+
var gridAutoRows = style({
|
|
1176
|
+
prop: 'gridAutoRows'
|
|
1177
|
+
});
|
|
1178
|
+
var gridTemplateColumns = style({
|
|
1179
|
+
prop: 'gridTemplateColumns'
|
|
1180
|
+
});
|
|
1181
|
+
var gridTemplateRows = style({
|
|
1182
|
+
prop: 'gridTemplateRows'
|
|
1183
|
+
});
|
|
1184
|
+
var gridTemplateAreas = style({
|
|
1185
|
+
prop: 'gridTemplateAreas'
|
|
1186
|
+
});
|
|
1187
|
+
var gridArea = style({
|
|
1188
|
+
prop: 'gridArea'
|
|
1189
|
+
});
|
|
1190
|
+
compose(gridGap, gridColumnGap, gridRowGap, gridColumn, gridRow, gridAutoFlow, gridAutoColumns, gridAutoRows, gridTemplateColumns, gridTemplateRows, gridTemplateAreas, gridArea);
|
|
1191
|
+
|
|
1192
|
+
var color = style({
|
|
1193
|
+
prop: 'color',
|
|
1194
|
+
themeKey: 'palette'
|
|
1195
|
+
});
|
|
1196
|
+
var bgcolor = style({
|
|
1197
|
+
prop: 'bgcolor',
|
|
1198
|
+
cssProperty: 'backgroundColor',
|
|
1199
|
+
themeKey: 'palette'
|
|
1200
|
+
});
|
|
1201
|
+
compose(color, bgcolor);
|
|
1202
|
+
|
|
1203
|
+
var position = style({
|
|
1204
|
+
prop: 'position'
|
|
1205
|
+
});
|
|
1206
|
+
var zIndex$1 = style({
|
|
1207
|
+
prop: 'zIndex',
|
|
1208
|
+
themeKey: 'zIndex'
|
|
1209
|
+
});
|
|
1210
|
+
var top = style({
|
|
1211
|
+
prop: 'top'
|
|
1212
|
+
});
|
|
1213
|
+
var right = style({
|
|
1214
|
+
prop: 'right'
|
|
1215
|
+
});
|
|
1216
|
+
var bottom = style({
|
|
1217
|
+
prop: 'bottom'
|
|
1218
|
+
});
|
|
1219
|
+
var left = style({
|
|
1220
|
+
prop: 'left'
|
|
1221
|
+
});
|
|
1222
|
+
compose(position, zIndex$1, top, right, bottom, left);
|
|
1223
|
+
|
|
1224
|
+
style({
|
|
1225
|
+
prop: 'boxShadow',
|
|
1226
|
+
themeKey: 'shadows'
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
function transform(value) {
|
|
1230
|
+
return value <= 1 ? "".concat(value * 100, "%") : value;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
var width = style({
|
|
1234
|
+
prop: 'width',
|
|
1235
|
+
transform: transform
|
|
1236
|
+
});
|
|
1237
|
+
var maxWidth = style({
|
|
1238
|
+
prop: 'maxWidth',
|
|
1239
|
+
transform: transform
|
|
1240
|
+
});
|
|
1241
|
+
var minWidth = style({
|
|
1242
|
+
prop: 'minWidth',
|
|
1243
|
+
transform: transform
|
|
1244
|
+
});
|
|
1245
|
+
var height = style({
|
|
1246
|
+
prop: 'height',
|
|
1247
|
+
transform: transform
|
|
1248
|
+
});
|
|
1249
|
+
var maxHeight = style({
|
|
1250
|
+
prop: 'maxHeight',
|
|
1251
|
+
transform: transform
|
|
1252
|
+
});
|
|
1253
|
+
var minHeight = style({
|
|
1254
|
+
prop: 'minHeight',
|
|
1255
|
+
transform: transform
|
|
1256
|
+
});
|
|
1257
|
+
style({
|
|
1258
|
+
prop: 'size',
|
|
1259
|
+
cssProperty: 'width',
|
|
1260
|
+
transform: transform
|
|
1261
|
+
});
|
|
1262
|
+
style({
|
|
1263
|
+
prop: 'size',
|
|
1264
|
+
cssProperty: 'height',
|
|
1265
|
+
transform: transform
|
|
1266
|
+
});
|
|
1267
|
+
var boxSizing = style({
|
|
1268
|
+
prop: 'boxSizing'
|
|
1269
|
+
});
|
|
1270
|
+
compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing);
|
|
1271
|
+
|
|
1272
|
+
function createUnarySpacing(theme) {
|
|
1273
|
+
var themeSpacing = theme.spacing || 8;
|
|
1274
|
+
|
|
1275
|
+
if (typeof themeSpacing === 'number') {
|
|
1276
|
+
return function (abs) {
|
|
1277
|
+
|
|
1278
|
+
return themeSpacing * abs;
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (Array.isArray(themeSpacing)) {
|
|
1283
|
+
return function (abs) {
|
|
1284
|
+
|
|
1285
|
+
return themeSpacing[abs];
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
if (typeof themeSpacing === 'function') {
|
|
1290
|
+
return themeSpacing;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
return function () {
|
|
1294
|
+
return undefined;
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
var fontFamily = style({
|
|
1299
|
+
prop: 'fontFamily',
|
|
1300
|
+
themeKey: 'typography'
|
|
1301
|
+
});
|
|
1302
|
+
var fontSize = style({
|
|
1303
|
+
prop: 'fontSize',
|
|
1304
|
+
themeKey: 'typography'
|
|
1305
|
+
});
|
|
1306
|
+
var fontStyle = style({
|
|
1307
|
+
prop: 'fontStyle',
|
|
1308
|
+
themeKey: 'typography'
|
|
1309
|
+
});
|
|
1310
|
+
var fontWeight = style({
|
|
1311
|
+
prop: 'fontWeight',
|
|
1312
|
+
themeKey: 'typography'
|
|
1313
|
+
});
|
|
1314
|
+
var letterSpacing = style({
|
|
1315
|
+
prop: 'letterSpacing'
|
|
1316
|
+
});
|
|
1317
|
+
var lineHeight = style({
|
|
1318
|
+
prop: 'lineHeight'
|
|
1319
|
+
});
|
|
1320
|
+
var textAlign = style({
|
|
1321
|
+
prop: 'textAlign'
|
|
1322
|
+
});
|
|
1323
|
+
compose(fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
|
|
1324
|
+
|
|
1325
|
+
function createSpacing() {
|
|
1326
|
+
var spacingInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
|
|
1327
|
+
|
|
1328
|
+
// Already transformed.
|
|
1329
|
+
if (spacingInput.mui) {
|
|
1330
|
+
return spacingInput;
|
|
1331
|
+
} // Material Design layouts are visually balanced. Most measurements align to an 8dp grid applied, which aligns both spacing and the overall layout.
|
|
1332
|
+
// Smaller components, such as icons and type, can align to a 4dp grid.
|
|
1333
|
+
// https://material.io/design/layout/understanding-layout.html#usage
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
var transform = createUnarySpacing({
|
|
1337
|
+
spacing: spacingInput
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
var spacing = function spacing() {
|
|
1341
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1342
|
+
args[_key] = arguments[_key];
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
if (args.length === 0) {
|
|
1346
|
+
return transform(1);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
if (args.length === 1) {
|
|
1350
|
+
return transform(args[0]);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
return args.map(function (argument) {
|
|
1354
|
+
if (typeof argument === 'string') {
|
|
1355
|
+
return argument;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
var output = transform(argument);
|
|
1359
|
+
return typeof output === 'number' ? "".concat(output, "px") : output;
|
|
1360
|
+
}).join(' ');
|
|
1361
|
+
}; // Backward compatibility, to remove in v5.
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
Object.defineProperty(spacing, 'unit', {
|
|
1365
|
+
get: function get() {
|
|
1366
|
+
|
|
1367
|
+
return spacingInput;
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
spacing.mui = true;
|
|
1371
|
+
return spacing;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// Follow https://material.google.com/motion/duration-easing.html#duration-easing-natural-easing-curves
|
|
1375
|
+
// to learn the context in which each easing should be used.
|
|
1376
|
+
var easing = {
|
|
1377
|
+
// This is the most common easing curve.
|
|
1378
|
+
easeInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
1379
|
+
// Objects enter the screen at full velocity from off-screen and
|
|
1380
|
+
// slowly decelerate to a resting point.
|
|
1381
|
+
easeOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
|
|
1382
|
+
// Objects leave the screen at full velocity. They do not decelerate when off-screen.
|
|
1383
|
+
easeIn: 'cubic-bezier(0.4, 0, 1, 1)',
|
|
1384
|
+
// The sharp curve is used by objects that may return to the screen at any time.
|
|
1385
|
+
sharp: 'cubic-bezier(0.4, 0, 0.6, 1)'
|
|
1386
|
+
}; // Follow https://material.io/guidelines/motion/duration-easing.html#duration-easing-common-durations
|
|
1387
|
+
// to learn when use what timing
|
|
1388
|
+
|
|
1389
|
+
var duration = {
|
|
1390
|
+
shortest: 150,
|
|
1391
|
+
shorter: 200,
|
|
1392
|
+
short: 250,
|
|
1393
|
+
// most basic recommended timing
|
|
1394
|
+
standard: 300,
|
|
1395
|
+
// this is to be used in complex animations
|
|
1396
|
+
complex: 375,
|
|
1397
|
+
// recommended when something is entering screen
|
|
1398
|
+
enteringScreen: 225,
|
|
1399
|
+
// recommended when something is leaving screen
|
|
1400
|
+
leavingScreen: 195
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
function formatMs(milliseconds) {
|
|
1404
|
+
return "".concat(Math.round(milliseconds), "ms");
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* @param {string|Array} props
|
|
1408
|
+
* @param {object} param
|
|
1409
|
+
* @param {string} param.prop
|
|
1410
|
+
* @param {number} param.duration
|
|
1411
|
+
* @param {string} param.easing
|
|
1412
|
+
* @param {number} param.delay
|
|
1413
|
+
*/
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
var transitions = {
|
|
1417
|
+
easing: easing,
|
|
1418
|
+
duration: duration,
|
|
1419
|
+
create: function create() {
|
|
1420
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['all'];
|
|
1421
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1422
|
+
|
|
1423
|
+
var _options$duration = options.duration,
|
|
1424
|
+
durationOption = _options$duration === void 0 ? duration.standard : _options$duration,
|
|
1425
|
+
_options$easing = options.easing,
|
|
1426
|
+
easingOption = _options$easing === void 0 ? easing.easeInOut : _options$easing,
|
|
1427
|
+
_options$delay = options.delay,
|
|
1428
|
+
delay = _options$delay === void 0 ? 0 : _options$delay;
|
|
1429
|
+
_objectWithoutProperties(options, ["duration", "easing", "delay"]);
|
|
1430
|
+
|
|
1431
|
+
return (Array.isArray(props) ? props : [props]).map(function (animatedProp) {
|
|
1432
|
+
return "".concat(animatedProp, " ").concat(typeof durationOption === 'string' ? durationOption : formatMs(durationOption), " ").concat(easingOption, " ").concat(typeof delay === 'string' ? delay : formatMs(delay));
|
|
1433
|
+
}).join(',');
|
|
1434
|
+
},
|
|
1435
|
+
getAutoHeightDuration: function getAutoHeightDuration(height) {
|
|
1436
|
+
if (!height) {
|
|
1437
|
+
return 0;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
var constant = height / 36; // https://www.wolframalpha.com/input/?i=(4+%2B+15+*+(x+%2F+36+)+**+0.25+%2B+(x+%2F+36)+%2F+5)+*+10
|
|
1441
|
+
|
|
1442
|
+
return Math.round((4 + 15 * Math.pow(constant, 0.25) + constant / 5) * 10);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
// We need to centralize the zIndex definitions as they work
|
|
1447
|
+
// like global values in the browser.
|
|
1448
|
+
var zIndex = {
|
|
1449
|
+
mobileStepper: 1000,
|
|
1450
|
+
speedDial: 1050,
|
|
1451
|
+
appBar: 1100,
|
|
1452
|
+
drawer: 1200,
|
|
1453
|
+
modal: 1300,
|
|
1454
|
+
snackbar: 1400,
|
|
1455
|
+
tooltip: 1500
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
function createTheme() {
|
|
1459
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1460
|
+
|
|
1461
|
+
var _options$breakpoints = options.breakpoints,
|
|
1462
|
+
breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints,
|
|
1463
|
+
_options$mixins = options.mixins,
|
|
1464
|
+
mixinsInput = _options$mixins === void 0 ? {} : _options$mixins,
|
|
1465
|
+
_options$palette = options.palette,
|
|
1466
|
+
paletteInput = _options$palette === void 0 ? {} : _options$palette,
|
|
1467
|
+
spacingInput = options.spacing,
|
|
1468
|
+
_options$typography = options.typography,
|
|
1469
|
+
typographyInput = _options$typography === void 0 ? {} : _options$typography,
|
|
1470
|
+
other = _objectWithoutProperties(options, ["breakpoints", "mixins", "palette", "spacing", "typography"]);
|
|
1471
|
+
|
|
1472
|
+
var palette = createPalette(paletteInput);
|
|
1473
|
+
var breakpoints = createBreakpoints(breakpointsInput);
|
|
1474
|
+
var spacing = createSpacing(spacingInput);
|
|
1475
|
+
var muiTheme = deepmerge({
|
|
1476
|
+
breakpoints: breakpoints,
|
|
1477
|
+
direction: 'ltr',
|
|
1478
|
+
mixins: createMixins(breakpoints, spacing, mixinsInput),
|
|
1479
|
+
overrides: {},
|
|
1480
|
+
// Inject custom styles
|
|
1481
|
+
palette: palette,
|
|
1482
|
+
props: {},
|
|
1483
|
+
// Provide default props
|
|
1484
|
+
shadows: shadows,
|
|
1485
|
+
typography: createTypography(palette, typographyInput),
|
|
1486
|
+
spacing: spacing,
|
|
1487
|
+
shape: shape,
|
|
1488
|
+
transitions: transitions,
|
|
1489
|
+
zIndex: zIndex
|
|
1490
|
+
}, other);
|
|
1491
|
+
|
|
1492
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1493
|
+
args[_key - 1] = arguments[_key];
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
muiTheme = args.reduce(function (acc, argument) {
|
|
1497
|
+
return deepmerge(acc, argument);
|
|
1498
|
+
}, muiTheme);
|
|
1499
|
+
|
|
1500
|
+
return muiTheme;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
var defaultTheme = createTheme();
|
|
1504
|
+
|
|
1505
|
+
export { _extends as _, _objectWithoutProperties as a, _objectWithoutPropertiesLoose as b, alpha as c, defaultTheme as d, createTheme as e, formatMuiErrorMessage as f };
|