UNPKG

4.15 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14 if (k2 === undefined) k2 = k;
15 var desc = Object.getOwnPropertyDescriptor(m, k);
16 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17 desc = { enumerable: true, get: function() { return m[k]; } };
18 }
19 Object.defineProperty(o, k2, desc);
20}) : (function(o, m, k, k2) {
21 if (k2 === undefined) k2 = k;
22 o[k2] = m[k];
23}));
24var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25 Object.defineProperty(o, "default", { enumerable: true, value: v });
26}) : function(o, v) {
27 o["default"] = v;
28});
29var __importStar = (this && this.__importStar) || function (mod) {
30 if (mod && mod.__esModule) return mod;
31 var result = {};
32 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33 __setModuleDefault(result, mod);
34 return result;
35};
36var __rest = (this && this.__rest) || function (s, e) {
37 var t = {};
38 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
39 t[p] = s[p];
40 if (s != null && typeof Object.getOwnPropertySymbols === "function")
41 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
42 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
43 t[p[i]] = s[p[i]];
44 }
45 return t;
46};
47Object.defineProperty(exports, "__esModule", { value: true });
48var React = __importStar(require("react"));
49var unitConverter_1 = require("./helpers/unitConverter");
50var animation_1 = require("./helpers/animation");
51var circle = (0, animation_1.createAnimation)("CircleLoader", "0% {transform: rotate(0deg)} 50% {transform: rotate(180deg)} 100% {transform: rotate(360deg)}", "circle");
52function CircleLoader(_a) {
53 var _b = _a.loading, loading = _b === void 0 ? true : _b, _c = _a.color, color = _c === void 0 ? "#000000" : _c, _d = _a.speedMultiplier, speedMultiplier = _d === void 0 ? 1 : _d, _e = _a.cssOverride, cssOverride = _e === void 0 ? {} : _e, _f = _a.size, size = _f === void 0 ? 50 : _f, additionalprops = __rest(_a, ["loading", "color", "speedMultiplier", "cssOverride", "size"]);
54 var wrapper = __assign({ display: "inherit", position: "relative", width: (0, unitConverter_1.cssValue)(size), height: (0, unitConverter_1.cssValue)(size) }, cssOverride);
55 var style = function (i) {
56 var _a = (0, unitConverter_1.parseLengthAndUnit)(size), value = _a.value, unit = _a.unit;
57 return {
58 position: "absolute",
59 height: "".concat(value * (1 - i / 10)).concat(unit),
60 width: "".concat(value * (1 - i / 10)).concat(unit),
61 borderTop: "1px solid ".concat(color),
62 borderBottom: "none",
63 borderLeft: "1px solid ".concat(color),
64 borderRight: "none",
65 borderRadius: "100%",
66 transition: "2s",
67 top: "".concat(i * 0.7 * 2.5, "%"),
68 left: "".concat(i * 0.35 * 2.5, "%"),
69 animation: "".concat(circle, " ").concat(1 / speedMultiplier, "s ").concat((i * 0.2) / speedMultiplier, "s infinite linear"),
70 };
71 };
72 if (!loading) {
73 return null;
74 }
75 return (React.createElement("span", __assign({ style: wrapper }, additionalprops),
76 React.createElement("span", { style: style(0) }),
77 React.createElement("span", { style: style(1) }),
78 React.createElement("span", { style: style(2) }),
79 React.createElement("span", { style: style(3) }),
80 React.createElement("span", { style: style(4) })));
81}
82exports.default = CircleLoader;