@micromag/core 0.4.69 → 0.4.74
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 +0 -1
- package/assets/css/vendor.css +2 -3
- package/es/components.d.ts +99 -56
- package/es/components.js +5098 -2330
- package/es/contexts.d.ts +139 -67
- package/es/contexts.js +2183 -1240
- package/es/hooks.d.ts +29 -73
- package/es/hooks.js +2522 -2155
- package/es/index.d.ts +51 -8
- package/es/index.js +1284 -1525
- package/es/styles.css +0 -1
- package/es/utils.d.ts +157 -15
- package/es/utils.js +748 -882
- package/package.json +36 -40
- package/lib/components.js +0 -3404
- package/lib/contexts.js +0 -1763
- package/lib/hooks.js +0 -2535
- package/lib/index.js +0 -1713
- package/lib/styles.css +0 -35
- package/lib/utils.js +0 -1284
package/es/utils.js
CHANGED
|
@@ -2,28 +2,17 @@ import isString from 'lodash/isString';
|
|
|
2
2
|
import isNumber from 'lodash/isNumber';
|
|
3
3
|
import { kebabCase, pascalCase, snakeCase } from 'change-case';
|
|
4
4
|
export { camelCase, pascalCase, snakeCase } from 'change-case';
|
|
5
|
-
import _regenerator from '@babel/runtime/helpers/regenerator';
|
|
6
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
7
5
|
import isObject from 'lodash/isObject';
|
|
8
|
-
import { useEffect
|
|
6
|
+
import { useEffect } from 'react';
|
|
9
7
|
import tinycolor from 'tinycolor2';
|
|
10
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
12
8
|
import isArray from 'lodash/isArray';
|
|
13
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
14
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
15
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
16
9
|
import slugify from 'slugify';
|
|
17
10
|
|
|
18
11
|
function addNonBreakingSpaces(text) {
|
|
19
12
|
return isString(text) ? text.replace(/«\s/g, '« ').replace(/\s»/g, ' »').replace(/\s:\s/g, ' : ') : text;
|
|
20
13
|
}
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
return style !== null ? Object.keys(style).map(function (key) {
|
|
24
|
-
return "".concat(kebabCase(key), ":").concat(isNumber(style[key]) ? "".concat(style[key], "px") : style[key], ";");
|
|
25
|
-
}).join('\n') : '';
|
|
26
|
-
};
|
|
15
|
+
const convertStyleToString = style => style !== null ? Object.keys(style).map(key => `${kebabCase(key)}:${isNumber(style[key]) ? `${style[key]}px` : style[key]};`).join('\n') : '';
|
|
27
16
|
|
|
28
17
|
/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
29
18
|
|
|
@@ -33,143 +22,82 @@ var convertStyleToString = function convertStyleToString(style) {
|
|
|
33
22
|
function makeError() {
|
|
34
23
|
return new DOMException('The request is not allowed', 'NotAllowedError');
|
|
35
24
|
}
|
|
36
|
-
function copyClipboardApi(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
case 0:
|
|
44
|
-
if (navigator.clipboard) {
|
|
45
|
-
_context.n = 1;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
throw makeError();
|
|
49
|
-
case 1:
|
|
50
|
-
return _context.a(2, navigator.clipboard.writeText(text));
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
}));
|
|
54
|
-
return _copyClipboardApi.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
function copyExecCommand(_x2) {
|
|
57
|
-
return _copyExecCommand.apply(this, arguments);
|
|
58
|
-
}
|
|
59
|
-
function _copyExecCommand() {
|
|
60
|
-
_copyExecCommand = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(text) {
|
|
61
|
-
var span, selection, range, success;
|
|
62
|
-
return _regenerator().w(function (_context2) {
|
|
63
|
-
while (1) switch (_context2.n) {
|
|
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
|
|
90
|
-
selection.removeAllRanges();
|
|
91
|
-
window.document.body.removeChild(span);
|
|
92
|
-
}
|
|
93
|
-
if (success) {
|
|
94
|
-
_context2.n = 1;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
throw makeError();
|
|
98
|
-
case 1:
|
|
99
|
-
return _context2.a(2);
|
|
100
|
-
}
|
|
101
|
-
}, _callee2);
|
|
102
|
-
}));
|
|
103
|
-
return _copyExecCommand.apply(this, arguments);
|
|
25
|
+
async function copyClipboardApi(text) {
|
|
26
|
+
// Use the Async Clipboard API when available. Requires a secure browsing
|
|
27
|
+
// context (i.e. HTTPS)
|
|
28
|
+
if (!navigator.clipboard) {
|
|
29
|
+
throw makeError();
|
|
30
|
+
}
|
|
31
|
+
return navigator.clipboard.writeText(text);
|
|
104
32
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
33
|
+
async function copyExecCommand(text) {
|
|
34
|
+
// Put the text to copy into a <span>
|
|
35
|
+
const span = document.createElement('span');
|
|
36
|
+
span.textContent = text;
|
|
37
|
+
|
|
38
|
+
// Preserve consecutive spaces and newlines
|
|
39
|
+
span.style.whiteSpace = 'pre';
|
|
40
|
+
span.style.webkitUserSelect = 'auto';
|
|
41
|
+
span.style.userSelect = 'all';
|
|
42
|
+
|
|
43
|
+
// Add the <span> to the page
|
|
44
|
+
document.body.appendChild(span);
|
|
45
|
+
|
|
46
|
+
// Make a selection object representing the range of text selected by the user
|
|
47
|
+
const selection = window.getSelection();
|
|
48
|
+
const range = window.document.createRange();
|
|
49
|
+
selection.removeAllRanges();
|
|
50
|
+
range.selectNode(span);
|
|
51
|
+
selection.addRange(range);
|
|
52
|
+
|
|
53
|
+
// Copy text to the clipboard
|
|
54
|
+
let success = false;
|
|
55
|
+
try {
|
|
56
|
+
success = window.document.execCommand('copy');
|
|
57
|
+
} finally {
|
|
58
|
+
// Cleanup
|
|
59
|
+
selection.removeAllRanges();
|
|
60
|
+
window.document.body.removeChild(span);
|
|
61
|
+
}
|
|
62
|
+
if (!success) throw makeError();
|
|
107
63
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
break;
|
|
120
|
-
case 2:
|
|
121
|
-
_context3.p = 2;
|
|
122
|
-
_t = _context3.v;
|
|
123
|
-
_context3.p = 3;
|
|
124
|
-
_context3.n = 4;
|
|
125
|
-
return copyExecCommand(text);
|
|
126
|
-
case 4:
|
|
127
|
-
_context3.n = 6;
|
|
128
|
-
break;
|
|
129
|
-
case 5:
|
|
130
|
-
_context3.p = 5;
|
|
131
|
-
_t2 = _context3.v;
|
|
132
|
-
throw _t2 || _t || makeError();
|
|
133
|
-
case 6:
|
|
134
|
-
return _context3.a(2);
|
|
135
|
-
}
|
|
136
|
-
}, _callee3, null, [[3, 5], [0, 2]]);
|
|
137
|
-
}));
|
|
138
|
-
return _copyToClipboard.apply(this, arguments);
|
|
64
|
+
async function copyToClipboard(text) {
|
|
65
|
+
try {
|
|
66
|
+
await copyClipboardApi(text);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
// ...Otherwise, use document.execCommand() fallback
|
|
69
|
+
try {
|
|
70
|
+
await copyExecCommand(text);
|
|
71
|
+
} catch (err2) {
|
|
72
|
+
throw err2 || err || makeError();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
139
75
|
}
|
|
140
76
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
return acc && newValue[key] === null;
|
|
148
|
-
}, true);
|
|
149
|
-
if (allNull) {
|
|
150
|
-
nullableValue = null;
|
|
151
|
-
}
|
|
77
|
+
const createNullableOnChange = (onChange = null) => newValue => {
|
|
78
|
+
let nullableValue = newValue;
|
|
79
|
+
if (isObject(newValue)) {
|
|
80
|
+
const allNull = Object.keys(newValue).reduce((acc, key) => acc && newValue[key] === null, true);
|
|
81
|
+
if (allNull) {
|
|
82
|
+
nullableValue = null;
|
|
152
83
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
84
|
+
}
|
|
85
|
+
if (onChange !== null) {
|
|
86
|
+
onChange(nullableValue);
|
|
87
|
+
}
|
|
157
88
|
};
|
|
158
89
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
90
|
+
const createUseEvent = eventsManager => (event, callback, enabled = true) => {
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (enabled && eventsManager !== null) {
|
|
93
|
+
eventsManager.subscribe(event, callback);
|
|
94
|
+
}
|
|
95
|
+
return () => {
|
|
163
96
|
if (enabled && eventsManager !== null) {
|
|
164
|
-
eventsManager.
|
|
97
|
+
eventsManager.unsubscribe(event, callback);
|
|
165
98
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
eventsManager.unsubscribe(event, callback);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}, [eventsManager, event, callback, enabled]);
|
|
172
|
-
};
|
|
99
|
+
};
|
|
100
|
+
}, [eventsManager, event, callback, enabled]);
|
|
173
101
|
};
|
|
174
102
|
|
|
175
103
|
function cssEscape(value) {
|
|
@@ -177,121 +105,59 @@ function cssEscape(value) {
|
|
|
177
105
|
}
|
|
178
106
|
|
|
179
107
|
/* eslint-disable */
|
|
180
|
-
|
|
181
|
-
linear:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return x < 0.5 ? 8 * x * x * x * x : 1 - Math.pow(-2 * x + 2, 4) / 2;
|
|
210
|
-
},
|
|
211
|
-
easeInQuint: function easeInQuint(x) {
|
|
212
|
-
return x * x * x * x * x;
|
|
213
|
-
},
|
|
214
|
-
easeOutQuint: function easeOutQuint(x) {
|
|
215
|
-
return 1 - Math.pow(1 - x, 5);
|
|
216
|
-
},
|
|
217
|
-
easeInOutQuint: function easeInOutQuint(x) {
|
|
218
|
-
return x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;
|
|
219
|
-
},
|
|
220
|
-
easeInSine: function easeInSine(x) {
|
|
221
|
-
return 1 - Math.cos(x * Math.PI / 2);
|
|
222
|
-
},
|
|
223
|
-
easeOutSine: function easeOutSine(x) {
|
|
224
|
-
return Math.sin(x * Math.PI / 2);
|
|
225
|
-
},
|
|
226
|
-
easeInOutSine: function easeInOutSine(x) {
|
|
227
|
-
return -(Math.cos(Math.PI * x) - 1) / 2;
|
|
228
|
-
},
|
|
229
|
-
easeInExpo: function easeInExpo(x) {
|
|
230
|
-
return x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
231
|
-
},
|
|
232
|
-
easeOutExpo: function easeOutExpo(x) {
|
|
233
|
-
return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
|
|
234
|
-
},
|
|
235
|
-
easeInOutExpo: function easeInOutExpo(x) {
|
|
236
|
-
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? Math.pow(2, 20 * x - 10) / 2 : (2 - Math.pow(2, -20 * x + 10)) / 2;
|
|
237
|
-
},
|
|
238
|
-
easeInCirc: function easeInCirc(x) {
|
|
239
|
-
return 1 - Math.sqrt(1 - Math.pow(x, 2));
|
|
240
|
-
},
|
|
241
|
-
easeOutCirc: function easeOutCirc(x) {
|
|
242
|
-
return Math.sqrt(1 - Math.pow(x - 1, 2));
|
|
243
|
-
},
|
|
244
|
-
easeInOutCirc: function easeInOutCirc(x) {
|
|
245
|
-
return x < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
|
|
246
|
-
},
|
|
247
|
-
easeInBack: function easeInBack(x) {
|
|
248
|
-
return c3 * x * x * x - c1 * x * x;
|
|
249
|
-
},
|
|
250
|
-
easeOutBack: function easeOutBack(x) {
|
|
251
|
-
return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
|
|
252
|
-
},
|
|
253
|
-
easeInOutBack: function easeInOutBack(x) {
|
|
254
|
-
return x < 0.5 ? Math.pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (Math.pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
|
|
255
|
-
},
|
|
256
|
-
easeInElastic: function easeInElastic(x) {
|
|
257
|
-
return x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4);
|
|
258
|
-
},
|
|
259
|
-
easeOutElastic: function easeOutElastic(x) {
|
|
260
|
-
return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
|
|
261
|
-
},
|
|
262
|
-
easeInOutElastic: function easeInOutElastic(x) {
|
|
263
|
-
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
|
|
264
|
-
}
|
|
108
|
+
const easings = {
|
|
109
|
+
linear: x => x,
|
|
110
|
+
easeInQuad: x => x * x,
|
|
111
|
+
easeOutQuad: x => 1 - (1 - x) * (1 - x),
|
|
112
|
+
easeInOutQuad: x => x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2,
|
|
113
|
+
easeInCubic: x => x * x * x,
|
|
114
|
+
easeOutCubic: x => 1 - (1 - x) ** 3,
|
|
115
|
+
easeInOutCubic: x => x < 0.5 ? 4 * x * x * x : 1 - (-2 * x + 2) ** 3 / 2,
|
|
116
|
+
easeInQuart: x => x * x * x * x,
|
|
117
|
+
easeOutQuart: x => 1 - (1 - x) ** 4,
|
|
118
|
+
easeInOutQuart: x => x < 0.5 ? 8 * x * x * x * x : 1 - (-2 * x + 2) ** 4 / 2,
|
|
119
|
+
easeInQuint: x => x * x * x * x * x,
|
|
120
|
+
easeOutQuint: x => 1 - (1 - x) ** 5,
|
|
121
|
+
easeInOutQuint: x => x < 0.5 ? 16 * x * x * x * x * x : 1 - (-2 * x + 2) ** 5 / 2,
|
|
122
|
+
easeInSine: x => 1 - Math.cos(x * Math.PI / 2),
|
|
123
|
+
easeOutSine: x => Math.sin(x * Math.PI / 2),
|
|
124
|
+
easeInOutSine: x => -(Math.cos(Math.PI * x) - 1) / 2,
|
|
125
|
+
easeInExpo: x => x === 0 ? 0 : 2 ** (10 * x - 10),
|
|
126
|
+
easeOutExpo: x => x === 1 ? 1 : 1 - 2 ** (-10 * x),
|
|
127
|
+
easeInOutExpo: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? 2 ** (20 * x - 10) / 2 : (2 - 2 ** (-20 * x + 10)) / 2,
|
|
128
|
+
easeInCirc: x => 1 - Math.sqrt(1 - x ** 2),
|
|
129
|
+
easeOutCirc: x => Math.sqrt(1 - (x - 1) ** 2),
|
|
130
|
+
easeInOutCirc: x => x < 0.5 ? (1 - Math.sqrt(1 - (2 * x) ** 2)) / 2 : (Math.sqrt(1 - (-2 * x + 2) ** 2) + 1) / 2,
|
|
131
|
+
easeInBack: x => c3 * x * x * x - c1 * x * x,
|
|
132
|
+
easeOutBack: x => 1 + c3 * (x - 1) ** 3 + c1 * (x - 1) ** 2,
|
|
133
|
+
easeInOutBack: x => x < 0.5 ? (2 * x) ** 2 * ((c2 + 1) * 2 * x - c2) / 2 : ((2 * x - 2) ** 2 * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
|
|
134
|
+
easeInElastic: x => x === 0 ? 0 : x === 1 ? 1 : -(2 ** (10 * x - 10)) * Math.sin((x * 10 - 10.75) * c4),
|
|
135
|
+
easeOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : 2 ** (-10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1,
|
|
136
|
+
easeInOutElastic: x => x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(2 ** (20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : 2 ** (-20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1
|
|
265
137
|
};
|
|
266
138
|
|
|
267
|
-
|
|
268
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
269
|
-
var overideAlpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
139
|
+
const getColorAsString = (value = null, overideAlpha = null) => {
|
|
270
140
|
if (value === null) {
|
|
271
141
|
return null;
|
|
272
142
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
color
|
|
278
|
-
|
|
279
|
-
alpha = _ref$alpha === void 0 ? null : _ref$alpha;
|
|
143
|
+
const {
|
|
144
|
+
color = null,
|
|
145
|
+
alpha = null
|
|
146
|
+
} = isString(value) ? {
|
|
147
|
+
color: value
|
|
148
|
+
} : value;
|
|
280
149
|
return alpha !== null || overideAlpha !== null ? tinycolor(color).setAlpha(overideAlpha !== null ? overideAlpha : alpha).toRgbString() : color;
|
|
281
150
|
};
|
|
282
151
|
|
|
283
|
-
|
|
284
|
-
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
285
|
-
var components = arguments.length > 1 ? arguments[1] : undefined;
|
|
286
|
-
var defaultComponent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
152
|
+
const getComponentFromName = (name = null, components, defaultComponent = null) => {
|
|
287
153
|
if (components === null || name === null) {
|
|
288
154
|
return defaultComponent;
|
|
289
155
|
}
|
|
290
|
-
|
|
156
|
+
const pascalName = pascalCase(name);
|
|
291
157
|
return components[pascalName] || components[name] || defaultComponent;
|
|
292
158
|
};
|
|
293
159
|
|
|
294
|
-
|
|
160
|
+
const deviceScreens = [{
|
|
295
161
|
name: 'mobile'
|
|
296
162
|
}, {
|
|
297
163
|
name: 'small',
|
|
@@ -308,299 +174,274 @@ var deviceScreens = [{
|
|
|
308
174
|
}];
|
|
309
175
|
|
|
310
176
|
// eslint-disable-next-line import/prefer-default-export
|
|
311
|
-
|
|
312
|
-
return deviceScreens;
|
|
313
|
-
};
|
|
177
|
+
const getDeviceScreens = () => deviceScreens;
|
|
314
178
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
name = _ref$name === void 0 ? null : _ref$name;
|
|
320
|
-
return displayName || name || 'Component';
|
|
321
|
-
};
|
|
179
|
+
const getDisplayName = ({
|
|
180
|
+
displayName = null,
|
|
181
|
+
name = null
|
|
182
|
+
}) => displayName || name || 'Component';
|
|
322
183
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}, null);
|
|
337
|
-
};
|
|
184
|
+
const getFieldByName = (fields, name) => fields.reduce((foundField, it) => {
|
|
185
|
+
if (foundField !== null) {
|
|
186
|
+
return foundField;
|
|
187
|
+
}
|
|
188
|
+
const {
|
|
189
|
+
name: fieldName = null,
|
|
190
|
+
fields: subFields = []
|
|
191
|
+
} = it;
|
|
192
|
+
if (name !== null && fieldName === name) {
|
|
193
|
+
return it;
|
|
194
|
+
}
|
|
195
|
+
return getFieldByName(subFields, name);
|
|
196
|
+
}, null);
|
|
338
197
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return _getFieldByName([].concat(_toConsumableArray(fieldFields || []), _toConsumableArray(subFields || []), _toConsumableArray(settings || [])), key);
|
|
369
|
-
}, {
|
|
370
|
-
fields: fields
|
|
371
|
-
});
|
|
372
|
-
};
|
|
198
|
+
const getFieldFromPath = (path, fields, fieldManager) => (isArray(path) ? path : [path]).reduce((foundField, key) => {
|
|
199
|
+
if (foundField === null) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const {
|
|
203
|
+
type = null,
|
|
204
|
+
fields: fieldFields = null,
|
|
205
|
+
field = null,
|
|
206
|
+
itemsField = null
|
|
207
|
+
} = foundField;
|
|
208
|
+
const finalType = field !== null ? field.type || type : type;
|
|
209
|
+
const definition = fieldManager.getDefinition(finalType);
|
|
210
|
+
const {
|
|
211
|
+
fields: subFields = null,
|
|
212
|
+
settings = null,
|
|
213
|
+
itemsField: defItemsField = null
|
|
214
|
+
} = finalType !== null ? definition : foundField;
|
|
215
|
+
const finalItemsField = itemsField || defItemsField;
|
|
216
|
+
if (finalItemsField !== null && key.match(/^[0-9]+$/)) {
|
|
217
|
+
return {
|
|
218
|
+
...finalItemsField,
|
|
219
|
+
name: path.join('/'),
|
|
220
|
+
listItems: true
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return getFieldByName([...(fieldFields || []), ...(subFields || []), ...(settings || [])], key);
|
|
224
|
+
}, {
|
|
225
|
+
fields
|
|
226
|
+
});
|
|
373
227
|
|
|
374
|
-
|
|
375
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
228
|
+
const getFileName = (url = null) => {
|
|
376
229
|
if (url === null || typeof url.match === 'undefined') {
|
|
377
230
|
return null;
|
|
378
231
|
}
|
|
379
232
|
return url.match(/([^/]+)(\?.*)?$/)[1] || url;
|
|
380
233
|
};
|
|
381
234
|
|
|
382
|
-
|
|
235
|
+
const getFontFamily = value => {
|
|
383
236
|
if (value == null) {
|
|
384
237
|
return null;
|
|
385
238
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return [name, fallback].filter(
|
|
393
|
-
return it !== null;
|
|
394
|
-
}).map(function (it) {
|
|
395
|
-
return "\"".concat(it, "\"");
|
|
396
|
-
}).join(', ');
|
|
239
|
+
const {
|
|
240
|
+
name,
|
|
241
|
+
fallback = null
|
|
242
|
+
} = isObject(value) ? value : {
|
|
243
|
+
name: value
|
|
244
|
+
};
|
|
245
|
+
return [name, fallback].filter(it => it !== null).map(it => `"${it}"`).join(', ');
|
|
397
246
|
};
|
|
398
247
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
focusable: current && isView,
|
|
424
|
-
openWebView: openWebView,
|
|
425
|
-
enableInteraction: enableInteraction,
|
|
426
|
-
disableInteraction: disableInteraction
|
|
427
|
-
}, otherProps)
|
|
428
|
-
};
|
|
429
|
-
}, [callToAction, isPreview, isView, current, enableInteraction, disableInteraction, otherProps]);
|
|
430
|
-
return footerProps;
|
|
431
|
-
};
|
|
248
|
+
function getFooterProps(footer = {}, {
|
|
249
|
+
isPreview = false,
|
|
250
|
+
isView = false,
|
|
251
|
+
current = false,
|
|
252
|
+
openWebView = false,
|
|
253
|
+
enableInteraction = true,
|
|
254
|
+
disableInteraction = false,
|
|
255
|
+
...otherProps
|
|
256
|
+
} = {}) {
|
|
257
|
+
const {
|
|
258
|
+
callToAction = null
|
|
259
|
+
} = footer || {};
|
|
260
|
+
return {
|
|
261
|
+
callToAction: {
|
|
262
|
+
...callToAction,
|
|
263
|
+
animationDisabled: isPreview,
|
|
264
|
+
focusable: current && isView,
|
|
265
|
+
openWebView,
|
|
266
|
+
enableInteraction,
|
|
267
|
+
disableInteraction,
|
|
268
|
+
...otherProps
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
432
272
|
|
|
433
|
-
|
|
434
|
-
return layout.map(function (it) {
|
|
435
|
-
return "".concat(it.rows, "_").concat(it.columns.join('_'));
|
|
436
|
-
}).join('|');
|
|
437
|
-
};
|
|
273
|
+
const getGridLayoutName = layout => layout.map(it => `${it.rows}_${it.columns.join('_')}`).join('|');
|
|
438
274
|
|
|
439
|
-
|
|
440
|
-
|
|
275
|
+
const getRemainder = number => {
|
|
276
|
+
const remainder = number - Math.floor(number);
|
|
441
277
|
return remainder.toFixed(4);
|
|
442
278
|
};
|
|
443
|
-
|
|
279
|
+
const largestRemainderRound = (numbers, desiredTotal) => {
|
|
444
280
|
if (!isArray(numbers) || numbers.length < 1) return numbers;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
});
|
|
454
|
-
var lowerSum = result.reduce(function (sum, current) {
|
|
455
|
-
return sum + current.floor;
|
|
456
|
-
}, 0);
|
|
457
|
-
var delta = desiredTotal - lowerSum;
|
|
458
|
-
for (var i = 0; i < delta; i += 1) {
|
|
281
|
+
const result = numbers.map((number, index) => ({
|
|
282
|
+
floor: Math.floor(number) || 0,
|
|
283
|
+
remainder: getRemainder(number),
|
|
284
|
+
index
|
|
285
|
+
})).sort((a, b) => b.remainder - a.remainder);
|
|
286
|
+
const lowerSum = result.reduce((sum, current) => sum + current.floor, 0);
|
|
287
|
+
const delta = desiredTotal - lowerSum;
|
|
288
|
+
for (let i = 0; i < delta; i += 1) {
|
|
459
289
|
if (result[i]) {
|
|
460
290
|
result[i].floor += 1;
|
|
461
291
|
}
|
|
462
292
|
}
|
|
463
|
-
return result.sort(
|
|
464
|
-
return a.index - b.index;
|
|
465
|
-
}).map(function (res) {
|
|
466
|
-
return res.floor;
|
|
467
|
-
});
|
|
293
|
+
return result.sort((a, b) => a.index - b.index).map(res => res.floor);
|
|
468
294
|
};
|
|
469
295
|
|
|
470
|
-
|
|
471
|
-
var getLayersFromBackground = function getLayersFromBackground() {
|
|
472
|
-
var background = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
296
|
+
const getLayersFromBackground = (background = null) => {
|
|
473
297
|
if (background === null) {
|
|
474
298
|
return [];
|
|
475
299
|
}
|
|
476
|
-
return (isArray(background) ? background : [background]).reduce(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
_ref$color = _ref.color,
|
|
484
|
-
color = _ref$color === void 0 ? null : _ref$color,
|
|
485
|
-
data = _objectWithoutProperties(_ref, _excluded);
|
|
300
|
+
return (isArray(background) ? background : [background]).reduce((layers, {
|
|
301
|
+
image = null,
|
|
302
|
+
video = null,
|
|
303
|
+
media = null,
|
|
304
|
+
color = null,
|
|
305
|
+
...data
|
|
306
|
+
}) => {
|
|
486
307
|
if (image === null && video === null && color === null) {
|
|
487
308
|
return layers;
|
|
488
309
|
}
|
|
489
310
|
if (image !== null && video !== null) {
|
|
490
|
-
return [
|
|
491
|
-
media: image
|
|
492
|
-
|
|
311
|
+
return [...layers, {
|
|
312
|
+
media: image,
|
|
313
|
+
...data
|
|
314
|
+
}, {
|
|
493
315
|
media: video,
|
|
494
|
-
color
|
|
495
|
-
|
|
316
|
+
color,
|
|
317
|
+
...data
|
|
318
|
+
}];
|
|
496
319
|
}
|
|
497
|
-
return [
|
|
320
|
+
return [...layers, {
|
|
498
321
|
media: media || image || video,
|
|
499
|
-
color
|
|
500
|
-
|
|
322
|
+
color,
|
|
323
|
+
...data
|
|
324
|
+
}];
|
|
501
325
|
}, []);
|
|
502
326
|
};
|
|
503
327
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
328
|
+
const getMediaFilesAsArray = files => files !== null && isArray(files) ? files : Object.keys(files || {}).reduce((newFiles, key) => [...newFiles, {
|
|
329
|
+
handle: key,
|
|
330
|
+
...files[key]
|
|
331
|
+
}], []);
|
|
332
|
+
|
|
333
|
+
function getMediaThumbnail(media, thumbnail = null) {
|
|
334
|
+
if (isObject(thumbnail)) {
|
|
335
|
+
return thumbnail;
|
|
336
|
+
}
|
|
337
|
+
const {
|
|
338
|
+
thumbnail_url: defaultThumbnailUrl = null,
|
|
339
|
+
files = null,
|
|
340
|
+
metadata = null
|
|
341
|
+
} = media || {};
|
|
342
|
+
const {
|
|
343
|
+
width: mediaWidth,
|
|
344
|
+
height: mediaHeight
|
|
345
|
+
} = metadata || {};
|
|
346
|
+
const filesArray = getMediaFilesAsArray(files) || [];
|
|
347
|
+
const {
|
|
348
|
+
url = null
|
|
349
|
+
} = (thumbnail !== null ? filesArray.find(({
|
|
350
|
+
handle
|
|
351
|
+
}) => handle === thumbnail) || null : null) || {};
|
|
352
|
+
return url !== null || defaultThumbnailUrl !== null ? {
|
|
353
|
+
url: url || defaultThumbnailUrl,
|
|
354
|
+
metadata: {
|
|
355
|
+
width: mediaWidth,
|
|
356
|
+
height: mediaHeight
|
|
357
|
+
}
|
|
358
|
+
} : null;
|
|
359
|
+
}
|
|
511
360
|
|
|
512
361
|
// eslint-disable-next-line import/prefer-default-export
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
defaultUrl = _ref2$url === void 0 ? null : _ref2$url,
|
|
529
|
-
_ref2$webp_url = _ref2.webp_url,
|
|
530
|
-
defaultWebpUrl = _ref2$webp_url === void 0 ? null : _ref2$webp_url,
|
|
531
|
-
_ref2$metadata = _ref2.metadata,
|
|
532
|
-
_ref2$metadata2 = _ref2$metadata === void 0 ? {} : _ref2$metadata,
|
|
533
|
-
imgWidth = _ref2$metadata2.width,
|
|
534
|
-
imgHeight = _ref2$metadata2.height;
|
|
535
|
-
var finalDefaultUrl = supportsWebp && defaultWebpUrl !== null ? defaultWebpUrl : defaultUrl;
|
|
362
|
+
const getOptimalImageUrl = (media = null, containerWidth = null, containerHeight = null, {
|
|
363
|
+
resolution = 1,
|
|
364
|
+
maxDiff = 800,
|
|
365
|
+
supportsWebp = false
|
|
366
|
+
} = {}) => {
|
|
367
|
+
const {
|
|
368
|
+
sizes = null,
|
|
369
|
+
url: defaultUrl = null,
|
|
370
|
+
webp_url: defaultWebpUrl = null,
|
|
371
|
+
metadata: {
|
|
372
|
+
width: imgWidth,
|
|
373
|
+
height: imgHeight
|
|
374
|
+
} = {}
|
|
375
|
+
} = media || {};
|
|
376
|
+
const finalDefaultUrl = supportsWebp && defaultWebpUrl !== null ? defaultWebpUrl : defaultUrl;
|
|
536
377
|
if (sizes === null || containerWidth === null && containerHeight === null) {
|
|
537
378
|
return finalDefaultUrl;
|
|
538
379
|
}
|
|
539
|
-
|
|
380
|
+
const finalSizes = {
|
|
540
381
|
original: {
|
|
541
382
|
url: finalDefaultUrl,
|
|
542
383
|
width: imgWidth,
|
|
543
384
|
height: imgHeight
|
|
385
|
+
},
|
|
386
|
+
...sizes
|
|
387
|
+
};
|
|
388
|
+
const finalContainerWidth = containerWidth !== null && resolution !== null ? containerWidth * resolution : containerWidth;
|
|
389
|
+
const finalContainerHeight = containerHeight !== null && resolution !== null ? containerHeight * resolution : containerHeight;
|
|
390
|
+
const {
|
|
391
|
+
url: finalUrl
|
|
392
|
+
} = Object.keys(finalSizes).reduce((acc, key) => {
|
|
393
|
+
const {
|
|
394
|
+
diff: currentDiff,
|
|
395
|
+
isLarger: currentIsLarger,
|
|
396
|
+
size: currentSize
|
|
397
|
+
} = acc;
|
|
398
|
+
const {
|
|
399
|
+
url,
|
|
400
|
+
webp_url: webpUrl = null,
|
|
401
|
+
width = null,
|
|
402
|
+
height = null
|
|
403
|
+
} = finalSizes[key];
|
|
404
|
+
const sizeUrl = supportsWebp && webpUrl !== null ? webpUrl : url;
|
|
405
|
+
const diffWidth = width !== null && finalContainerWidth !== null ? width - finalContainerWidth : null;
|
|
406
|
+
const diffHeight = height !== null && finalContainerHeight !== null ? height - finalContainerHeight : null;
|
|
407
|
+
const isLarger = (diffWidth === null || diffWidth >= 0) && (diffHeight === null || diffHeight >= 0);
|
|
408
|
+
let diff = [diffWidth, diffHeight].reduce((total, value) => value !== null ? (total || 0) + Math.abs(value) : total, null);
|
|
409
|
+
if (diff === null) {
|
|
410
|
+
diff = Infinity;
|
|
544
411
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
var sizeIsLarger = size > currentSize;
|
|
572
|
-
if (
|
|
573
|
-
// Difference is lower and image is larger
|
|
574
|
-
diff < currentDiff && isLarger ||
|
|
575
|
-
// Difference is lower and current is not larger or diff is greater than max
|
|
576
|
-
diff < currentDiff && (!currentIsLarger && sizeIsLarger || currentDiff > maxDiff) ||
|
|
577
|
-
// Image is larger and diff is smaller than max
|
|
578
|
-
diff <= maxDiff && !currentIsLarger && isLarger ||
|
|
579
|
-
// Image is larger than previous
|
|
580
|
-
diff <= maxDiff && !currentIsLarger && !isLarger && sizeIsLarger) {
|
|
581
|
-
return {
|
|
582
|
-
key: key,
|
|
583
|
-
url: sizeUrl,
|
|
584
|
-
diff: diff,
|
|
585
|
-
isLarger: isLarger
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
return acc;
|
|
589
|
-
}, {
|
|
590
|
-
key: null,
|
|
591
|
-
url: finalDefaultUrl,
|
|
592
|
-
diff: Infinity,
|
|
593
|
-
isLarger: false,
|
|
594
|
-
size: 0
|
|
595
|
-
}),
|
|
596
|
-
finalUrl = _Object$keys$reduce.url;
|
|
412
|
+
const size = (width || 0) + (height || 0);
|
|
413
|
+
const sizeIsLarger = size > currentSize;
|
|
414
|
+
if (
|
|
415
|
+
// Difference is lower and image is larger
|
|
416
|
+
diff < currentDiff && isLarger ||
|
|
417
|
+
// Difference is lower and current is not larger or diff is greater than max
|
|
418
|
+
diff < currentDiff && (!currentIsLarger && sizeIsLarger || currentDiff > maxDiff) ||
|
|
419
|
+
// Image is larger and diff is smaller than max
|
|
420
|
+
diff <= maxDiff && !currentIsLarger && isLarger ||
|
|
421
|
+
// Image is larger than previous
|
|
422
|
+
diff <= maxDiff && !currentIsLarger && !isLarger && sizeIsLarger) {
|
|
423
|
+
return {
|
|
424
|
+
key,
|
|
425
|
+
url: sizeUrl,
|
|
426
|
+
diff,
|
|
427
|
+
isLarger
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return acc;
|
|
431
|
+
}, {
|
|
432
|
+
key: null,
|
|
433
|
+
url: finalDefaultUrl,
|
|
434
|
+
diff: Infinity,
|
|
435
|
+
isLarger: false,
|
|
436
|
+
size: 0
|
|
437
|
+
});
|
|
597
438
|
return finalUrl;
|
|
598
439
|
};
|
|
599
440
|
|
|
600
|
-
|
|
601
|
-
|
|
441
|
+
const getSecondsFromTime = time => {
|
|
442
|
+
const t = time.split(':');
|
|
602
443
|
try {
|
|
603
|
-
|
|
444
|
+
let s = t[2].split(',');
|
|
604
445
|
if (s.length === 1) {
|
|
605
446
|
s = t[2].split('.');
|
|
606
447
|
}
|
|
@@ -610,72 +451,62 @@ var getSecondsFromTime = function getSecondsFromTime(time) {
|
|
|
610
451
|
}
|
|
611
452
|
};
|
|
612
453
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
"value": "Parameters"
|
|
622
|
-
}]
|
|
623
|
-
})
|
|
624
|
-
};
|
|
625
|
-
};
|
|
454
|
+
const getScreenExtraField = intl => ({
|
|
455
|
+
name: 'parameters',
|
|
456
|
+
type: 'parameters',
|
|
457
|
+
label: intl.formatMessage({
|
|
458
|
+
id: "8A8cuq",
|
|
459
|
+
defaultMessage: "Parameters"
|
|
460
|
+
})
|
|
461
|
+
});
|
|
626
462
|
|
|
627
463
|
function getScreenFieldsWithStates(definition) {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
states = _ref$states === void 0 ? null : _ref$states;
|
|
464
|
+
const {
|
|
465
|
+
fields: screenFields = null,
|
|
466
|
+
states = null
|
|
467
|
+
} = definition || {};
|
|
633
468
|
if (states === null) {
|
|
634
469
|
return screenFields;
|
|
635
470
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
id
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
_ref2$defaultValue = _ref2.defaultValue,
|
|
647
|
-
defaultValue = _ref2$defaultValue === void 0 ? null : _ref2$defaultValue;
|
|
648
|
-
return [].concat(_toConsumableArray(statesFields), _toConsumableArray(repeatable ? [{
|
|
471
|
+
const extraFields = states.reduce((statesFields, current) => {
|
|
472
|
+
const {
|
|
473
|
+
id,
|
|
474
|
+
fields = [],
|
|
475
|
+
repeatable = false,
|
|
476
|
+
fieldName = null,
|
|
477
|
+
label,
|
|
478
|
+
defaultValue = null
|
|
479
|
+
} = current || {};
|
|
480
|
+
return [...statesFields, ...(repeatable ? [{
|
|
649
481
|
type: 'items',
|
|
650
482
|
name: fieldName || id,
|
|
651
|
-
label
|
|
652
|
-
defaultValue
|
|
483
|
+
label,
|
|
484
|
+
defaultValue,
|
|
653
485
|
stateId: id,
|
|
654
486
|
itemsField: {
|
|
655
|
-
label
|
|
487
|
+
label,
|
|
656
488
|
type: 'fields',
|
|
657
|
-
fields
|
|
489
|
+
fields
|
|
658
490
|
}
|
|
659
|
-
}] : []),
|
|
491
|
+
}] : []), ...(!repeatable && fieldName !== null ? [{
|
|
660
492
|
type: 'fields',
|
|
661
493
|
name: fieldName,
|
|
662
494
|
stateId: id,
|
|
663
|
-
fields
|
|
664
|
-
}] : []),
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}) : []));
|
|
495
|
+
fields
|
|
496
|
+
}] : []), ...(!repeatable && fieldName === null ? fields.map(it => ({
|
|
497
|
+
...it,
|
|
498
|
+
stateId: id
|
|
499
|
+
})) : [])];
|
|
669
500
|
}, []);
|
|
670
|
-
return [
|
|
501
|
+
return [...extraFields, ...screenFields];
|
|
671
502
|
}
|
|
672
503
|
|
|
673
504
|
function getShadowCoords(angle, distance) {
|
|
674
|
-
|
|
675
|
-
|
|
505
|
+
const x = (Math.cos(angle) * distance).toFixed(3);
|
|
506
|
+
const y = (Math.sin(angle) * distance).toFixed(3);
|
|
676
507
|
return {
|
|
677
|
-
x
|
|
678
|
-
y
|
|
508
|
+
x,
|
|
509
|
+
y
|
|
679
510
|
};
|
|
680
511
|
}
|
|
681
512
|
|
|
@@ -691,18 +522,16 @@ function getAlignItems(vertical) {
|
|
|
691
522
|
if (vertical === 'bottom') return 'flex-end';
|
|
692
523
|
return null;
|
|
693
524
|
}
|
|
694
|
-
|
|
695
|
-
var invertAxis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
696
|
-
var defaultAlignment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
525
|
+
const getStyleFromAlignment = (value, invertAxis = false, defaultAlignment = null) => {
|
|
697
526
|
if (value === null) {
|
|
698
527
|
return null;
|
|
699
528
|
}
|
|
700
|
-
|
|
701
|
-
horizontal =
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
529
|
+
const {
|
|
530
|
+
horizontal = null,
|
|
531
|
+
vertical = null
|
|
532
|
+
} = value;
|
|
533
|
+
const justifyContent = getJustifyContent(horizontal);
|
|
534
|
+
const alignItems = getAlignItems(vertical);
|
|
706
535
|
if (invertAxis) {
|
|
707
536
|
return {
|
|
708
537
|
justifyContent: alignItems || defaultAlignment,
|
|
@@ -715,417 +544,419 @@ var getStyleFromAlignment = function getStyleFromAlignment(value) {
|
|
|
715
544
|
};
|
|
716
545
|
};
|
|
717
546
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
return color !== null ? _defineProperty({}, property, color) : null;
|
|
547
|
+
const getStyleFromColor = (value = null, property = 'backgroundColor', overideAlpha = null) => {
|
|
548
|
+
const color = getColorAsString(value, overideAlpha);
|
|
549
|
+
return color !== null ? {
|
|
550
|
+
[property]: color
|
|
551
|
+
} : null;
|
|
724
552
|
};
|
|
725
553
|
|
|
726
|
-
|
|
554
|
+
const getStyleFromBorder = value => {
|
|
727
555
|
if (value == null) {
|
|
728
556
|
return null;
|
|
729
557
|
}
|
|
730
|
-
|
|
731
|
-
width =
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
borderStyle
|
|
740
|
-
|
|
558
|
+
const {
|
|
559
|
+
width = null,
|
|
560
|
+
style: borderStyle = null,
|
|
561
|
+
color = null
|
|
562
|
+
} = value;
|
|
563
|
+
return {
|
|
564
|
+
...(width !== null ? {
|
|
565
|
+
borderWidth: width
|
|
566
|
+
} : null),
|
|
567
|
+
...(borderStyle !== null ? {
|
|
568
|
+
borderStyle
|
|
569
|
+
} : null),
|
|
570
|
+
...getStyleFromColor(color, 'borderColor')
|
|
571
|
+
};
|
|
741
572
|
};
|
|
742
573
|
|
|
743
|
-
|
|
574
|
+
const getStyleFromShadow = value => {
|
|
744
575
|
if (value == null) {
|
|
745
576
|
return null;
|
|
746
577
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
shadowBlur = _ref$shadowBlur === void 0 ? null : _ref$shadowBlur,
|
|
754
|
-
_ref$shadowColor = _ref.shadowColor,
|
|
755
|
-
shadowColor = _ref$shadowColor === void 0 ? null : _ref$shadowColor;
|
|
578
|
+
const {
|
|
579
|
+
shadowAngle = null,
|
|
580
|
+
shadowDistance = null,
|
|
581
|
+
shadowBlur = null,
|
|
582
|
+
shadowColor = null
|
|
583
|
+
} = value || {};
|
|
756
584
|
if (!shadowAngle) return null;
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
x
|
|
761
|
-
y
|
|
762
|
-
|
|
585
|
+
const blur = shadowBlur || '0';
|
|
586
|
+
const color = getColorAsString(shadowColor) || '#000000';
|
|
587
|
+
const {
|
|
588
|
+
x,
|
|
589
|
+
y
|
|
590
|
+
} = getShadowCoords(shadowAngle, shadowDistance);
|
|
591
|
+
const boxShadow = `${x}px ${y}px ${blur}px 0 ${color}`;
|
|
763
592
|
return {
|
|
764
|
-
boxShadow
|
|
593
|
+
boxShadow
|
|
765
594
|
};
|
|
766
595
|
};
|
|
767
596
|
|
|
768
597
|
// @todo hmm, gotta find a better way to handle this
|
|
769
|
-
|
|
598
|
+
const getStyleFromBox = value => {
|
|
770
599
|
if (value === null) {
|
|
771
600
|
return null;
|
|
772
601
|
}
|
|
773
|
-
|
|
774
|
-
backgroundColor =
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
borderStyle = _value$borderStyle === void 0 ? null : _value$borderStyle,
|
|
791
|
-
_value$borderColor = value.borderColor,
|
|
792
|
-
borderColor = _value$borderColor === void 0 ? null : _value$borderColor,
|
|
793
|
-
_value$shadowAngle = value.shadowAngle,
|
|
794
|
-
shadowAngle = _value$shadowAngle === void 0 ? null : _value$shadowAngle,
|
|
795
|
-
_value$shadowDistance = value.shadowDistance,
|
|
796
|
-
shadowDistance = _value$shadowDistance === void 0 ? null : _value$shadowDistance,
|
|
797
|
-
_value$shadowBlur = value.shadowBlur,
|
|
798
|
-
shadowBlur = _value$shadowBlur === void 0 ? null : _value$shadowBlur,
|
|
799
|
-
_value$shadowColor = value.shadowColor,
|
|
800
|
-
shadowColor = _value$shadowColor === void 0 ? null : _value$shadowColor;
|
|
801
|
-
var border = {
|
|
602
|
+
const {
|
|
603
|
+
backgroundColor = null,
|
|
604
|
+
borderRadius = null,
|
|
605
|
+
padding = null,
|
|
606
|
+
paddingTop = null,
|
|
607
|
+
paddingRight = null,
|
|
608
|
+
paddingBottom = null,
|
|
609
|
+
paddingLeft = null,
|
|
610
|
+
borderWidth = null,
|
|
611
|
+
borderStyle = null,
|
|
612
|
+
borderColor = null,
|
|
613
|
+
shadowAngle = null,
|
|
614
|
+
shadowDistance = null,
|
|
615
|
+
shadowBlur = null,
|
|
616
|
+
shadowColor = null
|
|
617
|
+
} = value;
|
|
618
|
+
const border = {
|
|
802
619
|
width: borderWidth,
|
|
803
620
|
style: borderStyle,
|
|
804
621
|
color: borderColor
|
|
805
622
|
};
|
|
806
|
-
|
|
807
|
-
shadowAngle
|
|
808
|
-
shadowDistance
|
|
809
|
-
shadowBlur
|
|
810
|
-
shadowColor
|
|
623
|
+
const shadow = {
|
|
624
|
+
shadowAngle,
|
|
625
|
+
shadowDistance,
|
|
626
|
+
shadowBlur,
|
|
627
|
+
shadowColor
|
|
811
628
|
};
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
var rightVal = paddingRight || paddingValueRight;
|
|
829
|
-
var bottomVal = paddingBottom || paddingValueBottom;
|
|
830
|
-
var leftVal = paddingLeft || paddingValueLeft;
|
|
831
|
-
var hasAnyIndividual = topVal !== null || rightVal !== null || bottomVal !== null || leftVal !== null;
|
|
629
|
+
const {
|
|
630
|
+
top: paddingValueTop = null,
|
|
631
|
+
right: paddingValueRight = null,
|
|
632
|
+
bottom: paddingValueBottom = null,
|
|
633
|
+
left: paddingValueLeft = null,
|
|
634
|
+
padding: paddingValue = null
|
|
635
|
+
} = isObject(padding) ? padding : {
|
|
636
|
+
padding
|
|
637
|
+
};
|
|
638
|
+
const basePadding = padding || paddingValue;
|
|
639
|
+
const hasBasePadding = basePadding !== null;
|
|
640
|
+
const topVal = paddingTop || paddingValueTop;
|
|
641
|
+
const rightVal = paddingRight || paddingValueRight;
|
|
642
|
+
const bottomVal = paddingBottom || paddingValueBottom;
|
|
643
|
+
const leftVal = paddingLeft || paddingValueLeft;
|
|
644
|
+
const hasAnyIndividual = topVal !== null || rightVal !== null || bottomVal !== null || leftVal !== null;
|
|
832
645
|
|
|
833
646
|
// Avoid mixing shorthand `padding` with longhand `paddingTop`/etc — React warns about this
|
|
834
|
-
|
|
835
|
-
paddingTop: topVal
|
|
836
|
-
paddingRight: rightVal
|
|
837
|
-
paddingBottom: bottomVal
|
|
838
|
-
paddingLeft: leftVal
|
|
839
|
-
} :
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
647
|
+
const paddingStyles = hasBasePadding && hasAnyIndividual ? {
|
|
648
|
+
paddingTop: topVal ?? basePadding,
|
|
649
|
+
paddingRight: rightVal ?? basePadding,
|
|
650
|
+
paddingBottom: bottomVal ?? basePadding,
|
|
651
|
+
paddingLeft: leftVal ?? basePadding
|
|
652
|
+
} : {
|
|
653
|
+
...(hasBasePadding ? {
|
|
654
|
+
padding: basePadding
|
|
655
|
+
} : null),
|
|
656
|
+
...(topVal !== null ? {
|
|
657
|
+
paddingTop: topVal
|
|
658
|
+
} : null),
|
|
659
|
+
...(rightVal !== null ? {
|
|
660
|
+
paddingRight: rightVal
|
|
661
|
+
} : null),
|
|
662
|
+
...(bottomVal !== null ? {
|
|
663
|
+
paddingBottom: bottomVal
|
|
664
|
+
} : null),
|
|
665
|
+
...(leftVal !== null ? {
|
|
666
|
+
paddingLeft: leftVal
|
|
667
|
+
} : null)
|
|
668
|
+
};
|
|
669
|
+
return {
|
|
670
|
+
...getStyleFromColor(backgroundColor, 'backgroundColor'),
|
|
671
|
+
...(borderRadius !== null ? {
|
|
672
|
+
borderRadius
|
|
673
|
+
} : null),
|
|
674
|
+
...getStyleFromBorder(border),
|
|
675
|
+
...getStyleFromShadow(shadow),
|
|
676
|
+
...paddingStyles
|
|
677
|
+
};
|
|
853
678
|
};
|
|
854
679
|
|
|
855
|
-
|
|
680
|
+
const getStyleFromContainer = value => {
|
|
856
681
|
if (value == null) {
|
|
857
682
|
return null;
|
|
858
683
|
}
|
|
859
|
-
|
|
860
|
-
size =
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
width =
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
return
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
684
|
+
const {
|
|
685
|
+
size = {},
|
|
686
|
+
backgroundColor = null
|
|
687
|
+
} = value;
|
|
688
|
+
const {
|
|
689
|
+
width = null,
|
|
690
|
+
height = null
|
|
691
|
+
} = size;
|
|
692
|
+
return {
|
|
693
|
+
// DO NOT OVERRIDE
|
|
694
|
+
...(width ? {
|
|
695
|
+
width: `${width}%`
|
|
696
|
+
} : null),
|
|
697
|
+
...(height ? {
|
|
698
|
+
height: `${height}%`
|
|
699
|
+
} : null),
|
|
700
|
+
...getStyleFromColor(backgroundColor, 'backgroundColor')
|
|
701
|
+
};
|
|
872
702
|
};
|
|
873
703
|
|
|
874
|
-
|
|
704
|
+
const getStyleFromHighlight = value => {
|
|
875
705
|
if (value == null) {
|
|
876
706
|
return null;
|
|
877
707
|
}
|
|
878
|
-
|
|
879
|
-
textColor =
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
return color !== null || textColor !== null ?
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
708
|
+
const {
|
|
709
|
+
textColor = null,
|
|
710
|
+
color = null
|
|
711
|
+
} = value;
|
|
712
|
+
const colorString = color !== null ? getColorAsString(color) : null;
|
|
713
|
+
const boxShadow = colorString !== null ? `0.05em 0px 0px ${colorString}, -0.05em 0px 0px ${colorString}` : null;
|
|
714
|
+
return color !== null || textColor !== null ? {
|
|
715
|
+
...(color !== null ? getStyleFromColor(color, 'backgroundColor') : null),
|
|
716
|
+
...(textColor !== null ? getStyleFromColor(textColor, 'color') : null),
|
|
717
|
+
...(color !== null ? {
|
|
718
|
+
boxShadow,
|
|
719
|
+
mozBoxShadow: boxShadow,
|
|
720
|
+
msBoxShadow: boxShadow,
|
|
721
|
+
webkitBoxShadow: boxShadow
|
|
722
|
+
} : null)
|
|
723
|
+
} : null;
|
|
890
724
|
};
|
|
891
725
|
|
|
892
|
-
|
|
726
|
+
const getStyleFromImage = value => {
|
|
893
727
|
if (value == null) {
|
|
894
728
|
return null;
|
|
895
729
|
}
|
|
896
|
-
|
|
897
|
-
fit =
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
size =
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
axisAlign =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
return
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
730
|
+
const {
|
|
731
|
+
fit = {},
|
|
732
|
+
backgroundColor = null
|
|
733
|
+
} = value;
|
|
734
|
+
const {
|
|
735
|
+
size = null,
|
|
736
|
+
position = {}
|
|
737
|
+
} = fit;
|
|
738
|
+
const {
|
|
739
|
+
axisAlign = null,
|
|
740
|
+
crossAlign = null
|
|
741
|
+
} = position;
|
|
742
|
+
return {
|
|
743
|
+
...(size !== null ? {
|
|
744
|
+
objectFit: size
|
|
745
|
+
} : null),
|
|
746
|
+
...(axisAlign !== null && crossAlign !== null ? {
|
|
747
|
+
objectPosition: `${axisAlign} ${crossAlign}`
|
|
748
|
+
} : null),
|
|
749
|
+
...getStyleFromColor(backgroundColor, 'backgroundColor')
|
|
750
|
+
};
|
|
913
751
|
};
|
|
914
752
|
|
|
915
|
-
|
|
753
|
+
const getStyleFromLink = value => {
|
|
916
754
|
if (value == null) {
|
|
917
755
|
return null;
|
|
918
756
|
}
|
|
919
|
-
|
|
920
|
-
color =
|
|
921
|
-
fontStyle
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
italic =
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
757
|
+
const {
|
|
758
|
+
color = null,
|
|
759
|
+
fontStyle
|
|
760
|
+
} = value;
|
|
761
|
+
const {
|
|
762
|
+
italic = false,
|
|
763
|
+
bold = false,
|
|
764
|
+
underline = false
|
|
765
|
+
} = fontStyle || {};
|
|
766
|
+
return {
|
|
767
|
+
...(color !== null ? getStyleFromColor(color, 'color') : null),
|
|
768
|
+
...(italic ? {
|
|
769
|
+
fontStyle: 'italic'
|
|
770
|
+
} : null),
|
|
771
|
+
...(bold ? {
|
|
772
|
+
fontWeight: 'bold'
|
|
773
|
+
} : null),
|
|
774
|
+
...(underline ? {
|
|
775
|
+
textDecoration: 'underline'
|
|
776
|
+
} : null)
|
|
777
|
+
};
|
|
936
778
|
};
|
|
937
779
|
|
|
938
|
-
|
|
780
|
+
const getStyleFromText = value => {
|
|
939
781
|
if (value == null) {
|
|
940
782
|
return null;
|
|
941
783
|
}
|
|
942
|
-
|
|
943
|
-
fontFamily =
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
784
|
+
const {
|
|
785
|
+
fontFamily = null,
|
|
786
|
+
fontSize = null,
|
|
787
|
+
fontStyle = null,
|
|
788
|
+
fontWeight = null,
|
|
789
|
+
lineHeight = null,
|
|
790
|
+
letterSpacing = null,
|
|
791
|
+
align: textAlign = null,
|
|
792
|
+
color = null
|
|
793
|
+
} = value;
|
|
794
|
+
const {
|
|
795
|
+
italic = false,
|
|
796
|
+
bold = false,
|
|
797
|
+
underline = false,
|
|
798
|
+
transform: textTransform = null,
|
|
799
|
+
outline = false
|
|
800
|
+
} = fontStyle || {};
|
|
801
|
+
return {
|
|
802
|
+
fontFamily: getFontFamily(fontFamily),
|
|
803
|
+
...(fontSize !== null ? {
|
|
804
|
+
fontSize
|
|
805
|
+
} : null),
|
|
806
|
+
...(italic ? {
|
|
807
|
+
fontStyle: 'italic'
|
|
808
|
+
} : null),
|
|
809
|
+
...(bold ? {
|
|
810
|
+
fontWeight: 'bold'
|
|
811
|
+
} : null),
|
|
812
|
+
...(fontWeight !== null ? {
|
|
813
|
+
fontWeight
|
|
814
|
+
} : null),
|
|
815
|
+
...(underline ? {
|
|
816
|
+
textDecoration: 'underline'
|
|
817
|
+
} : null),
|
|
818
|
+
...(textTransform !== null ? {
|
|
819
|
+
textTransform
|
|
820
|
+
} : null),
|
|
821
|
+
...(textAlign !== null ? {
|
|
822
|
+
textAlign
|
|
823
|
+
} : null),
|
|
824
|
+
...(lineHeight !== null ? {
|
|
825
|
+
lineHeight
|
|
826
|
+
} : null),
|
|
827
|
+
...(letterSpacing !== null ? {
|
|
828
|
+
letterSpacing
|
|
829
|
+
} : null),
|
|
830
|
+
...getStyleFromColor(color, 'color'),
|
|
831
|
+
...(outline ? {
|
|
832
|
+
WebkitTextStroke: `2px ${getColorAsString(color, 'color')}`,
|
|
833
|
+
color: 'transparent'
|
|
834
|
+
} : null)
|
|
835
|
+
};
|
|
993
836
|
};
|
|
994
837
|
|
|
995
|
-
|
|
838
|
+
const getStyleFromMargin = value => {
|
|
996
839
|
if (value == null) {
|
|
997
840
|
return null;
|
|
998
841
|
}
|
|
999
|
-
|
|
1000
|
-
marginTop =
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
return
|
|
1004
|
-
marginTop
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
842
|
+
const {
|
|
843
|
+
top: marginTop = null,
|
|
844
|
+
bottom: marginBottom = null
|
|
845
|
+
} = value;
|
|
846
|
+
return {
|
|
847
|
+
...(marginTop !== null ? {
|
|
848
|
+
marginTop
|
|
849
|
+
} : null),
|
|
850
|
+
...(marginBottom !== null ? {
|
|
851
|
+
marginBottom
|
|
852
|
+
} : null)
|
|
853
|
+
};
|
|
1008
854
|
};
|
|
1009
855
|
|
|
1010
856
|
// const possibleMimes = ['video/webm', 'video/mp4', 'video/ogg', 'application/vnd.apple.mpegurl'];
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
function getVideoSupportedMimes() {
|
|
1014
|
-
var mimes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : possibleMimes;
|
|
857
|
+
const possibleMimes = ['video/mp4'];
|
|
858
|
+
let supportedMimes = null;
|
|
859
|
+
function getVideoSupportedMimes(mimes = possibleMimes) {
|
|
1015
860
|
if (supportedMimes === null) {
|
|
1016
|
-
|
|
1017
|
-
supportedMimes = (mimes || possibleMimes).filter(
|
|
1018
|
-
return video.canPlayType(mime) !== '';
|
|
1019
|
-
});
|
|
861
|
+
const video = document.createElement('video');
|
|
862
|
+
supportedMimes = (mimes || possibleMimes).filter(mime => video.canPlayType(mime) !== '');
|
|
1020
863
|
}
|
|
1021
864
|
return supportedMimes;
|
|
1022
865
|
}
|
|
1023
866
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
var _ref = layout !== null && layout.indexOf('-') !== false ? layout.split('-') : [layout, null, null],
|
|
1027
|
-
_ref2 = _slicedToArray(_ref, 3),
|
|
1028
|
-
horizontal = _ref2[0],
|
|
1029
|
-
vertical = _ref2[1],
|
|
1030
|
-
suffix = _ref2[2];
|
|
867
|
+
const getLayoutParts = (layout = null) => {
|
|
868
|
+
const [horizontal, vertical, suffix] = layout !== null && layout.indexOf('-') !== false ? layout.split('-') : [layout, null, null];
|
|
1031
869
|
return {
|
|
1032
|
-
horizontal
|
|
1033
|
-
vertical
|
|
1034
|
-
suffix
|
|
870
|
+
horizontal,
|
|
871
|
+
vertical,
|
|
872
|
+
suffix
|
|
1035
873
|
};
|
|
1036
874
|
};
|
|
1037
875
|
|
|
1038
|
-
|
|
1039
|
-
var header = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
876
|
+
const isHeaderFilled = (header = {}) => {
|
|
1040
877
|
if (header === null || typeof header === 'undefined') {
|
|
1041
878
|
return false;
|
|
1042
879
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
body = _ref3$body === void 0 ? null : _ref3$body;
|
|
880
|
+
const {
|
|
881
|
+
badge = null
|
|
882
|
+
} = header || {};
|
|
883
|
+
const {
|
|
884
|
+
active: badgeActive = false,
|
|
885
|
+
label = null
|
|
886
|
+
} = badge || {};
|
|
887
|
+
const {
|
|
888
|
+
body = null
|
|
889
|
+
} = label || {};
|
|
1054
890
|
return badgeActive && body !== null;
|
|
1055
891
|
};
|
|
1056
892
|
|
|
1057
|
-
|
|
1058
|
-
var footer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
893
|
+
const isFooterFilled = (footer = {}) => {
|
|
1059
894
|
if (footer === null || typeof footer === 'undefined') {
|
|
1060
895
|
return false;
|
|
1061
896
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
body = _ref3$body === void 0 ? null : _ref3$body;
|
|
897
|
+
const {
|
|
898
|
+
callToAction = null
|
|
899
|
+
} = footer || {};
|
|
900
|
+
const {
|
|
901
|
+
active: callToActionActive = false,
|
|
902
|
+
label = null
|
|
903
|
+
} = callToAction || {};
|
|
904
|
+
const {
|
|
905
|
+
body = null
|
|
906
|
+
} = label || {};
|
|
1073
907
|
return callToActionActive && body !== null;
|
|
1074
908
|
};
|
|
1075
909
|
|
|
1076
|
-
|
|
1077
|
-
return isObject(message) && typeof message.
|
|
1078
|
-
}
|
|
910
|
+
function isMessage(message) {
|
|
911
|
+
return message !== null && isObject(message) && typeof message.id !== 'undefined';
|
|
912
|
+
}
|
|
1079
913
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
navigator.userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1084
|
-
};
|
|
914
|
+
const isIos = () => ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
|
915
|
+
// iPad on iOS 13 detection
|
|
916
|
+
navigator.userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1085
917
|
|
|
1086
|
-
|
|
918
|
+
const isImageFilled = image => {
|
|
1087
919
|
if (image === null || typeof image === 'undefined') {
|
|
1088
920
|
return false;
|
|
1089
921
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
url = _ref$url === void 0 ? null : _ref$url;
|
|
922
|
+
const {
|
|
923
|
+
media = null,
|
|
924
|
+
url = null
|
|
925
|
+
} = image || {};
|
|
1095
926
|
return media !== null || url !== null;
|
|
1096
927
|
};
|
|
1097
928
|
|
|
1098
|
-
|
|
929
|
+
const isTextFilled$1 = text => {
|
|
1099
930
|
if (text === null || typeof text === 'undefined') {
|
|
1100
931
|
return false;
|
|
1101
932
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
933
|
+
const {
|
|
934
|
+
label = null
|
|
935
|
+
} = text || {};
|
|
936
|
+
const {
|
|
937
|
+
length = 0
|
|
938
|
+
} = label || {};
|
|
1108
939
|
return typeof length === 'number' && length > 0;
|
|
1109
940
|
};
|
|
1110
941
|
|
|
1111
|
-
|
|
942
|
+
const isTextFilled = text => {
|
|
1112
943
|
if (text === null || typeof text === 'undefined') {
|
|
1113
944
|
return false;
|
|
1114
945
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
946
|
+
const {
|
|
947
|
+
body = null
|
|
948
|
+
} = text || {};
|
|
949
|
+
const {
|
|
950
|
+
length = 0
|
|
951
|
+
} = body || {};
|
|
1121
952
|
return typeof length === 'number' && length > 0;
|
|
1122
953
|
};
|
|
1123
954
|
|
|
1124
|
-
|
|
955
|
+
const isValidUrl = string => {
|
|
1125
956
|
if (string === null || typeof string === 'undefined') {
|
|
1126
957
|
return false;
|
|
1127
958
|
}
|
|
1128
|
-
|
|
959
|
+
let url;
|
|
1129
960
|
try {
|
|
1130
961
|
url = new URL(string);
|
|
1131
962
|
} catch (_) {
|
|
@@ -1134,20 +965,28 @@ var isValidUrl = function isValidUrl(string) {
|
|
|
1134
965
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
1135
966
|
};
|
|
1136
967
|
|
|
1137
|
-
|
|
1138
|
-
return
|
|
1139
|
-
|
|
968
|
+
function mergeRefs(...refs) {
|
|
969
|
+
return value => {
|
|
970
|
+
refs.forEach(ref => {
|
|
971
|
+
if (typeof ref === 'function') {
|
|
972
|
+
ref(value);
|
|
973
|
+
} else if (ref != null) {
|
|
974
|
+
ref.current = value;
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
};
|
|
978
|
+
}
|
|
1140
979
|
|
|
1141
|
-
|
|
1142
|
-
return createSchemaId(str.join('/'));
|
|
1143
|
-
};
|
|
980
|
+
const createSchemaId = id => `https://schemas.micromag.ca/0.1/${id}.json`;
|
|
1144
981
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
982
|
+
const schemaId = str => createSchemaId(str.join('/'));
|
|
983
|
+
|
|
984
|
+
const setValue = (value, keyParts, fieldValue) => {
|
|
985
|
+
const key = keyParts.shift();
|
|
986
|
+
const isArray = key.match(/^[0-9]+$/) !== null;
|
|
1148
987
|
if (value !== null || fieldValue !== null) {
|
|
1149
988
|
if (isArray) {
|
|
1150
|
-
|
|
989
|
+
const index = parseInt(key, 10);
|
|
1151
990
|
// TODO: fix this with an explicit delete
|
|
1152
991
|
// instead on splicing out the element on null fieldValue
|
|
1153
992
|
// const newArrayValue =
|
|
@@ -1165,17 +1004,19 @@ var _setValue = function setValue(value, keyParts, fieldValue) {
|
|
|
1165
1004
|
// ]
|
|
1166
1005
|
// : [...value.slice(0, index), ...value.slice(index + 1)];
|
|
1167
1006
|
|
|
1168
|
-
|
|
1007
|
+
const newArrayValue = [...value.slice(0, index), keyParts.length > 0 ? setValue(value !== null ? value[index] || null : null, keyParts, fieldValue) : fieldValue, ...value.slice(index + 1)];
|
|
1169
1008
|
return newArrayValue.length > 0 ? newArrayValue : null;
|
|
1170
1009
|
}
|
|
1171
|
-
return
|
|
1010
|
+
return {
|
|
1011
|
+
...value,
|
|
1012
|
+
[key]: keyParts.length > 0 ? setValue(value !== null ? value[key] || null : null, keyParts, fieldValue) : fieldValue
|
|
1013
|
+
};
|
|
1172
1014
|
}
|
|
1173
1015
|
return null;
|
|
1174
1016
|
};
|
|
1175
1017
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
var toSlug;
|
|
1018
|
+
const slug = (str, separator = null) => {
|
|
1019
|
+
let toSlug;
|
|
1179
1020
|
if (separator === '-') {
|
|
1180
1021
|
toSlug = kebabCase(str);
|
|
1181
1022
|
} else {
|
|
@@ -1186,29 +1027,23 @@ var slug = function slug(str) {
|
|
|
1186
1027
|
});
|
|
1187
1028
|
};
|
|
1188
1029
|
|
|
1189
|
-
|
|
1190
|
-
return arrArg !== null ? arrArg.filter(function (elem, pos, arr) {
|
|
1191
|
-
return arr.indexOf(elem) === pos;
|
|
1192
|
-
}) : [];
|
|
1193
|
-
};
|
|
1030
|
+
const unique = arrArg => arrArg !== null ? arrArg.filter((elem, pos, arr) => arr.indexOf(elem) === pos) : [];
|
|
1194
1031
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1199
|
-
return _validateFields(field.fields, value);
|
|
1200
|
-
}
|
|
1201
|
-
var val = value && value[field.name] ? value[field.name] : false;
|
|
1202
|
-
return !(field.required && !val);
|
|
1032
|
+
const validateFields = (fields, value) => fields.reduce((acc, field) => {
|
|
1033
|
+
if (acc === true) {
|
|
1034
|
+
if (field.type === 'fields' && field.fields) {
|
|
1035
|
+
return validateFields(field.fields, value);
|
|
1203
1036
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
}
|
|
1037
|
+
const val = value && value[field.name] ? value[field.name] : false;
|
|
1038
|
+
return !(field.required && !val);
|
|
1039
|
+
}
|
|
1040
|
+
return acc;
|
|
1041
|
+
}, true);
|
|
1207
1042
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1043
|
+
const getContrastingColor = backgroundColor => {
|
|
1044
|
+
const {
|
|
1045
|
+
color = 'white'
|
|
1046
|
+
} = backgroundColor || {};
|
|
1212
1047
|
if (tinycolor.equals(color, tinycolor('white'))) {
|
|
1213
1048
|
return '#A13DFF';
|
|
1214
1049
|
}
|
|
@@ -1218,4 +1053,35 @@ var getContrastingColor = function getContrastingColor(backgroundColor) {
|
|
|
1218
1053
|
return tinycolor(color).spin(30).toString();
|
|
1219
1054
|
};
|
|
1220
1055
|
|
|
1221
|
-
|
|
1056
|
+
function getMediaCurrentTime(media, tsOffset = 0) {
|
|
1057
|
+
return media !== null ? Math.max((media?.currentTime || 0) - tsOffset, 0) : 0;
|
|
1058
|
+
}
|
|
1059
|
+
function getMediaDuration(media, tsOffset = 0) {
|
|
1060
|
+
return media !== null ? Math.max((media?.duration || 0) - tsOffset, 0) : 0;
|
|
1061
|
+
}
|
|
1062
|
+
function getMediaTimestampOffset(media, attributeName = 'data-ts-offset') {
|
|
1063
|
+
return media !== null && media.hasAttribute(attributeName) ? parseFloat(media.getAttribute(attributeName)) : 0;
|
|
1064
|
+
}
|
|
1065
|
+
function getMediaIsMuted(media) {
|
|
1066
|
+
return media !== null && (media.muted || media.volume === 0);
|
|
1067
|
+
}
|
|
1068
|
+
function getMediaIsPlaying(media) {
|
|
1069
|
+
return media !== null && !!(media.currentTime > 0 && !media.paused && !media.ended && media.readyState > 2);
|
|
1070
|
+
}
|
|
1071
|
+
function getMediaIsBuffering(media) {
|
|
1072
|
+
return media !== null && (media.networkState === media.NETWORK_LOADING || media.readyState < media.HAVE_FUTURE_DATA);
|
|
1073
|
+
}
|
|
1074
|
+
function getMediaIsReady(media) {
|
|
1075
|
+
return media !== null && media.readyState >= 0;
|
|
1076
|
+
}
|
|
1077
|
+
function getMediaSrc(media) {
|
|
1078
|
+
return media !== null ? media.currentSrc || media.src : null;
|
|
1079
|
+
}
|
|
1080
|
+
function getMediaHasAudio(media) {
|
|
1081
|
+
return media !== null && (media.tagName.toLowerCase() === 'audio' || media.dataset.hasAudio === 'true');
|
|
1082
|
+
}
|
|
1083
|
+
function getMediaFilename(src) {
|
|
1084
|
+
return src !== null ? src.split('/')[src.split('/').length - 1].split('#')[0] || null : null;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
export { addNonBreakingSpaces, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, cssEscape, easings, getColorAsString, getComponentFromName, getContrastingColor, getDeviceScreens, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getFontFamily as getFontFamilyFromFont, getFooterProps, getGridLayoutName, largestRemainderRound as getLargestRemainderRound, getLayersFromBackground, getLayoutParts, getMediaCurrentTime, getMediaDuration, getMediaFilename, getMediaFilesAsArray, getMediaHasAudio, getMediaIsBuffering, getMediaIsMuted, getMediaIsPlaying, getMediaIsReady, getMediaSrc, getMediaThumbnail, getMediaTimestampOffset, getOptimalImageUrl, getScreenExtraField, getScreenFieldsWithStates, getSecondsFromTime, getShadowCoords, getStyleFromAlignment, getStyleFromBorder, getStyleFromBox, getStyleFromColor, getStyleFromContainer, getStyleFromHighlight, getStyleFromImage, getStyleFromLink, getStyleFromMargin, getStyleFromText, getVideoSupportedMimes, isFooterFilled, isHeaderFilled, isImageFilled, isIos, isTextFilled$1 as isLabelFilled, isMessage, isTextFilled, isValidUrl, mergeRefs, schemaId, setValue as setFieldValue, slug, unique, validateFields };
|