1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6 |
|
7 | require('./slicedToArray-0711941d.js');
|
8 | require('./unsupportedIterableToArray-68db1d3b.js');
|
9 | var React = require('react');
|
10 | var React__default = _interopDefault(React);
|
11 | require('./_commonjsHelpers-72d386ba.js');
|
12 | require('./index-b0606964.js');
|
13 | var defineProperty$1 = require('./defineProperty-0921a47c.js');
|
14 | require('./toConsumableArray-d8a4a2c3.js');
|
15 | var _styled = require('styled-components');
|
16 | var _styled__default = _interopDefault(_styled);
|
17 | require('./getPrototypeOf-2a661a20.js');
|
18 | require('./color.js');
|
19 | require('./components.js');
|
20 | require('./contains-component.js');
|
21 | require('./css.js');
|
22 | require('./dayjs.min-e07657bf.js');
|
23 | require('./date.js');
|
24 | require('./miscellaneous.js');
|
25 | var environment = require('./environment.js');
|
26 | require('./font.js');
|
27 | require('./math-f4029164.js');
|
28 | require('./characters.js');
|
29 | require('./format.js');
|
30 | require('./keycodes.js');
|
31 | require('./url.js');
|
32 | require('./web3.js');
|
33 | require('./constants.js');
|
34 | require('./breakpoints.js');
|
35 | var springs = require('./springs.js');
|
36 | require('./text-styles.js');
|
37 | require('./theme-dark.js');
|
38 | require('./theme-light.js');
|
39 | var Theme = require('./Theme.js');
|
40 | var objectWithoutPropertiesLoose = require('./objectWithoutPropertiesLoose-1af20ad0.js');
|
41 | require('react-dom');
|
42 | var proptypes = require('./proptypes-5b34673d.js');
|
43 |
|
44 | function _defineProperties(target, props) {
|
45 | for (var i = 0; i < props.length; i++) {
|
46 | var descriptor = props[i];
|
47 | descriptor.enumerable = descriptor.enumerable || false;
|
48 | descriptor.configurable = true;
|
49 | if ("value" in descriptor) descriptor.writable = true;
|
50 | Object.defineProperty(target, descriptor.key, descriptor);
|
51 | }
|
52 | }
|
53 |
|
54 | function _createClass(Constructor, protoProps, staticProps) {
|
55 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
56 | if (staticProps) _defineProperties(Constructor, staticProps);
|
57 | return Constructor;
|
58 | }
|
59 |
|
60 | var applyAnimatedValues = undefined;
|
61 | var colorNames = [];
|
62 | var requestFrame = function requestFrame(cb) {
|
63 | return typeof window !== 'undefined' && window.requestAnimationFrame(cb);
|
64 | };
|
65 | var interpolation = undefined;
|
66 | var now = function now() {
|
67 | return Date.now();
|
68 | };
|
69 | var createAnimatedStyle = undefined;
|
70 | var injectApplyAnimatedValues = function injectApplyAnimatedValues(fn, transform) {
|
71 | return applyAnimatedValues = {
|
72 | fn: fn,
|
73 | transform: transform
|
74 | };
|
75 | };
|
76 | var injectColorNames = function injectColorNames(names) {
|
77 | return colorNames = names;
|
78 | };
|
79 | var injectInterpolation = function injectInterpolation(cls) {
|
80 | return interpolation = cls;
|
81 | };
|
82 | var injectCreateAnimatedStyle = function injectCreateAnimatedStyle(factory) {
|
83 | return createAnimatedStyle = factory;
|
84 | };
|
85 |
|
86 | var Animated =
|
87 |
|
88 | function () {
|
89 | function Animated() {}
|
90 |
|
91 | var _proto = Animated.prototype;
|
92 |
|
93 | _proto.attach = function attach() {};
|
94 |
|
95 | _proto.detach = function detach() {};
|
96 |
|
97 | _proto.getValue = function getValue() {};
|
98 |
|
99 | _proto.getAnimatedValue = function getAnimatedValue() {
|
100 | return this.getValue();
|
101 | };
|
102 |
|
103 | _proto.addChild = function addChild(child) {};
|
104 |
|
105 | _proto.removeChild = function removeChild(child) {};
|
106 |
|
107 | _proto.getChildren = function getChildren() {
|
108 | return [];
|
109 | };
|
110 |
|
111 | return Animated;
|
112 | }();
|
113 |
|
114 | var getValues = function getValues(object) {
|
115 | return Object.keys(object).map(function (k) {
|
116 | return object[k];
|
117 | });
|
118 | };
|
119 |
|
120 | var AnimatedWithChildren =
|
121 |
|
122 | function (_Animated) {
|
123 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedWithChildren, _Animated);
|
124 |
|
125 | function AnimatedWithChildren() {
|
126 | var _this;
|
127 |
|
128 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
129 | args[_key] = arguments[_key];
|
130 | }
|
131 |
|
132 | _this = _Animated.call.apply(_Animated, [this].concat(args)) || this;
|
133 | _this.children = [];
|
134 |
|
135 | _this.getChildren = function () {
|
136 | return _this.children;
|
137 | };
|
138 |
|
139 | _this.getPayload = function (index) {
|
140 | if (index === void 0) {
|
141 | index = undefined;
|
142 | }
|
143 |
|
144 | return index !== void 0 && _this.payload ? _this.payload[index] : _this.payload || objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this));
|
145 | };
|
146 |
|
147 | return _this;
|
148 | }
|
149 |
|
150 | var _proto = AnimatedWithChildren.prototype;
|
151 |
|
152 | _proto.addChild = function addChild(child) {
|
153 | if (this.children.length === 0) this.attach();
|
154 | this.children.push(child);
|
155 | };
|
156 |
|
157 | _proto.removeChild = function removeChild(child) {
|
158 | var index = this.children.indexOf(child);
|
159 | this.children.splice(index, 1);
|
160 | if (this.children.length === 0) this.detach();
|
161 | };
|
162 |
|
163 | return AnimatedWithChildren;
|
164 | }(Animated);
|
165 | var AnimatedArrayWithChildren =
|
166 |
|
167 | function (_AnimatedWithChildren) {
|
168 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedArrayWithChildren, _AnimatedWithChildren);
|
169 |
|
170 | function AnimatedArrayWithChildren() {
|
171 | var _this2;
|
172 |
|
173 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
174 | args[_key2] = arguments[_key2];
|
175 | }
|
176 |
|
177 | _this2 = _AnimatedWithChildren.call.apply(_AnimatedWithChildren, [this].concat(args)) || this;
|
178 | _this2.payload = [];
|
179 |
|
180 | _this2.getAnimatedValue = function () {
|
181 | return _this2.getValue();
|
182 | };
|
183 |
|
184 | _this2.attach = function () {
|
185 | return _this2.payload.forEach(function (p) {
|
186 | return p instanceof Animated && p.addChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this2)));
|
187 | });
|
188 | };
|
189 |
|
190 | _this2.detach = function () {
|
191 | return _this2.payload.forEach(function (p) {
|
192 | return p instanceof Animated && p.removeChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this2)));
|
193 | });
|
194 | };
|
195 |
|
196 | return _this2;
|
197 | }
|
198 |
|
199 | return AnimatedArrayWithChildren;
|
200 | }(AnimatedWithChildren);
|
201 | var AnimatedObjectWithChildren =
|
202 |
|
203 | function (_AnimatedWithChildren2) {
|
204 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedObjectWithChildren, _AnimatedWithChildren2);
|
205 |
|
206 | function AnimatedObjectWithChildren() {
|
207 | var _this3;
|
208 |
|
209 | for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
210 | args[_key3] = arguments[_key3];
|
211 | }
|
212 |
|
213 | _this3 = _AnimatedWithChildren2.call.apply(_AnimatedWithChildren2, [this].concat(args)) || this;
|
214 | _this3.payload = {};
|
215 |
|
216 | _this3.getAnimatedValue = function () {
|
217 | return _this3.getValue(true);
|
218 | };
|
219 |
|
220 | _this3.attach = function () {
|
221 | return getValues(_this3.payload).forEach(function (s) {
|
222 | return s instanceof Animated && s.addChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this3)));
|
223 | });
|
224 | };
|
225 |
|
226 | _this3.detach = function () {
|
227 | return getValues(_this3.payload).forEach(function (s) {
|
228 | return s instanceof Animated && s.removeChild(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this3)));
|
229 | });
|
230 | };
|
231 |
|
232 | return _this3;
|
233 | }
|
234 |
|
235 | var _proto2 = AnimatedObjectWithChildren.prototype;
|
236 |
|
237 | _proto2.getValue = function getValue(animated) {
|
238 | if (animated === void 0) {
|
239 | animated = false;
|
240 | }
|
241 |
|
242 | var payload = {};
|
243 |
|
244 | for (var key in this.payload) {
|
245 | var value = this.payload[key];
|
246 | if (animated && !(value instanceof Animated)) continue;
|
247 | payload[key] = value instanceof Animated ? value[animated ? 'getAnimatedValue' : 'getValue']() : value;
|
248 | }
|
249 |
|
250 | return payload;
|
251 | };
|
252 |
|
253 | return AnimatedObjectWithChildren;
|
254 | }(AnimatedWithChildren);
|
255 |
|
256 | var AnimatedStyle =
|
257 |
|
258 | function (_AnimatedObjectWithCh) {
|
259 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedStyle, _AnimatedObjectWithCh);
|
260 |
|
261 | function AnimatedStyle(style) {
|
262 | var _this;
|
263 |
|
264 | _this = _AnimatedObjectWithCh.call(this) || this;
|
265 | style = style || {};
|
266 | if (style.transform && !(style.transform instanceof Animated)) style = applyAnimatedValues.transform(style);
|
267 | _this.payload = style;
|
268 | return _this;
|
269 | }
|
270 |
|
271 | return AnimatedStyle;
|
272 | }(AnimatedObjectWithChildren);
|
273 |
|
274 |
|
275 | var colors = {
|
276 | transparent: 0x00000000,
|
277 | aliceblue: 0xf0f8ffff,
|
278 | antiquewhite: 0xfaebd7ff,
|
279 | aqua: 0x00ffffff,
|
280 | aquamarine: 0x7fffd4ff,
|
281 | azure: 0xf0ffffff,
|
282 | beige: 0xf5f5dcff,
|
283 | bisque: 0xffe4c4ff,
|
284 | black: 0x000000ff,
|
285 | blanchedalmond: 0xffebcdff,
|
286 | blue: 0x0000ffff,
|
287 | blueviolet: 0x8a2be2ff,
|
288 | brown: 0xa52a2aff,
|
289 | burlywood: 0xdeb887ff,
|
290 | burntsienna: 0xea7e5dff,
|
291 | cadetblue: 0x5f9ea0ff,
|
292 | chartreuse: 0x7fff00ff,
|
293 | chocolate: 0xd2691eff,
|
294 | coral: 0xff7f50ff,
|
295 | cornflowerblue: 0x6495edff,
|
296 | cornsilk: 0xfff8dcff,
|
297 | crimson: 0xdc143cff,
|
298 | cyan: 0x00ffffff,
|
299 | darkblue: 0x00008bff,
|
300 | darkcyan: 0x008b8bff,
|
301 | darkgoldenrod: 0xb8860bff,
|
302 | darkgray: 0xa9a9a9ff,
|
303 | darkgreen: 0x006400ff,
|
304 | darkgrey: 0xa9a9a9ff,
|
305 | darkkhaki: 0xbdb76bff,
|
306 | darkmagenta: 0x8b008bff,
|
307 | darkolivegreen: 0x556b2fff,
|
308 | darkorange: 0xff8c00ff,
|
309 | darkorchid: 0x9932ccff,
|
310 | darkred: 0x8b0000ff,
|
311 | darksalmon: 0xe9967aff,
|
312 | darkseagreen: 0x8fbc8fff,
|
313 | darkslateblue: 0x483d8bff,
|
314 | darkslategray: 0x2f4f4fff,
|
315 | darkslategrey: 0x2f4f4fff,
|
316 | darkturquoise: 0x00ced1ff,
|
317 | darkviolet: 0x9400d3ff,
|
318 | deeppink: 0xff1493ff,
|
319 | deepskyblue: 0x00bfffff,
|
320 | dimgray: 0x696969ff,
|
321 | dimgrey: 0x696969ff,
|
322 | dodgerblue: 0x1e90ffff,
|
323 | firebrick: 0xb22222ff,
|
324 | floralwhite: 0xfffaf0ff,
|
325 | forestgreen: 0x228b22ff,
|
326 | fuchsia: 0xff00ffff,
|
327 | gainsboro: 0xdcdcdcff,
|
328 | ghostwhite: 0xf8f8ffff,
|
329 | gold: 0xffd700ff,
|
330 | goldenrod: 0xdaa520ff,
|
331 | gray: 0x808080ff,
|
332 | green: 0x008000ff,
|
333 | greenyellow: 0xadff2fff,
|
334 | grey: 0x808080ff,
|
335 | honeydew: 0xf0fff0ff,
|
336 | hotpink: 0xff69b4ff,
|
337 | indianred: 0xcd5c5cff,
|
338 | indigo: 0x4b0082ff,
|
339 | ivory: 0xfffff0ff,
|
340 | khaki: 0xf0e68cff,
|
341 | lavender: 0xe6e6faff,
|
342 | lavenderblush: 0xfff0f5ff,
|
343 | lawngreen: 0x7cfc00ff,
|
344 | lemonchiffon: 0xfffacdff,
|
345 | lightblue: 0xadd8e6ff,
|
346 | lightcoral: 0xf08080ff,
|
347 | lightcyan: 0xe0ffffff,
|
348 | lightgoldenrodyellow: 0xfafad2ff,
|
349 | lightgray: 0xd3d3d3ff,
|
350 | lightgreen: 0x90ee90ff,
|
351 | lightgrey: 0xd3d3d3ff,
|
352 | lightpink: 0xffb6c1ff,
|
353 | lightsalmon: 0xffa07aff,
|
354 | lightseagreen: 0x20b2aaff,
|
355 | lightskyblue: 0x87cefaff,
|
356 | lightslategray: 0x778899ff,
|
357 | lightslategrey: 0x778899ff,
|
358 | lightsteelblue: 0xb0c4deff,
|
359 | lightyellow: 0xffffe0ff,
|
360 | lime: 0x00ff00ff,
|
361 | limegreen: 0x32cd32ff,
|
362 | linen: 0xfaf0e6ff,
|
363 | magenta: 0xff00ffff,
|
364 | maroon: 0x800000ff,
|
365 | mediumaquamarine: 0x66cdaaff,
|
366 | mediumblue: 0x0000cdff,
|
367 | mediumorchid: 0xba55d3ff,
|
368 | mediumpurple: 0x9370dbff,
|
369 | mediumseagreen: 0x3cb371ff,
|
370 | mediumslateblue: 0x7b68eeff,
|
371 | mediumspringgreen: 0x00fa9aff,
|
372 | mediumturquoise: 0x48d1ccff,
|
373 | mediumvioletred: 0xc71585ff,
|
374 | midnightblue: 0x191970ff,
|
375 | mintcream: 0xf5fffaff,
|
376 | mistyrose: 0xffe4e1ff,
|
377 | moccasin: 0xffe4b5ff,
|
378 | navajowhite: 0xffdeadff,
|
379 | navy: 0x000080ff,
|
380 | oldlace: 0xfdf5e6ff,
|
381 | olive: 0x808000ff,
|
382 | olivedrab: 0x6b8e23ff,
|
383 | orange: 0xffa500ff,
|
384 | orangered: 0xff4500ff,
|
385 | orchid: 0xda70d6ff,
|
386 | palegoldenrod: 0xeee8aaff,
|
387 | palegreen: 0x98fb98ff,
|
388 | paleturquoise: 0xafeeeeff,
|
389 | palevioletred: 0xdb7093ff,
|
390 | papayawhip: 0xffefd5ff,
|
391 | peachpuff: 0xffdab9ff,
|
392 | peru: 0xcd853fff,
|
393 | pink: 0xffc0cbff,
|
394 | plum: 0xdda0ddff,
|
395 | powderblue: 0xb0e0e6ff,
|
396 | purple: 0x800080ff,
|
397 | rebeccapurple: 0x663399ff,
|
398 | red: 0xff0000ff,
|
399 | rosybrown: 0xbc8f8fff,
|
400 | royalblue: 0x4169e1ff,
|
401 | saddlebrown: 0x8b4513ff,
|
402 | salmon: 0xfa8072ff,
|
403 | sandybrown: 0xf4a460ff,
|
404 | seagreen: 0x2e8b57ff,
|
405 | seashell: 0xfff5eeff,
|
406 | sienna: 0xa0522dff,
|
407 | silver: 0xc0c0c0ff,
|
408 | skyblue: 0x87ceebff,
|
409 | slateblue: 0x6a5acdff,
|
410 | slategray: 0x708090ff,
|
411 | slategrey: 0x708090ff,
|
412 | snow: 0xfffafaff,
|
413 | springgreen: 0x00ff7fff,
|
414 | steelblue: 0x4682b4ff,
|
415 | tan: 0xd2b48cff,
|
416 | teal: 0x008080ff,
|
417 | thistle: 0xd8bfd8ff,
|
418 | tomato: 0xff6347ff,
|
419 | turquoise: 0x40e0d0ff,
|
420 | violet: 0xee82eeff,
|
421 | wheat: 0xf5deb3ff,
|
422 | white: 0xffffffff,
|
423 | whitesmoke: 0xf5f5f5ff,
|
424 | yellow: 0xffff00ff,
|
425 | yellowgreen: 0x9acd32ff
|
426 | };
|
427 |
|
428 | var Interpolation =
|
429 |
|
430 | function () {
|
431 | function Interpolation() {}
|
432 |
|
433 |
|
434 |
|
435 | Interpolation.create = function create(config, output, extra) {
|
436 | if (typeof config === 'function') return config;else if (interpolation && config.output && typeof config.output[0] === 'string') return interpolation(config);else if (Array.isArray(config)) return Interpolation.create({
|
437 | range: config,
|
438 | output: output,
|
439 | extrapolate: extra || 'extend'
|
440 | });
|
441 | var outputRange = config.output;
|
442 | var inputRange = config.range || [0, 1];
|
443 |
|
444 | var easing = config.easing || function (t) {
|
445 | return t;
|
446 | };
|
447 |
|
448 | var extrapolateLeft = 'extend';
|
449 | var map = config.map;
|
450 | if (config.extrapolateLeft !== undefined) extrapolateLeft = config.extrapolateLeft;else if (config.extrapolate !== undefined) extrapolateLeft = config.extrapolate;
|
451 | var extrapolateRight = 'extend';
|
452 | if (config.extrapolateRight !== undefined) extrapolateRight = config.extrapolateRight;else if (config.extrapolate !== undefined) extrapolateRight = config.extrapolate;
|
453 | return function (input) {
|
454 | var range = findRange(input, inputRange);
|
455 | return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, map);
|
456 | };
|
457 | };
|
458 |
|
459 | return Interpolation;
|
460 | }();
|
461 |
|
462 | function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
|
463 | var result = map ? map(input) : input;
|
464 |
|
465 | if (result < inputMin) {
|
466 | if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
|
467 | }
|
468 |
|
469 | if (result > inputMax) {
|
470 | if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
|
471 | }
|
472 |
|
473 | if (outputMin === outputMax) return outputMin;
|
474 | if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
|
475 |
|
476 | if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin);
|
477 |
|
478 | result = easing(result);
|
479 |
|
480 | if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
|
481 | return result;
|
482 | }
|
483 |
|
484 | function findRange(input, inputRange) {
|
485 | for (var i = 1; i < inputRange.length - 1; ++i) {
|
486 | if (inputRange[i] >= input) break;
|
487 | }
|
488 |
|
489 | return i - 1;
|
490 | }
|
491 |
|
492 |
|
493 | var NUMBER = '[-+]?\\d*\\.?\\d+';
|
494 | var PERCENTAGE = NUMBER + '%';
|
495 |
|
496 | function call() {
|
497 | return '\\(\\s*(' + Array.prototype.slice.call(arguments).join(')\\s*,\\s*(') + ')\\s*\\)';
|
498 | }
|
499 |
|
500 | var rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
|
501 | var rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
|
502 | var hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
|
503 | var hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
504 | var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
505 | var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
506 | var hex6 = /^#([0-9a-fA-F]{6})$/;
|
507 | var hex8 = /^#([0-9a-fA-F]{8})$/;
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 | function normalizeColor(color) {
|
543 | var match;
|
544 |
|
545 | if (typeof color === 'number') {
|
546 | return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
|
547 | }
|
548 |
|
549 |
|
550 | if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
|
551 | if (colors.hasOwnProperty(color)) return colors[color];
|
552 |
|
553 | if (match = rgb.exec(color)) {
|
554 | return (parse255(match[1]) << 24 |
|
555 | parse255(match[2]) << 16 |
|
556 | parse255(match[3]) << 8 |
|
557 | 0x000000ff) >>>
|
558 | 0;
|
559 | }
|
560 |
|
561 | if (match = rgba.exec(color)) {
|
562 | return (parse255(match[1]) << 24 |
|
563 | parse255(match[2]) << 16 |
|
564 | parse255(match[3]) << 8 |
|
565 | parse1(match[4])) >>>
|
566 | 0;
|
567 | }
|
568 |
|
569 | if (match = hex3.exec(color)) {
|
570 | return parseInt(match[1] + match[1] +
|
571 | match[2] + match[2] +
|
572 | match[3] + match[3] +
|
573 | 'ff',
|
574 | 16) >>> 0;
|
575 | }
|
576 |
|
577 |
|
578 | if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
|
579 |
|
580 | if (match = hex4.exec(color)) {
|
581 | return parseInt(match[1] + match[1] +
|
582 | match[2] + match[2] +
|
583 | match[3] + match[3] +
|
584 | match[4] + match[4],
|
585 | 16) >>> 0;
|
586 | }
|
587 |
|
588 | if (match = hsl.exec(color)) {
|
589 | return (hslToRgb(parse360(match[1]),
|
590 | parsePercentage(match[2]),
|
591 | parsePercentage(match[3])
|
592 | ) | 0x000000ff) >>>
|
593 | 0;
|
594 | }
|
595 |
|
596 | if (match = hsla.exec(color)) {
|
597 | return (hslToRgb(parse360(match[1]),
|
598 | parsePercentage(match[2]),
|
599 | parsePercentage(match[3])
|
600 | ) | parse1(match[4])) >>>
|
601 | 0;
|
602 | }
|
603 |
|
604 | return null;
|
605 | }
|
606 |
|
607 | function hue2rgb(p, q, t) {
|
608 | if (t < 0) t += 1;
|
609 | if (t > 1) t -= 1;
|
610 | if (t < 1 / 6) return p + (q - p) * 6 * t;
|
611 | if (t < 1 / 2) return q;
|
612 | if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
613 | return p;
|
614 | }
|
615 |
|
616 | function hslToRgb(h, s, l) {
|
617 | var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
618 | var p = 2 * l - q;
|
619 | var r = hue2rgb(p, q, h + 1 / 3);
|
620 | var g = hue2rgb(p, q, h);
|
621 | var b = hue2rgb(p, q, h - 1 / 3);
|
622 | return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
|
623 | }
|
624 |
|
625 | function parse255(str) {
|
626 | var int = parseInt(str, 10);
|
627 | if (int < 0) return 0;
|
628 | if (int > 255) return 255;
|
629 | return int;
|
630 | }
|
631 |
|
632 | function parse360(str) {
|
633 | var int = parseFloat(str);
|
634 | return (int % 360 + 360) % 360 / 360;
|
635 | }
|
636 |
|
637 | function parse1(str) {
|
638 | var num = parseFloat(str);
|
639 | if (num < 0) return 0;
|
640 | if (num > 1) return 255;
|
641 | return Math.round(num * 255);
|
642 | }
|
643 |
|
644 | function parsePercentage(str) {
|
645 |
|
646 | var int = parseFloat(str);
|
647 | if (int < 0) return 0;
|
648 | if (int > 100) return 1;
|
649 | return int / 100;
|
650 | }
|
651 |
|
652 | function colorToRgba(input) {
|
653 | var int32Color = normalizeColor(input);
|
654 | if (int32Color === null) return input;
|
655 | int32Color = int32Color || 0;
|
656 | var r = (int32Color & 0xff000000) >>> 24;
|
657 | var g = (int32Color & 0x00ff0000) >>> 16;
|
658 | var b = (int32Color & 0x0000ff00) >>> 8;
|
659 | var a = (int32Color & 0x000000ff) / 255;
|
660 | return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
661 | }
|
662 |
|
663 |
|
664 |
|
665 | var stringShapeRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
|
666 |
|
667 |
|
668 | var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
|
669 |
|
670 | var colorNamesRegex = new RegExp("(" + Object.keys(colors).join('|') + ")", 'g');
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 | function createInterpolation(config) {
|
682 |
|
683 | var outputRange = config.output.map(function (rangeValue) {
|
684 | return rangeValue.replace(colorRegex, colorToRgba);
|
685 | }).map(function (rangeValue) {
|
686 | return rangeValue.replace(colorNamesRegex, colorToRgba);
|
687 | });
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 |
|
695 | var outputRanges = outputRange[0].match(stringShapeRegex).map(function () {
|
696 | return [];
|
697 | });
|
698 | outputRange.forEach(function (value) {
|
699 | value.match(stringShapeRegex).forEach(function (number, i) {
|
700 | return outputRanges[i].push(+number);
|
701 | });
|
702 | });
|
703 | var interpolations = outputRange[0].match(stringShapeRegex).map(function (value, i) {
|
704 | return Interpolation.create(objectWithoutPropertiesLoose._extends({}, config, {
|
705 | output: outputRanges[i]
|
706 | }));
|
707 | });
|
708 | return function (input) {
|
709 | var i = 0;
|
710 | return outputRange[0]
|
711 |
|
712 |
|
713 | .replace(stringShapeRegex, function () {
|
714 | return interpolations[i++](input);
|
715 | })
|
716 |
|
717 | .replace(/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, function (_, p1, p2, p3, p4) {
|
718 | return "rgba(" + Math.round(p1) + ", " + Math.round(p2) + ", " + Math.round(p3) + ", " + p4 + ")";
|
719 | });
|
720 | };
|
721 | }
|
722 |
|
723 | var AnimatedInterpolation =
|
724 |
|
725 | function (_AnimatedArrayWithChi) {
|
726 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedInterpolation, _AnimatedArrayWithChi);
|
727 |
|
728 | function AnimatedInterpolation(parents, _config, _arg) {
|
729 | var _this;
|
730 |
|
731 | _this = _AnimatedArrayWithChi.call(this) || this;
|
732 |
|
733 | _this.getValue = function () {
|
734 | var _this2;
|
735 |
|
736 | return (_this2 = _this).calc.apply(_this2, _this.payload.map(function (value) {
|
737 | return value.getValue();
|
738 | }));
|
739 | };
|
740 |
|
741 | _this.updateConfig = function (config, arg) {
|
742 | return _this.calc = Interpolation.create(config, arg);
|
743 | };
|
744 |
|
745 | _this.interpolate = function (config, arg) {
|
746 | return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
|
747 | };
|
748 |
|
749 | _this.payload =
|
750 | parents instanceof AnimatedArrayWithChildren && !parents.updateConfig ? parents.payload : Array.isArray(parents) ? parents : [parents];
|
751 | _this.calc = Interpolation.create(_config, _arg);
|
752 | return _this;
|
753 | }
|
754 |
|
755 | return AnimatedInterpolation;
|
756 | }(AnimatedArrayWithChildren);
|
757 | var interpolate$1 = function interpolate(parents, config, arg) {
|
758 | return parents && new AnimatedInterpolation(parents, config, arg);
|
759 | };
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 | function findAnimatedStyles(node, styles) {
|
785 | if (typeof node.update === 'function') styles.add(node);else node.getChildren().forEach(function (child) {
|
786 | return findAnimatedStyles(child, styles);
|
787 | });
|
788 | }
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 |
|
797 | var AnimatedValue =
|
798 |
|
799 | function (_AnimatedWithChildren) {
|
800 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedValue, _AnimatedWithChildren);
|
801 |
|
802 | function AnimatedValue(_value) {
|
803 | var _this;
|
804 |
|
805 | _this = _AnimatedWithChildren.call(this) || this;
|
806 |
|
807 | _this.setValue = function (value, flush) {
|
808 | if (flush === void 0) {
|
809 | flush = true;
|
810 | }
|
811 |
|
812 | _this.value = value;
|
813 | if (flush) _this.flush();
|
814 | };
|
815 |
|
816 | _this.getValue = function () {
|
817 | return _this.value;
|
818 | };
|
819 |
|
820 | _this.updateStyles = function () {
|
821 | return findAnimatedStyles(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), _this.animatedStyles);
|
822 | };
|
823 |
|
824 | _this.updateValue = function (value) {
|
825 | return _this.flush(_this.value = value);
|
826 | };
|
827 |
|
828 | _this.interpolate = function (config, arg) {
|
829 | return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
|
830 | };
|
831 |
|
832 | _this.value = _value;
|
833 | _this.animatedStyles = new Set();
|
834 | _this.done = false;
|
835 | _this.startPosition = _value;
|
836 | _this.lastPosition = _value;
|
837 | _this.lastVelocity = undefined;
|
838 | _this.lastTime = undefined;
|
839 | _this.controller = undefined;
|
840 | return _this;
|
841 | }
|
842 |
|
843 | var _proto = AnimatedValue.prototype;
|
844 |
|
845 | _proto.flush = function flush() {
|
846 | if (this.animatedStyles.size === 0) this.updateStyles();
|
847 | this.animatedStyles.forEach(function (animatedStyle) {
|
848 | return animatedStyle.update();
|
849 | });
|
850 | };
|
851 |
|
852 | _proto.prepare = function prepare(controller) {
|
853 |
|
854 |
|
855 | if (this.controller === undefined) this.controller = controller;
|
856 |
|
857 | if (this.controller === controller) {
|
858 | this.startPosition = this.value;
|
859 | this.lastPosition = this.value;
|
860 | this.lastVelocity = controller.isActive ? this.lastVelocity : undefined;
|
861 | this.lastTime = controller.isActive ? this.lastTime : undefined;
|
862 | this.done = false;
|
863 | this.animatedStyles.clear();
|
864 | }
|
865 | };
|
866 |
|
867 | return AnimatedValue;
|
868 | }(AnimatedWithChildren);
|
869 |
|
870 | var AnimatedArray =
|
871 |
|
872 | function (_AnimatedArrayWithChi) {
|
873 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedArray, _AnimatedArrayWithChi);
|
874 |
|
875 | function AnimatedArray(array) {
|
876 | var _this;
|
877 |
|
878 | _this = _AnimatedArrayWithChi.call(this) || this;
|
879 |
|
880 | _this.setValue = function (value, flush) {
|
881 | if (flush === void 0) {
|
882 | flush = true;
|
883 | }
|
884 |
|
885 | if (Array.isArray(value)) {
|
886 | if (value.length === _this.payload.length) value.forEach(function (v, i) {
|
887 | return _this.payload[i].setValue(v, flush);
|
888 | });
|
889 | } else _this.payload.forEach(function (v, i) {
|
890 | return _this.payload[i].setValue(value, flush);
|
891 | });
|
892 | };
|
893 |
|
894 | _this.getValue = function () {
|
895 | return _this.payload.map(function (v) {
|
896 | return v.getValue();
|
897 | });
|
898 | };
|
899 |
|
900 | _this.interpolate = function (config, arg) {
|
901 | return new AnimatedInterpolation(objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)), config, arg);
|
902 | };
|
903 |
|
904 | _this.payload = array.map(function (n) {
|
905 | return new AnimatedValue(n);
|
906 | });
|
907 | return _this;
|
908 | }
|
909 |
|
910 | return AnimatedArray;
|
911 | }(AnimatedArrayWithChildren);
|
912 |
|
913 | function withDefault(value, defaultValue) {
|
914 | return value === undefined || value === null ? defaultValue : value;
|
915 | }
|
916 | function toArray(a) {
|
917 | return a !== void 0 ? Array.isArray(a) ? a : [a] : [];
|
918 | }
|
919 | function shallowEqual(a, b) {
|
920 | if (typeof a !== typeof b) return false;
|
921 | if (typeof a === 'string' || typeof a === 'number') return a === b;
|
922 | var i;
|
923 |
|
924 | for (i in a) {
|
925 | if (!(i in b)) return false;
|
926 | }
|
927 |
|
928 | for (i in b) {
|
929 | if (a[i] !== b[i]) return false;
|
930 | }
|
931 |
|
932 | return i === void 0 ? a === b : true;
|
933 | }
|
934 | function callProp(obj) {
|
935 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
936 | args[_key - 1] = arguments[_key];
|
937 | }
|
938 |
|
939 | return typeof obj === 'function' ? obj.apply(void 0, args) : obj;
|
940 | }
|
941 | function getValues$1(object) {
|
942 | return Object.keys(object).map(function (k) {
|
943 | return object[k];
|
944 | });
|
945 | }
|
946 | function getForwardProps(props) {
|
947 | var to = props.to,
|
948 | from = props.from,
|
949 | config = props.config,
|
950 | native = props.native,
|
951 | onStart = props.onStart,
|
952 | onRest = props.onRest,
|
953 | onFrame = props.onFrame,
|
954 | children = props.children,
|
955 | reset = props.reset,
|
956 | reverse = props.reverse,
|
957 | force = props.force,
|
958 | immediate = props.immediate,
|
959 | impl = props.impl,
|
960 | inject = props.inject,
|
961 | delay = props.delay,
|
962 | attach = props.attach,
|
963 | destroyed = props.destroyed,
|
964 | interpolateTo = props.interpolateTo,
|
965 | autoStart = props.autoStart,
|
966 | ref = props.ref,
|
967 | forward = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["to", "from", "config", "native", "onStart", "onRest", "onFrame", "children", "reset", "reverse", "force", "immediate", "impl", "inject", "delay", "attach", "destroyed", "interpolateTo", "autoStart", "ref"]);
|
968 |
|
969 | return forward;
|
970 | }
|
971 | function interpolateTo(props) {
|
972 | var forward = getForwardProps(props);
|
973 | var rest = Object.keys(props).reduce(function (a, k) {
|
974 | var _extends2;
|
975 |
|
976 | return forward[k] !== void 0 ? a : objectWithoutPropertiesLoose._extends({}, a, (_extends2 = {}, _extends2[k] = props[k], _extends2));
|
977 | }, {});
|
978 | return objectWithoutPropertiesLoose._extends({
|
979 | to: forward
|
980 | }, rest);
|
981 | }
|
982 | function handleRef(ref, forward) {
|
983 | if (forward) {
|
984 |
|
985 | if (typeof forward === 'function') forward(ref);else if (typeof forward === 'object') {
|
986 |
|
987 | forward.current = ref;
|
988 | }
|
989 | }
|
990 |
|
991 | return ref;
|
992 | }
|
993 |
|
994 | var isUnitlessNumber = {
|
995 | animationIterationCount: true,
|
996 | borderImageOutset: true,
|
997 | borderImageSlice: true,
|
998 | borderImageWidth: true,
|
999 | boxFlex: true,
|
1000 | boxFlexGroup: true,
|
1001 | boxOrdinalGroup: true,
|
1002 | columnCount: true,
|
1003 | columns: true,
|
1004 | flex: true,
|
1005 | flexGrow: true,
|
1006 | flexPositive: true,
|
1007 | flexShrink: true,
|
1008 | flexNegative: true,
|
1009 | flexOrder: true,
|
1010 | gridRow: true,
|
1011 | gridRowEnd: true,
|
1012 | gridRowSpan: true,
|
1013 | gridRowStart: true,
|
1014 | gridColumn: true,
|
1015 | gridColumnEnd: true,
|
1016 | gridColumnSpan: true,
|
1017 | gridColumnStart: true,
|
1018 | fontWeight: true,
|
1019 | lineClamp: true,
|
1020 | lineHeight: true,
|
1021 | opacity: true,
|
1022 | order: true,
|
1023 | orphans: true,
|
1024 | tabSize: true,
|
1025 | widows: true,
|
1026 | zIndex: true,
|
1027 | zoom: true,
|
1028 |
|
1029 | fillOpacity: true,
|
1030 | floodOpacity: true,
|
1031 | stopOpacity: true,
|
1032 | strokeDasharray: true,
|
1033 | strokeDashoffset: true,
|
1034 | strokeMiterlimit: true,
|
1035 | strokeOpacity: true,
|
1036 | strokeWidth: true
|
1037 | };
|
1038 |
|
1039 | var prefixKey = function prefixKey(prefix, key) {
|
1040 | return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
1041 | };
|
1042 |
|
1043 | var prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
|
1044 | isUnitlessNumber = Object.keys(isUnitlessNumber).reduce(function (acc, prop) {
|
1045 | prefixes.forEach(function (prefix) {
|
1046 | return acc[prefixKey(prefix, prop)] = acc[prop];
|
1047 | });
|
1048 | return acc;
|
1049 | }, isUnitlessNumber);
|
1050 |
|
1051 | function dangerousStyleValue(name, value, isCustomProperty) {
|
1052 | if (value == null || typeof value === 'boolean' || value === '') return '';
|
1053 | if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
|
1054 |
|
1055 | return ('' + value).trim();
|
1056 | }
|
1057 |
|
1058 | var attributeCache = {};
|
1059 | injectCreateAnimatedStyle(function (style) {
|
1060 | return new AnimatedStyle(style);
|
1061 | });
|
1062 | injectInterpolation(createInterpolation);
|
1063 | injectColorNames(colors);
|
1064 | injectApplyAnimatedValues(function (instance, props) {
|
1065 | if (instance.nodeType && instance.setAttribute !== undefined) {
|
1066 | var style = props.style,
|
1067 | children = props.children,
|
1068 | scrollTop = props.scrollTop,
|
1069 | scrollLeft = props.scrollLeft,
|
1070 | attributes = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["style", "children", "scrollTop", "scrollLeft"]);
|
1071 |
|
1072 | if (scrollTop !== void 0) instance.scrollTop = scrollTop;
|
1073 | if (scrollLeft !== void 0) instance.scrollLeft = scrollLeft;
|
1074 |
|
1075 | if (children !== void 0) instance.textContent = children;
|
1076 |
|
1077 | for (var styleName in style) {
|
1078 | if (!style.hasOwnProperty(styleName)) continue;
|
1079 | var isCustomProperty = styleName.indexOf('--') === 0;
|
1080 | var styleValue = dangerousStyleValue(styleName, style[styleName], isCustomProperty);
|
1081 | if (styleName === 'float') styleName = 'cssFloat';
|
1082 | if (isCustomProperty) instance.style.setProperty(styleName, styleValue);else instance.style[styleName] = styleValue;
|
1083 | }
|
1084 |
|
1085 |
|
1086 | for (var name in attributes) {
|
1087 |
|
1088 | var dashCase = attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, function (n) {
|
1089 | return '-' + n.toLowerCase();
|
1090 | }));
|
1091 | if (typeof instance.getAttribute(dashCase) !== 'undefined') instance.setAttribute(dashCase, attributes[name]);
|
1092 | }
|
1093 | } else return false;
|
1094 | }, function (style) {
|
1095 | return style;
|
1096 | });
|
1097 |
|
1098 | var AnimatedProps =
|
1099 |
|
1100 | function (_AnimatedObjectWithCh) {
|
1101 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedProps, _AnimatedObjectWithCh);
|
1102 |
|
1103 | function AnimatedProps(props, callback) {
|
1104 | var _this;
|
1105 |
|
1106 | _this = _AnimatedObjectWithCh.call(this) || this;
|
1107 | if (props.style) props = objectWithoutPropertiesLoose._extends({}, props, {
|
1108 | style: createAnimatedStyle(props.style)
|
1109 | });
|
1110 | _this.payload = props;
|
1111 | _this.update = callback;
|
1112 |
|
1113 | _this.attach();
|
1114 |
|
1115 | return _this;
|
1116 | }
|
1117 |
|
1118 | return AnimatedProps;
|
1119 | }(AnimatedObjectWithChildren);
|
1120 |
|
1121 | function createAnimatedComponent(Component) {
|
1122 | var AnimatedComponent =
|
1123 |
|
1124 | function (_React$Component) {
|
1125 | objectWithoutPropertiesLoose._inheritsLoose(AnimatedComponent, _React$Component);
|
1126 |
|
1127 | function AnimatedComponent(props) {
|
1128 | var _this;
|
1129 |
|
1130 | _this = _React$Component.call(this) || this;
|
1131 |
|
1132 | _this.callback = function () {
|
1133 | if (_this.node) {
|
1134 | var didUpdate = applyAnimatedValues.fn(_this.node, _this.propsAnimated.getAnimatedValue(), objectWithoutPropertiesLoose._assertThisInitialized(objectWithoutPropertiesLoose._assertThisInitialized(_this)));
|
1135 | if (didUpdate === false) _this.forceUpdate();
|
1136 | }
|
1137 | };
|
1138 |
|
1139 | _this.attachProps(props);
|
1140 |
|
1141 | return _this;
|
1142 | }
|
1143 |
|
1144 | var _proto = AnimatedComponent.prototype;
|
1145 |
|
1146 | _proto.componentWillUnmount = function componentWillUnmount() {
|
1147 | this.propsAnimated && this.propsAnimated.detach();
|
1148 | };
|
1149 |
|
1150 | _proto.setNativeProps = function setNativeProps(props) {
|
1151 | var didUpdate = applyAnimatedValues.fn(this.node, props, this);
|
1152 | if (didUpdate === false) this.forceUpdate();
|
1153 | }
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 | ;
|
1160 |
|
1161 | _proto.attachProps = function attachProps(_ref) {
|
1162 | var forwardRef = _ref.forwardRef,
|
1163 | nextProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_ref, ["forwardRef"]);
|
1164 |
|
1165 | var oldPropsAnimated = this.propsAnimated;
|
1166 | this.propsAnimated = new AnimatedProps(nextProps, this.callback);
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 | oldPropsAnimated && oldPropsAnimated.detach();
|
1176 | };
|
1177 |
|
1178 | _proto.shouldComponentUpdate = function shouldComponentUpdate(props) {
|
1179 | var style = props.style,
|
1180 | nextProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(props, ["style"]);
|
1181 |
|
1182 | var _this$props = this.props,
|
1183 | currentStyle = _this$props.style,
|
1184 | currentProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_this$props, ["style"]);
|
1185 |
|
1186 | if (!shallowEqual(currentProps, nextProps) || !shallowEqual(currentStyle, style)) {
|
1187 | this.attachProps(props);
|
1188 | return true;
|
1189 | }
|
1190 |
|
1191 | return false;
|
1192 | };
|
1193 |
|
1194 | _proto.render = function render() {
|
1195 | var _this2 = this;
|
1196 |
|
1197 | var _this$propsAnimated$g = this.propsAnimated.getValue(),
|
1198 | scrollTop = _this$propsAnimated$g.scrollTop,
|
1199 | scrollLeft = _this$propsAnimated$g.scrollLeft,
|
1200 | animatedProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_this$propsAnimated$g, ["scrollTop", "scrollLeft"]);
|
1201 |
|
1202 | return React__default.createElement(Component, objectWithoutPropertiesLoose._extends({}, animatedProps, {
|
1203 | ref: function ref(node) {
|
1204 | return _this2.node = handleRef(node, _this2.props.forwardRef);
|
1205 | }
|
1206 | }));
|
1207 | };
|
1208 |
|
1209 | return AnimatedComponent;
|
1210 | }(React__default.Component);
|
1211 |
|
1212 | return React__default.forwardRef(function (props, ref) {
|
1213 | return React__default.createElement(AnimatedComponent, objectWithoutPropertiesLoose._extends({}, props, {
|
1214 | forwardRef: ref
|
1215 | }));
|
1216 | });
|
1217 | }
|
1218 |
|
1219 | var active = false;
|
1220 | var controllers = new Set();
|
1221 |
|
1222 | var frameLoop = function frameLoop() {
|
1223 | var time = now();
|
1224 |
|
1225 | for (var _iterator = controllers, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
1226 | var _ref;
|
1227 |
|
1228 | if (_isArray) {
|
1229 | if (_i >= _iterator.length) break;
|
1230 | _ref = _iterator[_i++];
|
1231 | } else {
|
1232 | _i = _iterator.next();
|
1233 | if (_i.done) break;
|
1234 | _ref = _i.value;
|
1235 | }
|
1236 |
|
1237 | var controller = _ref;
|
1238 | var isDone = true;
|
1239 | var noChange = true;
|
1240 |
|
1241 | for (var configIdx = 0; configIdx < controller.configs.length; configIdx++) {
|
1242 | var config = controller.configs[configIdx];
|
1243 | var endOfAnimation = void 0,
|
1244 | lastTime = void 0;
|
1245 |
|
1246 | for (var valIdx = 0; valIdx < config.animatedValues.length; valIdx++) {
|
1247 | var animation = config.animatedValues[valIdx];
|
1248 |
|
1249 | if (animation.done) continue;
|
1250 | var from = config.fromValues[valIdx];
|
1251 | var to = config.toValues[valIdx];
|
1252 | var position = animation.lastPosition;
|
1253 | var isAnimated = to instanceof Animated;
|
1254 |
|
1255 | var _velocity = Array.isArray(config.initialVelocity) ? config.initialVelocity[valIdx] : config.initialVelocity;
|
1256 |
|
1257 | if (isAnimated) to = to.getValue();
|
1258 |
|
1259 | if (config.immediate || !isAnimated && !config.decay && from === to) {
|
1260 | animation.updateValue(to);
|
1261 | animation.done = true;
|
1262 | continue;
|
1263 | }
|
1264 |
|
1265 |
|
1266 | if (config.delay && time - controller.startTime < config.delay) {
|
1267 | isDone = false;
|
1268 | continue;
|
1269 | }
|
1270 |
|
1271 |
|
1272 | noChange = false;
|
1273 |
|
1274 | if (typeof from === 'string' || typeof to === 'string') {
|
1275 | animation.updateValue(to);
|
1276 | animation.done = true;
|
1277 | continue;
|
1278 | }
|
1279 |
|
1280 | if (config.duration !== void 0) {
|
1281 |
|
1282 | position = from + config.easing((time - controller.startTime - config.delay) / config.duration) * (to - from);
|
1283 | endOfAnimation = time >= controller.startTime + config.delay + config.duration;
|
1284 | } else if (config.decay) {
|
1285 |
|
1286 | position = from + _velocity / (1 - 0.998) * (1 - Math.exp(-(1 - 0.998) * (time - controller.startTime)));
|
1287 | endOfAnimation = Math.abs(animation.lastPosition - position) < 0.1;
|
1288 | if (endOfAnimation) to = position;
|
1289 | } else {
|
1290 |
|
1291 | lastTime = animation.lastTime !== void 0 ? animation.lastTime : time;
|
1292 | _velocity = animation.lastVelocity !== void 0 ? animation.lastVelocity : config.initialVelocity;
|
1293 |
|
1294 | if (time > lastTime + 64) lastTime = time;
|
1295 |
|
1296 | var numSteps = Math.floor(time - lastTime);
|
1297 |
|
1298 | for (var i = 0; i < numSteps; ++i) {
|
1299 | var force = -config.tension * (position - to);
|
1300 | var damping = -config.friction * _velocity;
|
1301 | var acceleration = (force + damping) / config.mass;
|
1302 | _velocity = _velocity + acceleration * 1 / 1000;
|
1303 | position = position + _velocity * 1 / 1000;
|
1304 | }
|
1305 |
|
1306 |
|
1307 | var isOvershooting = config.clamp && config.tension !== 0 ? from < to ? position > to : position < to : false;
|
1308 | var isVelocity = Math.abs(_velocity) <= config.precision;
|
1309 | var isDisplacement = config.tension !== 0 ? Math.abs(to - position) <= config.precision : true;
|
1310 | endOfAnimation = isOvershooting || isVelocity && isDisplacement;
|
1311 | animation.lastVelocity = _velocity;
|
1312 | animation.lastTime = time;
|
1313 | }
|
1314 |
|
1315 |
|
1316 | if (isAnimated && !config.toValues[valIdx].done) endOfAnimation = false;
|
1317 |
|
1318 | if (endOfAnimation) {
|
1319 |
|
1320 | if (animation.value !== to) position = to;
|
1321 | animation.done = true;
|
1322 | } else isDone = false;
|
1323 |
|
1324 | animation.updateValue(position);
|
1325 | animation.lastPosition = position;
|
1326 | }
|
1327 |
|
1328 |
|
1329 | if (controller.props.onFrame || !controller.props.native) controller.animatedProps[config.name] = config.interpolation.getValue();
|
1330 | }
|
1331 |
|
1332 |
|
1333 | if (controller.props.onFrame || !controller.props.native) {
|
1334 | if (!controller.props.native && controller.onUpdate) controller.onUpdate();
|
1335 | if (controller.props.onFrame) controller.props.onFrame(controller.animatedProps);
|
1336 | }
|
1337 |
|
1338 |
|
1339 | if (isDone) {
|
1340 | controllers.delete(controller);
|
1341 | controller.debouncedOnEnd({
|
1342 | finished: true,
|
1343 | noChange: noChange
|
1344 | });
|
1345 | }
|
1346 | }
|
1347 |
|
1348 |
|
1349 | if (controllers.size) requestFrame(frameLoop);else active = false;
|
1350 | };
|
1351 |
|
1352 | var addController = function addController(controller) {
|
1353 | if (!controllers.has(controller)) {
|
1354 | controllers.add(controller);
|
1355 | if (!active) requestFrame(frameLoop);
|
1356 | active = true;
|
1357 | }
|
1358 | };
|
1359 |
|
1360 | var removeController = function removeController(controller) {
|
1361 | if (controllers.has(controller)) {
|
1362 | controllers.delete(controller);
|
1363 | }
|
1364 | };
|
1365 |
|
1366 | var Controller =
|
1367 |
|
1368 | function () {
|
1369 | function Controller(props, config) {
|
1370 | var _this = this;
|
1371 |
|
1372 | if (config === void 0) {
|
1373 | config = {
|
1374 | native: true,
|
1375 | interpolateTo: true,
|
1376 | autoStart: true
|
1377 | };
|
1378 | }
|
1379 |
|
1380 | this.getValues = function () {
|
1381 | return _this.props.native ? _this.interpolations : _this.animatedProps;
|
1382 | };
|
1383 |
|
1384 | this.dependents = new Set();
|
1385 | this.isActive = false;
|
1386 | this.hasChanged = false;
|
1387 | this.props = {};
|
1388 | this.merged = {};
|
1389 | this.animations = {};
|
1390 | this.interpolations = {};
|
1391 | this.animatedProps = {};
|
1392 | this.configs = [];
|
1393 | this.frame = undefined;
|
1394 | this.startTime = undefined;
|
1395 | this.lastTime = undefined;
|
1396 | this.update(objectWithoutPropertiesLoose._extends({}, props, config));
|
1397 | }
|
1398 |
|
1399 | var _proto = Controller.prototype;
|
1400 |
|
1401 | _proto.update = function update(props) {
|
1402 | var _this2 = this;
|
1403 |
|
1404 | this.props = objectWithoutPropertiesLoose._extends({}, this.props, props);
|
1405 |
|
1406 | var _ref = this.props.interpolateTo ? interpolateTo(this.props) : this.props,
|
1407 | _ref$from = _ref.from,
|
1408 | from = _ref$from === void 0 ? {} : _ref$from,
|
1409 | _ref$to = _ref.to,
|
1410 | to = _ref$to === void 0 ? {} : _ref$to,
|
1411 | _ref$config = _ref.config,
|
1412 | config = _ref$config === void 0 ? {} : _ref$config,
|
1413 | _ref$delay = _ref.delay,
|
1414 | delay = _ref$delay === void 0 ? 0 : _ref$delay,
|
1415 | reverse = _ref.reverse,
|
1416 | attach = _ref.attach,
|
1417 | reset = _ref.reset,
|
1418 | immediate = _ref.immediate,
|
1419 | autoStart = _ref.autoStart,
|
1420 | ref = _ref.ref;
|
1421 |
|
1422 |
|
1423 | if (reverse) {
|
1424 | var _ref2 = [to, from];
|
1425 | from = _ref2[0];
|
1426 | to = _ref2[1];
|
1427 | }
|
1428 |
|
1429 | this.hasChanged = false;
|
1430 |
|
1431 | var target = attach && attach(this);
|
1432 |
|
1433 | var extra = reset ? {} : this.merged;
|
1434 |
|
1435 | this.merged = objectWithoutPropertiesLoose._extends({}, from, extra, to);
|
1436 |
|
1437 | this.animations = Object.entries(this.merged).reduce(function (acc, _ref3, i) {
|
1438 | var name = _ref3[0],
|
1439 | value = _ref3[1];
|
1440 |
|
1441 | var entry = !reset && acc[name] || {};
|
1442 |
|
1443 | var isNumber = typeof value === 'number';
|
1444 | var isString = typeof value === 'string' && !value.startsWith('#') && !/\d/.test(value) && !colorNames[value];
|
1445 | var isArray = !isNumber && !isString && Array.isArray(value);
|
1446 | var fromValue = from[name] !== undefined ? from[name] : value;
|
1447 | var toValue = isNumber || isArray ? value : isString ? value : 1;
|
1448 | var toConfig = callProp(config, name);
|
1449 | if (target) toValue = target.animations[name].parent;
|
1450 |
|
1451 | if (toConfig.decay !== void 0 || !shallowEqual(entry.changes, value)) {
|
1452 | var _extends2;
|
1453 |
|
1454 | _this2.hasChanged = true;
|
1455 | var parent, interpolation$$1;
|
1456 | if (isNumber || isString) parent = interpolation$$1 = entry.parent || new AnimatedValue(fromValue);else if (isArray) parent = interpolation$$1 = entry.parent || new AnimatedArray(fromValue);else {
|
1457 | var prev = entry.interpolation && entry.interpolation.calc(entry.parent.value);
|
1458 |
|
1459 | if (entry.parent) {
|
1460 | parent = entry.parent;
|
1461 | parent.setValue(0, false);
|
1462 | } else parent = new AnimatedValue(0);
|
1463 |
|
1464 | var range = {
|
1465 | output: [prev !== void 0 ? prev : fromValue, value]
|
1466 | };
|
1467 |
|
1468 | if (entry.interpolation) {
|
1469 | interpolation$$1 = entry.interpolation;
|
1470 | entry.interpolation.updateConfig(range);
|
1471 | } else interpolation$$1 = parent.interpolate(range);
|
1472 | }
|
1473 |
|
1474 | if (callProp(immediate, name)) parent.setValue(value, false);
|
1475 |
|
1476 | var animatedValues = toArray(parent.getPayload());
|
1477 | animatedValues.forEach(function (value) {
|
1478 | return value.prepare(_this2);
|
1479 | });
|
1480 | return objectWithoutPropertiesLoose._extends({}, acc, (_extends2 = {}, _extends2[name] = objectWithoutPropertiesLoose._extends({}, entry, {
|
1481 | name: name,
|
1482 | parent: parent,
|
1483 | interpolation: interpolation$$1,
|
1484 | animatedValues: animatedValues,
|
1485 | changes: value,
|
1486 | fromValues: toArray(parent.getValue()),
|
1487 | toValues: toArray(target ? toValue.getPayload() : toValue),
|
1488 | immediate: callProp(immediate, name),
|
1489 | delay: withDefault(toConfig.delay, delay || 0),
|
1490 | initialVelocity: withDefault(toConfig.velocity, 0),
|
1491 | clamp: withDefault(toConfig.clamp, false),
|
1492 | precision: withDefault(toConfig.precision, 0.01),
|
1493 | tension: withDefault(toConfig.tension, 170),
|
1494 | friction: withDefault(toConfig.friction, 26),
|
1495 | mass: withDefault(toConfig.mass, 1),
|
1496 | duration: toConfig.duration,
|
1497 | easing: withDefault(toConfig.easing, function (t) {
|
1498 | return t;
|
1499 | }),
|
1500 | decay: toConfig.decay
|
1501 | }), _extends2));
|
1502 | } else return acc;
|
1503 | }, this.animations);
|
1504 |
|
1505 | if (this.hasChanged) {
|
1506 | this.configs = getValues$1(this.animations);
|
1507 | this.animatedProps = {};
|
1508 | this.interpolations = {};
|
1509 |
|
1510 | for (var key in this.animations) {
|
1511 | this.interpolations[key] = this.animations[key].interpolation;
|
1512 | this.animatedProps[key] = this.animations[key].interpolation.getValue();
|
1513 | }
|
1514 | }
|
1515 |
|
1516 |
|
1517 | for (var _len = arguments.length, start = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1518 | start[_key - 1] = arguments[_key];
|
1519 | }
|
1520 |
|
1521 | if (!ref && (autoStart || start.length)) this.start.apply(this, start);
|
1522 | var onEnd = start[0],
|
1523 | onUpdate = start[1];
|
1524 | this.onEnd = typeof onEnd === 'function' && onEnd;
|
1525 | this.onUpdate = onUpdate;
|
1526 | return this.getValues();
|
1527 | };
|
1528 |
|
1529 | _proto.start = function start(onEnd, onUpdate) {
|
1530 | var _this3 = this;
|
1531 |
|
1532 | this.startTime = now();
|
1533 | if (this.isActive) this.stop();
|
1534 | this.isActive = true;
|
1535 | this.onEnd = typeof onEnd === 'function' && onEnd;
|
1536 | this.onUpdate = onUpdate;
|
1537 | if (this.props.onStart) this.props.onStart();
|
1538 | addController(this);
|
1539 | return new Promise(function (res) {
|
1540 | return _this3.resolve = res;
|
1541 | });
|
1542 | };
|
1543 |
|
1544 | _proto.stop = function stop(finished) {
|
1545 | if (finished === void 0) {
|
1546 | finished = false;
|
1547 | }
|
1548 |
|
1549 |
|
1550 | if (finished) getValues$1(this.animations).forEach(function (a) {
|
1551 | return a.changes = undefined;
|
1552 | });
|
1553 | this.debouncedOnEnd({
|
1554 | finished: finished
|
1555 | });
|
1556 | };
|
1557 |
|
1558 | _proto.destroy = function destroy() {
|
1559 | removeController(this);
|
1560 | this.props = {};
|
1561 | this.merged = {};
|
1562 | this.animations = {};
|
1563 | this.interpolations = {};
|
1564 | this.animatedProps = {};
|
1565 | this.configs = [];
|
1566 | };
|
1567 |
|
1568 | _proto.debouncedOnEnd = function debouncedOnEnd(result) {
|
1569 | removeController(this);
|
1570 | this.isActive = false;
|
1571 | var onEnd = this.onEnd;
|
1572 | this.onEnd = null;
|
1573 | if (onEnd) onEnd(result);
|
1574 | if (this.resolve) this.resolve();
|
1575 | this.resolve = null;
|
1576 | };
|
1577 |
|
1578 | return Controller;
|
1579 | }();
|
1580 |
|
1581 | var KeyframeController =
|
1582 |
|
1583 | function () {
|
1584 | function KeyframeController(_props) {
|
1585 | var _this = this;
|
1586 |
|
1587 | this.frameId = 0;
|
1588 |
|
1589 | this.next = function (props, localFrameId, last, index) {
|
1590 | if (last === void 0) {
|
1591 | last = true;
|
1592 | }
|
1593 |
|
1594 | if (index === void 0) {
|
1595 | index = 0;
|
1596 | }
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 | var config = props.config ? props.config : Array.isArray(_this.globalConfig) ? _this.globalConfig[index] : _this.globalConfig;
|
1603 | _this.onFrameRest = props.onRest;
|
1604 | return new Promise(function (resolve) {
|
1605 |
|
1606 | _this.instance.update(objectWithoutPropertiesLoose._extends({}, _this.globalProps, props, {
|
1607 | config: config
|
1608 | }), _this.onEnd(_this.onFrameRest, localFrameId, last, resolve));
|
1609 |
|
1610 |
|
1611 | if (_this.ref) {
|
1612 | _this.instance.start(_this.onEnd(_this.onFrameRest, localFrameId, last, resolve));
|
1613 | }
|
1614 |
|
1615 |
|
1616 |
|
1617 | _this.instance.props.reset && _this.instance.props.native && _this.parentForceUpdate && requestFrame(_this.parentForceUpdate);
|
1618 | });
|
1619 | };
|
1620 |
|
1621 | this.start = function (onEnd) {
|
1622 | _this.globalOnEnd = onEnd;
|
1623 |
|
1624 | if (_this.currSlots) {
|
1625 | var _ret = function () {
|
1626 | var localFrameId = ++_this.frameId;
|
1627 |
|
1628 | if (Array.isArray(_this.currSlots)) {
|
1629 | var q = Promise.resolve();
|
1630 |
|
1631 | var _loop = function _loop(i) {
|
1632 | var index = i;
|
1633 | var slot = _this.currSlots[index];
|
1634 | var last = index === _this.currSlots.length - 1;
|
1635 | q = q.then(function () {
|
1636 | return localFrameId === _this.frameId && _this.next(slot, localFrameId, last, index);
|
1637 | });
|
1638 | };
|
1639 |
|
1640 | for (var i = 0; i < _this.currSlots.length; i++) {
|
1641 | _loop(i);
|
1642 | }
|
1643 | } else if (typeof _this.currSlots === 'function') {
|
1644 | var index = 0;
|
1645 |
|
1646 | _this.currSlots(
|
1647 | function (props, last) {
|
1648 | if (last === void 0) {
|
1649 | last = false;
|
1650 | }
|
1651 |
|
1652 | return localFrameId === _this.frameId && _this.next(props, localFrameId, last, index++);
|
1653 | },
|
1654 | function () {
|
1655 | return requestFrame(function () {
|
1656 | return _this.instance.isActive && _this.instance.stop(true);
|
1657 | });
|
1658 | });
|
1659 | } else _this.next(_this.currSlots, localFrameId);
|
1660 |
|
1661 | _this.prevSlots = _this.currSlots;
|
1662 | return {
|
1663 | v: new Promise(function (resolve) {
|
1664 | return _this.keyFrameEndResolver = resolve;
|
1665 | })
|
1666 | };
|
1667 | }();
|
1668 |
|
1669 | if (typeof _ret === "object") return _ret.v;
|
1670 | }
|
1671 | };
|
1672 |
|
1673 | this.stop = function (finished) {
|
1674 | if (finished === void 0) {
|
1675 | finished = false;
|
1676 | }
|
1677 |
|
1678 | ++_this.frameId;
|
1679 | if (_this.instance.isActive) _this.instance.stop(finished);
|
1680 | };
|
1681 |
|
1682 | this.onEnd = function (onFrameRest, localFrameId, last, resolve) {
|
1683 | return function (args) {
|
1684 | if (localFrameId === _this.frameId) {
|
1685 | if (resolve) resolve();
|
1686 | if (onFrameRest) onFrameRest(_this.merged);
|
1687 | if (last && _this.globalOnEnd) _this.globalOnEnd(args);
|
1688 | if (last && _this.keyFrameEndResolver) _this.keyFrameEndResolver();
|
1689 |
|
1690 | if (args.finished && last && _this.globalOnRest) {
|
1691 | _this.globalOnRest(_this.merged);
|
1692 | }
|
1693 | }
|
1694 | };
|
1695 | };
|
1696 |
|
1697 | this.updateWithForceUpdate = function (forceUpdate) {
|
1698 |
|
1699 |
|
1700 | _this.parentForceUpdate = forceUpdate;
|
1701 |
|
1702 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1703 | args[_key - 1] = arguments[_key];
|
1704 | }
|
1705 |
|
1706 | _this.update.apply(_this, args);
|
1707 | };
|
1708 |
|
1709 | this.update = function (args) {
|
1710 | var isFnOrArray = typeof args === 'function' || Array.isArray(args);
|
1711 |
|
1712 | if (isFnOrArray) {
|
1713 | _this.currSlots = args;
|
1714 | !_this.ref && _this.start();
|
1715 | } else {
|
1716 | var slots = args.slots,
|
1717 | rest = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(args, ["slots"]);
|
1718 |
|
1719 | _this.currSlots = slots;
|
1720 | !_this.ref && _this.start.apply(_this, rest);
|
1721 | }
|
1722 | };
|
1723 |
|
1724 | this.getValues = function () {
|
1725 | return _this.instance.getValues();
|
1726 | };
|
1727 |
|
1728 | this.destroy = function () {
|
1729 | return _this.instance.destroy();
|
1730 | };
|
1731 |
|
1732 | var _config = _props.config,
|
1733 | onRest = _props.onRest,
|
1734 | initialProps = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_props, ["config", "onRest"]);
|
1735 |
|
1736 | this.globalProps = function (_ref) {
|
1737 | var native = _ref.native,
|
1738 | onStart = _ref.onStart,
|
1739 | onFrame = _ref.onFrame,
|
1740 | children = _ref.children,
|
1741 | reset = _ref.reset,
|
1742 | delay = _ref.delay,
|
1743 | destroyed = _ref.destroyed;
|
1744 | return {
|
1745 | native: native,
|
1746 | onStart: onStart,
|
1747 | reset: reset,
|
1748 | onFrame: onFrame,
|
1749 | children: children,
|
1750 | delay: delay,
|
1751 | destroyed: destroyed
|
1752 | };
|
1753 | }(_props);
|
1754 |
|
1755 | this.globalConfig = _props.config;
|
1756 | this.globalOnRest = _props.onRest;
|
1757 | this.ref = _props.ref;
|
1758 | this.prevSlots = {};
|
1759 | this.currSlots = null;
|
1760 | this.instance = new Controller(objectWithoutPropertiesLoose._extends({}, initialProps, {
|
1761 | native: true
|
1762 | }));
|
1763 | }
|
1764 |
|
1765 | _createClass(KeyframeController, [{
|
1766 | key: "isActive",
|
1767 | get: function get() {
|
1768 | return this.instance.isActive;
|
1769 | }
|
1770 | }, {
|
1771 | key: "config",
|
1772 | set: function set(config) {
|
1773 | this.globalConfig = config;
|
1774 | }
|
1775 | }, {
|
1776 | key: "globals",
|
1777 | set: function set(props) {
|
1778 | this.globalProps = objectWithoutPropertiesLoose._extends({}, this.globalProps, props);
|
1779 | }
|
1780 | }, {
|
1781 | key: "merged",
|
1782 | get: function get() {
|
1783 | return this.instance.merged;
|
1784 | }
|
1785 | }, {
|
1786 | key: "props",
|
1787 | get: function get() {
|
1788 | return this.instance.props;
|
1789 | }
|
1790 | }]);
|
1791 |
|
1792 | return KeyframeController;
|
1793 | }();
|
1794 |
|
1795 | var useSpringImpl = function useSpringImpl(type) {
|
1796 | if (type === void 0) {
|
1797 | type = 'default';
|
1798 | }
|
1799 |
|
1800 | return function (args) {
|
1801 | var _useState = React.useState(),
|
1802 | f = _useState[1];
|
1803 |
|
1804 | var forceUpdate = function forceUpdate() {
|
1805 | return f(function (v) {
|
1806 | return !v;
|
1807 | });
|
1808 | };
|
1809 |
|
1810 |
|
1811 | var isFn = typeof args === 'function';
|
1812 |
|
1813 | var _callProp = callProp(args),
|
1814 | onRest = _callProp.onRest,
|
1815 | onKeyframesHalt = _callProp.onKeyframesHalt,
|
1816 | props = objectWithoutPropertiesLoose._objectWithoutPropertiesLoose(_callProp, ["onRest", "onKeyframesHalt"]);
|
1817 |
|
1818 |
|
1819 | var _useState2 = React.useState(function () {
|
1820 | return type === 'keyframe' ? new KeyframeController(props) : new Controller(props);
|
1821 | }),
|
1822 | ctrl = _useState2[0];
|
1823 |
|
1824 |
|
1825 | React.useEffect(function () {
|
1826 | return function () {
|
1827 | return ctrl.destroy();
|
1828 | };
|
1829 | }, []);
|
1830 |
|
1831 | var onHalt = function onHalt(_ref) {
|
1832 | var finished = _ref.finished;
|
1833 | return finished && onRest && onRest(ctrl.merged);
|
1834 | };
|
1835 |
|
1836 |
|
1837 | React.useImperativeHandle(props.ref, function () {
|
1838 | return {
|
1839 | start: function start() {
|
1840 | return ctrl.start(onHalt);
|
1841 | },
|
1842 |
|
1843 | get isActive() {
|
1844 | return ctrl.isActive;
|
1845 | },
|
1846 |
|
1847 | stop: function stop(finished) {
|
1848 | if (finished === void 0) {
|
1849 | finished = false;
|
1850 | }
|
1851 |
|
1852 | if (ctrl.isActive) ctrl.stop(finished);
|
1853 | }
|
1854 | };
|
1855 | });
|
1856 |
|
1857 | var updateCtrl = React.useCallback(function (updateProps) {
|
1858 | type === 'keyframe' ? ctrl.updateWithForceUpdate(forceUpdate, updateProps) : ctrl.update(updateProps);
|
1859 | if (!ctrl.props.ref) ctrl.start(onHalt);
|
1860 | if (ctrl.props.reset && type === 'default') requestFrame(forceUpdate);
|
1861 | }, [onRest, ctrl.props.ref]);
|
1862 |
|
1863 | React.useEffect(function () {
|
1864 | return void (!isFn && updateCtrl(props));
|
1865 | });
|
1866 |
|
1867 | var propValues = ctrl.getValues();
|
1868 | return isFn ? [propValues, updateCtrl, function (finished) {
|
1869 | if (finished === void 0) {
|
1870 | finished = false;
|
1871 | }
|
1872 |
|
1873 | return ctrl.stop(finished);
|
1874 | }] : propValues;
|
1875 | };
|
1876 | };
|
1877 | var useSpring = useSpringImpl();
|
1878 |
|
1879 | var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr',
|
1880 | 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
1881 | var extendedAnimated = domElements.reduce(function (acc, element) {
|
1882 | acc[element] = createAnimatedComponent(element);
|
1883 | return acc;
|
1884 | }, createAnimatedComponent);
|
1885 |
|
1886 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
1887 |
|
1888 | function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty$1._defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
1889 | var RADIUS = 2;
|
1890 | var BAR_HEIGHT = 6;
|
1891 | var INDETERMINATE_WIDTH = 1 / 4;
|
1892 | var INDETERMINATE_DURATION = 1600;
|
1893 | var indeterminateAnim = _styled.keyframes(["0%{transform:translate3d(calc(-100% - 1px),0,0);}70%,100%{transform:translate3d(calc(", "% + 1px),0,0);}"], 100 / INDETERMINATE_WIDTH);
|
1894 |
|
1895 | var _StyledDiv = _styled__default("div").withConfig({
|
1896 | displayName: "ProgressBar___StyledDiv",
|
1897 | componentId: "sc-1gly9sn-0"
|
1898 | })(["width:100%;height:", "px;background:", ";border-radius:", "px;overflow:hidden;"], BAR_HEIGHT, function (p) {
|
1899 | return p._css;
|
1900 | }, RADIUS);
|
1901 |
|
1902 | var ProgressBar = React__default.memo(function (_ref) {
|
1903 | var animate = _ref.animate,
|
1904 | color = _ref.color,
|
1905 | progress = _ref.progress,
|
1906 | value = _ref.value;
|
1907 |
|
1908 |
|
1909 | if (value === -1 && typeof progress === 'number') {
|
1910 | value = progress;
|
1911 | environment.warnOnce('ProgressBar:progress', 'The `progress` prop of ProgressBar is deprecated: please use `value` instead.');
|
1912 | }
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 | var indeterminate = value === -1;
|
1918 | var theme = Theme.useTheme();
|
1919 | var currentColor = color === undefined ? theme.accent : color;
|
1920 | var transition = useSpring({
|
1921 | config: _objectSpread({}, springs.springs.smooth, {
|
1922 | precision: 0.001
|
1923 | }),
|
1924 | from: {
|
1925 | scale: 0,
|
1926 | x: 0
|
1927 | },
|
1928 | to: {
|
1929 | scale: value,
|
1930 | x: 0
|
1931 | },
|
1932 | immediate: !animate
|
1933 | });
|
1934 | return React__default.createElement(_StyledDiv, {
|
1935 | _css: theme.surfaceUnder
|
1936 | }, React__default.createElement(Bar, {
|
1937 | style: {
|
1938 | width: "".concat((indeterminate ? INDETERMINATE_WIDTH : 1) * 100, "%"),
|
1939 | background: currentColor,
|
1940 | borderRadius: "".concat(indeterminate ? RADIUS : 0, "px"),
|
1941 | animationName: "".concat(indeterminate ? indeterminateAnim.name : 'none'),
|
1942 | transform: interpolate$1([transition.x, transition.scale], function (x, s) {
|
1943 | return "translate3d(".concat(x * 100, "%, 0, 0) scale3d(").concat(s, ", 1, 1)");
|
1944 | })
|
1945 | }
|
1946 | }));
|
1947 | });
|
1948 | var Bar = _styled__default(extendedAnimated.div).withConfig({
|
1949 | displayName: "ProgressBar__Bar",
|
1950 | componentId: "sc-1gly9sn-1"
|
1951 | })(["width:100%;height:", "px;transform-origin:0 0;animation:", " ", "ms ease-in-out infinite;animation-name:none;"], BAR_HEIGHT, indeterminateAnim, INDETERMINATE_DURATION);
|
1952 | ProgressBar.defaultProps = {
|
1953 | animate: true,
|
1954 | value: -1
|
1955 | };
|
1956 | ProgressBar.propTypes = {
|
1957 | animate: proptypes.PropTypes.bool,
|
1958 | color: proptypes.PropTypes.string,
|
1959 | progress: proptypes.PropTypes._0to1,
|
1960 | value: proptypes.PropTypes.oneOfType([proptypes.PropTypes._0to1, proptypes.PropTypes.oneOf([-1])])
|
1961 | };
|
1962 |
|
1963 | exports.default = ProgressBar;
|
1964 |
|