@micromag/core 0.3.307 → 0.3.318
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/assets/css/styles.css +21 -21
- package/assets/css/vendor.css +1 -1
- package/es/components.js +650 -859
- package/es/contexts.js +309 -444
- package/es/hooks.js +437 -694
- package/es/index.js +247 -391
- package/es/utils.js +294 -391
- package/lib/components.js +649 -858
- package/lib/contexts.js +309 -444
- package/lib/hooks.js +437 -694
- package/lib/index.js +247 -391
- package/lib/utils.js +294 -391
- package/package.json +6 -6
package/es/utils.js
CHANGED
|
@@ -23,134 +23,116 @@ var convertStyleToString = function convertStyleToString(style) {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
26
|
+
|
|
26
27
|
// @note vendoring this: https://github.com/feross/clipboard-copy/blob/master/index.js
|
|
27
28
|
// we might want to add that to the npm deps and just use it
|
|
29
|
+
|
|
28
30
|
function makeError() {
|
|
29
31
|
return new DOMException('The request is not allowed', 'NotAllowedError');
|
|
30
32
|
}
|
|
31
|
-
|
|
32
33
|
function copyClipboardApi(_x) {
|
|
33
34
|
return _copyClipboardApi.apply(this, arguments);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
36
|
function _copyClipboardApi() {
|
|
37
37
|
_copyClipboardApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(text) {
|
|
38
38
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
39
|
-
while (1) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
case 3:
|
|
53
|
-
case "end":
|
|
54
|
-
return _context.stop();
|
|
55
|
-
}
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
if (navigator.clipboard) {
|
|
42
|
+
_context.next = 2;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
throw makeError();
|
|
46
|
+
case 2:
|
|
47
|
+
return _context.abrupt("return", navigator.clipboard.writeText(text));
|
|
48
|
+
case 3:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
56
51
|
}
|
|
57
52
|
}, _callee);
|
|
58
53
|
}));
|
|
59
54
|
return _copyClipboardApi.apply(this, arguments);
|
|
60
55
|
}
|
|
61
|
-
|
|
62
56
|
function copyExecCommand(_x2) {
|
|
63
57
|
return _copyExecCommand.apply(this, arguments);
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
function _copyExecCommand() {
|
|
67
60
|
_copyExecCommand = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(text) {
|
|
68
61
|
var span, selection, range, success;
|
|
69
62
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
70
|
-
while (1) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
// Put the text to copy into a <span>
|
|
66
|
+
span = document.createElement('span');
|
|
67
|
+
span.textContent = text;
|
|
68
|
+
|
|
69
|
+
// Preserve consecutive spaces and newlines
|
|
70
|
+
span.style.whiteSpace = 'pre';
|
|
71
|
+
span.style.webkitUserSelect = 'auto';
|
|
72
|
+
span.style.userSelect = 'all';
|
|
73
|
+
|
|
74
|
+
// Add the <span> to the page
|
|
75
|
+
document.body.appendChild(span);
|
|
76
|
+
|
|
77
|
+
// Make a selection object representing the range of text selected by the user
|
|
78
|
+
selection = window.getSelection();
|
|
79
|
+
range = window.document.createRange();
|
|
80
|
+
selection.removeAllRanges();
|
|
81
|
+
range.selectNode(span);
|
|
82
|
+
selection.addRange(range);
|
|
83
|
+
|
|
84
|
+
// Copy text to the clipboard
|
|
85
|
+
success = false;
|
|
86
|
+
try {
|
|
87
|
+
success = window.document.execCommand('copy');
|
|
88
|
+
} finally {
|
|
89
|
+
// Cleanup
|
|
85
90
|
selection.removeAllRanges();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
window.document.body.removeChild(span);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (success) {
|
|
100
|
-
_context2.next = 15;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
throw makeError();
|
|
105
|
-
|
|
106
|
-
case 15:
|
|
107
|
-
case "end":
|
|
108
|
-
return _context2.stop();
|
|
109
|
-
}
|
|
91
|
+
window.document.body.removeChild(span);
|
|
92
|
+
}
|
|
93
|
+
if (success) {
|
|
94
|
+
_context2.next = 15;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
throw makeError();
|
|
98
|
+
case 15:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
110
101
|
}
|
|
111
102
|
}, _callee2);
|
|
112
103
|
}));
|
|
113
104
|
return _copyExecCommand.apply(this, arguments);
|
|
114
105
|
}
|
|
115
|
-
|
|
116
106
|
function copyToClipboard(_x3) {
|
|
117
107
|
return _copyToClipboard.apply(this, arguments);
|
|
118
108
|
}
|
|
119
|
-
|
|
120
109
|
function _copyToClipboard() {
|
|
121
110
|
_copyToClipboard = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(text) {
|
|
122
111
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
123
|
-
while (1) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_context3.t1 = _context3["catch"](7);
|
|
148
|
-
throw _context3.t1 || _context3.t0 || makeError();
|
|
149
|
-
|
|
150
|
-
case 15:
|
|
151
|
-
case "end":
|
|
152
|
-
return _context3.stop();
|
|
153
|
-
}
|
|
112
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
113
|
+
case 0:
|
|
114
|
+
_context3.prev = 0;
|
|
115
|
+
_context3.next = 3;
|
|
116
|
+
return copyClipboardApi(text);
|
|
117
|
+
case 3:
|
|
118
|
+
_context3.next = 15;
|
|
119
|
+
break;
|
|
120
|
+
case 5:
|
|
121
|
+
_context3.prev = 5;
|
|
122
|
+
_context3.t0 = _context3["catch"](0);
|
|
123
|
+
_context3.prev = 7;
|
|
124
|
+
_context3.next = 10;
|
|
125
|
+
return copyExecCommand(text);
|
|
126
|
+
case 10:
|
|
127
|
+
_context3.next = 15;
|
|
128
|
+
break;
|
|
129
|
+
case 12:
|
|
130
|
+
_context3.prev = 12;
|
|
131
|
+
_context3.t1 = _context3["catch"](7);
|
|
132
|
+
throw _context3.t1 || _context3.t0 || makeError();
|
|
133
|
+
case 15:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context3.stop();
|
|
154
136
|
}
|
|
155
137
|
}, _callee3, null, [[0, 5], [7, 12]]);
|
|
156
138
|
}));
|
|
@@ -161,17 +143,14 @@ var createNullableOnChange = function createNullableOnChange() {
|
|
|
161
143
|
var onChange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
162
144
|
return function (newValue) {
|
|
163
145
|
var nullableValue = newValue;
|
|
164
|
-
|
|
165
146
|
if (isObject(newValue)) {
|
|
166
147
|
var allNull = Object.keys(newValue).reduce(function (acc, key) {
|
|
167
148
|
return acc && newValue[key] === null;
|
|
168
149
|
}, true);
|
|
169
|
-
|
|
170
150
|
if (allNull) {
|
|
171
151
|
nullableValue = null;
|
|
172
152
|
}
|
|
173
153
|
}
|
|
174
|
-
|
|
175
154
|
if (onChange !== null) {
|
|
176
155
|
onChange(nullableValue);
|
|
177
156
|
}
|
|
@@ -185,7 +164,6 @@ var createUseEvent = function createUseEvent(eventsManager) {
|
|
|
185
164
|
if (enabled && eventsManager !== null) {
|
|
186
165
|
eventsManager.subscribe(event, callback);
|
|
187
166
|
}
|
|
188
|
-
|
|
189
167
|
return function () {
|
|
190
168
|
if (enabled && eventsManager !== null) {
|
|
191
169
|
eventsManager.unsubscribe(event, callback);
|
|
@@ -286,19 +264,16 @@ var easings = {
|
|
|
286
264
|
var getColorAsString = function getColorAsString() {
|
|
287
265
|
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
288
266
|
var overideAlpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
289
|
-
|
|
290
267
|
if (value === null) {
|
|
291
268
|
return null;
|
|
292
269
|
}
|
|
293
|
-
|
|
294
270
|
var _ref = isString(value) ? {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
271
|
+
color: value
|
|
272
|
+
} : value,
|
|
273
|
+
_ref$color = _ref.color,
|
|
274
|
+
color = _ref$color === void 0 ? null : _ref$color,
|
|
275
|
+
_ref$alpha = _ref.alpha,
|
|
276
|
+
alpha = _ref$alpha === void 0 ? null : _ref$alpha;
|
|
302
277
|
return alpha !== null || overideAlpha !== null ? tinycolor(color).setAlpha(overideAlpha !== null ? overideAlpha : alpha).toRgbString() : color;
|
|
303
278
|
};
|
|
304
279
|
|
|
@@ -306,11 +281,9 @@ var getComponentFromName = function getComponentFromName() {
|
|
|
306
281
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
307
282
|
var components = arguments.length > 1 ? arguments[1] : undefined;
|
|
308
283
|
var defaultComponent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
309
|
-
|
|
310
284
|
if (components === null || name === null) {
|
|
311
285
|
return defaultComponent;
|
|
312
286
|
}
|
|
313
|
-
|
|
314
287
|
var pascalName = pascalCase(name);
|
|
315
288
|
return components[pascalName] || components[name] || defaultComponent;
|
|
316
289
|
};
|
|
@@ -329,17 +302,18 @@ var deviceScreens = [{
|
|
|
329
302
|
}, {
|
|
330
303
|
name: 'very-large',
|
|
331
304
|
mediaQuery: 'only screen and (min-width: 1600px)'
|
|
332
|
-
}];
|
|
305
|
+
}];
|
|
333
306
|
|
|
307
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
334
308
|
var getDeviceScreens = function getDeviceScreens() {
|
|
335
309
|
return deviceScreens;
|
|
336
310
|
};
|
|
337
311
|
|
|
338
312
|
var getDisplayName = function getDisplayName(_ref) {
|
|
339
313
|
var _ref$displayName = _ref.displayName,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
314
|
+
displayName = _ref$displayName === void 0 ? null : _ref$displayName,
|
|
315
|
+
_ref$name = _ref.name,
|
|
316
|
+
name = _ref$name === void 0 ? null : _ref$name;
|
|
343
317
|
return displayName || name || 'Component';
|
|
344
318
|
};
|
|
345
319
|
|
|
@@ -348,16 +322,13 @@ var getFieldByName = function getFieldByName(fields, name) {
|
|
|
348
322
|
if (foundField !== null) {
|
|
349
323
|
return foundField;
|
|
350
324
|
}
|
|
351
|
-
|
|
352
325
|
var _it$name = it.name,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
326
|
+
fieldName = _it$name === void 0 ? null : _it$name,
|
|
327
|
+
_it$fields = it.fields,
|
|
328
|
+
subFields = _it$fields === void 0 ? [] : _it$fields;
|
|
357
329
|
if (name !== null && fieldName === name) {
|
|
358
330
|
return it;
|
|
359
331
|
}
|
|
360
|
-
|
|
361
332
|
return getFieldByName(subFields, name);
|
|
362
333
|
}, null);
|
|
363
334
|
};
|
|
@@ -367,35 +338,30 @@ var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
|
|
|
367
338
|
if (foundField === null) {
|
|
368
339
|
return null;
|
|
369
340
|
}
|
|
370
|
-
|
|
371
341
|
var _foundField$type = foundField.type,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
342
|
+
type = _foundField$type === void 0 ? null : _foundField$type,
|
|
343
|
+
_foundField$fields = foundField.fields,
|
|
344
|
+
fieldFields = _foundField$fields === void 0 ? null : _foundField$fields,
|
|
345
|
+
_foundField$field = foundField.field,
|
|
346
|
+
field = _foundField$field === void 0 ? null : _foundField$field,
|
|
347
|
+
_foundField$itemsFiel = foundField.itemsField,
|
|
348
|
+
itemsField = _foundField$itemsFiel === void 0 ? null : _foundField$itemsFiel;
|
|
379
349
|
var finalType = field !== null ? field.type || type : type;
|
|
380
350
|
var definition = fieldManager.getDefinition(finalType);
|
|
381
|
-
|
|
382
351
|
var _ref = finalType !== null ? definition : foundField,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
352
|
+
_ref$fields = _ref.fields,
|
|
353
|
+
subFields = _ref$fields === void 0 ? null : _ref$fields,
|
|
354
|
+
_ref$settings = _ref.settings,
|
|
355
|
+
settings = _ref$settings === void 0 ? null : _ref$settings,
|
|
356
|
+
_ref$itemsField = _ref.itemsField,
|
|
357
|
+
defItemsField = _ref$itemsField === void 0 ? null : _ref$itemsField;
|
|
390
358
|
var finalItemsField = itemsField || defItemsField;
|
|
391
|
-
|
|
392
359
|
if (finalItemsField !== null && key.match(/^[0-9]+$/)) {
|
|
393
360
|
return _objectSpread(_objectSpread({}, finalItemsField), {}, {
|
|
394
361
|
name: path.join('/'),
|
|
395
362
|
listItems: true
|
|
396
363
|
});
|
|
397
364
|
}
|
|
398
|
-
|
|
399
365
|
return getFieldByName([].concat(_toConsumableArray(fieldFields || []), _toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
|
|
400
366
|
}, {
|
|
401
367
|
fields: fields
|
|
@@ -404,11 +370,9 @@ var getFieldFromPath = function getFieldFromPath(path, fields, fieldManager) {
|
|
|
404
370
|
|
|
405
371
|
var getFileName = function getFileName() {
|
|
406
372
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
407
|
-
|
|
408
373
|
if (url === null || typeof url.match === 'undefined') {
|
|
409
374
|
return null;
|
|
410
375
|
}
|
|
411
|
-
|
|
412
376
|
return url.match(/([^/]+)(\?.*)?$/)[1] || url;
|
|
413
377
|
};
|
|
414
378
|
|
|
@@ -416,14 +380,12 @@ var getFontFamily = function getFontFamily(value) {
|
|
|
416
380
|
if (value == null) {
|
|
417
381
|
return null;
|
|
418
382
|
}
|
|
419
|
-
|
|
420
383
|
var _ref = isObject(value) ? value : {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
384
|
+
name: value
|
|
385
|
+
},
|
|
386
|
+
name = _ref.name,
|
|
387
|
+
_ref$fallback = _ref.fallback,
|
|
388
|
+
fallback = _ref$fallback === void 0 ? null : _ref$fallback;
|
|
427
389
|
return [name, fallback].filter(function (it) {
|
|
428
390
|
return it !== null;
|
|
429
391
|
}).map(function (it) {
|
|
@@ -441,7 +403,6 @@ var getRemainder = function getRemainder(number) {
|
|
|
441
403
|
var remainder = number - Math.floor(number);
|
|
442
404
|
return remainder.toFixed(4);
|
|
443
405
|
};
|
|
444
|
-
|
|
445
406
|
var largestRemainderRound = function largestRemainderRound(numbers, desiredTotal) {
|
|
446
407
|
if (!isArray(numbers) || numbers.length < 1) return numbers;
|
|
447
408
|
var result = numbers.map(function (number, index) {
|
|
@@ -457,13 +418,11 @@ var largestRemainderRound = function largestRemainderRound(numbers, desiredTotal
|
|
|
457
418
|
return sum + current.floor;
|
|
458
419
|
}, 0);
|
|
459
420
|
var delta = desiredTotal - lowerSum;
|
|
460
|
-
|
|
461
421
|
for (var i = 0; i < delta; i += 1) {
|
|
462
422
|
if (result[i]) {
|
|
463
423
|
result[i].floor += 1;
|
|
464
424
|
}
|
|
465
425
|
}
|
|
466
|
-
|
|
467
426
|
return result.sort(function (a, b) {
|
|
468
427
|
return a.index - b.index;
|
|
469
428
|
}).map(function (res) {
|
|
@@ -472,23 +431,19 @@ var largestRemainderRound = function largestRemainderRound(numbers, desiredTotal
|
|
|
472
431
|
};
|
|
473
432
|
|
|
474
433
|
var _excluded = ["image", "video", "media"];
|
|
475
|
-
|
|
476
434
|
var getLayersFromBackground = function getLayersFromBackground() {
|
|
477
435
|
var background = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
478
|
-
|
|
479
436
|
if (background === null) {
|
|
480
437
|
return [];
|
|
481
438
|
}
|
|
482
|
-
|
|
483
439
|
return (isArray(background) ? background : [background]).reduce(function (layers, _ref) {
|
|
484
440
|
var _ref$image = _ref.image,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
441
|
+
image = _ref$image === void 0 ? null : _ref$image,
|
|
442
|
+
_ref$video = _ref.video,
|
|
443
|
+
video = _ref$video === void 0 ? null : _ref$video,
|
|
444
|
+
_ref$media = _ref.media,
|
|
445
|
+
media = _ref$media === void 0 ? null : _ref$media,
|
|
446
|
+
data = _objectWithoutProperties(_ref, _excluded);
|
|
492
447
|
if (image !== null && video !== null) {
|
|
493
448
|
return [].concat(_toConsumableArray(layers), [_objectSpread({
|
|
494
449
|
media: image
|
|
@@ -496,7 +451,6 @@ var getLayersFromBackground = function getLayersFromBackground() {
|
|
|
496
451
|
media: video
|
|
497
452
|
}, data)]);
|
|
498
453
|
}
|
|
499
|
-
|
|
500
454
|
return [].concat(_toConsumableArray(layers), [_objectSpread({
|
|
501
455
|
media: media || image || video
|
|
502
456
|
}, data)]);
|
|
@@ -516,28 +470,23 @@ var getOptimalImageUrl = function getOptimalImageUrl() {
|
|
|
516
470
|
var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
517
471
|
var containerWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
518
472
|
var containerHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
519
|
-
|
|
520
473
|
var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
474
|
+
_ref$resolution = _ref.resolution,
|
|
475
|
+
resolution = _ref$resolution === void 0 ? 1 : _ref$resolution,
|
|
476
|
+
_ref$maxDiff = _ref.maxDiff,
|
|
477
|
+
maxDiff = _ref$maxDiff === void 0 ? 800 : _ref$maxDiff;
|
|
526
478
|
var _ref2 = media || {},
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
imgHeight = _ref2$metadata.height;
|
|
536
|
-
|
|
479
|
+
_ref2$sizes = _ref2.sizes,
|
|
480
|
+
sizes = _ref2$sizes === void 0 ? null : _ref2$sizes,
|
|
481
|
+
_ref2$url = _ref2.url,
|
|
482
|
+
defaultUrl = _ref2$url === void 0 ? null : _ref2$url,
|
|
483
|
+
_ref2$metadata = _ref2.metadata,
|
|
484
|
+
_ref2$metadata2 = _ref2$metadata === void 0 ? {} : _ref2$metadata,
|
|
485
|
+
imgWidth = _ref2$metadata2.width,
|
|
486
|
+
imgHeight = _ref2$metadata2.height;
|
|
537
487
|
if (sizes === null || containerWidth === null && containerHeight === null) {
|
|
538
488
|
return defaultUrl;
|
|
539
489
|
}
|
|
540
|
-
|
|
541
490
|
var finalSizes = _objectSpread({
|
|
542
491
|
original: {
|
|
543
492
|
url: defaultUrl,
|
|
@@ -545,70 +494,64 @@ var getOptimalImageUrl = function getOptimalImageUrl() {
|
|
|
545
494
|
height: imgHeight
|
|
546
495
|
}
|
|
547
496
|
}, sizes);
|
|
548
|
-
|
|
549
497
|
var finalContainerWidth = containerWidth !== null && resolution !== null ? containerWidth * resolution : containerWidth;
|
|
550
498
|
var finalContainerHeight = containerHeight !== null && resolution !== null ? containerHeight * resolution : containerHeight;
|
|
551
|
-
|
|
552
499
|
var _Object$keys$reduce = Object.keys(finalSizes).reduce(function (acc, key) {
|
|
553
|
-
|
|
500
|
+
var currentDiff = acc.diff,
|
|
554
501
|
currentIsLarger = acc.isLarger,
|
|
555
502
|
currentSize = acc.size;
|
|
556
|
-
|
|
503
|
+
var _finalSizes$key = finalSizes[key],
|
|
557
504
|
url = _finalSizes$key.url,
|
|
558
505
|
_finalSizes$key$width = _finalSizes$key.width,
|
|
559
506
|
width = _finalSizes$key$width === void 0 ? null : _finalSizes$key$width,
|
|
560
507
|
_finalSizes$key$heigh = _finalSizes$key.height,
|
|
561
508
|
height = _finalSizes$key$heigh === void 0 ? null : _finalSizes$key$heigh;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
509
|
+
var diffWidth = width !== null && finalContainerWidth !== null ? width - finalContainerWidth : null;
|
|
510
|
+
var diffHeight = height !== null && finalContainerHeight !== null ? height - finalContainerHeight : null;
|
|
511
|
+
var isLarger = (diffWidth === null || diffWidth >= 0) && (diffHeight === null || diffHeight >= 0);
|
|
512
|
+
var diff = [diffWidth, diffHeight].reduce(function (total, value) {
|
|
513
|
+
return value !== null ? (total || 0) + Math.abs(value) : total;
|
|
514
|
+
}, null);
|
|
515
|
+
if (diff === null) {
|
|
516
|
+
diff = Infinity;
|
|
517
|
+
}
|
|
518
|
+
var size = (width || 0) + (height || 0);
|
|
519
|
+
var sizeIsLarger = size > currentSize;
|
|
520
|
+
if (
|
|
521
|
+
// Difference is lower and image is larger
|
|
522
|
+
diff < currentDiff && isLarger ||
|
|
523
|
+
// Difference is lower and current is not larger or diff is greater than max
|
|
524
|
+
diff < currentDiff && (!currentIsLarger && sizeIsLarger || currentDiff > maxDiff) ||
|
|
525
|
+
// Image is larger and diff is smaller than max
|
|
526
|
+
diff <= maxDiff && !currentIsLarger && isLarger ||
|
|
527
|
+
// Image is larger than previous
|
|
528
|
+
diff <= maxDiff && !currentIsLarger && !isLarger && sizeIsLarger) {
|
|
529
|
+
return {
|
|
530
|
+
key: key,
|
|
531
|
+
url: url,
|
|
532
|
+
diff: diff,
|
|
533
|
+
isLarger: isLarger
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
return acc;
|
|
537
|
+
}, {
|
|
538
|
+
key: null,
|
|
539
|
+
url: defaultUrl,
|
|
540
|
+
diff: Infinity,
|
|
541
|
+
isLarger: false,
|
|
542
|
+
size: 0
|
|
543
|
+
}),
|
|
544
|
+
finalUrl = _Object$keys$reduce.url;
|
|
599
545
|
return finalUrl;
|
|
600
546
|
};
|
|
601
547
|
|
|
602
548
|
var getSecondsFromTime = function getSecondsFromTime(time) {
|
|
603
549
|
var t = time.split(':');
|
|
604
|
-
|
|
605
550
|
try {
|
|
606
551
|
var s = t[2].split(',');
|
|
607
|
-
|
|
608
552
|
if (s.length === 1) {
|
|
609
553
|
s = t[2].split('.');
|
|
610
554
|
}
|
|
611
|
-
|
|
612
555
|
return parseFloat(t[0], 10) * 3600 + parseFloat(t[1], 10) * 60 + parseFloat(s[0], 10) + parseFloat(s[1], 10) / 1000;
|
|
613
556
|
} catch (e) {
|
|
614
557
|
return 0;
|
|
@@ -644,23 +587,20 @@ function getJustifyContent(horizontal) {
|
|
|
644
587
|
if (horizontal === 'right') return 'flex-end';
|
|
645
588
|
return null;
|
|
646
589
|
}
|
|
647
|
-
|
|
648
590
|
function getAlignItems(vertical) {
|
|
649
591
|
if (vertical === 'top') return 'flex-start';
|
|
650
592
|
if (vertical === 'middle') return 'center';
|
|
651
593
|
if (vertical === 'bottom') return 'flex-end';
|
|
652
594
|
return null;
|
|
653
595
|
}
|
|
654
|
-
|
|
655
596
|
var getStyleFromAlignment = function getStyleFromAlignment(value) {
|
|
656
597
|
if (value === null) {
|
|
657
598
|
return null;
|
|
658
599
|
}
|
|
659
|
-
|
|
660
600
|
var _value$horizontal = value.horizontal,
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
601
|
+
horizontal = _value$horizontal === void 0 ? null : _value$horizontal,
|
|
602
|
+
_value$vertical = value.vertical,
|
|
603
|
+
vertical = _value$vertical === void 0 ? null : _value$vertical;
|
|
664
604
|
var justifyContent = getJustifyContent(horizontal);
|
|
665
605
|
var alignItems = getAlignItems(vertical);
|
|
666
606
|
return {
|
|
@@ -681,13 +621,12 @@ var getStyleFromBorder = function getStyleFromBorder(value) {
|
|
|
681
621
|
if (value == null) {
|
|
682
622
|
return null;
|
|
683
623
|
}
|
|
684
|
-
|
|
685
624
|
var _value$width = value.width,
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
625
|
+
width = _value$width === void 0 ? null : _value$width,
|
|
626
|
+
_value$style = value.style,
|
|
627
|
+
borderStyle = _value$style === void 0 ? null : _value$style,
|
|
628
|
+
_value$color = value.color,
|
|
629
|
+
color = _value$color === void 0 ? null : _value$color;
|
|
691
630
|
return _objectSpread(_objectSpread(_objectSpread({}, width !== null ? {
|
|
692
631
|
borderWidth: width
|
|
693
632
|
} : null), borderStyle !== null ? {
|
|
@@ -699,64 +638,60 @@ var getStyleFromShadow = function getStyleFromShadow(value) {
|
|
|
699
638
|
if (value == null) {
|
|
700
639
|
return null;
|
|
701
640
|
}
|
|
702
|
-
|
|
703
641
|
var _ref = value || {},
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
642
|
+
_ref$shadowAngle = _ref.shadowAngle,
|
|
643
|
+
shadowAngle = _ref$shadowAngle === void 0 ? null : _ref$shadowAngle,
|
|
644
|
+
_ref$shadowDistance = _ref.shadowDistance,
|
|
645
|
+
shadowDistance = _ref$shadowDistance === void 0 ? null : _ref$shadowDistance,
|
|
646
|
+
_ref$shadowBlur = _ref.shadowBlur,
|
|
647
|
+
shadowBlur = _ref$shadowBlur === void 0 ? null : _ref$shadowBlur,
|
|
648
|
+
_ref$shadowColor = _ref.shadowColor,
|
|
649
|
+
shadowColor = _ref$shadowColor === void 0 ? null : _ref$shadowColor;
|
|
713
650
|
if (!shadowAngle) return null;
|
|
714
651
|
var blur = shadowBlur || '0';
|
|
715
652
|
var color = getColorAsString(shadowColor) || '#000000';
|
|
716
|
-
|
|
717
653
|
var _getShadowCoords = getShadowCoords(shadowAngle, shadowDistance),
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
654
|
+
x = _getShadowCoords.x,
|
|
655
|
+
y = _getShadowCoords.y;
|
|
721
656
|
var boxShadow = "".concat(x, "px ").concat(y, "px ").concat(blur, "px 0 ").concat(color);
|
|
722
657
|
return {
|
|
723
658
|
boxShadow: boxShadow
|
|
724
659
|
};
|
|
725
660
|
};
|
|
726
661
|
|
|
662
|
+
// @todo hmm, gotta find a better way to handle this
|
|
727
663
|
var getStyleFromBox = function getStyleFromBox(value) {
|
|
728
664
|
if (value === null) {
|
|
729
665
|
return null;
|
|
730
666
|
}
|
|
731
|
-
|
|
732
667
|
var _value$backgroundColo = value.backgroundColor,
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
668
|
+
backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo,
|
|
669
|
+
_value$borderRadius = value.borderRadius,
|
|
670
|
+
borderRadius = _value$borderRadius === void 0 ? null : _value$borderRadius,
|
|
671
|
+
_value$padding = value.padding,
|
|
672
|
+
padding = _value$padding === void 0 ? null : _value$padding,
|
|
673
|
+
_value$paddingTop = value.paddingTop,
|
|
674
|
+
paddingTop = _value$paddingTop === void 0 ? null : _value$paddingTop,
|
|
675
|
+
_value$paddingRight = value.paddingRight,
|
|
676
|
+
paddingRight = _value$paddingRight === void 0 ? null : _value$paddingRight,
|
|
677
|
+
_value$paddingBottom = value.paddingBottom,
|
|
678
|
+
paddingBottom = _value$paddingBottom === void 0 ? null : _value$paddingBottom,
|
|
679
|
+
_value$paddingLeft = value.paddingLeft,
|
|
680
|
+
paddingLeft = _value$paddingLeft === void 0 ? null : _value$paddingLeft,
|
|
681
|
+
_value$borderWidth = value.borderWidth,
|
|
682
|
+
borderWidth = _value$borderWidth === void 0 ? null : _value$borderWidth,
|
|
683
|
+
_value$borderStyle = value.borderStyle,
|
|
684
|
+
borderStyle = _value$borderStyle === void 0 ? null : _value$borderStyle,
|
|
685
|
+
_value$borderColor = value.borderColor,
|
|
686
|
+
borderColor = _value$borderColor === void 0 ? null : _value$borderColor,
|
|
687
|
+
_value$shadowAngle = value.shadowAngle,
|
|
688
|
+
shadowAngle = _value$shadowAngle === void 0 ? null : _value$shadowAngle,
|
|
689
|
+
_value$shadowDistance = value.shadowDistance,
|
|
690
|
+
shadowDistance = _value$shadowDistance === void 0 ? null : _value$shadowDistance,
|
|
691
|
+
_value$shadowBlur = value.shadowBlur,
|
|
692
|
+
shadowBlur = _value$shadowBlur === void 0 ? null : _value$shadowBlur,
|
|
693
|
+
_value$shadowColor = value.shadowColor,
|
|
694
|
+
shadowColor = _value$shadowColor === void 0 ? null : _value$shadowColor;
|
|
760
695
|
var border = {
|
|
761
696
|
width: borderWidth,
|
|
762
697
|
style: borderStyle,
|
|
@@ -768,21 +703,19 @@ var getStyleFromBox = function getStyleFromBox(value) {
|
|
|
768
703
|
shadowBlur: shadowBlur,
|
|
769
704
|
shadowColor: shadowColor
|
|
770
705
|
};
|
|
771
|
-
|
|
772
706
|
var _ref = isObject(padding) ? padding : {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
707
|
+
padding: padding
|
|
708
|
+
},
|
|
709
|
+
_ref$top = _ref.top,
|
|
710
|
+
paddingValueTop = _ref$top === void 0 ? null : _ref$top,
|
|
711
|
+
_ref$right = _ref.right,
|
|
712
|
+
paddingValueRight = _ref$right === void 0 ? null : _ref$right,
|
|
713
|
+
_ref$bottom = _ref.bottom,
|
|
714
|
+
paddingValueBottom = _ref$bottom === void 0 ? null : _ref$bottom,
|
|
715
|
+
_ref$left = _ref.left,
|
|
716
|
+
paddingValueLeft = _ref$left === void 0 ? null : _ref$left,
|
|
717
|
+
_ref$padding = _ref.padding,
|
|
718
|
+
paddingValue = _ref$padding === void 0 ? null : _ref$padding;
|
|
786
719
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getStyleFromColor(backgroundColor, 'backgroundColor')), borderRadius !== null ? {
|
|
787
720
|
borderRadius: borderRadius
|
|
788
721
|
} : null), getStyleFromBorder(border)), getStyleFromShadow(shadow)), padding !== null || paddingValue !== null ? {
|
|
@@ -802,15 +735,14 @@ var getStyleFromContainer = function getStyleFromContainer(value) {
|
|
|
802
735
|
if (value == null) {
|
|
803
736
|
return null;
|
|
804
737
|
}
|
|
805
|
-
|
|
806
738
|
var _value$size = value.size,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
739
|
+
size = _value$size === void 0 ? {} : _value$size,
|
|
740
|
+
_value$backgroundColo = value.backgroundColor,
|
|
741
|
+
backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo;
|
|
810
742
|
var _size$width = size.width,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
743
|
+
width = _size$width === void 0 ? null : _size$width,
|
|
744
|
+
_size$height = size.height,
|
|
745
|
+
height = _size$height === void 0 ? null : _size$height;
|
|
814
746
|
return _objectSpread(_objectSpread(_objectSpread({}, width ? {
|
|
815
747
|
width: "".concat(width, "%")
|
|
816
748
|
} : null), height ? {
|
|
@@ -822,11 +754,10 @@ var getStyleFromHighlight = function getStyleFromHighlight(value) {
|
|
|
822
754
|
if (value == null) {
|
|
823
755
|
return null;
|
|
824
756
|
}
|
|
825
|
-
|
|
826
757
|
var _value$textColor = value.textColor,
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
758
|
+
textColor = _value$textColor === void 0 ? null : _value$textColor,
|
|
759
|
+
_value$color = value.color,
|
|
760
|
+
color = _value$color === void 0 ? null : _value$color;
|
|
830
761
|
var colorString = color !== null ? getColorAsString(color) : null;
|
|
831
762
|
var boxShadow = colorString !== null ? "0.05em 0px 0px ".concat(colorString, ", -0.05em 0px 0px ").concat(colorString) : null;
|
|
832
763
|
return color !== null || textColor !== null ? _objectSpread(_objectSpread(_objectSpread({}, color !== null ? getStyleFromColor(color, 'backgroundColor') : null), textColor !== null ? getStyleFromColor(textColor, 'color') : null), color !== null ? {
|
|
@@ -841,19 +772,18 @@ var getStyleFromImage = function getStyleFromImage(value) {
|
|
|
841
772
|
if (value == null) {
|
|
842
773
|
return null;
|
|
843
774
|
}
|
|
844
|
-
|
|
845
775
|
var _value$fit = value.fit,
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
776
|
+
fit = _value$fit === void 0 ? {} : _value$fit,
|
|
777
|
+
_value$backgroundColo = value.backgroundColor,
|
|
778
|
+
backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo;
|
|
849
779
|
var _fit$size = fit.size,
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
780
|
+
size = _fit$size === void 0 ? null : _fit$size,
|
|
781
|
+
_fit$position = fit.position,
|
|
782
|
+
position = _fit$position === void 0 ? {} : _fit$position;
|
|
853
783
|
var _position$axisAlign = position.axisAlign,
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
784
|
+
axisAlign = _position$axisAlign === void 0 ? null : _position$axisAlign,
|
|
785
|
+
_position$crossAlign = position.crossAlign,
|
|
786
|
+
crossAlign = _position$crossAlign === void 0 ? null : _position$crossAlign;
|
|
857
787
|
return _objectSpread(_objectSpread(_objectSpread({}, size !== null ? {
|
|
858
788
|
objectFit: size
|
|
859
789
|
} : null), axisAlign !== null && crossAlign !== null ? {
|
|
@@ -865,19 +795,16 @@ var getStyleFromLink = function getStyleFromLink(value) {
|
|
|
865
795
|
if (value == null) {
|
|
866
796
|
return null;
|
|
867
797
|
}
|
|
868
|
-
|
|
869
798
|
var _value$color = value.color,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
799
|
+
color = _value$color === void 0 ? null : _value$color,
|
|
800
|
+
fontStyle = value.fontStyle;
|
|
873
801
|
var _ref = fontStyle || {},
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
802
|
+
_ref$italic = _ref.italic,
|
|
803
|
+
italic = _ref$italic === void 0 ? false : _ref$italic,
|
|
804
|
+
_ref$bold = _ref.bold,
|
|
805
|
+
bold = _ref$bold === void 0 ? false : _ref$bold,
|
|
806
|
+
_ref$underline = _ref.underline,
|
|
807
|
+
underline = _ref$underline === void 0 ? false : _ref$underline;
|
|
881
808
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, color !== null ? getStyleFromColor(color, 'color') : null), italic ? {
|
|
882
809
|
fontStyle: 'italic'
|
|
883
810
|
} : null), bold ? {
|
|
@@ -891,35 +818,32 @@ var getStyleFromText = function getStyleFromText(value) {
|
|
|
891
818
|
if (value == null) {
|
|
892
819
|
return null;
|
|
893
820
|
}
|
|
894
|
-
|
|
895
821
|
var _value$fontFamily = value.fontFamily,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
822
|
+
fontFamily = _value$fontFamily === void 0 ? null : _value$fontFamily,
|
|
823
|
+
_value$fontSize = value.fontSize,
|
|
824
|
+
fontSize = _value$fontSize === void 0 ? null : _value$fontSize,
|
|
825
|
+
_value$fontStyle = value.fontStyle,
|
|
826
|
+
fontStyle = _value$fontStyle === void 0 ? null : _value$fontStyle,
|
|
827
|
+
_value$fontWeight = value.fontWeight,
|
|
828
|
+
fontWeight = _value$fontWeight === void 0 ? null : _value$fontWeight,
|
|
829
|
+
_value$lineHeight = value.lineHeight,
|
|
830
|
+
lineHeight = _value$lineHeight === void 0 ? null : _value$lineHeight,
|
|
831
|
+
_value$letterSpacing = value.letterSpacing,
|
|
832
|
+
letterSpacing = _value$letterSpacing === void 0 ? null : _value$letterSpacing,
|
|
833
|
+
_value$align = value.align,
|
|
834
|
+
textAlign = _value$align === void 0 ? null : _value$align,
|
|
835
|
+
_value$color = value.color,
|
|
836
|
+
color = _value$color === void 0 ? null : _value$color;
|
|
912
837
|
var _ref = fontStyle || {},
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
838
|
+
_ref$italic = _ref.italic,
|
|
839
|
+
italic = _ref$italic === void 0 ? false : _ref$italic,
|
|
840
|
+
_ref$bold = _ref.bold,
|
|
841
|
+
bold = _ref$bold === void 0 ? false : _ref$bold,
|
|
842
|
+
_ref$underline = _ref.underline,
|
|
843
|
+
underline = _ref$underline === void 0 ? false : _ref$underline,
|
|
844
|
+
textTransform = _ref.transform,
|
|
845
|
+
_ref$outline = _ref.outline,
|
|
846
|
+
outline = _ref$outline === void 0 ? false : _ref$outline;
|
|
923
847
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
924
848
|
fontFamily: getFontFamily(fontFamily)
|
|
925
849
|
}, fontSize !== null ? {
|
|
@@ -950,11 +874,10 @@ var getStyleFromMargin = function getStyleFromMargin(value) {
|
|
|
950
874
|
if (value == null) {
|
|
951
875
|
return null;
|
|
952
876
|
}
|
|
953
|
-
|
|
954
877
|
var _value$top = value.top,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
878
|
+
marginTop = _value$top === void 0 ? null : _value$top,
|
|
879
|
+
_value$bottom = value.bottom,
|
|
880
|
+
marginBottom = _value$bottom === void 0 ? null : _value$bottom;
|
|
958
881
|
return _objectSpread(_objectSpread({}, marginTop !== null ? {
|
|
959
882
|
marginTop: marginTop
|
|
960
883
|
} : null), marginBottom !== null ? {
|
|
@@ -964,29 +887,24 @@ var getStyleFromMargin = function getStyleFromMargin(value) {
|
|
|
964
887
|
|
|
965
888
|
var possibleMimes = ['video/webm', 'video/mp4', 'video/ogg'];
|
|
966
889
|
var supportedMimes = null;
|
|
967
|
-
|
|
968
890
|
function getVideoSupportedMimes() {
|
|
969
891
|
var mimes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : possibleMimes;
|
|
970
|
-
|
|
971
892
|
if (supportedMimes === null) {
|
|
972
893
|
var video = document.createElement('video');
|
|
973
894
|
supportedMimes = mimes.filter(function (mime) {
|
|
974
895
|
return video.canPlayType(mime) !== '';
|
|
975
896
|
});
|
|
976
897
|
}
|
|
977
|
-
|
|
978
898
|
return supportedMimes;
|
|
979
899
|
}
|
|
980
900
|
|
|
981
901
|
var getLayoutParts = function getLayoutParts() {
|
|
982
902
|
var layout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
983
|
-
|
|
984
903
|
var _ref = layout !== null && layout.indexOf('-') !== false ? layout.split('-') : [layout, null, null],
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
904
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
905
|
+
horizontal = _ref2[0],
|
|
906
|
+
vertical = _ref2[1],
|
|
907
|
+
suffix = _ref2[2];
|
|
990
908
|
return {
|
|
991
909
|
horizontal: horizontal,
|
|
992
910
|
vertical: vertical,
|
|
@@ -999,51 +917,45 @@ var isMessage = function isMessage(message) {
|
|
|
999
917
|
};
|
|
1000
918
|
|
|
1001
919
|
var isIos = function isIos() {
|
|
1002
|
-
return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
|
920
|
+
return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
|
921
|
+
// iPad on iOS 13 detection
|
|
1003
922
|
navigator.userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1004
923
|
};
|
|
1005
924
|
|
|
1006
925
|
var isImageFilled = function isImageFilled(image) {
|
|
1007
926
|
var _ref = image || {},
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
927
|
+
_ref$media = _ref.media,
|
|
928
|
+
media = _ref$media === void 0 ? null : _ref$media;
|
|
1011
929
|
return media !== null;
|
|
1012
930
|
};
|
|
1013
931
|
|
|
1014
932
|
var isTextFilled$1 = function isTextFilled(text) {
|
|
1015
933
|
var _ref = text || {},
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
934
|
+
_ref$label = _ref.label,
|
|
935
|
+
label = _ref$label === void 0 ? null : _ref$label;
|
|
1019
936
|
var _ref2 = label || {},
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
937
|
+
_ref2$length = _ref2.length,
|
|
938
|
+
length = _ref2$length === void 0 ? 0 : _ref2$length;
|
|
1023
939
|
return typeof length === 'number' && length > 0;
|
|
1024
940
|
};
|
|
1025
941
|
|
|
1026
942
|
var isTextFilled = function isTextFilled(text) {
|
|
1027
943
|
var _ref = text || {},
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
944
|
+
_ref$body = _ref.body,
|
|
945
|
+
body = _ref$body === void 0 ? null : _ref$body;
|
|
1031
946
|
var _ref2 = body || {},
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
947
|
+
_ref2$length = _ref2.length,
|
|
948
|
+
length = _ref2$length === void 0 ? 0 : _ref2$length;
|
|
1035
949
|
return typeof length === 'number' && length > 0;
|
|
1036
950
|
};
|
|
1037
951
|
|
|
1038
952
|
var isValidUrl = function isValidUrl(string) {
|
|
1039
953
|
var url;
|
|
1040
|
-
|
|
1041
954
|
try {
|
|
1042
955
|
url = new URL(string);
|
|
1043
956
|
} catch (_) {
|
|
1044
957
|
return false;
|
|
1045
958
|
}
|
|
1046
|
-
|
|
1047
959
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
1048
960
|
};
|
|
1049
961
|
|
|
@@ -1058,10 +970,10 @@ var schemaId = function schemaId(str) {
|
|
|
1058
970
|
var setValue = function setValue(value, keyParts, fieldValue) {
|
|
1059
971
|
var key = keyParts.shift();
|
|
1060
972
|
var isArray = key.match(/^[0-9]+$/) !== null;
|
|
1061
|
-
|
|
1062
973
|
if (value !== null || fieldValue !== null) {
|
|
1063
974
|
if (isArray) {
|
|
1064
|
-
var index = parseInt(key, 10);
|
|
975
|
+
var index = parseInt(key, 10);
|
|
976
|
+
// TODO: fix this with an explicit delete
|
|
1065
977
|
// instead on splicing out the element on null fieldValue
|
|
1066
978
|
// const newArrayValue =
|
|
1067
979
|
// fieldValue !== null
|
|
@@ -1081,23 +993,19 @@ var setValue = function setValue(value, keyParts, fieldValue) {
|
|
|
1081
993
|
var newArrayValue = [].concat(_toConsumableArray(value.slice(0, index)), [keyParts.length > 0 ? setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue], _toConsumableArray(value.slice(index + 1)));
|
|
1082
994
|
return newArrayValue.length > 0 ? newArrayValue : null;
|
|
1083
995
|
}
|
|
1084
|
-
|
|
1085
996
|
return _objectSpread(_objectSpread({}, value), {}, _defineProperty({}, key, keyParts.length > 0 ? setValue(value !== null ? value[key] || null : null, keyParts, fieldValue) : fieldValue));
|
|
1086
997
|
}
|
|
1087
|
-
|
|
1088
998
|
return null;
|
|
1089
999
|
};
|
|
1090
1000
|
|
|
1091
1001
|
var slug = function slug(str) {
|
|
1092
1002
|
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1093
1003
|
var toSlug;
|
|
1094
|
-
|
|
1095
1004
|
if (separator === '-') {
|
|
1096
1005
|
toSlug = paramCase$1(str);
|
|
1097
1006
|
} else {
|
|
1098
1007
|
toSlug = snakeCase(str);
|
|
1099
1008
|
}
|
|
1100
|
-
|
|
1101
1009
|
return slugify(toSlug, {
|
|
1102
1010
|
lower: true
|
|
1103
1011
|
});
|
|
@@ -1115,28 +1023,23 @@ var validateFields = function validateFields(fields, value) {
|
|
|
1115
1023
|
if (field.type === 'fields' && field.fields) {
|
|
1116
1024
|
return validateFields(field.fields, value);
|
|
1117
1025
|
}
|
|
1118
|
-
|
|
1119
1026
|
var val = value && value[field.name] ? value[field.name] : false;
|
|
1120
1027
|
return !(field.required && !val);
|
|
1121
1028
|
}
|
|
1122
|
-
|
|
1123
1029
|
return acc;
|
|
1124
1030
|
}, true);
|
|
1125
1031
|
};
|
|
1126
1032
|
|
|
1127
1033
|
var getContrastingColor = function getContrastingColor(backgroundColor) {
|
|
1128
1034
|
var _ref = backgroundColor || {},
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1035
|
+
_ref$color = _ref.color,
|
|
1036
|
+
color = _ref$color === void 0 ? 'white' : _ref$color;
|
|
1132
1037
|
if (tinycolor.equals(color, tinycolor('white'))) {
|
|
1133
1038
|
return '#A13DFF';
|
|
1134
1039
|
}
|
|
1135
|
-
|
|
1136
1040
|
if (tinycolor.equals(color, tinycolor('black'))) {
|
|
1137
1041
|
return 'white';
|
|
1138
1042
|
}
|
|
1139
|
-
|
|
1140
1043
|
return tinycolor(color).spin(30).toString();
|
|
1141
1044
|
};
|
|
1142
1045
|
|