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-ef426d0f.js');
|
8 | require('./unsupportedIterableToArray-8a00e599.js');
|
9 | var React = require('react');
|
10 | var React__default = _interopDefault(React);
|
11 | var _commonjsHelpers = require('./_commonjsHelpers-72d386ba.js');
|
12 | var index = require('./index-b0606964.js');
|
13 | var defineProperty = require('./defineProperty-0921a47c.js');
|
14 | var toConsumableArray = require('./toConsumableArray-7f36359f.js');
|
15 | var _styled = require('styled-components');
|
16 | var _styled__default = _interopDefault(_styled);
|
17 | var getPrototypeOf = require('./getPrototypeOf-e2d1e599.js');
|
18 | require('./color.js');
|
19 | var components = require('./components.js');
|
20 | require('./contains-component.js');
|
21 | require('./css.js');
|
22 | require('./dayjs.min-aa59a48e.js');
|
23 | require('./date.js');
|
24 | require('./miscellaneous.js');
|
25 | require('./environment.js');
|
26 | require('./font.js');
|
27 | require('./math-ecfd5d91.js');
|
28 | require('./characters.js');
|
29 | require('./format.js');
|
30 | require('./keycodes.js');
|
31 | require('./url.js');
|
32 | require('./web3.js');
|
33 | var constants = require('./constants.js');
|
34 | require('./breakpoints.js');
|
35 | var springs = require('./springs.js');
|
36 | var textStyles = require('./text-styles.js');
|
37 | require('./theme-dark.js');
|
38 | require('./theme-light.js');
|
39 | var Theme = require('./Theme.js');
|
40 | var _extends = require('./extends-40571110.js');
|
41 | var objectWithoutProperties = require('./objectWithoutProperties-35db8ab0.js');
|
42 | require('./isObject-52908731.js');
|
43 | var Viewport = require('./Viewport-fe2db97a.js');
|
44 | require('./objectWithoutPropertiesLoose-1af20ad0.js');
|
45 | require('react-dom');
|
46 | var web = require('./web-d0294535.js');
|
47 | require('./index-5aaa52c3.js');
|
48 | var RootPortal = require('./RootPortal.js');
|
49 |
|
50 | var runtime_1 = _commonjsHelpers.createCommonjsModule(function (module) {
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | var runtime = (function (exports) {
|
59 |
|
60 | var Op = Object.prototype;
|
61 | var hasOwn = Op.hasOwnProperty;
|
62 | var undefined$1;
|
63 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
64 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
65 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
66 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
67 |
|
68 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
69 |
|
70 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
71 | var generator = Object.create(protoGenerator.prototype);
|
72 | var context = new Context(tryLocsList || []);
|
73 |
|
74 |
|
75 |
|
76 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
77 |
|
78 | return generator;
|
79 | }
|
80 | exports.wrap = wrap;
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | function tryCatch(fn, obj, arg) {
|
93 | try {
|
94 | return { type: "normal", arg: fn.call(obj, arg) };
|
95 | } catch (err) {
|
96 | return { type: "throw", arg: err };
|
97 | }
|
98 | }
|
99 |
|
100 | var GenStateSuspendedStart = "suspendedStart";
|
101 | var GenStateSuspendedYield = "suspendedYield";
|
102 | var GenStateExecuting = "executing";
|
103 | var GenStateCompleted = "completed";
|
104 |
|
105 |
|
106 |
|
107 | var ContinueSentinel = {};
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | function Generator() {}
|
114 | function GeneratorFunction() {}
|
115 | function GeneratorFunctionPrototype() {}
|
116 |
|
117 |
|
118 |
|
119 | var IteratorPrototype = {};
|
120 | IteratorPrototype[iteratorSymbol] = function () {
|
121 | return this;
|
122 | };
|
123 |
|
124 | var getProto = Object.getPrototypeOf;
|
125 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
126 | if (NativeIteratorPrototype &&
|
127 | NativeIteratorPrototype !== Op &&
|
128 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
129 |
|
130 |
|
131 | IteratorPrototype = NativeIteratorPrototype;
|
132 | }
|
133 |
|
134 | var Gp = GeneratorFunctionPrototype.prototype =
|
135 | Generator.prototype = Object.create(IteratorPrototype);
|
136 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
137 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
138 | GeneratorFunctionPrototype[toStringTagSymbol] =
|
139 | GeneratorFunction.displayName = "GeneratorFunction";
|
140 |
|
141 |
|
142 |
|
143 | function defineIteratorMethods(prototype) {
|
144 | ["next", "throw", "return"].forEach(function(method) {
|
145 | prototype[method] = function(arg) {
|
146 | return this._invoke(method, arg);
|
147 | };
|
148 | });
|
149 | }
|
150 |
|
151 | exports.isGeneratorFunction = function(genFun) {
|
152 | var ctor = typeof genFun === "function" && genFun.constructor;
|
153 | return ctor
|
154 | ? ctor === GeneratorFunction ||
|
155 |
|
156 |
|
157 | (ctor.displayName || ctor.name) === "GeneratorFunction"
|
158 | : false;
|
159 | };
|
160 |
|
161 | exports.mark = function(genFun) {
|
162 | if (Object.setPrototypeOf) {
|
163 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
164 | } else {
|
165 | genFun.__proto__ = GeneratorFunctionPrototype;
|
166 | if (!(toStringTagSymbol in genFun)) {
|
167 | genFun[toStringTagSymbol] = "GeneratorFunction";
|
168 | }
|
169 | }
|
170 | genFun.prototype = Object.create(Gp);
|
171 | return genFun;
|
172 | };
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | exports.awrap = function(arg) {
|
179 | return { __await: arg };
|
180 | };
|
181 |
|
182 | function AsyncIterator(generator, PromiseImpl) {
|
183 | function invoke(method, arg, resolve, reject) {
|
184 | var record = tryCatch(generator[method], generator, arg);
|
185 | if (record.type === "throw") {
|
186 | reject(record.arg);
|
187 | } else {
|
188 | var result = record.arg;
|
189 | var value = result.value;
|
190 | if (value &&
|
191 | typeof value === "object" &&
|
192 | hasOwn.call(value, "__await")) {
|
193 | return PromiseImpl.resolve(value.__await).then(function(value) {
|
194 | invoke("next", value, resolve, reject);
|
195 | }, function(err) {
|
196 | invoke("throw", err, resolve, reject);
|
197 | });
|
198 | }
|
199 |
|
200 | return PromiseImpl.resolve(value).then(function(unwrapped) {
|
201 |
|
202 |
|
203 |
|
204 | result.value = unwrapped;
|
205 | resolve(result);
|
206 | }, function(error) {
|
207 |
|
208 |
|
209 | return invoke("throw", error, resolve, reject);
|
210 | });
|
211 | }
|
212 | }
|
213 |
|
214 | var previousPromise;
|
215 |
|
216 | function enqueue(method, arg) {
|
217 | function callInvokeWithMethodAndArg() {
|
218 | return new PromiseImpl(function(resolve, reject) {
|
219 | invoke(method, arg, resolve, reject);
|
220 | });
|
221 | }
|
222 |
|
223 | return previousPromise =
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | previousPromise ? previousPromise.then(
|
237 | callInvokeWithMethodAndArg,
|
238 |
|
239 |
|
240 | callInvokeWithMethodAndArg
|
241 | ) : callInvokeWithMethodAndArg();
|
242 | }
|
243 |
|
244 |
|
245 |
|
246 | this._invoke = enqueue;
|
247 | }
|
248 |
|
249 | defineIteratorMethods(AsyncIterator.prototype);
|
250 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
251 | return this;
|
252 | };
|
253 | exports.AsyncIterator = AsyncIterator;
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
259 | if (PromiseImpl === void 0) PromiseImpl = Promise;
|
260 |
|
261 | var iter = new AsyncIterator(
|
262 | wrap(innerFn, outerFn, self, tryLocsList),
|
263 | PromiseImpl
|
264 | );
|
265 |
|
266 | return exports.isGeneratorFunction(outerFn)
|
267 | ? iter
|
268 | : iter.next().then(function(result) {
|
269 | return result.done ? result.value : iter.next();
|
270 | });
|
271 | };
|
272 |
|
273 | function makeInvokeMethod(innerFn, self, context) {
|
274 | var state = GenStateSuspendedStart;
|
275 |
|
276 | return function invoke(method, arg) {
|
277 | if (state === GenStateExecuting) {
|
278 | throw new Error("Generator is already running");
|
279 | }
|
280 |
|
281 | if (state === GenStateCompleted) {
|
282 | if (method === "throw") {
|
283 | throw arg;
|
284 | }
|
285 |
|
286 |
|
287 |
|
288 | return doneResult();
|
289 | }
|
290 |
|
291 | context.method = method;
|
292 | context.arg = arg;
|
293 |
|
294 | while (true) {
|
295 | var delegate = context.delegate;
|
296 | if (delegate) {
|
297 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
298 | if (delegateResult) {
|
299 | if (delegateResult === ContinueSentinel) continue;
|
300 | return delegateResult;
|
301 | }
|
302 | }
|
303 |
|
304 | if (context.method === "next") {
|
305 |
|
306 |
|
307 | context.sent = context._sent = context.arg;
|
308 |
|
309 | } else if (context.method === "throw") {
|
310 | if (state === GenStateSuspendedStart) {
|
311 | state = GenStateCompleted;
|
312 | throw context.arg;
|
313 | }
|
314 |
|
315 | context.dispatchException(context.arg);
|
316 |
|
317 | } else if (context.method === "return") {
|
318 | context.abrupt("return", context.arg);
|
319 | }
|
320 |
|
321 | state = GenStateExecuting;
|
322 |
|
323 | var record = tryCatch(innerFn, self, context);
|
324 | if (record.type === "normal") {
|
325 |
|
326 |
|
327 | state = context.done
|
328 | ? GenStateCompleted
|
329 | : GenStateSuspendedYield;
|
330 |
|
331 | if (record.arg === ContinueSentinel) {
|
332 | continue;
|
333 | }
|
334 |
|
335 | return {
|
336 | value: record.arg,
|
337 | done: context.done
|
338 | };
|
339 |
|
340 | } else if (record.type === "throw") {
|
341 | state = GenStateCompleted;
|
342 |
|
343 |
|
344 | context.method = "throw";
|
345 | context.arg = record.arg;
|
346 | }
|
347 | }
|
348 | };
|
349 | }
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 | function maybeInvokeDelegate(delegate, context) {
|
356 | var method = delegate.iterator[context.method];
|
357 | if (method === undefined$1) {
|
358 |
|
359 |
|
360 | context.delegate = null;
|
361 |
|
362 | if (context.method === "throw") {
|
363 |
|
364 | if (delegate.iterator["return"]) {
|
365 |
|
366 |
|
367 | context.method = "return";
|
368 | context.arg = undefined$1;
|
369 | maybeInvokeDelegate(delegate, context);
|
370 |
|
371 | if (context.method === "throw") {
|
372 |
|
373 |
|
374 | return ContinueSentinel;
|
375 | }
|
376 | }
|
377 |
|
378 | context.method = "throw";
|
379 | context.arg = new TypeError(
|
380 | "The iterator does not provide a 'throw' method");
|
381 | }
|
382 |
|
383 | return ContinueSentinel;
|
384 | }
|
385 |
|
386 | var record = tryCatch(method, delegate.iterator, context.arg);
|
387 |
|
388 | if (record.type === "throw") {
|
389 | context.method = "throw";
|
390 | context.arg = record.arg;
|
391 | context.delegate = null;
|
392 | return ContinueSentinel;
|
393 | }
|
394 |
|
395 | var info = record.arg;
|
396 |
|
397 | if (! info) {
|
398 | context.method = "throw";
|
399 | context.arg = new TypeError("iterator result is not an object");
|
400 | context.delegate = null;
|
401 | return ContinueSentinel;
|
402 | }
|
403 |
|
404 | if (info.done) {
|
405 |
|
406 |
|
407 | context[delegate.resultName] = info.value;
|
408 |
|
409 |
|
410 | context.next = delegate.nextLoc;
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 | if (context.method !== "return") {
|
419 | context.method = "next";
|
420 | context.arg = undefined$1;
|
421 | }
|
422 |
|
423 | } else {
|
424 |
|
425 | return info;
|
426 | }
|
427 |
|
428 |
|
429 |
|
430 | context.delegate = null;
|
431 | return ContinueSentinel;
|
432 | }
|
433 |
|
434 |
|
435 |
|
436 | defineIteratorMethods(Gp);
|
437 |
|
438 | Gp[toStringTagSymbol] = "Generator";
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 | Gp[iteratorSymbol] = function() {
|
446 | return this;
|
447 | };
|
448 |
|
449 | Gp.toString = function() {
|
450 | return "[object Generator]";
|
451 | };
|
452 |
|
453 | function pushTryEntry(locs) {
|
454 | var entry = { tryLoc: locs[0] };
|
455 |
|
456 | if (1 in locs) {
|
457 | entry.catchLoc = locs[1];
|
458 | }
|
459 |
|
460 | if (2 in locs) {
|
461 | entry.finallyLoc = locs[2];
|
462 | entry.afterLoc = locs[3];
|
463 | }
|
464 |
|
465 | this.tryEntries.push(entry);
|
466 | }
|
467 |
|
468 | function resetTryEntry(entry) {
|
469 | var record = entry.completion || {};
|
470 | record.type = "normal";
|
471 | delete record.arg;
|
472 | entry.completion = record;
|
473 | }
|
474 |
|
475 | function Context(tryLocsList) {
|
476 |
|
477 |
|
478 |
|
479 | this.tryEntries = [{ tryLoc: "root" }];
|
480 | tryLocsList.forEach(pushTryEntry, this);
|
481 | this.reset(true);
|
482 | }
|
483 |
|
484 | exports.keys = function(object) {
|
485 | var keys = [];
|
486 | for (var key in object) {
|
487 | keys.push(key);
|
488 | }
|
489 | keys.reverse();
|
490 |
|
491 |
|
492 |
|
493 | return function next() {
|
494 | while (keys.length) {
|
495 | var key = keys.pop();
|
496 | if (key in object) {
|
497 | next.value = key;
|
498 | next.done = false;
|
499 | return next;
|
500 | }
|
501 | }
|
502 |
|
503 |
|
504 |
|
505 |
|
506 | next.done = true;
|
507 | return next;
|
508 | };
|
509 | };
|
510 |
|
511 | function values(iterable) {
|
512 | if (iterable) {
|
513 | var iteratorMethod = iterable[iteratorSymbol];
|
514 | if (iteratorMethod) {
|
515 | return iteratorMethod.call(iterable);
|
516 | }
|
517 |
|
518 | if (typeof iterable.next === "function") {
|
519 | return iterable;
|
520 | }
|
521 |
|
522 | if (!isNaN(iterable.length)) {
|
523 | var i = -1, next = function next() {
|
524 | while (++i < iterable.length) {
|
525 | if (hasOwn.call(iterable, i)) {
|
526 | next.value = iterable[i];
|
527 | next.done = false;
|
528 | return next;
|
529 | }
|
530 | }
|
531 |
|
532 | next.value = undefined$1;
|
533 | next.done = true;
|
534 |
|
535 | return next;
|
536 | };
|
537 |
|
538 | return next.next = next;
|
539 | }
|
540 | }
|
541 |
|
542 |
|
543 | return { next: doneResult };
|
544 | }
|
545 | exports.values = values;
|
546 |
|
547 | function doneResult() {
|
548 | return { value: undefined$1, done: true };
|
549 | }
|
550 |
|
551 | Context.prototype = {
|
552 | constructor: Context,
|
553 |
|
554 | reset: function(skipTempReset) {
|
555 | this.prev = 0;
|
556 | this.next = 0;
|
557 |
|
558 |
|
559 | this.sent = this._sent = undefined$1;
|
560 | this.done = false;
|
561 | this.delegate = null;
|
562 |
|
563 | this.method = "next";
|
564 | this.arg = undefined$1;
|
565 |
|
566 | this.tryEntries.forEach(resetTryEntry);
|
567 |
|
568 | if (!skipTempReset) {
|
569 | for (var name in this) {
|
570 |
|
571 | if (name.charAt(0) === "t" &&
|
572 | hasOwn.call(this, name) &&
|
573 | !isNaN(+name.slice(1))) {
|
574 | this[name] = undefined$1;
|
575 | }
|
576 | }
|
577 | }
|
578 | },
|
579 |
|
580 | stop: function() {
|
581 | this.done = true;
|
582 |
|
583 | var rootEntry = this.tryEntries[0];
|
584 | var rootRecord = rootEntry.completion;
|
585 | if (rootRecord.type === "throw") {
|
586 | throw rootRecord.arg;
|
587 | }
|
588 |
|
589 | return this.rval;
|
590 | },
|
591 |
|
592 | dispatchException: function(exception) {
|
593 | if (this.done) {
|
594 | throw exception;
|
595 | }
|
596 |
|
597 | var context = this;
|
598 | function handle(loc, caught) {
|
599 | record.type = "throw";
|
600 | record.arg = exception;
|
601 | context.next = loc;
|
602 |
|
603 | if (caught) {
|
604 |
|
605 |
|
606 | context.method = "next";
|
607 | context.arg = undefined$1;
|
608 | }
|
609 |
|
610 | return !! caught;
|
611 | }
|
612 |
|
613 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
614 | var entry = this.tryEntries[i];
|
615 | var record = entry.completion;
|
616 |
|
617 | if (entry.tryLoc === "root") {
|
618 |
|
619 |
|
620 |
|
621 | return handle("end");
|
622 | }
|
623 |
|
624 | if (entry.tryLoc <= this.prev) {
|
625 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
626 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
627 |
|
628 | if (hasCatch && hasFinally) {
|
629 | if (this.prev < entry.catchLoc) {
|
630 | return handle(entry.catchLoc, true);
|
631 | } else if (this.prev < entry.finallyLoc) {
|
632 | return handle(entry.finallyLoc);
|
633 | }
|
634 |
|
635 | } else if (hasCatch) {
|
636 | if (this.prev < entry.catchLoc) {
|
637 | return handle(entry.catchLoc, true);
|
638 | }
|
639 |
|
640 | } else if (hasFinally) {
|
641 | if (this.prev < entry.finallyLoc) {
|
642 | return handle(entry.finallyLoc);
|
643 | }
|
644 |
|
645 | } else {
|
646 | throw new Error("try statement without catch or finally");
|
647 | }
|
648 | }
|
649 | }
|
650 | },
|
651 |
|
652 | abrupt: function(type, arg) {
|
653 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
654 | var entry = this.tryEntries[i];
|
655 | if (entry.tryLoc <= this.prev &&
|
656 | hasOwn.call(entry, "finallyLoc") &&
|
657 | this.prev < entry.finallyLoc) {
|
658 | var finallyEntry = entry;
|
659 | break;
|
660 | }
|
661 | }
|
662 |
|
663 | if (finallyEntry &&
|
664 | (type === "break" ||
|
665 | type === "continue") &&
|
666 | finallyEntry.tryLoc <= arg &&
|
667 | arg <= finallyEntry.finallyLoc) {
|
668 |
|
669 |
|
670 | finallyEntry = null;
|
671 | }
|
672 |
|
673 | var record = finallyEntry ? finallyEntry.completion : {};
|
674 | record.type = type;
|
675 | record.arg = arg;
|
676 |
|
677 | if (finallyEntry) {
|
678 | this.method = "next";
|
679 | this.next = finallyEntry.finallyLoc;
|
680 | return ContinueSentinel;
|
681 | }
|
682 |
|
683 | return this.complete(record);
|
684 | },
|
685 |
|
686 | complete: function(record, afterLoc) {
|
687 | if (record.type === "throw") {
|
688 | throw record.arg;
|
689 | }
|
690 |
|
691 | if (record.type === "break" ||
|
692 | record.type === "continue") {
|
693 | this.next = record.arg;
|
694 | } else if (record.type === "return") {
|
695 | this.rval = this.arg = record.arg;
|
696 | this.method = "return";
|
697 | this.next = "end";
|
698 | } else if (record.type === "normal" && afterLoc) {
|
699 | this.next = afterLoc;
|
700 | }
|
701 |
|
702 | return ContinueSentinel;
|
703 | },
|
704 |
|
705 | finish: function(finallyLoc) {
|
706 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
707 | var entry = this.tryEntries[i];
|
708 | if (entry.finallyLoc === finallyLoc) {
|
709 | this.complete(entry.completion, entry.afterLoc);
|
710 | resetTryEntry(entry);
|
711 | return ContinueSentinel;
|
712 | }
|
713 | }
|
714 | },
|
715 |
|
716 | "catch": function(tryLoc) {
|
717 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
718 | var entry = this.tryEntries[i];
|
719 | if (entry.tryLoc === tryLoc) {
|
720 | var record = entry.completion;
|
721 | if (record.type === "throw") {
|
722 | var thrown = record.arg;
|
723 | resetTryEntry(entry);
|
724 | }
|
725 | return thrown;
|
726 | }
|
727 | }
|
728 |
|
729 |
|
730 |
|
731 | throw new Error("illegal catch attempt");
|
732 | },
|
733 |
|
734 | delegateYield: function(iterable, resultName, nextLoc) {
|
735 | this.delegate = {
|
736 | iterator: values(iterable),
|
737 | resultName: resultName,
|
738 | nextLoc: nextLoc
|
739 | };
|
740 |
|
741 | if (this.method === "next") {
|
742 |
|
743 |
|
744 | this.arg = undefined$1;
|
745 | }
|
746 |
|
747 | return ContinueSentinel;
|
748 | }
|
749 | };
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 | return exports;
|
756 |
|
757 | }(
|
758 |
|
759 |
|
760 |
|
761 |
|
762 | module.exports
|
763 | ));
|
764 |
|
765 | try {
|
766 | regeneratorRuntime = runtime;
|
767 | } catch (accidentalStrictMode) {
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 | Function("r", "regeneratorRuntime = r")(runtime);
|
778 | }
|
779 | });
|
780 |
|
781 | var regenerator = runtime_1;
|
782 |
|
783 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
784 | try {
|
785 | var info = gen[key](arg);
|
786 | var value = info.value;
|
787 | } catch (error) {
|
788 | reject(error);
|
789 | return;
|
790 | }
|
791 |
|
792 | if (info.done) {
|
793 | resolve(value);
|
794 | } else {
|
795 | Promise.resolve(value).then(_next, _throw);
|
796 | }
|
797 | }
|
798 |
|
799 | function _asyncToGenerator(fn) {
|
800 | return function () {
|
801 | var self = this,
|
802 | args = arguments;
|
803 | return new Promise(function (resolve, reject) {
|
804 | var gen = fn.apply(self, args);
|
805 |
|
806 | function _next(value) {
|
807 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
808 | }
|
809 |
|
810 | function _throw(err) {
|
811 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
812 | }
|
813 |
|
814 | _next(undefined);
|
815 | });
|
816 | };
|
817 | }
|
818 |
|
819 | var asyncToGenerator = _asyncToGenerator;
|
820 |
|
821 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = getPrototypeOf._getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = getPrototypeOf._getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return getPrototypeOf._possibleConstructorReturn(this, result); }; }
|
822 |
|
823 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
824 | var id = 0;
|
825 |
|
826 | var move = function move(pixel) {
|
827 | return "translate3d(0,".concat(pixel, "px,0)");
|
828 | };
|
829 |
|
830 | var ToastContext = React__default.createContext(function () {
|
831 | throw new Error("For Toast to work it needs to be part of a ToastHub's tree, which has to be declared at an upper level!");
|
832 | });
|
833 |
|
834 | var ToastHubProvider = function (_React$PureComponent) {
|
835 | getPrototypeOf._inherits(ToastHubProvider, _React$PureComponent);
|
836 |
|
837 | var _super = _createSuper(ToastHubProvider);
|
838 |
|
839 | function ToastHubProvider() {
|
840 | var _this;
|
841 |
|
842 | getPrototypeOf._classCallCheck(this, ToastHubProvider);
|
843 |
|
844 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
845 | args[_key] = arguments[_key];
|
846 | }
|
847 |
|
848 | _this = _super.call.apply(_super, [this].concat(args));
|
849 |
|
850 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "state", {
|
851 | items: [],
|
852 | leaving: [],
|
853 | preLeaving: []
|
854 | });
|
855 |
|
856 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "cancelMap", new WeakMap());
|
857 |
|
858 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "add", function (msg) {
|
859 | var threshold = _this.props.threshold;
|
860 |
|
861 | _this.setState(function (state) {
|
862 |
|
863 | if (threshold !== Infinity) {
|
864 | state.leaving.slice(threshold - 1).forEach(function (item) {
|
865 | return _this.cancel(item, true);
|
866 | });
|
867 | }
|
868 |
|
869 | return {
|
870 | items: [].concat(toConsumableArray._toConsumableArray(state.items), [{
|
871 | key: id++,
|
872 | msg: msg
|
873 | }]),
|
874 | preLeaving: []
|
875 | };
|
876 | });
|
877 | });
|
878 |
|
879 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "remove", function (item) {
|
880 | _this.setState(function (state) {
|
881 | return {
|
882 | items: state.items.filter(function (i) {
|
883 | return i.key !== item.key;
|
884 | }),
|
885 | leaving: state.leaving.includes(item) ? state.leaving : [item].concat(toConsumableArray._toConsumableArray(state.leaving))
|
886 | };
|
887 | });
|
888 | });
|
889 |
|
890 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "config", function (item, state) {
|
891 | var config = springs.springs.lazy;
|
892 |
|
893 | return state === 'leave' ? [{
|
894 | duration: _this.props.timeout
|
895 | }, config, config] : config;
|
896 | });
|
897 |
|
898 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "cancel", function (item) {
|
899 | var secondPass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
900 |
|
901 | if (_this.cancelMap.has(item)) {
|
902 | var fn = _this.cancelMap.get(item);
|
903 |
|
904 | fn();
|
905 |
|
906 | if (secondPass) fn();
|
907 | }
|
908 | });
|
909 |
|
910 | defineProperty._defineProperty(getPrototypeOf._assertThisInitialized(_this), "leave", function (item) {
|
911 | return function () {
|
912 | var _ref = asyncToGenerator( regenerator.mark(function _callee(next, cancel) {
|
913 | return regenerator.wrap(function _callee$(_context) {
|
914 | while (1) {
|
915 | switch (_context.prev = _context.next) {
|
916 | case 0:
|
917 |
|
918 | _this.cancelMap.set(item, cancel);
|
919 |
|
920 |
|
921 | _context.next = 3;
|
922 | return next({
|
923 | to: {
|
924 | life: '0%'
|
925 | }
|
926 | });
|
927 |
|
928 | case 3:
|
929 |
|
930 |
|
931 | _this.setState(function (state) {
|
932 | return {
|
933 | preLeaving: [].concat(toConsumableArray._toConsumableArray(state.preLeaving), [item])
|
934 | };
|
935 | });
|
936 |
|
937 |
|
938 | _context.next = 6;
|
939 | return next({
|
940 | to: {
|
941 | opacity: 0
|
942 | }
|
943 | });
|
944 |
|
945 | case 6:
|
946 | _context.next = 8;
|
947 | return next({
|
948 | to: {
|
949 | height: 0
|
950 | }
|
951 | }, true);
|
952 |
|
953 | case 8:
|
954 | _this.setState(function (state) {
|
955 | return {
|
956 | leaving: state.leaving.filter(function (i) {
|
957 | return i.key !== item.key;
|
958 | }),
|
959 | preLeaving: state.preLeaving.filter(function (i) {
|
960 | return i.key !== item.key;
|
961 | })
|
962 | };
|
963 | });
|
964 |
|
965 | case 9:
|
966 | case "end":
|
967 | return _context.stop();
|
968 | }
|
969 | }
|
970 | }, _callee);
|
971 | }));
|
972 |
|
973 | return function (_x, _x2) {
|
974 | return _ref.apply(this, arguments);
|
975 | };
|
976 | }();
|
977 | });
|
978 |
|
979 | return _this;
|
980 | }
|
981 |
|
982 | getPrototypeOf._createClass(ToastHubProvider, [{
|
983 | key: "render",
|
984 | value: function render() {
|
985 | var _this$props = this.props,
|
986 | children = _this$props.children,
|
987 | showIndicator = _this$props.showIndicator,
|
988 | position = _this$props.position,
|
989 | top = _this$props.top,
|
990 | shift = _this$props.shift;
|
991 | var _this$state = this.state,
|
992 | items = _this$state.items,
|
993 | leaving = _this$state.leaving,
|
994 | preLeaving = _this$state.preLeaving;
|
995 | var renderList = items.length > 0 || leaving.length > 0;
|
996 | var itemsVisible = leaving.length === preLeaving.length && leaving.length > 0 ? false : renderList;
|
997 | return React__default.createElement(React__default.Fragment, null, React__default.createElement(ToastContext.Provider, {
|
998 | value: {
|
999 | itemsVisible: itemsVisible,
|
1000 | add: this.add
|
1001 | }
|
1002 | }, children), renderList && React__default.createElement(RootPortal.default, null, React__default.createElement(ToastList, _extends._extends({
|
1003 | config: this.config,
|
1004 | items: items,
|
1005 | leave: this.leave,
|
1006 | position: position,
|
1007 | remove: this.remove,
|
1008 | showIndicator: showIndicator,
|
1009 | top: top
|
1010 | }, components.stylingProps(this), {
|
1011 | shift: shift
|
1012 | }))));
|
1013 | }
|
1014 | }]);
|
1015 |
|
1016 | return ToastHubProvider;
|
1017 | }(React__default.PureComponent);
|
1018 |
|
1019 |
|
1020 | defineProperty._defineProperty(ToastHubProvider, "propTypes", {
|
1021 | children: index.PropTypes.node,
|
1022 | position: index.PropTypes.PropTypes.oneOf(['left', 'center', 'right']),
|
1023 | shift: index.PropTypes.number,
|
1024 | showIndicator: index.PropTypes.bool,
|
1025 | threshold: index.PropTypes.number,
|
1026 | timeout: index.PropTypes.number,
|
1027 | top: index.PropTypes.bool
|
1028 | });
|
1029 |
|
1030 | defineProperty._defineProperty(ToastHubProvider, "defaultProps", {
|
1031 | position: 'right',
|
1032 | showIndicator: false,
|
1033 | threshold: Infinity,
|
1034 | timeout: 4000,
|
1035 | top: false
|
1036 | });
|
1037 |
|
1038 | var _StyledDiv = _styled__default("div").withConfig({
|
1039 | displayName: "ToastHub___StyledDiv",
|
1040 | componentId: "sc-1y0i8xl-0"
|
1041 | })(["position:fixed;z-index:1000;top:", ";bottom:", ";left:", "px;right:", "px;display:flex;margin:0 auto;flex-direction:", ";pointer-events:none;align-items:", ";"], function (p) {
|
1042 | return p._css;
|
1043 | }, function (p) {
|
1044 | return p._css2;
|
1045 | }, function (p) {
|
1046 | return p._css3;
|
1047 | }, function (p) {
|
1048 | return p._css4;
|
1049 | }, function (p) {
|
1050 | return p._css5;
|
1051 | }, function (p) {
|
1052 | return p._css6;
|
1053 | });
|
1054 |
|
1055 | var _StyledAnimatedDiv = _styled__default(web.extendedAnimated.div).withConfig({
|
1056 | displayName: "ToastHub___StyledAnimatedDiv",
|
1057 | componentId: "sc-1y0i8xl-1"
|
1058 | })(["box-sizing:border-box;position:relative;width:", ";"], function (p) {
|
1059 | return p._css7;
|
1060 | });
|
1061 |
|
1062 | var _StyledDiv2 = _styled__default("div").withConfig({
|
1063 | displayName: "ToastHub___StyledDiv2",
|
1064 | componentId: "sc-1y0i8xl-2"
|
1065 | })(["display:flex;align-items:center;overflow:hidden;height:", "px;margin-top:", ";margin-bottom:", ";padding:0 ", "px;", ";color:", ";background:", ";border-radius:", "px;"], function (p) {
|
1066 | return p._css8;
|
1067 | }, function (p) {
|
1068 | return p._css9;
|
1069 | }, function (p) {
|
1070 | return p._css10;
|
1071 | }, function (p) {
|
1072 | return p._css11;
|
1073 | }, function (p) {
|
1074 | return p._css12;
|
1075 | }, function (p) {
|
1076 | return p._css13;
|
1077 | }, function (p) {
|
1078 | return p._css14;
|
1079 | }, constants.RADIUS);
|
1080 |
|
1081 | var _StyledAnimatedDiv2 = _styled__default(web.extendedAnimated.div).withConfig({
|
1082 | displayName: "ToastHub___StyledAnimatedDiv2",
|
1083 | componentId: "sc-1y0i8xl-3"
|
1084 | })(["position:absolute;bottom:", ";left:0;width:auto;height:5px;background-image:linear-gradient( 130deg,#00b4e6,#00f0e0 );"], function (p) {
|
1085 | return p._css15;
|
1086 | });
|
1087 |
|
1088 | var ToastList = React__default.memo(function ToastList(_ref2) {
|
1089 | var config = _ref2.config,
|
1090 | items = _ref2.items,
|
1091 | leave = _ref2.leave,
|
1092 | position = _ref2.position,
|
1093 | remove = _ref2.remove,
|
1094 | showIndicator = _ref2.showIndicator,
|
1095 | top = _ref2.top,
|
1096 | shift = _ref2.shift,
|
1097 | props = objectWithoutProperties._objectWithoutProperties(_ref2, ["config", "items", "leave", "position", "remove", "showIndicator", "top", "shift"]);
|
1098 |
|
1099 | var theme = Theme.useTheme();
|
1100 |
|
1101 | var _useViewport = Viewport.useViewport(),
|
1102 | below = _useViewport.below;
|
1103 |
|
1104 | var spacing = below('medium') ? 2 * constants.GU : 3 * constants.GU;
|
1105 | return React__default.createElement(_StyledDiv, _extends._extends({}, props, {
|
1106 | _css: top ? "".concat(spacing, "px") : 'unset',
|
1107 | _css2: top ? 'unset' : "".concat(spacing, "px"),
|
1108 | _css3: spacing + (shift || 0),
|
1109 | _css4: spacing + (shift || 0),
|
1110 | _css5: top ? 'column-reverse' : 'column',
|
1111 | _css6: function () {
|
1112 | if (below('medium')) return 'center';
|
1113 | if (position === 'left') return 'flex-start';
|
1114 | if (position === 'right') return 'flex-end';
|
1115 | return 'center';
|
1116 | }()
|
1117 | }), React__default.createElement(web.Transition, {
|
1118 | native: true,
|
1119 | items: items,
|
1120 | keys: function keys(item) {
|
1121 | return item.key;
|
1122 | },
|
1123 | from: {
|
1124 | opacity: 0,
|
1125 | height: 0,
|
1126 | life: '100%',
|
1127 | transform: move(30)
|
1128 | },
|
1129 | enter: {
|
1130 | opacity: 1,
|
1131 | height: 'auto',
|
1132 | transform: move(0)
|
1133 | },
|
1134 | leave: leave,
|
1135 | onRest: remove,
|
1136 | config: config
|
1137 | }, function (item) {
|
1138 | return (
|
1139 |
|
1140 | function (_ref3) {
|
1141 | var life = _ref3.life,
|
1142 | props = objectWithoutProperties._objectWithoutProperties(_ref3, ["life"]);
|
1143 |
|
1144 | return React__default.createElement(_StyledAnimatedDiv, {
|
1145 | style: props,
|
1146 | _css7: below('medium') ? '100%' : '42ch'
|
1147 | }, React__default.createElement(_StyledDiv2, {
|
1148 | _css8: 6 * constants.GU,
|
1149 | _css9: top ? '0' : "".concat(1.25 * constants.GU, "px"),
|
1150 | _css10: top ? "".concat(1.25 * constants.GU, "px") : '0',
|
1151 | _css11: 2.5 * constants.GU,
|
1152 | _css12: textStyles.textStyle('body3'),
|
1153 | _css13: theme.floatingContent,
|
1154 | _css14: theme.floating.alpha(0.95)
|
1155 | }, showIndicator && React__default.createElement(_StyledAnimatedDiv2, {
|
1156 | style: {
|
1157 | right: life
|
1158 | },
|
1159 | _css15: top ? "".concat(1.25 * constants.GU, "px") : '0'
|
1160 | }), React__default.createElement("p", null, item.msg)));
|
1161 | }
|
1162 | );
|
1163 | }
|
1164 |
|
1165 | ));
|
1166 | });
|
1167 | ToastList.propTypes = {
|
1168 | config: index.PropTypes.func,
|
1169 | items: index.PropTypes.array,
|
1170 | leave: index.PropTypes.func,
|
1171 | position: index.PropTypes.PropTypes.oneOf(['left', 'center', 'right']),
|
1172 | remove: index.PropTypes.func,
|
1173 | shift: index.PropTypes.number,
|
1174 | showIndicator: index.PropTypes.bool,
|
1175 | top: index.PropTypes.bool
|
1176 | };
|
1177 |
|
1178 | var useToast = function useToast() {
|
1179 | return React.useContext(ToastContext).add;
|
1180 | };
|
1181 |
|
1182 | var Toast = function Toast(props) {
|
1183 | return props.children(useToast());
|
1184 | };
|
1185 |
|
1186 | exports.Toast = Toast;
|
1187 | exports.ToastContext = ToastContext;
|
1188 | exports.default = ToastHubProvider;
|
1189 | exports.useToast = useToast;
|
1190 |
|