@vidispine/vdt-react-timeline 22.2.0
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/LICENSE.md +55 -0
- package/README.md +3 -0
- package/dist/index.es.js +2752 -0
- package/package.json +67 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,2752 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
+
import { useState, useRef, useContext, createContext, useMemo, useEffect, memo, Children, cloneElement } from 'react';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import clamp from 'lodash.clamp';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
import { Stage, Layer, Rect, Group, Text, Line } from 'react-konva';
|
|
8
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
9
|
+
import sortBy from 'lodash.sortby';
|
|
10
|
+
import uniq from 'lodash.uniq';
|
|
11
|
+
|
|
12
|
+
function toVal(mix) {
|
|
13
|
+
var k, y, str='';
|
|
14
|
+
|
|
15
|
+
if (typeof mix === 'string' || typeof mix === 'number') {
|
|
16
|
+
str += mix;
|
|
17
|
+
} else if (typeof mix === 'object') {
|
|
18
|
+
if (Array.isArray(mix)) {
|
|
19
|
+
for (k=0; k < mix.length; k++) {
|
|
20
|
+
if (mix[k]) {
|
|
21
|
+
if (y = toVal(mix[k])) {
|
|
22
|
+
str && (str += ' ');
|
|
23
|
+
str += y;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
for (k in mix) {
|
|
29
|
+
if (mix[k]) {
|
|
30
|
+
str && (str += ' ');
|
|
31
|
+
str += k;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return str;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function clsx () {
|
|
41
|
+
var i=0, tmp, x, str='';
|
|
42
|
+
while (i < arguments.length) {
|
|
43
|
+
if (tmp = arguments[i++]) {
|
|
44
|
+
if (x = toVal(tmp)) {
|
|
45
|
+
str && (str += ' ');
|
|
46
|
+
str += x;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return str;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var propTypes = {exports: {}};
|
|
54
|
+
|
|
55
|
+
var reactIs = {exports: {}};
|
|
56
|
+
|
|
57
|
+
var reactIs_production_min = {};
|
|
58
|
+
|
|
59
|
+
/** @license React v16.13.1
|
|
60
|
+
* react-is.production.min.js
|
|
61
|
+
*
|
|
62
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the MIT license found in the
|
|
65
|
+
* LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/
|
|
67
|
+
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e$1=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n$1=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
68
|
+
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t$1=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
69
|
+
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e$1:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n$1:case t$1:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n$1;reactIs_production_min.Fragment=e$1;reactIs_production_min.Lazy=t$1;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
|
|
70
|
+
reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n$1};reactIs_production_min.isFragment=function(a){return z(a)===e$1};reactIs_production_min.isLazy=function(a){return z(a)===t$1};
|
|
71
|
+
reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
|
|
72
|
+
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e$1||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t$1||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n$1||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
|
|
73
|
+
|
|
74
|
+
var reactIs_development = {};
|
|
75
|
+
|
|
76
|
+
/** @license React v16.13.1
|
|
77
|
+
* react-is.development.js
|
|
78
|
+
*
|
|
79
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
80
|
+
*
|
|
81
|
+
* This source code is licensed under the MIT license found in the
|
|
82
|
+
* LICENSE file in the root directory of this source tree.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if (process.env.NODE_ENV !== "production") {
|
|
88
|
+
(function() {
|
|
89
|
+
|
|
90
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
91
|
+
// nor polyfill, then a plain number is used for performance.
|
|
92
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
93
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
94
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
95
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
96
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
97
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
98
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
99
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
100
|
+
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
101
|
+
|
|
102
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
103
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
104
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
105
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
106
|
+
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
107
|
+
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
108
|
+
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
109
|
+
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
110
|
+
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
111
|
+
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
112
|
+
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
113
|
+
|
|
114
|
+
function isValidElementType(type) {
|
|
115
|
+
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
116
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function typeOf(object) {
|
|
120
|
+
if (typeof object === 'object' && object !== null) {
|
|
121
|
+
var $$typeof = object.$$typeof;
|
|
122
|
+
|
|
123
|
+
switch ($$typeof) {
|
|
124
|
+
case REACT_ELEMENT_TYPE:
|
|
125
|
+
var type = object.type;
|
|
126
|
+
|
|
127
|
+
switch (type) {
|
|
128
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
129
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
130
|
+
case REACT_FRAGMENT_TYPE:
|
|
131
|
+
case REACT_PROFILER_TYPE:
|
|
132
|
+
case REACT_STRICT_MODE_TYPE:
|
|
133
|
+
case REACT_SUSPENSE_TYPE:
|
|
134
|
+
return type;
|
|
135
|
+
|
|
136
|
+
default:
|
|
137
|
+
var $$typeofType = type && type.$$typeof;
|
|
138
|
+
|
|
139
|
+
switch ($$typeofType) {
|
|
140
|
+
case REACT_CONTEXT_TYPE:
|
|
141
|
+
case REACT_FORWARD_REF_TYPE:
|
|
142
|
+
case REACT_LAZY_TYPE:
|
|
143
|
+
case REACT_MEMO_TYPE:
|
|
144
|
+
case REACT_PROVIDER_TYPE:
|
|
145
|
+
return $$typeofType;
|
|
146
|
+
|
|
147
|
+
default:
|
|
148
|
+
return $$typeof;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
case REACT_PORTAL_TYPE:
|
|
154
|
+
return $$typeof;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return undefined;
|
|
159
|
+
} // AsyncMode is deprecated along with isAsyncMode
|
|
160
|
+
|
|
161
|
+
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
162
|
+
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
163
|
+
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
164
|
+
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
165
|
+
var Element = REACT_ELEMENT_TYPE;
|
|
166
|
+
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
167
|
+
var Fragment = REACT_FRAGMENT_TYPE;
|
|
168
|
+
var Lazy = REACT_LAZY_TYPE;
|
|
169
|
+
var Memo = REACT_MEMO_TYPE;
|
|
170
|
+
var Portal = REACT_PORTAL_TYPE;
|
|
171
|
+
var Profiler = REACT_PROFILER_TYPE;
|
|
172
|
+
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
173
|
+
var Suspense = REACT_SUSPENSE_TYPE;
|
|
174
|
+
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
175
|
+
|
|
176
|
+
function isAsyncMode(object) {
|
|
177
|
+
{
|
|
178
|
+
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
179
|
+
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
180
|
+
|
|
181
|
+
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
186
|
+
}
|
|
187
|
+
function isConcurrentMode(object) {
|
|
188
|
+
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
189
|
+
}
|
|
190
|
+
function isContextConsumer(object) {
|
|
191
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
192
|
+
}
|
|
193
|
+
function isContextProvider(object) {
|
|
194
|
+
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
195
|
+
}
|
|
196
|
+
function isElement(object) {
|
|
197
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
198
|
+
}
|
|
199
|
+
function isForwardRef(object) {
|
|
200
|
+
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
201
|
+
}
|
|
202
|
+
function isFragment(object) {
|
|
203
|
+
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
204
|
+
}
|
|
205
|
+
function isLazy(object) {
|
|
206
|
+
return typeOf(object) === REACT_LAZY_TYPE;
|
|
207
|
+
}
|
|
208
|
+
function isMemo(object) {
|
|
209
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
210
|
+
}
|
|
211
|
+
function isPortal(object) {
|
|
212
|
+
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
213
|
+
}
|
|
214
|
+
function isProfiler(object) {
|
|
215
|
+
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
216
|
+
}
|
|
217
|
+
function isStrictMode(object) {
|
|
218
|
+
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
219
|
+
}
|
|
220
|
+
function isSuspense(object) {
|
|
221
|
+
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
reactIs_development.AsyncMode = AsyncMode;
|
|
225
|
+
reactIs_development.ConcurrentMode = ConcurrentMode;
|
|
226
|
+
reactIs_development.ContextConsumer = ContextConsumer;
|
|
227
|
+
reactIs_development.ContextProvider = ContextProvider;
|
|
228
|
+
reactIs_development.Element = Element;
|
|
229
|
+
reactIs_development.ForwardRef = ForwardRef;
|
|
230
|
+
reactIs_development.Fragment = Fragment;
|
|
231
|
+
reactIs_development.Lazy = Lazy;
|
|
232
|
+
reactIs_development.Memo = Memo;
|
|
233
|
+
reactIs_development.Portal = Portal;
|
|
234
|
+
reactIs_development.Profiler = Profiler;
|
|
235
|
+
reactIs_development.StrictMode = StrictMode;
|
|
236
|
+
reactIs_development.Suspense = Suspense;
|
|
237
|
+
reactIs_development.isAsyncMode = isAsyncMode;
|
|
238
|
+
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
239
|
+
reactIs_development.isContextConsumer = isContextConsumer;
|
|
240
|
+
reactIs_development.isContextProvider = isContextProvider;
|
|
241
|
+
reactIs_development.isElement = isElement;
|
|
242
|
+
reactIs_development.isForwardRef = isForwardRef;
|
|
243
|
+
reactIs_development.isFragment = isFragment;
|
|
244
|
+
reactIs_development.isLazy = isLazy;
|
|
245
|
+
reactIs_development.isMemo = isMemo;
|
|
246
|
+
reactIs_development.isPortal = isPortal;
|
|
247
|
+
reactIs_development.isProfiler = isProfiler;
|
|
248
|
+
reactIs_development.isStrictMode = isStrictMode;
|
|
249
|
+
reactIs_development.isSuspense = isSuspense;
|
|
250
|
+
reactIs_development.isValidElementType = isValidElementType;
|
|
251
|
+
reactIs_development.typeOf = typeOf;
|
|
252
|
+
})();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (process.env.NODE_ENV === 'production') {
|
|
256
|
+
reactIs.exports = reactIs_production_min;
|
|
257
|
+
} else {
|
|
258
|
+
reactIs.exports = reactIs_development;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/*
|
|
262
|
+
object-assign
|
|
263
|
+
(c) Sindre Sorhus
|
|
264
|
+
@license MIT
|
|
265
|
+
*/
|
|
266
|
+
/* eslint-disable no-unused-vars */
|
|
267
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
268
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
269
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
270
|
+
|
|
271
|
+
function toObject(val) {
|
|
272
|
+
if (val === null || val === undefined) {
|
|
273
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return Object(val);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function shouldUseNative() {
|
|
280
|
+
try {
|
|
281
|
+
if (!Object.assign) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
286
|
+
|
|
287
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
288
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
289
|
+
test1[5] = 'de';
|
|
290
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
295
|
+
var test2 = {};
|
|
296
|
+
for (var i = 0; i < 10; i++) {
|
|
297
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
298
|
+
}
|
|
299
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
300
|
+
return test2[n];
|
|
301
|
+
});
|
|
302
|
+
if (order2.join('') !== '0123456789') {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
307
|
+
var test3 = {};
|
|
308
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
309
|
+
test3[letter] = letter;
|
|
310
|
+
});
|
|
311
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
312
|
+
'abcdefghijklmnopqrst') {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return true;
|
|
317
|
+
} catch (err) {
|
|
318
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
324
|
+
var from;
|
|
325
|
+
var to = toObject(target);
|
|
326
|
+
var symbols;
|
|
327
|
+
|
|
328
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
329
|
+
from = Object(arguments[s]);
|
|
330
|
+
|
|
331
|
+
for (var key in from) {
|
|
332
|
+
if (hasOwnProperty.call(from, key)) {
|
|
333
|
+
to[key] = from[key];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (getOwnPropertySymbols) {
|
|
338
|
+
symbols = getOwnPropertySymbols(from);
|
|
339
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
340
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
341
|
+
to[symbols[i]] = from[symbols[i]];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return to;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
352
|
+
*
|
|
353
|
+
* This source code is licensed under the MIT license found in the
|
|
354
|
+
* LICENSE file in the root directory of this source tree.
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
var ReactPropTypesSecret$3 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
358
|
+
|
|
359
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$3;
|
|
360
|
+
|
|
361
|
+
var has$2 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
365
|
+
*
|
|
366
|
+
* This source code is licensed under the MIT license found in the
|
|
367
|
+
* LICENSE file in the root directory of this source tree.
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
var printWarning$1 = function() {};
|
|
371
|
+
|
|
372
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
373
|
+
var ReactPropTypesSecret$2 = ReactPropTypesSecret_1;
|
|
374
|
+
var loggedTypeFailures = {};
|
|
375
|
+
var has$1 = has$2;
|
|
376
|
+
|
|
377
|
+
printWarning$1 = function(text) {
|
|
378
|
+
var message = 'Warning: ' + text;
|
|
379
|
+
if (typeof console !== 'undefined') {
|
|
380
|
+
console.error(message);
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
// --- Welcome to debugging React ---
|
|
384
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
385
|
+
// to find the callsite that caused this warning to fire.
|
|
386
|
+
throw new Error(message);
|
|
387
|
+
} catch (x) { /**/ }
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Assert that the values match with the type specs.
|
|
393
|
+
* Error messages are memorized and will only be shown once.
|
|
394
|
+
*
|
|
395
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
396
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
397
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
398
|
+
* @param {string} componentName Name of the component for error messages.
|
|
399
|
+
* @param {?Function} getStack Returns the component stack.
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) {
|
|
403
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
404
|
+
for (var typeSpecName in typeSpecs) {
|
|
405
|
+
if (has$1(typeSpecs, typeSpecName)) {
|
|
406
|
+
var error;
|
|
407
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
408
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
409
|
+
// After these have been cleaned up, we'll let them throw.
|
|
410
|
+
try {
|
|
411
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
412
|
+
// behavior as without this statement except with a better message.
|
|
413
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
414
|
+
var err = Error(
|
|
415
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
416
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
|
417
|
+
'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
|
418
|
+
);
|
|
419
|
+
err.name = 'Invariant Violation';
|
|
420
|
+
throw err;
|
|
421
|
+
}
|
|
422
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$2);
|
|
423
|
+
} catch (ex) {
|
|
424
|
+
error = ex;
|
|
425
|
+
}
|
|
426
|
+
if (error && !(error instanceof Error)) {
|
|
427
|
+
printWarning$1(
|
|
428
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
429
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
430
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
431
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
432
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
433
|
+
'shape all require an argument).'
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
437
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
438
|
+
// same error.
|
|
439
|
+
loggedTypeFailures[error.message] = true;
|
|
440
|
+
|
|
441
|
+
var stack = getStack ? getStack() : '';
|
|
442
|
+
|
|
443
|
+
printWarning$1(
|
|
444
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Resets warning cache when testing.
|
|
454
|
+
*
|
|
455
|
+
* @private
|
|
456
|
+
*/
|
|
457
|
+
checkPropTypes$1.resetWarningCache = function() {
|
|
458
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
459
|
+
loggedTypeFailures = {};
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
var checkPropTypes_1 = checkPropTypes$1;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
467
|
+
*
|
|
468
|
+
* This source code is licensed under the MIT license found in the
|
|
469
|
+
* LICENSE file in the root directory of this source tree.
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
var ReactIs$1 = reactIs.exports;
|
|
473
|
+
var assign = objectAssign;
|
|
474
|
+
|
|
475
|
+
var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
|
|
476
|
+
var has = has$2;
|
|
477
|
+
var checkPropTypes = checkPropTypes_1;
|
|
478
|
+
|
|
479
|
+
var printWarning = function() {};
|
|
480
|
+
|
|
481
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
482
|
+
printWarning = function(text) {
|
|
483
|
+
var message = 'Warning: ' + text;
|
|
484
|
+
if (typeof console !== 'undefined') {
|
|
485
|
+
console.error(message);
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
// --- Welcome to debugging React ---
|
|
489
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
490
|
+
// to find the callsite that caused this warning to fire.
|
|
491
|
+
throw new Error(message);
|
|
492
|
+
} catch (x) {}
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function emptyFunctionThatReturnsNull() {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
501
|
+
/* global Symbol */
|
|
502
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
503
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Returns the iterator method function contained on the iterable object.
|
|
507
|
+
*
|
|
508
|
+
* Be sure to invoke the function with the iterable as context:
|
|
509
|
+
*
|
|
510
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
511
|
+
* if (iteratorFn) {
|
|
512
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
513
|
+
* ...
|
|
514
|
+
* }
|
|
515
|
+
*
|
|
516
|
+
* @param {?object} maybeIterable
|
|
517
|
+
* @return {?function}
|
|
518
|
+
*/
|
|
519
|
+
function getIteratorFn(maybeIterable) {
|
|
520
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
521
|
+
if (typeof iteratorFn === 'function') {
|
|
522
|
+
return iteratorFn;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
528
|
+
* supplied to React components. Example usage:
|
|
529
|
+
*
|
|
530
|
+
* var Props = require('ReactPropTypes');
|
|
531
|
+
* var MyArticle = React.createClass({
|
|
532
|
+
* propTypes: {
|
|
533
|
+
* // An optional string prop named "description".
|
|
534
|
+
* description: Props.string,
|
|
535
|
+
*
|
|
536
|
+
* // A required enum prop named "category".
|
|
537
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
538
|
+
*
|
|
539
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
540
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
541
|
+
* },
|
|
542
|
+
* render: function() { ... }
|
|
543
|
+
* });
|
|
544
|
+
*
|
|
545
|
+
* A more formal specification of how these methods are used:
|
|
546
|
+
*
|
|
547
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
548
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
549
|
+
*
|
|
550
|
+
* Each and every declaration produces a function with the same signature. This
|
|
551
|
+
* allows the creation of custom validation functions. For example:
|
|
552
|
+
*
|
|
553
|
+
* var MyLink = React.createClass({
|
|
554
|
+
* propTypes: {
|
|
555
|
+
* // An optional string or URI prop named "href".
|
|
556
|
+
* href: function(props, propName, componentName) {
|
|
557
|
+
* var propValue = props[propName];
|
|
558
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
559
|
+
* !(propValue instanceof URI)) {
|
|
560
|
+
* return new Error(
|
|
561
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
562
|
+
* componentName
|
|
563
|
+
* );
|
|
564
|
+
* }
|
|
565
|
+
* }
|
|
566
|
+
* },
|
|
567
|
+
* render: function() {...}
|
|
568
|
+
* });
|
|
569
|
+
*
|
|
570
|
+
* @internal
|
|
571
|
+
*/
|
|
572
|
+
|
|
573
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
574
|
+
|
|
575
|
+
// Important!
|
|
576
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
577
|
+
var ReactPropTypes = {
|
|
578
|
+
array: createPrimitiveTypeChecker('array'),
|
|
579
|
+
bigint: createPrimitiveTypeChecker('bigint'),
|
|
580
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
581
|
+
func: createPrimitiveTypeChecker('function'),
|
|
582
|
+
number: createPrimitiveTypeChecker('number'),
|
|
583
|
+
object: createPrimitiveTypeChecker('object'),
|
|
584
|
+
string: createPrimitiveTypeChecker('string'),
|
|
585
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
586
|
+
|
|
587
|
+
any: createAnyTypeChecker(),
|
|
588
|
+
arrayOf: createArrayOfTypeChecker,
|
|
589
|
+
element: createElementTypeChecker(),
|
|
590
|
+
elementType: createElementTypeTypeChecker(),
|
|
591
|
+
instanceOf: createInstanceTypeChecker,
|
|
592
|
+
node: createNodeChecker(),
|
|
593
|
+
objectOf: createObjectOfTypeChecker,
|
|
594
|
+
oneOf: createEnumTypeChecker,
|
|
595
|
+
oneOfType: createUnionTypeChecker,
|
|
596
|
+
shape: createShapeTypeChecker,
|
|
597
|
+
exact: createStrictShapeTypeChecker,
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
602
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
603
|
+
*/
|
|
604
|
+
/*eslint-disable no-self-compare*/
|
|
605
|
+
function is(x, y) {
|
|
606
|
+
// SameValue algorithm
|
|
607
|
+
if (x === y) {
|
|
608
|
+
// Steps 1-5, 7-10
|
|
609
|
+
// Steps 6.b-6.e: +0 != -0
|
|
610
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
611
|
+
} else {
|
|
612
|
+
// Step 6.a: NaN == NaN
|
|
613
|
+
return x !== x && y !== y;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/*eslint-enable no-self-compare*/
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
620
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
621
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
622
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
623
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
624
|
+
*/
|
|
625
|
+
function PropTypeError(message, data) {
|
|
626
|
+
this.message = message;
|
|
627
|
+
this.data = data && typeof data === 'object' ? data: {};
|
|
628
|
+
this.stack = '';
|
|
629
|
+
}
|
|
630
|
+
// Make `instanceof Error` still work for returned errors.
|
|
631
|
+
PropTypeError.prototype = Error.prototype;
|
|
632
|
+
|
|
633
|
+
function createChainableTypeChecker(validate) {
|
|
634
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
635
|
+
var manualPropTypeCallCache = {};
|
|
636
|
+
var manualPropTypeWarningCount = 0;
|
|
637
|
+
}
|
|
638
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
639
|
+
componentName = componentName || ANONYMOUS;
|
|
640
|
+
propFullName = propFullName || propName;
|
|
641
|
+
|
|
642
|
+
if (secret !== ReactPropTypesSecret$1) {
|
|
643
|
+
if (throwOnDirectAccess) {
|
|
644
|
+
// New behavior only for users of `prop-types` package
|
|
645
|
+
var err = new Error(
|
|
646
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
647
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
648
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
649
|
+
);
|
|
650
|
+
err.name = 'Invariant Violation';
|
|
651
|
+
throw err;
|
|
652
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
653
|
+
// Old behavior for people using React.PropTypes
|
|
654
|
+
var cacheKey = componentName + ':' + propName;
|
|
655
|
+
if (
|
|
656
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
657
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
658
|
+
manualPropTypeWarningCount < 3
|
|
659
|
+
) {
|
|
660
|
+
printWarning(
|
|
661
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
662
|
+
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
663
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
664
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
665
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
666
|
+
);
|
|
667
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
668
|
+
manualPropTypeWarningCount++;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
if (props[propName] == null) {
|
|
673
|
+
if (isRequired) {
|
|
674
|
+
if (props[propName] === null) {
|
|
675
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
676
|
+
}
|
|
677
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
678
|
+
}
|
|
679
|
+
return null;
|
|
680
|
+
} else {
|
|
681
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
686
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
687
|
+
|
|
688
|
+
return chainedCheckType;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
692
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
693
|
+
var propValue = props[propName];
|
|
694
|
+
var propType = getPropType(propValue);
|
|
695
|
+
if (propType !== expectedType) {
|
|
696
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
697
|
+
// check, but we can offer a more precise error message here rather than
|
|
698
|
+
// 'of type `object`'.
|
|
699
|
+
var preciseType = getPreciseType(propValue);
|
|
700
|
+
|
|
701
|
+
return new PropTypeError(
|
|
702
|
+
'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
|
703
|
+
{expectedType: expectedType}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
return createChainableTypeChecker(validate);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function createAnyTypeChecker() {
|
|
712
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
716
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
717
|
+
if (typeof typeChecker !== 'function') {
|
|
718
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
719
|
+
}
|
|
720
|
+
var propValue = props[propName];
|
|
721
|
+
if (!Array.isArray(propValue)) {
|
|
722
|
+
var propType = getPropType(propValue);
|
|
723
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
724
|
+
}
|
|
725
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
726
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret$1);
|
|
727
|
+
if (error instanceof Error) {
|
|
728
|
+
return error;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
return createChainableTypeChecker(validate);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
function createElementTypeChecker() {
|
|
737
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
738
|
+
var propValue = props[propName];
|
|
739
|
+
if (!isValidElement(propValue)) {
|
|
740
|
+
var propType = getPropType(propValue);
|
|
741
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
742
|
+
}
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
return createChainableTypeChecker(validate);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function createElementTypeTypeChecker() {
|
|
749
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
750
|
+
var propValue = props[propName];
|
|
751
|
+
if (!ReactIs$1.isValidElementType(propValue)) {
|
|
752
|
+
var propType = getPropType(propValue);
|
|
753
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
754
|
+
}
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
return createChainableTypeChecker(validate);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
761
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
762
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
763
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
764
|
+
var actualClassName = getClassName(props[propName]);
|
|
765
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
766
|
+
}
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
return createChainableTypeChecker(validate);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
function createEnumTypeChecker(expectedValues) {
|
|
773
|
+
if (!Array.isArray(expectedValues)) {
|
|
774
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
775
|
+
if (arguments.length > 1) {
|
|
776
|
+
printWarning(
|
|
777
|
+
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
778
|
+
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
779
|
+
);
|
|
780
|
+
} else {
|
|
781
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return emptyFunctionThatReturnsNull;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
788
|
+
var propValue = props[propName];
|
|
789
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
790
|
+
if (is(propValue, expectedValues[i])) {
|
|
791
|
+
return null;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
796
|
+
var type = getPreciseType(value);
|
|
797
|
+
if (type === 'symbol') {
|
|
798
|
+
return String(value);
|
|
799
|
+
}
|
|
800
|
+
return value;
|
|
801
|
+
});
|
|
802
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
803
|
+
}
|
|
804
|
+
return createChainableTypeChecker(validate);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
808
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
809
|
+
if (typeof typeChecker !== 'function') {
|
|
810
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
811
|
+
}
|
|
812
|
+
var propValue = props[propName];
|
|
813
|
+
var propType = getPropType(propValue);
|
|
814
|
+
if (propType !== 'object') {
|
|
815
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
816
|
+
}
|
|
817
|
+
for (var key in propValue) {
|
|
818
|
+
if (has(propValue, key)) {
|
|
819
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
|
|
820
|
+
if (error instanceof Error) {
|
|
821
|
+
return error;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
return createChainableTypeChecker(validate);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
831
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
832
|
+
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
833
|
+
return emptyFunctionThatReturnsNull;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
837
|
+
var checker = arrayOfTypeCheckers[i];
|
|
838
|
+
if (typeof checker !== 'function') {
|
|
839
|
+
printWarning(
|
|
840
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
841
|
+
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
842
|
+
);
|
|
843
|
+
return emptyFunctionThatReturnsNull;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
848
|
+
var expectedTypes = [];
|
|
849
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
850
|
+
var checker = arrayOfTypeCheckers[i];
|
|
851
|
+
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret$1);
|
|
852
|
+
if (checkerResult == null) {
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
855
|
+
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
856
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
|
860
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
861
|
+
}
|
|
862
|
+
return createChainableTypeChecker(validate);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function createNodeChecker() {
|
|
866
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
867
|
+
if (!isNode(props[propName])) {
|
|
868
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
869
|
+
}
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
return createChainableTypeChecker(validate);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
876
|
+
return new PropTypeError(
|
|
877
|
+
(componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
|
878
|
+
'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
883
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
884
|
+
var propValue = props[propName];
|
|
885
|
+
var propType = getPropType(propValue);
|
|
886
|
+
if (propType !== 'object') {
|
|
887
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
888
|
+
}
|
|
889
|
+
for (var key in shapeTypes) {
|
|
890
|
+
var checker = shapeTypes[key];
|
|
891
|
+
if (typeof checker !== 'function') {
|
|
892
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
893
|
+
}
|
|
894
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
|
|
895
|
+
if (error) {
|
|
896
|
+
return error;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
return createChainableTypeChecker(validate);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
905
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
906
|
+
var propValue = props[propName];
|
|
907
|
+
var propType = getPropType(propValue);
|
|
908
|
+
if (propType !== 'object') {
|
|
909
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
910
|
+
}
|
|
911
|
+
// We need to check all keys in case some are required but missing from props.
|
|
912
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
913
|
+
for (var key in allKeys) {
|
|
914
|
+
var checker = shapeTypes[key];
|
|
915
|
+
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
916
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
917
|
+
}
|
|
918
|
+
if (!checker) {
|
|
919
|
+
return new PropTypeError(
|
|
920
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
921
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
922
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$1);
|
|
926
|
+
if (error) {
|
|
927
|
+
return error;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
return createChainableTypeChecker(validate);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function isNode(propValue) {
|
|
937
|
+
switch (typeof propValue) {
|
|
938
|
+
case 'number':
|
|
939
|
+
case 'string':
|
|
940
|
+
case 'undefined':
|
|
941
|
+
return true;
|
|
942
|
+
case 'boolean':
|
|
943
|
+
return !propValue;
|
|
944
|
+
case 'object':
|
|
945
|
+
if (Array.isArray(propValue)) {
|
|
946
|
+
return propValue.every(isNode);
|
|
947
|
+
}
|
|
948
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
953
|
+
if (iteratorFn) {
|
|
954
|
+
var iterator = iteratorFn.call(propValue);
|
|
955
|
+
var step;
|
|
956
|
+
if (iteratorFn !== propValue.entries) {
|
|
957
|
+
while (!(step = iterator.next()).done) {
|
|
958
|
+
if (!isNode(step.value)) {
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
964
|
+
while (!(step = iterator.next()).done) {
|
|
965
|
+
var entry = step.value;
|
|
966
|
+
if (entry) {
|
|
967
|
+
if (!isNode(entry[1])) {
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
} else {
|
|
974
|
+
return false;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return true;
|
|
978
|
+
default:
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
function isSymbol(propType, propValue) {
|
|
984
|
+
// Native Symbol.
|
|
985
|
+
if (propType === 'symbol') {
|
|
986
|
+
return true;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// falsy value can't be a Symbol
|
|
990
|
+
if (!propValue) {
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
995
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
996
|
+
return true;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
1000
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
1001
|
+
return true;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
return false;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
1008
|
+
function getPropType(propValue) {
|
|
1009
|
+
var propType = typeof propValue;
|
|
1010
|
+
if (Array.isArray(propValue)) {
|
|
1011
|
+
return 'array';
|
|
1012
|
+
}
|
|
1013
|
+
if (propValue instanceof RegExp) {
|
|
1014
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
1015
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
1016
|
+
// passes PropTypes.object.
|
|
1017
|
+
return 'object';
|
|
1018
|
+
}
|
|
1019
|
+
if (isSymbol(propType, propValue)) {
|
|
1020
|
+
return 'symbol';
|
|
1021
|
+
}
|
|
1022
|
+
return propType;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
1026
|
+
// See `createPrimitiveTypeChecker`.
|
|
1027
|
+
function getPreciseType(propValue) {
|
|
1028
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
1029
|
+
return '' + propValue;
|
|
1030
|
+
}
|
|
1031
|
+
var propType = getPropType(propValue);
|
|
1032
|
+
if (propType === 'object') {
|
|
1033
|
+
if (propValue instanceof Date) {
|
|
1034
|
+
return 'date';
|
|
1035
|
+
} else if (propValue instanceof RegExp) {
|
|
1036
|
+
return 'regexp';
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return propType;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
1043
|
+
// For example, "undefined" or "of type array"
|
|
1044
|
+
function getPostfixForTypeWarning(value) {
|
|
1045
|
+
var type = getPreciseType(value);
|
|
1046
|
+
switch (type) {
|
|
1047
|
+
case 'array':
|
|
1048
|
+
case 'object':
|
|
1049
|
+
return 'an ' + type;
|
|
1050
|
+
case 'boolean':
|
|
1051
|
+
case 'date':
|
|
1052
|
+
case 'regexp':
|
|
1053
|
+
return 'a ' + type;
|
|
1054
|
+
default:
|
|
1055
|
+
return type;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// Returns class name of the object, if any.
|
|
1060
|
+
function getClassName(propValue) {
|
|
1061
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
1062
|
+
return ANONYMOUS;
|
|
1063
|
+
}
|
|
1064
|
+
return propValue.constructor.name;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
1068
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
1069
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1070
|
+
|
|
1071
|
+
return ReactPropTypes;
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1076
|
+
*
|
|
1077
|
+
* This source code is licensed under the MIT license found in the
|
|
1078
|
+
* LICENSE file in the root directory of this source tree.
|
|
1079
|
+
*/
|
|
1080
|
+
|
|
1081
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
1082
|
+
|
|
1083
|
+
function emptyFunction() {}
|
|
1084
|
+
function emptyFunctionWithReset() {}
|
|
1085
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1086
|
+
|
|
1087
|
+
var factoryWithThrowingShims = function() {
|
|
1088
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1089
|
+
if (secret === ReactPropTypesSecret) {
|
|
1090
|
+
// It is still safe when called from React.
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
var err = new Error(
|
|
1094
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
1095
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
1096
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
1097
|
+
);
|
|
1098
|
+
err.name = 'Invariant Violation';
|
|
1099
|
+
throw err;
|
|
1100
|
+
} shim.isRequired = shim;
|
|
1101
|
+
function getShim() {
|
|
1102
|
+
return shim;
|
|
1103
|
+
} // Important!
|
|
1104
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1105
|
+
var ReactPropTypes = {
|
|
1106
|
+
array: shim,
|
|
1107
|
+
bigint: shim,
|
|
1108
|
+
bool: shim,
|
|
1109
|
+
func: shim,
|
|
1110
|
+
number: shim,
|
|
1111
|
+
object: shim,
|
|
1112
|
+
string: shim,
|
|
1113
|
+
symbol: shim,
|
|
1114
|
+
|
|
1115
|
+
any: shim,
|
|
1116
|
+
arrayOf: getShim,
|
|
1117
|
+
element: shim,
|
|
1118
|
+
elementType: shim,
|
|
1119
|
+
instanceOf: getShim,
|
|
1120
|
+
node: shim,
|
|
1121
|
+
objectOf: getShim,
|
|
1122
|
+
oneOf: getShim,
|
|
1123
|
+
oneOfType: getShim,
|
|
1124
|
+
shape: getShim,
|
|
1125
|
+
exact: getShim,
|
|
1126
|
+
|
|
1127
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
1128
|
+
resetWarningCache: emptyFunction
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1132
|
+
|
|
1133
|
+
return ReactPropTypes;
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1138
|
+
*
|
|
1139
|
+
* This source code is licensed under the MIT license found in the
|
|
1140
|
+
* LICENSE file in the root directory of this source tree.
|
|
1141
|
+
*/
|
|
1142
|
+
|
|
1143
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1144
|
+
var ReactIs = reactIs.exports;
|
|
1145
|
+
|
|
1146
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
1147
|
+
// http://fb.me/prop-types-in-prod
|
|
1148
|
+
var throwOnDirectAccess = true;
|
|
1149
|
+
propTypes.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
|
|
1150
|
+
} else {
|
|
1151
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1152
|
+
// http://fb.me/prop-types-in-prod
|
|
1153
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
var PropTypes = propTypes.exports;
|
|
1157
|
+
|
|
1158
|
+
var interpolate = function interpolate(y0, y1, x0, x1, x) {
|
|
1159
|
+
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
var vLogImpl = function vLogImpl(component, msg, level) {
|
|
1163
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1164
|
+
// eslint-disable-next-line no-console
|
|
1165
|
+
console[level]("".concat(component ? "".concat(component, ": ") : '').concat(msg));
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
var vLog = {
|
|
1170
|
+
error: function error() {
|
|
1171
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1172
|
+
args[_key] = arguments[_key];
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return vLogImpl.apply(void 0, args.concat(['error']));
|
|
1176
|
+
},
|
|
1177
|
+
warn: function warn() {
|
|
1178
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1179
|
+
args[_key2] = arguments[_key2];
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
return vLogImpl.apply(void 0, args.concat(['warn']));
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
function mapPairs(arr, func) {
|
|
1186
|
+
var result = [];
|
|
1187
|
+
|
|
1188
|
+
for (var i = 0; i < arr.length - 1; i += 1) {
|
|
1189
|
+
result.push(func(arr[i], arr[i + 1]));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
return result;
|
|
1193
|
+
}
|
|
1194
|
+
function getStyleProperties() {
|
|
1195
|
+
var style = getComputedStyle(document.body);
|
|
1196
|
+
|
|
1197
|
+
for (var _len3 = arguments.length, properties = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1198
|
+
properties[_key3] = arguments[_key3];
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
return properties.map(function (prop) {
|
|
1202
|
+
return style.getPropertyValue(prop);
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
function useOptionallyControlledState(_ref) {
|
|
1207
|
+
var _ref$uncontrolledDefa = _ref.uncontrolledDefaultState,
|
|
1208
|
+
uncontrolledDefaultState = _ref$uncontrolledDefa === void 0 ? undefined : _ref$uncontrolledDefa,
|
|
1209
|
+
_ref$uncontrolledOnCh = _ref.uncontrolledOnChange,
|
|
1210
|
+
uncontrolledOnChange = _ref$uncontrolledOnCh === void 0 ? undefined : _ref$uncontrolledOnCh,
|
|
1211
|
+
_ref$controlledState = _ref.controlledState,
|
|
1212
|
+
controlledState = _ref$controlledState === void 0 ? undefined : _ref$controlledState,
|
|
1213
|
+
_ref$controlledOnChan = _ref.controlledOnChange,
|
|
1214
|
+
controlledOnChange = _ref$controlledOnChan === void 0 ? undefined : _ref$controlledOnChan,
|
|
1215
|
+
componentName = _ref.componentName,
|
|
1216
|
+
stateName = _ref.stateName;
|
|
1217
|
+
|
|
1218
|
+
var _useState = useState(uncontrolledDefaultState),
|
|
1219
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1220
|
+
uncontrolledState = _useState2[0],
|
|
1221
|
+
setUncontrolledState = _useState2[1];
|
|
1222
|
+
|
|
1223
|
+
var isControlled = useRef(null);
|
|
1224
|
+
|
|
1225
|
+
var setIsControlled = function setIsControlled(newValue) {
|
|
1226
|
+
if (isControlled.current !== null && isControlled.current !== newValue) {
|
|
1227
|
+
if (newValue) {
|
|
1228
|
+
vLog.warn(componentName, "".concat(stateName, " changed from uncontrolled to controlled"));
|
|
1229
|
+
} else {
|
|
1230
|
+
vLog.warn(componentName, "".concat(stateName, " changed from controlled to uncontrolled"));
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
isControlled.current = newValue;
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
if (controlledState !== undefined) {
|
|
1238
|
+
setIsControlled(true);
|
|
1239
|
+
return [controlledState, controlledOnChange];
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
setIsControlled(false);
|
|
1243
|
+
return [uncontrolledState, controlledOnChange ? function () {
|
|
1244
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1245
|
+
args[_key] = arguments[_key];
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
if (uncontrolledOnChange) {
|
|
1249
|
+
uncontrolledOnChange.apply(void 0, [setUncontrolledState].concat(args));
|
|
1250
|
+
} else {
|
|
1251
|
+
setUncontrolledState.apply(void 0, args);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
controlledOnChange.apply(void 0, args);
|
|
1255
|
+
} : uncontrolledOnChange || setUncontrolledState];
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
function defaultGetZoomMultiplier(direction, time, perspective) {
|
|
1259
|
+
var multiplier = perspective.end - perspective.start < 100 && direction === 'in' ? 1 : 2;
|
|
1260
|
+
return direction === 'in' ? 1 / multiplier : multiplier;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
function useTimelinePerspective(_ref) {
|
|
1264
|
+
var start = _ref.start,
|
|
1265
|
+
end = _ref.end,
|
|
1266
|
+
propDefaultPerspective = _ref.defaultPerspective,
|
|
1267
|
+
propPerspective = _ref.perspective,
|
|
1268
|
+
propOnChangePerspective = _ref.onChangePerspective,
|
|
1269
|
+
_ref$zoomMultiplier = _ref.zoomMultiplier,
|
|
1270
|
+
zoomMultiplier = _ref$zoomMultiplier === void 0 ? defaultGetZoomMultiplier : _ref$zoomMultiplier;
|
|
1271
|
+
|
|
1272
|
+
var _useOptionallyControl = useOptionallyControlledState({
|
|
1273
|
+
uncontrolledDefaultState: propDefaultPerspective || {
|
|
1274
|
+
start: start,
|
|
1275
|
+
end: end
|
|
1276
|
+
},
|
|
1277
|
+
controlledState: propPerspective,
|
|
1278
|
+
controlledOnChange: propOnChangePerspective,
|
|
1279
|
+
componentName: 'VdtTimeline',
|
|
1280
|
+
stateName: 'perspective'
|
|
1281
|
+
}),
|
|
1282
|
+
_useOptionallyControl2 = _slicedToArray(_useOptionallyControl, 2),
|
|
1283
|
+
perspective = _useOptionallyControl2[0],
|
|
1284
|
+
setPerspective = _useOptionallyControl2[1];
|
|
1285
|
+
|
|
1286
|
+
var getZoomMultiplier = typeof zoomMultiplier === 'function' ? zoomMultiplier : function (direction) {
|
|
1287
|
+
return direction === 'in' ? 1 / zoomMultiplier : zoomMultiplier;
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
var checkedSetPerspective = function checkedSetPerspective(perspectiveStart, perspectiveEnd) {
|
|
1291
|
+
setPerspective({
|
|
1292
|
+
start: clamp(Number(perspectiveStart), start, end),
|
|
1293
|
+
end: clamp(Number(perspectiveEnd), start, end)
|
|
1294
|
+
});
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
var zoom = function zoom(direction, time) {
|
|
1298
|
+
var perspectiveDuration = perspective.end - perspective.start;
|
|
1299
|
+
var normalizedTimeOffset = (time - perspective.start) / perspectiveDuration;
|
|
1300
|
+
var currZoomMultiplier = getZoomMultiplier(direction, time, perspective);
|
|
1301
|
+
|
|
1302
|
+
if (currZoomMultiplier === 1) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
var newPerspectiveDuration = (perspective.end - perspective.start) * currZoomMultiplier;
|
|
1307
|
+
var newPerspectiveStart = time - normalizedTimeOffset * newPerspectiveDuration;
|
|
1308
|
+
var newPerspectiveEnd = time + (1 - normalizedTimeOffset) * newPerspectiveDuration;
|
|
1309
|
+
|
|
1310
|
+
var perspectiveMisalignmentCorrection = function () {
|
|
1311
|
+
if (start > newPerspectiveStart) {
|
|
1312
|
+
return start - newPerspectiveStart;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
if (newPerspectiveEnd > end) {
|
|
1316
|
+
return end - newPerspectiveEnd;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
return 0;
|
|
1320
|
+
}();
|
|
1321
|
+
|
|
1322
|
+
checkedSetPerspective(newPerspectiveStart + perspectiveMisalignmentCorrection, newPerspectiveEnd + perspectiveMisalignmentCorrection);
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
return {
|
|
1326
|
+
perspective: perspective,
|
|
1327
|
+
setPerspective: checkedSetPerspective,
|
|
1328
|
+
zoom: zoom
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1333
|
+
|
|
1334
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1335
|
+
var TimelineContext = /*#__PURE__*/createContext();
|
|
1336
|
+
function TimelineProvider(_ref) {
|
|
1337
|
+
var start = _ref.start,
|
|
1338
|
+
end = _ref.end,
|
|
1339
|
+
time = _ref.time,
|
|
1340
|
+
onChangeTime = _ref.onChangeTime,
|
|
1341
|
+
timelineRef = _ref.timelineRef,
|
|
1342
|
+
children = _ref.children,
|
|
1343
|
+
perspective = _ref.perspective,
|
|
1344
|
+
onChangePerspective = _ref.onChangePerspective,
|
|
1345
|
+
defaultPerspective = _ref.defaultPerspective;
|
|
1346
|
+
var timelinePerspective = useTimelinePerspective({
|
|
1347
|
+
start: start,
|
|
1348
|
+
end: end,
|
|
1349
|
+
perspective: perspective,
|
|
1350
|
+
onChangePerspective: onChangePerspective,
|
|
1351
|
+
defaultPerspective: defaultPerspective
|
|
1352
|
+
});
|
|
1353
|
+
var contextValue = useMemo(function () {
|
|
1354
|
+
return _objectSpread$9(_objectSpread$9({}, timelinePerspective), {}, {
|
|
1355
|
+
start: start,
|
|
1356
|
+
end: end,
|
|
1357
|
+
time: time,
|
|
1358
|
+
onChangeTime: onChangeTime,
|
|
1359
|
+
timelineRef: timelineRef
|
|
1360
|
+
});
|
|
1361
|
+
}, [end, onChangeTime, start, time, timelinePerspective, timelineRef]);
|
|
1362
|
+
return /*#__PURE__*/jsx(TimelineContext.Provider, {
|
|
1363
|
+
value: contextValue,
|
|
1364
|
+
children: children
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
function useTimeline() {
|
|
1368
|
+
return useContext(TimelineContext);
|
|
1369
|
+
}
|
|
1370
|
+
TimelineContext.propTypes = {
|
|
1371
|
+
start: PropTypes.number.isRequired,
|
|
1372
|
+
end: PropTypes.number.isRequired,
|
|
1373
|
+
time: PropTypes.number,
|
|
1374
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
1375
|
+
onChangeTime: PropTypes.func,
|
|
1376
|
+
timelineRef: PropTypes.shape({
|
|
1377
|
+
current: PropTypes.instanceOf(Element)
|
|
1378
|
+
}),
|
|
1379
|
+
perspective: PropTypes.shape({
|
|
1380
|
+
start: PropTypes.number,
|
|
1381
|
+
end: PropTypes.number
|
|
1382
|
+
}),
|
|
1383
|
+
onChangePerspective: PropTypes.func,
|
|
1384
|
+
defaultPerspective: PropTypes.shape({
|
|
1385
|
+
start: PropTypes.number,
|
|
1386
|
+
end: PropTypes.number
|
|
1387
|
+
}),
|
|
1388
|
+
zoomMultiplier: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
|
1389
|
+
};
|
|
1390
|
+
TimelineContext.defaultProps = {
|
|
1391
|
+
children: undefined,
|
|
1392
|
+
time: undefined,
|
|
1393
|
+
onChangeTime: undefined,
|
|
1394
|
+
timelineRef: undefined,
|
|
1395
|
+
perspective: undefined,
|
|
1396
|
+
onChangePerspective: undefined,
|
|
1397
|
+
defaultPerspective: undefined,
|
|
1398
|
+
zoomMultiplier: undefined
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
1402
|
+
|
|
1403
|
+
var css$7 = ":root {\n --vdt-timeline-palette-primary:#ba67c8;;\n --vdt-timeline-palette-primary-dark: rgb(130, 72, 140);\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimeline-root {\n display: flex;\n flex-direction: column;\n padding: 0 8px 8px 8px;\n background-color: var(--vdt-timeline-palette-background-primary);\n}";
|
|
1404
|
+
n(css$7,{});
|
|
1405
|
+
|
|
1406
|
+
var _excluded$8 = ["start", "end", "time", "onChangeTime", "children", "className", "perspective", "onChangePerspective", "defaultPerspective", "zoomMultiplier"];
|
|
1407
|
+
|
|
1408
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1409
|
+
|
|
1410
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1411
|
+
function Timeline(_ref) {
|
|
1412
|
+
var start = _ref.start,
|
|
1413
|
+
end = _ref.end,
|
|
1414
|
+
time = _ref.time,
|
|
1415
|
+
onChangeTime = _ref.onChangeTime,
|
|
1416
|
+
children = _ref.children,
|
|
1417
|
+
className = _ref.className,
|
|
1418
|
+
perspective = _ref.perspective,
|
|
1419
|
+
onChangePerspective = _ref.onChangePerspective,
|
|
1420
|
+
defaultPerspective = _ref.defaultPerspective,
|
|
1421
|
+
zoomMultiplier = _ref.zoomMultiplier,
|
|
1422
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
1423
|
+
|
|
1424
|
+
var timelineRef = useRef();
|
|
1425
|
+
return /*#__PURE__*/jsx(TimelineProvider, {
|
|
1426
|
+
start: start,
|
|
1427
|
+
end: end,
|
|
1428
|
+
time: time,
|
|
1429
|
+
onChangeTime: onChangeTime,
|
|
1430
|
+
timelineRef: timelineRef,
|
|
1431
|
+
perspective: perspective,
|
|
1432
|
+
onChangePerspective: onChangePerspective,
|
|
1433
|
+
defaultPerspective: defaultPerspective,
|
|
1434
|
+
zoomMultiplier: zoomMultiplier,
|
|
1435
|
+
children: /*#__PURE__*/jsx("div", _objectSpread$8(_objectSpread$8({
|
|
1436
|
+
ref: timelineRef,
|
|
1437
|
+
className: clsx('VdtTimeline-root', className) // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1438
|
+
|
|
1439
|
+
}, props), {}, {
|
|
1440
|
+
children: children
|
|
1441
|
+
}))
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
Timeline.propTypes = {
|
|
1445
|
+
/**
|
|
1446
|
+
* @ignore
|
|
1447
|
+
*/
|
|
1448
|
+
className: PropTypes.string,
|
|
1449
|
+
start: PropTypes.number.isRequired,
|
|
1450
|
+
end: PropTypes.number.isRequired,
|
|
1451
|
+
time: PropTypes.number,
|
|
1452
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1453
|
+
onChangeTime: PropTypes.func,
|
|
1454
|
+
perspective: PropTypes.shape({
|
|
1455
|
+
start: PropTypes.number,
|
|
1456
|
+
end: PropTypes.number
|
|
1457
|
+
}),
|
|
1458
|
+
onChangePerspective: PropTypes.func,
|
|
1459
|
+
defaultPerspective: PropTypes.shape({
|
|
1460
|
+
start: PropTypes.number,
|
|
1461
|
+
end: PropTypes.number
|
|
1462
|
+
}),
|
|
1463
|
+
zoomMultiplier: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
|
1464
|
+
};
|
|
1465
|
+
Timeline.defaultProps = {
|
|
1466
|
+
className: undefined,
|
|
1467
|
+
time: undefined,
|
|
1468
|
+
children: undefined,
|
|
1469
|
+
onChangeTime: undefined,
|
|
1470
|
+
perspective: undefined,
|
|
1471
|
+
onChangePerspective: undefined,
|
|
1472
|
+
defaultPerspective: undefined,
|
|
1473
|
+
zoomMultiplier: undefined
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
var DEFAULT_EVENT_HEIGHT = 15;
|
|
1477
|
+
var DEFAULT_PLAYHEAD_ZINDEX = 100;
|
|
1478
|
+
|
|
1479
|
+
var css$6 = ":root {\n --vdt-timeline-palette-primary:#ba67c8;;\n --vdt-timeline-palette-primary-dark: rgb(130, 72, 140);\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelinePlayhead-root {\n background-color: var(--vdt-timeline-palette-secondary);\n position: absolute;\n}\n\n\n.VdtTimelinePlayhead-root:hover {\n cursor: ew-resize;\n}";
|
|
1480
|
+
n(css$6,{});
|
|
1481
|
+
|
|
1482
|
+
var _excluded$7 = ["className", "perspective", "time", "lineWidth", "headWidth", "headHeight", "style", "onDrag", "HeadProps"];
|
|
1483
|
+
|
|
1484
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1485
|
+
|
|
1486
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1487
|
+
|
|
1488
|
+
var _getStyleProperties$3 = getStyleProperties('--vdt-timeline-palette-secondary'),
|
|
1489
|
+
_getStyleProperties2$3 = _slicedToArray(_getStyleProperties$3, 1),
|
|
1490
|
+
paletteSecondary$1 = _getStyleProperties2$3[0];
|
|
1491
|
+
|
|
1492
|
+
function TimelinePlayhead(_ref) {
|
|
1493
|
+
var _ref$current;
|
|
1494
|
+
|
|
1495
|
+
var className = _ref.className,
|
|
1496
|
+
propPerspective = _ref.perspective,
|
|
1497
|
+
propTime = _ref.time,
|
|
1498
|
+
lineWidth = _ref.lineWidth,
|
|
1499
|
+
headWidth = _ref.headWidth,
|
|
1500
|
+
headHeight = _ref.headHeight,
|
|
1501
|
+
style = _ref.style,
|
|
1502
|
+
onDrag = _ref.onDrag,
|
|
1503
|
+
HeadProps = _ref.HeadProps,
|
|
1504
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
1505
|
+
|
|
1506
|
+
var _ref2 = useTimeline() || {
|
|
1507
|
+
perspective: propPerspective,
|
|
1508
|
+
time: propTime
|
|
1509
|
+
},
|
|
1510
|
+
perspective = _ref2.perspective,
|
|
1511
|
+
time = _ref2.time,
|
|
1512
|
+
onChangeTime = _ref2.onChangeTime;
|
|
1513
|
+
|
|
1514
|
+
if (perspective === undefined) {
|
|
1515
|
+
vLog.error('VdtTimelinePlayhead', "missing 'perspective' prop. If the component is used outside a VdtTimelineContext, 'perspective' must be passed explicitly");
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
var ref = useRef();
|
|
1519
|
+
var containerEl = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
|
|
1520
|
+
var containerWidth = (containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientWidth) || 0;
|
|
1521
|
+
|
|
1522
|
+
var _useState = useState(false),
|
|
1523
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1524
|
+
isDragging = _useState2[0],
|
|
1525
|
+
setIsDragging = _useState2[1];
|
|
1526
|
+
|
|
1527
|
+
var _useState3 = useState(time),
|
|
1528
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1529
|
+
localTime = _useState4[0],
|
|
1530
|
+
setLocalTime = _useState4[1];
|
|
1531
|
+
|
|
1532
|
+
var markerLeft = interpolate(0, containerWidth, perspective.start, perspective.end, localTime);
|
|
1533
|
+
|
|
1534
|
+
var isValidTime = function isValidTime(f) {
|
|
1535
|
+
return f <= perspective.end && f >= perspective.start;
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
var hide = !isValidTime(localTime);
|
|
1539
|
+
useEffect(function () {
|
|
1540
|
+
if (time !== undefined && !isDragging) {
|
|
1541
|
+
setLocalTime(time);
|
|
1542
|
+
}
|
|
1543
|
+
}, [time, isDragging]);
|
|
1544
|
+
|
|
1545
|
+
var handleDrag = onDrag || onChangeTime && function (e) {
|
|
1546
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1547
|
+
args[_key - 1] = arguments[_key];
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
return onChangeTime.apply(void 0, args);
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
return /*#__PURE__*/jsx("div", _objectSpread$7(_objectSpread$7({
|
|
1554
|
+
ref: ref,
|
|
1555
|
+
className: clsx('VdtTimelinePlayhead-root', className),
|
|
1556
|
+
style: _objectSpread$7({
|
|
1557
|
+
width: lineWidth,
|
|
1558
|
+
left: markerLeft,
|
|
1559
|
+
display: hide && 'none',
|
|
1560
|
+
zIndex: DEFAULT_PLAYHEAD_ZINDEX
|
|
1561
|
+
}, style),
|
|
1562
|
+
draggable: true,
|
|
1563
|
+
onDragStart: function onDragStart(e) {
|
|
1564
|
+
setIsDragging(true);
|
|
1565
|
+
e.dataTransfer.setDragImage(ref.current, -99999, -99999);
|
|
1566
|
+
},
|
|
1567
|
+
onDragEnd: function onDragEnd() {
|
|
1568
|
+
setIsDragging(false);
|
|
1569
|
+
|
|
1570
|
+
if (handleDrag !== null && handleDrag !== void 0 && handleDrag.flush) {
|
|
1571
|
+
handleDrag.flush();
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
onDrag: function onDrag(e) {
|
|
1575
|
+
if (handleDrag) {
|
|
1576
|
+
var _ref$current$parentEl = ref.current.parentElement.getBoundingClientRect(),
|
|
1577
|
+
containerX = _ref$current$parentEl.x;
|
|
1578
|
+
|
|
1579
|
+
var newTime = interpolate(perspective.start, perspective.end, 0, containerWidth, e.clientX - containerX);
|
|
1580
|
+
|
|
1581
|
+
if (isValidTime(newTime)) {
|
|
1582
|
+
var clampedNewTime = clamp(newTime, perspective.start, perspective.end);
|
|
1583
|
+
handleDrag(e, clampedNewTime);
|
|
1584
|
+
setLocalTime(clampedNewTime);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1588
|
+
|
|
1589
|
+
}, props), {}, {
|
|
1590
|
+
children: /*#__PURE__*/jsx("div", _objectSpread$7({
|
|
1591
|
+
className: "VdtTimelinePlayhead-head",
|
|
1592
|
+
style: {
|
|
1593
|
+
position: 'absolute',
|
|
1594
|
+
height: headHeight,
|
|
1595
|
+
width: headWidth,
|
|
1596
|
+
backgroundColor: paletteSecondary$1,
|
|
1597
|
+
left: -(headWidth / 2 - lineWidth / 2),
|
|
1598
|
+
top: -headHeight + 1,
|
|
1599
|
+
clipPath: 'polygon(0% 0%, 0% 70%, 50% 100%, 100% 70%, 100% 0%)'
|
|
1600
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1601
|
+
|
|
1602
|
+
}, HeadProps))
|
|
1603
|
+
}));
|
|
1604
|
+
}
|
|
1605
|
+
TimelinePlayhead.propTypes = {
|
|
1606
|
+
/**
|
|
1607
|
+
* @ignore
|
|
1608
|
+
*/
|
|
1609
|
+
className: PropTypes.string,
|
|
1610
|
+
style: PropTypes.instanceOf(Object),
|
|
1611
|
+
headHeight: PropTypes.number,
|
|
1612
|
+
headWidth: PropTypes.number,
|
|
1613
|
+
lineWidth: PropTypes.number,
|
|
1614
|
+
perspective: PropTypes.shape({
|
|
1615
|
+
start: PropTypes.number,
|
|
1616
|
+
end: PropTypes.number
|
|
1617
|
+
}),
|
|
1618
|
+
time: PropTypes.number,
|
|
1619
|
+
onDrag: PropTypes.func,
|
|
1620
|
+
HeadProps: PropTypes.instanceOf(Object)
|
|
1621
|
+
};
|
|
1622
|
+
TimelinePlayhead.defaultProps = {
|
|
1623
|
+
className: undefined,
|
|
1624
|
+
style: {},
|
|
1625
|
+
headHeight: 16,
|
|
1626
|
+
headWidth: 12,
|
|
1627
|
+
lineWidth: 2,
|
|
1628
|
+
perspective: undefined,
|
|
1629
|
+
time: 0,
|
|
1630
|
+
onDrag: undefined,
|
|
1631
|
+
HeadProps: {}
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
function useResizeObserver(ref) {
|
|
1635
|
+
var _useState = useState({}),
|
|
1636
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1637
|
+
rect = _useState2[0],
|
|
1638
|
+
setRect = _useState2[1];
|
|
1639
|
+
|
|
1640
|
+
var observerRef = useRef(new ResizeObserver(function (entries) {
|
|
1641
|
+
var _entries$;
|
|
1642
|
+
|
|
1643
|
+
var contentRect = (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : _entries$.contentRect;
|
|
1644
|
+
|
|
1645
|
+
if (contentRect) {
|
|
1646
|
+
setRect(contentRect);
|
|
1647
|
+
}
|
|
1648
|
+
}));
|
|
1649
|
+
useEffect(function () {
|
|
1650
|
+
var observer = observerRef === null || observerRef === void 0 ? void 0 : observerRef.current;
|
|
1651
|
+
var el = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
1652
|
+
|
|
1653
|
+
if (el) {
|
|
1654
|
+
observer.observe(el);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
return function () {
|
|
1658
|
+
if (el) {
|
|
1659
|
+
observer.unobserve(el);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
}, [ref]);
|
|
1663
|
+
return rect;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
var css$5 = ":root {\n --vdt-timeline-palette-primary:#ba67c8;;\n --vdt-timeline-palette-primary-dark: rgb(130, 72, 140);\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}";
|
|
1667
|
+
n(css$5,{});
|
|
1668
|
+
|
|
1669
|
+
var css$4 = ".VdtTimelineWaveform-root {\n height: 40px;\n}";
|
|
1670
|
+
n(css$4,{});
|
|
1671
|
+
|
|
1672
|
+
var _excluded$6 = ["amplitudeSegments", "pxPerTimeUnit", "start", "height"],
|
|
1673
|
+
_excluded2$2 = ["className", "waveform", "start", "end", "perspective", "StageProps", "LayerProps", "RectProps", "WaveRectProps"];
|
|
1674
|
+
|
|
1675
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1676
|
+
|
|
1677
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1678
|
+
|
|
1679
|
+
var _getStyleProperties$2 = getStyleProperties('--vdt-timeline-palette-primary'),
|
|
1680
|
+
_getStyleProperties2$2 = _slicedToArray(_getStyleProperties$2, 1),
|
|
1681
|
+
palettePrimary = _getStyleProperties2$2[0];
|
|
1682
|
+
|
|
1683
|
+
var TimelineWaveFormRects = /*#__PURE__*/memo(function (_ref) {
|
|
1684
|
+
var amplitudeSegments = _ref.amplitudeSegments,
|
|
1685
|
+
pxPerTimeUnit = _ref.pxPerTimeUnit,
|
|
1686
|
+
start = _ref.start,
|
|
1687
|
+
height = _ref.height,
|
|
1688
|
+
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
1689
|
+
|
|
1690
|
+
return amplitudeSegments.map(function (_ref2, i) {
|
|
1691
|
+
var amplitude = _ref2.amplitude,
|
|
1692
|
+
segmentStart = _ref2.start,
|
|
1693
|
+
segmentEnd = _ref2.end;
|
|
1694
|
+
var rectWidth = pxPerTimeUnit * (segmentEnd - segmentStart);
|
|
1695
|
+
var rectX = (segmentStart - start) * pxPerTimeUnit;
|
|
1696
|
+
var rectHeight = height * amplitude;
|
|
1697
|
+
var centeredY = (height - rectHeight) / 2;
|
|
1698
|
+
return /*#__PURE__*/jsx(Rect // eslint-disable-next-line react/no-array-index-key
|
|
1699
|
+
, _objectSpread$6({
|
|
1700
|
+
x: rectX,
|
|
1701
|
+
y: centeredY,
|
|
1702
|
+
height: rectHeight,
|
|
1703
|
+
width: rectWidth,
|
|
1704
|
+
fill: palettePrimary // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1705
|
+
|
|
1706
|
+
}, props), i);
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1710
|
+
function TimelineWaveform(_ref3) {
|
|
1711
|
+
var className = _ref3.className,
|
|
1712
|
+
waveform = _ref3.waveform,
|
|
1713
|
+
propStart = _ref3.start,
|
|
1714
|
+
propEnd = _ref3.end,
|
|
1715
|
+
propPerspective = _ref3.perspective,
|
|
1716
|
+
StageProps = _ref3.StageProps,
|
|
1717
|
+
LayerProps = _ref3.LayerProps,
|
|
1718
|
+
RectProps = _ref3.RectProps,
|
|
1719
|
+
WaveRectProps = _ref3.WaveRectProps,
|
|
1720
|
+
props = _objectWithoutProperties(_ref3, _excluded2$2);
|
|
1721
|
+
|
|
1722
|
+
var _ref4 = useTimeline() || {
|
|
1723
|
+
start: propStart,
|
|
1724
|
+
end: propEnd,
|
|
1725
|
+
perspective: propPerspective
|
|
1726
|
+
},
|
|
1727
|
+
start = _ref4.start,
|
|
1728
|
+
end = _ref4.end,
|
|
1729
|
+
perspective = _ref4.perspective;
|
|
1730
|
+
|
|
1731
|
+
if (start === undefined || end === undefined || perspective === undefined) {
|
|
1732
|
+
vLog.error('VdtTimelineWaveform', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' or 'perspective' must be passed explicitly");
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
var ref = useRef();
|
|
1736
|
+
|
|
1737
|
+
var _useResizeObserver = useResizeObserver(ref),
|
|
1738
|
+
_useResizeObserver$wi = _useResizeObserver.width,
|
|
1739
|
+
width = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
1740
|
+
_useResizeObserver$he = _useResizeObserver.height,
|
|
1741
|
+
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
1742
|
+
|
|
1743
|
+
var amplitudeSegments = useMemo(function () {
|
|
1744
|
+
return waveform.map(function (amplitude, i) {
|
|
1745
|
+
return {
|
|
1746
|
+
amplitude: amplitude,
|
|
1747
|
+
start: interpolate(start, end, 0, waveform.length - 1, i),
|
|
1748
|
+
end: interpolate(start, end, 0, waveform.length - 1, i + 1)
|
|
1749
|
+
};
|
|
1750
|
+
});
|
|
1751
|
+
}, [waveform, start, end]);
|
|
1752
|
+
var pxPerTimeUnit = width / (end - start);
|
|
1753
|
+
var scaleX = (end - start) / (perspective.end - perspective.start);
|
|
1754
|
+
var offsetX = interpolate(0, scaleX * width, start, end, perspective.start);
|
|
1755
|
+
return /*#__PURE__*/jsx("div", _objectSpread$6(_objectSpread$6({
|
|
1756
|
+
ref: ref,
|
|
1757
|
+
className: clsx('VdtTimelineWaveform-root', className) // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1758
|
+
|
|
1759
|
+
}, props), {}, {
|
|
1760
|
+
children: /*#__PURE__*/jsx(Stage, _objectSpread$6(_objectSpread$6({
|
|
1761
|
+
height: height,
|
|
1762
|
+
width: width,
|
|
1763
|
+
x: -offsetX,
|
|
1764
|
+
scaleX: scaleX // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1765
|
+
|
|
1766
|
+
}, StageProps), {}, {
|
|
1767
|
+
children: /*#__PURE__*/jsxs(Layer, _objectSpread$6(_objectSpread$6({
|
|
1768
|
+
listening: false // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1769
|
+
|
|
1770
|
+
}, LayerProps), {}, {
|
|
1771
|
+
children: [/*#__PURE__*/jsx(Rect, _objectSpread$6({
|
|
1772
|
+
x: 0,
|
|
1773
|
+
y: 0,
|
|
1774
|
+
width: width,
|
|
1775
|
+
height: height // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1776
|
+
|
|
1777
|
+
}, RectProps)), /*#__PURE__*/jsx(TimelineWaveFormRects, _objectSpread$6({
|
|
1778
|
+
amplitudeSegments: amplitudeSegments,
|
|
1779
|
+
pxPerTimeUnit: pxPerTimeUnit,
|
|
1780
|
+
start: start,
|
|
1781
|
+
height: height // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1782
|
+
|
|
1783
|
+
}, WaveRectProps))]
|
|
1784
|
+
}))
|
|
1785
|
+
}))
|
|
1786
|
+
}));
|
|
1787
|
+
}
|
|
1788
|
+
TimelineWaveform.propTypes = {
|
|
1789
|
+
/**
|
|
1790
|
+
* @ignore
|
|
1791
|
+
*/
|
|
1792
|
+
className: PropTypes.string,
|
|
1793
|
+
waveform: PropTypes.arrayOf(PropTypes.number),
|
|
1794
|
+
start: PropTypes.number,
|
|
1795
|
+
end: PropTypes.number,
|
|
1796
|
+
perspective: PropTypes.shape({
|
|
1797
|
+
start: PropTypes.number,
|
|
1798
|
+
end: PropTypes.number
|
|
1799
|
+
}),
|
|
1800
|
+
StageProps: PropTypes.instanceOf(Object),
|
|
1801
|
+
LayerProps: PropTypes.instanceOf(Object),
|
|
1802
|
+
RectProps: PropTypes.instanceOf(Object),
|
|
1803
|
+
WaveRectProps: PropTypes.instanceOf(Object)
|
|
1804
|
+
};
|
|
1805
|
+
TimelineWaveform.defaultProps = {
|
|
1806
|
+
className: undefined,
|
|
1807
|
+
waveform: [],
|
|
1808
|
+
start: undefined,
|
|
1809
|
+
end: undefined,
|
|
1810
|
+
perspective: undefined,
|
|
1811
|
+
StageProps: {},
|
|
1812
|
+
LayerProps: {},
|
|
1813
|
+
RectProps: {},
|
|
1814
|
+
WaveRectProps: {}
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
function useHover() {
|
|
1818
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1819
|
+
_ref$hoverEffect = _ref.hoverEffect,
|
|
1820
|
+
hoverEffect = _ref$hoverEffect === void 0 ? function () {} : _ref$hoverEffect;
|
|
1821
|
+
|
|
1822
|
+
var _useState = useState(false),
|
|
1823
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1824
|
+
isHovering = _useState2[0],
|
|
1825
|
+
setIsHovering = _useState2[1];
|
|
1826
|
+
|
|
1827
|
+
var cleanupHover = useRef(null);
|
|
1828
|
+
return {
|
|
1829
|
+
isHovering: isHovering,
|
|
1830
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
1831
|
+
setIsHovering(true);
|
|
1832
|
+
cleanupHover.current = hoverEffect(e);
|
|
1833
|
+
},
|
|
1834
|
+
onMouseLeave: function onMouseLeave() {
|
|
1835
|
+
setIsHovering(false);
|
|
1836
|
+
|
|
1837
|
+
if (cleanupHover.current) {
|
|
1838
|
+
cleanupHover.current();
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
cleanupHover.current = null;
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
var _excluded$5 = ["className", "children", "perspective", "onClick", "style", "onHover", "StageProps", "LayerProps", "GroupProps", "RectProps"],
|
|
1847
|
+
_excluded2$1 = ["isHovering"];
|
|
1848
|
+
|
|
1849
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1850
|
+
|
|
1851
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1852
|
+
function TimelineTrack(_ref) {
|
|
1853
|
+
var className = _ref.className,
|
|
1854
|
+
children = _ref.children,
|
|
1855
|
+
propPerspective = _ref.perspective,
|
|
1856
|
+
onClick = _ref.onClick,
|
|
1857
|
+
style = _ref.style,
|
|
1858
|
+
onHover = _ref.onHover,
|
|
1859
|
+
StageProps = _ref.StageProps,
|
|
1860
|
+
LayerProps = _ref.LayerProps,
|
|
1861
|
+
GroupProps = _ref.GroupProps,
|
|
1862
|
+
RectProps = _ref.RectProps,
|
|
1863
|
+
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
1864
|
+
|
|
1865
|
+
var _ref2 = useTimeline() || {
|
|
1866
|
+
perspective: propPerspective
|
|
1867
|
+
},
|
|
1868
|
+
perspective = _ref2.perspective;
|
|
1869
|
+
|
|
1870
|
+
if (perspective === undefined) {
|
|
1871
|
+
vLog.error('VdtTimelineTrack', "missing 'perspective' prop. If the component is used outside a VdtTimelineContext, 'perspective' must be passed explicitly");
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
var visibleChildren = Children.toArray(children).filter(function (_ref3) {
|
|
1875
|
+
var _ref3$props = _ref3.props,
|
|
1876
|
+
childProps = _ref3$props === void 0 ? {} : _ref3$props;
|
|
1877
|
+
var isOutsidePerspective = childProps.start > perspective.end || childProps.end < perspective.start;
|
|
1878
|
+
return !isOutsidePerspective;
|
|
1879
|
+
});
|
|
1880
|
+
var eventsContainerRef = useRef();
|
|
1881
|
+
|
|
1882
|
+
var _useResizeObserver = useResizeObserver(eventsContainerRef),
|
|
1883
|
+
_useResizeObserver$wi = _useResizeObserver.width,
|
|
1884
|
+
eventContainerWidth = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
1885
|
+
_useResizeObserver$he = _useResizeObserver.height,
|
|
1886
|
+
eventContainerHeight = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he; // expect children to be passed 'y' and 'height' props so that we can calculate the track height
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
var eventsContainerHeight = Math.max.apply(Math, _toConsumableArray(Children.map(children, function (_ref4) {
|
|
1890
|
+
var _ref4$props = _ref4.props;
|
|
1891
|
+
_ref4$props = _ref4$props === void 0 ? {} : _ref4$props;
|
|
1892
|
+
var _ref4$props$y = _ref4$props.y,
|
|
1893
|
+
y = _ref4$props$y === void 0 ? 0 : _ref4$props$y,
|
|
1894
|
+
_ref4$props$height = _ref4$props.height,
|
|
1895
|
+
height = _ref4$props$height === void 0 ? 0 : _ref4$props$height;
|
|
1896
|
+
return y + height;
|
|
1897
|
+
}))) || DEFAULT_EVENT_HEIGHT;
|
|
1898
|
+
|
|
1899
|
+
var cloneChild = function cloneChild(child) {
|
|
1900
|
+
var _ref5 = child.props || {},
|
|
1901
|
+
childStart = _ref5.start,
|
|
1902
|
+
childEnd = _ref5.end;
|
|
1903
|
+
|
|
1904
|
+
var xProps = function () {
|
|
1905
|
+
if (childStart !== undefined && childEnd !== undefined) {
|
|
1906
|
+
var childX = interpolate(0, eventContainerWidth, perspective.start, perspective.end, childStart);
|
|
1907
|
+
var childWidth = interpolate(0, eventContainerWidth, perspective.start, perspective.end, childEnd) - childX;
|
|
1908
|
+
return {
|
|
1909
|
+
x: childX,
|
|
1910
|
+
width: childWidth
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
return {};
|
|
1915
|
+
}();
|
|
1916
|
+
|
|
1917
|
+
return /*#__PURE__*/cloneElement(child, _objectSpread$5(_objectSpread$5({}, child.props), xProps));
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
var _useHover = useHover({
|
|
1921
|
+
hoverEffect: function hoverEffect(e) {
|
|
1922
|
+
if (onHover) onHover(e, true);
|
|
1923
|
+
var container = e.target.getStage().container();
|
|
1924
|
+
|
|
1925
|
+
if (onClick) {
|
|
1926
|
+
container.style.cursor = 'pointer';
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
return function () {
|
|
1930
|
+
if (onHover) onHover(e, false);
|
|
1931
|
+
|
|
1932
|
+
if (onClick) {
|
|
1933
|
+
container.style.cursor = 'default';
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
_useHover.isHovering;
|
|
1939
|
+
var hoverProps = _objectWithoutProperties(_useHover, _excluded2$1);
|
|
1940
|
+
|
|
1941
|
+
return /*#__PURE__*/jsx("div", _objectSpread$5(_objectSpread$5({
|
|
1942
|
+
ref: eventsContainerRef,
|
|
1943
|
+
className: clsx('VdtTimelineTrack-root', className),
|
|
1944
|
+
style: _objectSpread$5({
|
|
1945
|
+
height: eventsContainerHeight
|
|
1946
|
+
}, style) // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1947
|
+
|
|
1948
|
+
}, props), {}, {
|
|
1949
|
+
children: /*#__PURE__*/jsx(Stage, _objectSpread$5(_objectSpread$5({
|
|
1950
|
+
height: eventContainerHeight,
|
|
1951
|
+
width: eventContainerWidth // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1952
|
+
|
|
1953
|
+
}, StageProps), {}, {
|
|
1954
|
+
children: /*#__PURE__*/jsx(Layer // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1955
|
+
, _objectSpread$5(_objectSpread$5({}, LayerProps), {}, {
|
|
1956
|
+
children: /*#__PURE__*/jsxs(Group // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1957
|
+
, _objectSpread$5(_objectSpread$5({}, GroupProps), {}, {
|
|
1958
|
+
children: [/*#__PURE__*/jsx(Rect, _objectSpread$5(_objectSpread$5({
|
|
1959
|
+
x: 0,
|
|
1960
|
+
y: 0,
|
|
1961
|
+
width: eventContainerWidth,
|
|
1962
|
+
height: eventContainerHeight,
|
|
1963
|
+
onClick: onClick // eslint-disable-next-line react/jsx-props-no-spreading
|
|
1964
|
+
|
|
1965
|
+
}, hoverProps), RectProps)), Children.map(visibleChildren, cloneChild)]
|
|
1966
|
+
}))
|
|
1967
|
+
}))
|
|
1968
|
+
}))
|
|
1969
|
+
}));
|
|
1970
|
+
}
|
|
1971
|
+
TimelineTrack.propTypes = {
|
|
1972
|
+
/**
|
|
1973
|
+
* @ignore
|
|
1974
|
+
*/
|
|
1975
|
+
className: PropTypes.string,
|
|
1976
|
+
style: PropTypes.instanceOf(Object),
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* children are positioned within the track according to 'start' and 'end' props passed to them
|
|
1980
|
+
*/
|
|
1981
|
+
// children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1982
|
+
children: function children(props, propName, componentName) {
|
|
1983
|
+
var prop = props[propName];
|
|
1984
|
+
var err;
|
|
1985
|
+
Children.forEach(prop, function (child) {
|
|
1986
|
+
var _child$props = child.props;
|
|
1987
|
+
_child$props = _child$props === void 0 ? {} : _child$props;
|
|
1988
|
+
var start = _child$props.start,
|
|
1989
|
+
end = _child$props.end;
|
|
1990
|
+
|
|
1991
|
+
if (start === undefined || end === undefined) {
|
|
1992
|
+
err = new Error("children of ".concat(componentName, " must be passed a 'start' and 'end' prop. These props are used to position the child within the track."));
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
return err;
|
|
1996
|
+
},
|
|
1997
|
+
perspective: PropTypes.shape({
|
|
1998
|
+
start: PropTypes.number,
|
|
1999
|
+
end: PropTypes.number
|
|
2000
|
+
}),
|
|
2001
|
+
onClick: PropTypes.func,
|
|
2002
|
+
onHover: PropTypes.func,
|
|
2003
|
+
StageProps: PropTypes.instanceOf(Object),
|
|
2004
|
+
LayerProps: PropTypes.instanceOf(Object),
|
|
2005
|
+
GroupProps: PropTypes.instanceOf(Object),
|
|
2006
|
+
RectProps: PropTypes.instanceOf(Object)
|
|
2007
|
+
};
|
|
2008
|
+
TimelineTrack.defaultProps = {
|
|
2009
|
+
className: undefined,
|
|
2010
|
+
style: {},
|
|
2011
|
+
children: undefined,
|
|
2012
|
+
perspective: undefined,
|
|
2013
|
+
onClick: undefined,
|
|
2014
|
+
onHover: undefined,
|
|
2015
|
+
StageProps: {},
|
|
2016
|
+
LayerProps: {},
|
|
2017
|
+
GroupProps: {},
|
|
2018
|
+
RectProps: {}
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
var css$3 = ":root {\n --vdt-timeline-palette-primary:#ba67c8;;\n --vdt-timeline-palette-primary-dark: rgb(130, 72, 140);\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelineRow-root {\n display: flex;\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel:hover {\n background-color: var(--vdt-timeline-palette-background-hover);\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel {\n border-width: 2px 0 0 0;\n border-style: solid;\n border-color: var(--vdt-timeline-palette-background-secondary);\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel > :first-child {\n width: 100px;\n padding: 0 8px;\n border-width: 0 2px 0 0;\n border-style: solid;\n border-color: var(--vdt-timeline-palette-background-secondary);\n}\n\n.VdtTimelineRow-root > :not(.VdtTimelineRow-label) {\n flex-grow: 1;\n margin: 4px 0;\n}\n\n.VdtTimelineRow-root:not(.VdtTimelineRow-hasLabel) > :first-child {\n margin-left: 100px;\n}\n\n.VdtTimelineRow-label {\n display: flex;\n align-items: center;\n}\n\n.VdtTimelineRow-labelText {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: center;\n}";
|
|
2022
|
+
n(css$3,{});
|
|
2023
|
+
|
|
2024
|
+
var _excluded$4 = ["className", "children", "label", "LabelProps", "LabelTextProps"];
|
|
2025
|
+
|
|
2026
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2027
|
+
|
|
2028
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2029
|
+
function TimelineRow(_ref) {
|
|
2030
|
+
var className = _ref.className,
|
|
2031
|
+
children = _ref.children,
|
|
2032
|
+
label = _ref.label,
|
|
2033
|
+
LabelProps = _ref.LabelProps,
|
|
2034
|
+
LabelTextProps = _ref.LabelTextProps,
|
|
2035
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
2036
|
+
|
|
2037
|
+
return /*#__PURE__*/jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
2038
|
+
className: clsx('VdtTimelineRow-root', className, {
|
|
2039
|
+
'VdtTimelineRow-hasLabel': !!label
|
|
2040
|
+
}) // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2041
|
+
|
|
2042
|
+
}, props), {}, {
|
|
2043
|
+
children: [label && /*#__PURE__*/jsx("div", _objectSpread$4(_objectSpread$4({
|
|
2044
|
+
className: "VdtTimelineRow-label" // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2045
|
+
|
|
2046
|
+
}, LabelProps), {}, {
|
|
2047
|
+
children: /*#__PURE__*/jsx("span", _objectSpread$4(_objectSpread$4({
|
|
2048
|
+
className: "VdtTimelineRow-labelText" // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2049
|
+
|
|
2050
|
+
}, LabelTextProps), {}, {
|
|
2051
|
+
children: label
|
|
2052
|
+
}))
|
|
2053
|
+
})), children]
|
|
2054
|
+
}));
|
|
2055
|
+
}
|
|
2056
|
+
TimelineRow.propTypes = {
|
|
2057
|
+
/**
|
|
2058
|
+
* @ignore
|
|
2059
|
+
*/
|
|
2060
|
+
className: PropTypes.string,
|
|
2061
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
2062
|
+
label: PropTypes.node,
|
|
2063
|
+
LabelProps: PropTypes.instanceOf(Object),
|
|
2064
|
+
LabelTextProps: PropTypes.instanceOf(Object)
|
|
2065
|
+
};
|
|
2066
|
+
TimelineRow.defaultProps = {
|
|
2067
|
+
className: undefined,
|
|
2068
|
+
children: undefined,
|
|
2069
|
+
label: undefined,
|
|
2070
|
+
LabelProps: {},
|
|
2071
|
+
LabelTextProps: {}
|
|
2072
|
+
};
|
|
2073
|
+
|
|
2074
|
+
var css$2 = "\n.VdtTimelinePlayheadTrack-root {\n height: 40px;\n position: relative;\n}";
|
|
2075
|
+
n(css$2,{});
|
|
2076
|
+
|
|
2077
|
+
var _excluded$3 = ["className", "children", "ticks", "onClick", "onHover", "onWheel", "onDrag", "start", "end", "perspective", "timelineRef", "StageProps", "LayerProps", "GroupProps", "RectProps", "TickGroupProps", "TickTextProps", "TickLineProps"],
|
|
2078
|
+
_excluded2 = ["isHovering"];
|
|
2079
|
+
|
|
2080
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2081
|
+
|
|
2082
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2083
|
+
var LABEL_EDGE_MARGIN = 2;
|
|
2084
|
+
|
|
2085
|
+
var _getStyleProperties$1 = getStyleProperties('--vdt-timeline-palette-text-primary', '--vdt-timeline-palette-text-secondary'),
|
|
2086
|
+
_getStyleProperties2$1 = _slicedToArray(_getStyleProperties$1, 2),
|
|
2087
|
+
paletteTextPrimary = _getStyleProperties2$1[0],
|
|
2088
|
+
paletteTextSecondary = _getStyleProperties2$1[1];
|
|
2089
|
+
|
|
2090
|
+
function TimelineTick(_ref) {
|
|
2091
|
+
var x = _ref.x,
|
|
2092
|
+
y = _ref.y,
|
|
2093
|
+
minX = _ref.minX,
|
|
2094
|
+
maxX = _ref.maxX,
|
|
2095
|
+
label = _ref.label,
|
|
2096
|
+
TickGroupProps = _ref.TickGroupProps,
|
|
2097
|
+
TickTextProps = _ref.TickTextProps,
|
|
2098
|
+
TickLineProps = _ref.TickLineProps;
|
|
2099
|
+
var hasLabel = label !== undefined;
|
|
2100
|
+
|
|
2101
|
+
var _ref2 = hasLabel ? {
|
|
2102
|
+
color: paletteTextPrimary,
|
|
2103
|
+
tickWidth: 2,
|
|
2104
|
+
tickSize: 8
|
|
2105
|
+
} : {
|
|
2106
|
+
color: paletteTextSecondary,
|
|
2107
|
+
tickWidth: 1,
|
|
2108
|
+
tickSize: 4
|
|
2109
|
+
},
|
|
2110
|
+
color = _ref2.color,
|
|
2111
|
+
tickWidth = _ref2.tickWidth,
|
|
2112
|
+
tickSize = _ref2.tickSize;
|
|
2113
|
+
|
|
2114
|
+
var _useState = useState(),
|
|
2115
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2116
|
+
labelWidth = _useState2[0],
|
|
2117
|
+
setLabelWidth = _useState2[1];
|
|
2118
|
+
|
|
2119
|
+
var textRef = useRef();
|
|
2120
|
+
useEffect(function () {
|
|
2121
|
+
if (textRef.current) {
|
|
2122
|
+
setLabelWidth(textRef.current.getTextWidth());
|
|
2123
|
+
}
|
|
2124
|
+
}, []);
|
|
2125
|
+
var textX = clamp(x - labelWidth / 2, minX + LABEL_EDGE_MARGIN, maxX - labelWidth - LABEL_EDGE_MARGIN) || undefined;
|
|
2126
|
+
|
|
2127
|
+
if (x < minX || x > maxX) {
|
|
2128
|
+
return null;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
return (
|
|
2132
|
+
/*#__PURE__*/
|
|
2133
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
2134
|
+
jsxs(Group, _objectSpread$3(_objectSpread$3({}, TickGroupProps), {}, {
|
|
2135
|
+
children: [/*#__PURE__*/jsx(Text, _objectSpread$3({
|
|
2136
|
+
ref: textRef,
|
|
2137
|
+
x: textX,
|
|
2138
|
+
y: y - tickSize - 20,
|
|
2139
|
+
fontFamily: "Helvetica",
|
|
2140
|
+
text: label,
|
|
2141
|
+
fontStyle: "bold",
|
|
2142
|
+
fontSize: 10,
|
|
2143
|
+
fill: color // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2144
|
+
|
|
2145
|
+
}, TickTextProps)), /*#__PURE__*/jsx(Line, _objectSpread$3({
|
|
2146
|
+
points: [x, y - tickSize, x, y],
|
|
2147
|
+
stroke: color,
|
|
2148
|
+
strokeWidth: tickWidth // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2149
|
+
|
|
2150
|
+
}, TickLineProps))]
|
|
2151
|
+
}))
|
|
2152
|
+
);
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
function defaultTicks(_ref3) {
|
|
2156
|
+
var width = _ref3.width,
|
|
2157
|
+
perspective = _ref3.perspective;
|
|
2158
|
+
var numTicks = Math.max(Math.floor(width / 90), 2);
|
|
2159
|
+
var labeledTicks = uniq(_toConsumableArray(Array(numTicks).keys()).map(function (i) {
|
|
2160
|
+
return interpolate(perspective.start, perspective.end, 0, numTicks - 1, i);
|
|
2161
|
+
})).map(function (time) {
|
|
2162
|
+
return {
|
|
2163
|
+
time: time,
|
|
2164
|
+
label: String(Math.round(time))
|
|
2165
|
+
};
|
|
2166
|
+
});
|
|
2167
|
+
var unlabeledTicks = mapPairs(labeledTicks, function (curr, next) {
|
|
2168
|
+
var tickDelta = (next.time - curr.time) / 10;
|
|
2169
|
+
return _toConsumableArray(Array(9).keys()).map(function (i) {
|
|
2170
|
+
return {
|
|
2171
|
+
time: curr.time + (i + 1) * tickDelta
|
|
2172
|
+
};
|
|
2173
|
+
});
|
|
2174
|
+
}).flat();
|
|
2175
|
+
return sortBy([].concat(_toConsumableArray(labeledTicks), _toConsumableArray(unlabeledTicks)), ['time']);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
function TimelinePlayheadTrack(_ref4) {
|
|
2179
|
+
var _trackContainerRef$cu, _timelineRef$current;
|
|
2180
|
+
|
|
2181
|
+
var className = _ref4.className,
|
|
2182
|
+
children = _ref4.children,
|
|
2183
|
+
propTicks = _ref4.ticks,
|
|
2184
|
+
onClick = _ref4.onClick,
|
|
2185
|
+
onHover = _ref4.onHover,
|
|
2186
|
+
onWheel = _ref4.onWheel,
|
|
2187
|
+
onDrag = _ref4.onDrag,
|
|
2188
|
+
propStart = _ref4.start,
|
|
2189
|
+
propEnd = _ref4.end,
|
|
2190
|
+
propPerspective = _ref4.perspective,
|
|
2191
|
+
propTimelineRef = _ref4.timelineRef,
|
|
2192
|
+
StageProps = _ref4.StageProps,
|
|
2193
|
+
LayerProps = _ref4.LayerProps,
|
|
2194
|
+
GroupProps = _ref4.GroupProps,
|
|
2195
|
+
RectProps = _ref4.RectProps,
|
|
2196
|
+
TickGroupProps = _ref4.TickGroupProps,
|
|
2197
|
+
TickTextProps = _ref4.TickTextProps,
|
|
2198
|
+
TickLineProps = _ref4.TickLineProps,
|
|
2199
|
+
props = _objectWithoutProperties(_ref4, _excluded$3);
|
|
2200
|
+
|
|
2201
|
+
var _ref5 = useTimeline() || {
|
|
2202
|
+
start: propStart,
|
|
2203
|
+
end: propEnd,
|
|
2204
|
+
perspective: propPerspective,
|
|
2205
|
+
timelineRef: propTimelineRef
|
|
2206
|
+
},
|
|
2207
|
+
start = _ref5.start,
|
|
2208
|
+
end = _ref5.end,
|
|
2209
|
+
perspective = _ref5.perspective,
|
|
2210
|
+
setPerspective = _ref5.setPerspective,
|
|
2211
|
+
zoom = _ref5.zoom,
|
|
2212
|
+
onChangeTime = _ref5.onChangeTime,
|
|
2213
|
+
timelineRef = _ref5.timelineRef;
|
|
2214
|
+
|
|
2215
|
+
if (start === undefined || end === undefined || perspective === undefined) {
|
|
2216
|
+
vLog.error('VdtTimelinePlayheadTrack', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' and 'perspective' must be passed explicitly");
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
if (timelineRef === undefined && (children === null || children === void 0 ? void 0 : children.length) > 0) {
|
|
2220
|
+
vLog.warn('VdtTimelinePlayheadTrack', "missing 'timelineRef' prop. This ref is used to set the height of the playhead within the timeline.");
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
var handleWheel = onWheel || zoom && function (e) {
|
|
2224
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2225
|
+
args[_key - 1] = arguments[_key];
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
return zoom.apply(void 0, args);
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
var handleClick = onClick || onChangeTime && function (e) {
|
|
2232
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2233
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
return onChangeTime.apply(void 0, args);
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2239
|
+
var handleDrag = onDrag || setPerspective && function (e) {
|
|
2240
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
2241
|
+
args[_key3 - 1] = arguments[_key3];
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
return setPerspective.apply(void 0, args);
|
|
2245
|
+
};
|
|
2246
|
+
|
|
2247
|
+
var trackContainerRef = useRef();
|
|
2248
|
+
|
|
2249
|
+
var _useResizeObserver = useResizeObserver(trackContainerRef),
|
|
2250
|
+
_useResizeObserver$wi = _useResizeObserver.width,
|
|
2251
|
+
width = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
2252
|
+
_useResizeObserver$he = _useResizeObserver.height,
|
|
2253
|
+
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
2254
|
+
|
|
2255
|
+
var getTicks = propTicks || defaultTicks;
|
|
2256
|
+
var timeTicks = typeof getTicks === 'function' ? getTicks({
|
|
2257
|
+
start: start,
|
|
2258
|
+
end: end,
|
|
2259
|
+
width: width,
|
|
2260
|
+
perspective: perspective
|
|
2261
|
+
}) : getTicks;
|
|
2262
|
+
var ticks = timeTicks.map(function (_ref6) {
|
|
2263
|
+
var label = _ref6.label,
|
|
2264
|
+
time = _ref6.time;
|
|
2265
|
+
return {
|
|
2266
|
+
x: interpolate(0, width, perspective.start, perspective.end, time),
|
|
2267
|
+
label: label,
|
|
2268
|
+
time: time
|
|
2269
|
+
};
|
|
2270
|
+
});
|
|
2271
|
+
|
|
2272
|
+
var _useResizeObserver2 = useResizeObserver(timelineRef),
|
|
2273
|
+
timelineHeight = _useResizeObserver2.height;
|
|
2274
|
+
|
|
2275
|
+
var timelineOffsetTop = ((trackContainerRef === null || trackContainerRef === void 0 ? void 0 : (_trackContainerRef$cu = trackContainerRef.current) === null || _trackContainerRef$cu === void 0 ? void 0 : _trackContainerRef$cu.offsetTop) || 0) - ((timelineRef === null || timelineRef === void 0 ? void 0 : (_timelineRef$current = timelineRef.current) === null || _timelineRef$current === void 0 ? void 0 : _timelineRef$current.offsetTop) || 0);
|
|
2276
|
+
var playheadTop = height;
|
|
2277
|
+
var playheadHeight = timelineHeight - height - timelineOffsetTop || undefined;
|
|
2278
|
+
var trackRectRef = useRef();
|
|
2279
|
+
|
|
2280
|
+
var _useHover = useHover({
|
|
2281
|
+
hoverEffect: function hoverEffect(e) {
|
|
2282
|
+
if (onHover) onHover(e, true);
|
|
2283
|
+
var container = e.target.getStage().container();
|
|
2284
|
+
|
|
2285
|
+
if (handleClick) {
|
|
2286
|
+
container.style.cursor = 'pointer';
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
return function () {
|
|
2290
|
+
if (onHover) onHover(e, false);
|
|
2291
|
+
|
|
2292
|
+
if (handleClick) {
|
|
2293
|
+
container.style.cursor = 'default';
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
_useHover.isHovering;
|
|
2299
|
+
var hoverProps = _objectWithoutProperties(_useHover, _excluded2);
|
|
2300
|
+
|
|
2301
|
+
return /*#__PURE__*/jsxs("div", _objectSpread$3(_objectSpread$3({
|
|
2302
|
+
ref: trackContainerRef,
|
|
2303
|
+
className: clsx('VdtTimelinePlayheadTrack-root', className) // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2304
|
+
|
|
2305
|
+
}, props), {}, {
|
|
2306
|
+
children: [Children.map(children, function (child) {
|
|
2307
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
2308
|
+
style: {
|
|
2309
|
+
top: playheadTop,
|
|
2310
|
+
height: playheadHeight
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
}), /*#__PURE__*/jsx(Stage, _objectSpread$3(_objectSpread$3({
|
|
2314
|
+
height: height,
|
|
2315
|
+
width: width // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2316
|
+
|
|
2317
|
+
}, StageProps), {}, {
|
|
2318
|
+
children: /*#__PURE__*/jsx(Layer // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2319
|
+
, _objectSpread$3(_objectSpread$3({}, LayerProps), {}, {
|
|
2320
|
+
children: /*#__PURE__*/jsxs(Group, _objectSpread$3(_objectSpread$3(_objectSpread$3({
|
|
2321
|
+
onClick: function onClick(e) {
|
|
2322
|
+
if (trackRectRef.current && handleClick) {
|
|
2323
|
+
var _trackRectRef$current = trackRectRef.current.getRelativePointerPosition(),
|
|
2324
|
+
x = _trackRectRef$current.x;
|
|
2325
|
+
|
|
2326
|
+
handleClick(e, interpolate(perspective.start, perspective.end, 0, width, x));
|
|
2327
|
+
}
|
|
2328
|
+
},
|
|
2329
|
+
onWheel: function onWheel(e) {
|
|
2330
|
+
if (trackRectRef.current && handleWheel) {
|
|
2331
|
+
var _trackRectRef$current2 = trackRectRef.current.getRelativePointerPosition(),
|
|
2332
|
+
x = _trackRectRef$current2.x;
|
|
2333
|
+
|
|
2334
|
+
handleWheel(e, e.evt.deltaY < 0 ? 'in' : 'out', interpolate(perspective.start, perspective.end, 0, width, x));
|
|
2335
|
+
}
|
|
2336
|
+
},
|
|
2337
|
+
draggable: true,
|
|
2338
|
+
dragBoundFunc: function dragBoundFunc() {
|
|
2339
|
+
return {
|
|
2340
|
+
x: 0,
|
|
2341
|
+
y: 0
|
|
2342
|
+
};
|
|
2343
|
+
},
|
|
2344
|
+
onDragStart: function onDragStart(e) {
|
|
2345
|
+
var container = e.target.getStage().container();
|
|
2346
|
+
container.style.cursor = 'grabbing';
|
|
2347
|
+
},
|
|
2348
|
+
onDragEnd: function onDragEnd(e) {
|
|
2349
|
+
var container = e.target.getStage().container();
|
|
2350
|
+
container.style.cursor = 'pointer';
|
|
2351
|
+
},
|
|
2352
|
+
onDragMove: function onDragMove(e) {
|
|
2353
|
+
if (handleDrag) {
|
|
2354
|
+
var movementX = e.evt.movementX;
|
|
2355
|
+
if (movementX === 0) return;
|
|
2356
|
+
var newStart = interpolate(perspective.start, perspective.end, 0, width, -movementX);
|
|
2357
|
+
var perspectiveDuration = perspective.end - perspective.start;
|
|
2358
|
+
var clampedNewStart = clamp(newStart, start, end - perspectiveDuration);
|
|
2359
|
+
var newEnd = clampedNewStart + perspectiveDuration;
|
|
2360
|
+
handleDrag(e, clampedNewStart, newEnd);
|
|
2361
|
+
}
|
|
2362
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2363
|
+
|
|
2364
|
+
}, hoverProps), GroupProps), {}, {
|
|
2365
|
+
children: [/*#__PURE__*/jsx(Rect, _objectSpread$3({
|
|
2366
|
+
ref: trackRectRef,
|
|
2367
|
+
x: 0,
|
|
2368
|
+
y: 0,
|
|
2369
|
+
width: width,
|
|
2370
|
+
height: height // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2371
|
+
|
|
2372
|
+
}, RectProps)), ticks.map(function (_ref7) {
|
|
2373
|
+
var x = _ref7.x,
|
|
2374
|
+
label = _ref7.label,
|
|
2375
|
+
time = _ref7.time;
|
|
2376
|
+
return /*#__PURE__*/jsx(TimelineTick, {
|
|
2377
|
+
minX: 0,
|
|
2378
|
+
maxX: width,
|
|
2379
|
+
x: x,
|
|
2380
|
+
label: label,
|
|
2381
|
+
y: height,
|
|
2382
|
+
TickGroupProps: TickGroupProps,
|
|
2383
|
+
TickLineProps: TickLineProps,
|
|
2384
|
+
TickTextProps: TickTextProps
|
|
2385
|
+
}, time);
|
|
2386
|
+
})]
|
|
2387
|
+
}))
|
|
2388
|
+
}))
|
|
2389
|
+
}))]
|
|
2390
|
+
}));
|
|
2391
|
+
}
|
|
2392
|
+
TimelinePlayheadTrack.propTypes = {
|
|
2393
|
+
/**
|
|
2394
|
+
* @ignore
|
|
2395
|
+
*/
|
|
2396
|
+
className: PropTypes.string,
|
|
2397
|
+
onClick: PropTypes.func,
|
|
2398
|
+
onHover: PropTypes.func,
|
|
2399
|
+
ticks: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
|
|
2400
|
+
time: PropTypes.number,
|
|
2401
|
+
label: PropTypes.string
|
|
2402
|
+
})), PropTypes.func]),
|
|
2403
|
+
onWheel: PropTypes.func,
|
|
2404
|
+
onDrag: PropTypes.func,
|
|
2405
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
2406
|
+
start: PropTypes.number,
|
|
2407
|
+
end: PropTypes.number,
|
|
2408
|
+
perspective: PropTypes.shape({
|
|
2409
|
+
start: PropTypes.number,
|
|
2410
|
+
end: PropTypes.number
|
|
2411
|
+
}),
|
|
2412
|
+
timelineRef: PropTypes.shape({
|
|
2413
|
+
current: PropTypes.instanceOf(Element)
|
|
2414
|
+
}),
|
|
2415
|
+
StageProps: PropTypes.instanceOf(Object),
|
|
2416
|
+
LayerProps: PropTypes.instanceOf(Object),
|
|
2417
|
+
GroupProps: PropTypes.instanceOf(Object),
|
|
2418
|
+
RectProps: PropTypes.instanceOf(Object),
|
|
2419
|
+
TickGroupProps: PropTypes.instanceOf(Object),
|
|
2420
|
+
TickTextProps: PropTypes.instanceOf(Object),
|
|
2421
|
+
TickLineProps: PropTypes.instanceOf(Object)
|
|
2422
|
+
};
|
|
2423
|
+
TimelinePlayheadTrack.defaultProps = {
|
|
2424
|
+
className: undefined,
|
|
2425
|
+
onClick: undefined,
|
|
2426
|
+
onHover: undefined,
|
|
2427
|
+
ticks: defaultTicks,
|
|
2428
|
+
children: undefined,
|
|
2429
|
+
start: undefined,
|
|
2430
|
+
end: undefined,
|
|
2431
|
+
perspective: undefined,
|
|
2432
|
+
onWheel: undefined,
|
|
2433
|
+
onDrag: undefined,
|
|
2434
|
+
timelineRef: undefined,
|
|
2435
|
+
StageProps: {},
|
|
2436
|
+
LayerProps: {},
|
|
2437
|
+
GroupProps: {},
|
|
2438
|
+
RectProps: {},
|
|
2439
|
+
TickGroupProps: {},
|
|
2440
|
+
TickTextProps: {},
|
|
2441
|
+
TickLineProps: {}
|
|
2442
|
+
};
|
|
2443
|
+
|
|
2444
|
+
var _excluded$2 = ["index"];
|
|
2445
|
+
|
|
2446
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2447
|
+
|
|
2448
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2449
|
+
|
|
2450
|
+
/**
|
|
2451
|
+
* Extends events with height and y props to display them if they are overlapping
|
|
2452
|
+
* @param {Object[]} events - events to add overlapping info for
|
|
2453
|
+
* @param {Object} options - options for how to extend events
|
|
2454
|
+
* @param {number} options.height=15 - height of events
|
|
2455
|
+
* @returns {Array} events with height and y position added
|
|
2456
|
+
*/
|
|
2457
|
+
|
|
2458
|
+
var getStackOverlappingEventProps = function getStackOverlappingEventProps(events) {
|
|
2459
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2460
|
+
|
|
2461
|
+
var _ref = options || {},
|
|
2462
|
+
_ref$height = _ref.height,
|
|
2463
|
+
height = _ref$height === void 0 ? DEFAULT_EVENT_HEIGHT : _ref$height;
|
|
2464
|
+
|
|
2465
|
+
var sortedEvents = sortBy(events.map(function (e, index) {
|
|
2466
|
+
return _objectSpread$2(_objectSpread$2({}, e), {}, {
|
|
2467
|
+
index: index
|
|
2468
|
+
});
|
|
2469
|
+
}), ['start', 'end']);
|
|
2470
|
+
var tracks = [0];
|
|
2471
|
+
var eventTracks = [];
|
|
2472
|
+
|
|
2473
|
+
var _loop = function _loop(i) {
|
|
2474
|
+
var event = sortedEvents[i];
|
|
2475
|
+
|
|
2476
|
+
var trackIndex = function () {
|
|
2477
|
+
for (var j = 0; j < tracks.length; j += 1) {
|
|
2478
|
+
var firstVacantFrame = tracks[j];
|
|
2479
|
+
|
|
2480
|
+
if (event.start >= firstVacantFrame) {
|
|
2481
|
+
return j;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
tracks.push(0);
|
|
2486
|
+
return tracks.length - 1;
|
|
2487
|
+
}();
|
|
2488
|
+
|
|
2489
|
+
tracks[trackIndex] = event.end;
|
|
2490
|
+
eventTracks.push(_objectSpread$2(_objectSpread$2({}, event), {}, {
|
|
2491
|
+
height: height,
|
|
2492
|
+
y: trackIndex * height
|
|
2493
|
+
}));
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
|
+
for (var i = 0; i < sortedEvents.length; i += 1) {
|
|
2497
|
+
_loop(i);
|
|
2498
|
+
} // retain the original order of the events
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
return sortBy(eventTracks, 'index').map(function (_ref2) {
|
|
2502
|
+
_ref2.index;
|
|
2503
|
+
var event = _objectWithoutProperties(_ref2, _excluded$2);
|
|
2504
|
+
|
|
2505
|
+
return event;
|
|
2506
|
+
});
|
|
2507
|
+
};
|
|
2508
|
+
|
|
2509
|
+
var css$1 = ":root {\n --vdt-timeline-palette-primary:#ba67c8;;\n --vdt-timeline-palette-primary-dark: rgb(130, 72, 140);\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelineScroll-root {\n height: 4px;\n background-color: var(--vdt-timeline-palette-background-secondary);\n}";
|
|
2510
|
+
n(css$1,{});
|
|
2511
|
+
|
|
2512
|
+
var _excluded$1 = ["className", "onScroll", "onClick", "start", "end", "perspective", "style", "StageProps", "LayerProps", "RectProps"];
|
|
2513
|
+
|
|
2514
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2515
|
+
|
|
2516
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2517
|
+
|
|
2518
|
+
var _getStyleProperties = getStyleProperties('--vdt-timeline-palette-secondary'),
|
|
2519
|
+
_getStyleProperties2 = _slicedToArray(_getStyleProperties, 1),
|
|
2520
|
+
paletteSecondary = _getStyleProperties2[0];
|
|
2521
|
+
|
|
2522
|
+
function TimelineScroll(_ref) {
|
|
2523
|
+
var className = _ref.className,
|
|
2524
|
+
onScroll = _ref.onScroll,
|
|
2525
|
+
onClick = _ref.onClick,
|
|
2526
|
+
propStart = _ref.start,
|
|
2527
|
+
propEnd = _ref.end,
|
|
2528
|
+
propPerspective = _ref.perspective,
|
|
2529
|
+
style = _ref.style,
|
|
2530
|
+
StageProps = _ref.StageProps,
|
|
2531
|
+
LayerProps = _ref.LayerProps,
|
|
2532
|
+
RectProps = _ref.RectProps,
|
|
2533
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
2534
|
+
|
|
2535
|
+
var _ref2 = useTimeline() || {
|
|
2536
|
+
start: propStart,
|
|
2537
|
+
end: propEnd,
|
|
2538
|
+
perspective: propPerspective
|
|
2539
|
+
},
|
|
2540
|
+
start = _ref2.start,
|
|
2541
|
+
end = _ref2.end,
|
|
2542
|
+
perspective = _ref2.perspective,
|
|
2543
|
+
setPerspective = _ref2.setPerspective;
|
|
2544
|
+
|
|
2545
|
+
if (start === undefined || end === undefined || perspective === undefined) {
|
|
2546
|
+
vLog.error('VdtTimelineScroll', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' and 'perspective' must be passed explicitly");
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
var ref = useRef();
|
|
2550
|
+
|
|
2551
|
+
var _useResizeObserver = useResizeObserver(ref),
|
|
2552
|
+
_useResizeObserver$wi = _useResizeObserver.width,
|
|
2553
|
+
scrollTrackWidth = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
2554
|
+
_useResizeObserver$he = _useResizeObserver.height,
|
|
2555
|
+
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
2556
|
+
|
|
2557
|
+
var scrollLeft = interpolate(0, scrollTrackWidth, start, end, perspective.start);
|
|
2558
|
+
var perspectiveDuration = perspective.end - perspective.start;
|
|
2559
|
+
var scrollWidth = interpolate(0, scrollTrackWidth, 0, end - start, perspectiveDuration);
|
|
2560
|
+
|
|
2561
|
+
var handleScroll = onScroll || setPerspective && function (e) {
|
|
2562
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2563
|
+
args[_key - 1] = arguments[_key];
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
return setPerspective.apply(void 0, args);
|
|
2567
|
+
};
|
|
2568
|
+
|
|
2569
|
+
var handleClick = onClick || setPerspective && function (e) {
|
|
2570
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2571
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
return setPerspective.apply(void 0, args);
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2577
|
+
var isZoomed = start !== perspective.start || end !== perspective.end;
|
|
2578
|
+
return /*#__PURE__*/jsx("div", _objectSpread$1(_objectSpread$1({
|
|
2579
|
+
className: clsx('VdtTimelineScroll-root', className),
|
|
2580
|
+
style: _objectSpread$1({
|
|
2581
|
+
display: !isZoomed && 'none',
|
|
2582
|
+
zIndex: DEFAULT_PLAYHEAD_ZINDEX + 1
|
|
2583
|
+
}, style),
|
|
2584
|
+
ref: ref // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2585
|
+
|
|
2586
|
+
}, props), {}, {
|
|
2587
|
+
children: /*#__PURE__*/jsx(Stage, _objectSpread$1(_objectSpread$1({
|
|
2588
|
+
height: height,
|
|
2589
|
+
width: scrollTrackWidth,
|
|
2590
|
+
onClick: function onClick(e) {
|
|
2591
|
+
if (!handleClick) return;
|
|
2592
|
+
|
|
2593
|
+
var _e$currentTarget$getR = e.currentTarget.getRelativePointerPosition(),
|
|
2594
|
+
x = _e$currentTarget$getR.x;
|
|
2595
|
+
|
|
2596
|
+
var newStart;
|
|
2597
|
+
|
|
2598
|
+
if (x > scrollLeft + scrollWidth) {
|
|
2599
|
+
newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x - scrollWidth));
|
|
2600
|
+
} else if (x < scrollLeft) {
|
|
2601
|
+
newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x));
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
if (newStart !== undefined && newStart !== perspective.start) {
|
|
2605
|
+
handleClick(e, newStart, newStart + perspectiveDuration);
|
|
2606
|
+
}
|
|
2607
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2608
|
+
|
|
2609
|
+
}, StageProps), {}, {
|
|
2610
|
+
children: /*#__PURE__*/jsx(Layer // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2611
|
+
, _objectSpread$1(_objectSpread$1({}, LayerProps), {}, {
|
|
2612
|
+
children: /*#__PURE__*/jsx(Rect, _objectSpread$1({
|
|
2613
|
+
x: scrollLeft,
|
|
2614
|
+
y: 0,
|
|
2615
|
+
width: scrollWidth,
|
|
2616
|
+
height: height,
|
|
2617
|
+
fill: paletteSecondary,
|
|
2618
|
+
draggable: true,
|
|
2619
|
+
dragBoundFunc: function dragBoundFunc(pos) {
|
|
2620
|
+
return {
|
|
2621
|
+
x: clamp(pos.x, 0, scrollTrackWidth - scrollWidth),
|
|
2622
|
+
y: 0
|
|
2623
|
+
};
|
|
2624
|
+
},
|
|
2625
|
+
onDragMove: function onDragMove(e) {
|
|
2626
|
+
if (!handleScroll) return;
|
|
2627
|
+
|
|
2628
|
+
var _e$target$position = e.target.position(),
|
|
2629
|
+
x = _e$target$position.x;
|
|
2630
|
+
|
|
2631
|
+
e.target.x(scrollLeft);
|
|
2632
|
+
var newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x));
|
|
2633
|
+
handleScroll(e, newStart, newStart + perspectiveDuration);
|
|
2634
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2635
|
+
|
|
2636
|
+
}, RectProps))
|
|
2637
|
+
}))
|
|
2638
|
+
}))
|
|
2639
|
+
}));
|
|
2640
|
+
}
|
|
2641
|
+
TimelineScroll.propTypes = {
|
|
2642
|
+
/**
|
|
2643
|
+
* @ignore
|
|
2644
|
+
*/
|
|
2645
|
+
className: PropTypes.string,
|
|
2646
|
+
onScroll: PropTypes.func,
|
|
2647
|
+
onClick: PropTypes.func,
|
|
2648
|
+
start: PropTypes.number,
|
|
2649
|
+
end: PropTypes.number,
|
|
2650
|
+
perspective: PropTypes.shape({
|
|
2651
|
+
start: PropTypes.number,
|
|
2652
|
+
end: PropTypes.number
|
|
2653
|
+
}),
|
|
2654
|
+
style: PropTypes.instanceOf(Object),
|
|
2655
|
+
StageProps: PropTypes.instanceOf(Object),
|
|
2656
|
+
LayerProps: PropTypes.instanceOf(Object),
|
|
2657
|
+
RectProps: PropTypes.instanceOf(Object)
|
|
2658
|
+
};
|
|
2659
|
+
TimelineScroll.defaultProps = {
|
|
2660
|
+
className: undefined,
|
|
2661
|
+
onScroll: undefined,
|
|
2662
|
+
onClick: undefined,
|
|
2663
|
+
start: undefined,
|
|
2664
|
+
end: undefined,
|
|
2665
|
+
perspective: undefined,
|
|
2666
|
+
style: {},
|
|
2667
|
+
StageProps: {},
|
|
2668
|
+
LayerProps: {},
|
|
2669
|
+
RectProps: {}
|
|
2670
|
+
};
|
|
2671
|
+
|
|
2672
|
+
var css = "\n\n.VdtTimelineScrollContainer-timelineRow > :not(.VdtTimelineRow-label) {\n /* margin messes with the playhead line alignment */\n margin: 0;\n}";
|
|
2673
|
+
n(css,{});
|
|
2674
|
+
|
|
2675
|
+
var _excluded = ["className", "children", "getScrollDistance", "RowProps", "ScrollProps"];
|
|
2676
|
+
|
|
2677
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2678
|
+
|
|
2679
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2680
|
+
|
|
2681
|
+
function defaultGetScrollDistance(e, _ref) {
|
|
2682
|
+
var start = _ref.start,
|
|
2683
|
+
end = _ref.end;
|
|
2684
|
+
return Math.floor(0.02 * (start - end));
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
function TimelineScrollContainer(_ref2) {
|
|
2688
|
+
var className = _ref2.className,
|
|
2689
|
+
children = _ref2.children,
|
|
2690
|
+
getScrollDistance = _ref2.getScrollDistance,
|
|
2691
|
+
RowProps = _ref2.RowProps,
|
|
2692
|
+
ScrollProps = _ref2.ScrollProps,
|
|
2693
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
2694
|
+
|
|
2695
|
+
var _useTimeline = useTimeline(),
|
|
2696
|
+
start = _useTimeline.start,
|
|
2697
|
+
end = _useTimeline.end,
|
|
2698
|
+
perspective = _useTimeline.perspective,
|
|
2699
|
+
setPerspective = _useTimeline.setPerspective;
|
|
2700
|
+
|
|
2701
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
2702
|
+
className: clsx('VdtTimelineScrollContainer-root', className),
|
|
2703
|
+
onWheel: function onWheel(e) {
|
|
2704
|
+
if (e.shiftKey) {
|
|
2705
|
+
var delta = getScrollDistance(e, {
|
|
2706
|
+
start: start,
|
|
2707
|
+
end: end,
|
|
2708
|
+
perspective: perspective
|
|
2709
|
+
});
|
|
2710
|
+
var newPerspectiveStart = perspective.start + (e.deltaY > 0 ? -delta : delta);
|
|
2711
|
+
var perspectiveDuration = perspective.end - perspective.start;
|
|
2712
|
+
var newPerspectiveEnd = newPerspectiveStart + perspectiveDuration;
|
|
2713
|
+
|
|
2714
|
+
if (newPerspectiveEnd > end) {
|
|
2715
|
+
setPerspective(end - perspectiveDuration, end);
|
|
2716
|
+
} else if (newPerspectiveStart < start) {
|
|
2717
|
+
setPerspective(start, perspectiveDuration);
|
|
2718
|
+
} else {
|
|
2719
|
+
setPerspective(newPerspectiveStart, newPerspectiveEnd);
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
} // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2723
|
+
|
|
2724
|
+
}, props), {}, {
|
|
2725
|
+
children: [children, /*#__PURE__*/jsx(TimelineRow, _objectSpread(_objectSpread({
|
|
2726
|
+
className: clsx('VdtTimelineScrollContainer-timelineRow') // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2727
|
+
|
|
2728
|
+
}, RowProps), {}, {
|
|
2729
|
+
children: /*#__PURE__*/jsx(TimelineScroll // eslint-disable-next-line react/jsx-props-no-spreading
|
|
2730
|
+
, _objectSpread({}, ScrollProps))
|
|
2731
|
+
}))]
|
|
2732
|
+
}));
|
|
2733
|
+
}
|
|
2734
|
+
TimelineScrollContainer.propTypes = {
|
|
2735
|
+
/**
|
|
2736
|
+
* @ignore
|
|
2737
|
+
*/
|
|
2738
|
+
className: PropTypes.string,
|
|
2739
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
2740
|
+
getScrollDistance: PropTypes.func,
|
|
2741
|
+
RowProps: PropTypes.instanceOf(Object),
|
|
2742
|
+
ScrollProps: PropTypes.instanceOf(Object)
|
|
2743
|
+
};
|
|
2744
|
+
TimelineScrollContainer.defaultProps = {
|
|
2745
|
+
className: undefined,
|
|
2746
|
+
children: undefined,
|
|
2747
|
+
getScrollDistance: defaultGetScrollDistance,
|
|
2748
|
+
RowProps: {},
|
|
2749
|
+
ScrollProps: {}
|
|
2750
|
+
};
|
|
2751
|
+
|
|
2752
|
+
export { Timeline, TimelineContext, TimelinePlayhead, TimelinePlayheadTrack, TimelineProvider, TimelineRow, TimelineScroll, TimelineScrollContainer, TimelineTrack, TimelineWaveform, getStackOverlappingEventProps, useTimeline };
|