1 | "use strict";
|
2 | var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
3 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
4 | return cooked;
|
5 | };
|
6 | var __extends = (this && this.__extends) || (function () {
|
7 | var extendStatics = function (d, b) {
|
8 | extendStatics = Object.setPrototypeOf ||
|
9 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
10 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
11 | return extendStatics(d, b);
|
12 | };
|
13 | return function (d, b) {
|
14 | extendStatics(d, b);
|
15 | function __() { this.constructor = d; }
|
16 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
17 | };
|
18 | })();
|
19 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
20 | if (k2 === undefined) k2 = k;
|
21 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
22 | }) : (function(o, m, k, k2) {
|
23 | if (k2 === undefined) k2 = k;
|
24 | o[k2] = m[k];
|
25 | }));
|
26 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
27 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
28 | }) : function(o, v) {
|
29 | o["default"] = v;
|
30 | });
|
31 | var __importStar = (this && this.__importStar) || function (mod) {
|
32 | if (mod && mod.__esModule) return mod;
|
33 | var result = {};
|
34 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
35 | __setModuleDefault(result, mod);
|
36 | return result;
|
37 | };
|
38 | Object.defineProperty(exports, "__esModule", { value: true });
|
39 |
|
40 | var React = __importStar(require("react"));
|
41 | var react_1 = require("@emotion/react");
|
42 | var helpers_1 = require("./helpers");
|
43 | var rotate = react_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 100% {transform: rotate(360deg)}\n"], ["\n 100% {transform: rotate(360deg)}\n"])));
|
44 | var bounce = react_1.keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0%, 100% {transform: scale(0)}\n 50% {transform: scale(1.0)}\n"], ["\n 0%, 100% {transform: scale(0)}\n 50% {transform: scale(1.0)}\n"])));
|
45 | var Loader = (function (_super) {
|
46 | __extends(Loader, _super);
|
47 | function Loader() {
|
48 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
49 | _this.style = function (i) {
|
50 | var _a = _this.props, size = _a.size, color = _a.color, speedMultiplier = _a.speedMultiplier;
|
51 | var _b = helpers_1.parseLengthAndUnit(size), value = _b.value, unit = _b.unit;
|
52 | return react_1.css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: ", ";\n bottom: ", ";\n height: ", ";\n width: ", ";\n background-color: ", ";\n border-radius: 100%;\n animation-fill-mode: forwards;\n animation: ", " ", "s ", " infinite linear;\n "], ["\n position: absolute;\n top: ", ";\n bottom: ", ";\n height: ", ";\n width: ", ";\n background-color: ", ";\n border-radius: 100%;\n animation-fill-mode: forwards;\n animation: ", " ", "s ", " infinite linear;\n "])), i % 2 ? "0" : "auto", i % 2 ? "auto" : "0", "" + value / 2 + unit, "" + value / 2 + unit, color, bounce, 2 / speedMultiplier, i === 2 ? "-1s" : "0s");
|
53 | };
|
54 | _this.wrapper = function () {
|
55 | var _a = _this.props, size = _a.size, speedMultiplier = _a.speedMultiplier;
|
56 | return react_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n width: ", ";\n height: ", ";\n animation-fill-mode: forwards;\n animation: ", " ", "s 0s infinite linear;\n "], ["\n position: relative;\n width: ", ";\n height: ", ";\n animation-fill-mode: forwards;\n animation: ", " ", "s 0s infinite linear;\n "])), helpers_1.cssValue(size), helpers_1.cssValue(size), rotate, 2 / speedMultiplier);
|
57 | };
|
58 | return _this;
|
59 | }
|
60 | Loader.prototype.render = function () {
|
61 | var _a = this.props, loading = _a.loading, css = _a.css;
|
62 | return loading ? (react_1.jsx("span", { css: [this.wrapper(), css] },
|
63 | react_1.jsx("span", { css: this.style(1) }),
|
64 | react_1.jsx("span", { css: this.style(2) }))) : null;
|
65 | };
|
66 | Loader.defaultProps = helpers_1.sizeDefaults(60);
|
67 | return Loader;
|
68 | }(React.PureComponent));
|
69 | exports.default = Loader;
|
70 | var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|