UNPKG

@perfma/heaven

Version:

An UI Framework base [Ant Design V4](https://ant.design/components/overview-cn/) for React.

127 lines (98 loc) 9.83 kB
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } var _excluded = ["loading", "className", "children"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } import React from 'react'; import { Spin } from 'antd'; import { classNames } from '../_util'; import Simple from './simple'; import './index.less'; var Loading = /*#__PURE__*/function (_React$PureComponent) { _inherits(Loading, _React$PureComponent); var _super = _createSuper(Loading); function Loading() { var _this; _classCallCheck(this, Loading); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _this.path = null; return _this; } _createClass(Loading, [{ key: "componentDidMount", value: function componentDidMount() { this.injectAnimation(); } }, { key: "componentDidUpdate", value: function componentDidUpdate() { this.injectAnimation(); } }, { key: "injectAnimation", value: function injectAnimation() { var _this$props = this.props, _this$props$time = _this$props.time, time = _this$props$time === void 0 ? 4000 : _this$props$time, loop = _this$props.loop; if (this.path) { this.path.style.animation = "perfma ".concat(time / 1000, "s ").concat(loop ? 'infinite' : 'forwards', " linear"); } } }, { key: "render", value: function render() { var _this2 = this; var _this$props2 = this.props, loading = _this$props2.loading, className = _this$props2.className, children = _this$props2.children, rest = _objectWithoutProperties(_this$props2, _excluded); return /*#__PURE__*/React.createElement(Spin, _objectSpread(_objectSpread({}, rest), {}, { spinning: false, className: classNames(['heaven-loading-body', className]) }), children, loading && /*#__PURE__*/React.createElement("div", { className: "heaven-loading-body-background" }, /*#__PURE__*/React.createElement("div", { className: "heaven-loading-body-loading" }, /*#__PURE__*/React.createElement("svg", { viewBox: "0 0 25 32", xmlns: "http://www.w3.org/2000/svg" }, /*#__PURE__*/React.createElement("path", { ref: function ref(c) { _this2.path = c; }, d: "m15.1277882.24999896c2.4715875.00714207 4.7127654.99269638 6.3566216 2.58977652 1.6486446 1.60173233 2.6965389 3.81853955 2.7733046 6.27338593l.0046272 1.36777339c-.0075859 2.4714169-.9932455 4.7123862-2.5902769 6.3561802-1.601681 1.6485797-3.8182802 2.6965581-6.2724621 2.7737422l-2.9280459.0046934-.732385.068393c-.9481323.1765259-1.78005613.6838393-2.3711315 1.3979131-.57859884.699001-.92653727 1.5959454-.92697637 2.5743135l.00000002 3.6681799c.00042638 1.1245744-.44590018 2.2032585-1.2407929 2.9987541-.79489273.7954956-1.87323814 1.2426398-2.99771776 1.243066h-3.95254367l.0005232-13.7418551c.00672875-.1391472.08233662-.8945566.78531719-1.6385226.40170636-.4251268 1.00408273-.8436217 1.90156433-1.1527662 3.05623518-1.0502063 6.7621111-1.2730355 7.55022636-1.3095743.2563789.4346753.6555554.8520536 1.2764319 1.1346527.5252706.239083 1.2142122.382377 2.1195779.3458344.1866601.0283801 1.5425792.269185 1.9952423 1.3330874.0059545.0129563.4032801.7723941 1.0677683.823414.3111284.0238887.6965398-.0884049 1.133657-.5532191.2544701-.0599932 1.0403688-.2703599 1.6082056-.6947946.386095-.2885901.6670321-.6711144.687211-1.1486813-.1159807-.2217376-2.8739549-1.9658286-4.2944444-4.0606373-.1188891-.2071519-1.5241815-2.63223576-2.4511858-3.15240095-.0429262-.29913775-.189335-.98129486-.6694255-1.5673793-.3206-.39138191-.7876295-.74170377-1.4700222-.90792764-.1762209-.04292561-.3453348-.06834446-.5071674-.07894686.3124444.60997989.4642052.91122635.5871875 1.23416694-.363328-.35866483-.6222633-.51640358-.8510088-.61903806l-.5742209-.25764386.2409211.58143532c.3061612.73888459-1.53417907.15067046-1.53417907.15067046s-1.83046888-.58505903-1.16808732-1.00916037c-.38468909-.09484521-.81779407-.15072414-1.25737023-.1085061-.1530087.00563418-2.06958994.06159862-2.79241258-.63820419l-1.03230206-.9994262.63406799 1.28936343c.15772618.32073276.33618525.63037805.53390182.92697735-.46113872-.08787222-.93693321-.09384901-1.52175996.05103469-.85986289-.58095114-.87046318-.73322483-.81777577-.88467102 1.5691452-2.78595887 4.47368678-4.54581748 7.64734587-4.65764434z", fill: "none", stroke: "#2082fb", strokeDashoffset: "140.533737", strokeWidth: ".5" }))))); } }]); return Loading; }(React.PureComponent); Loading.defaultProps = void 0; Loading.Simple = void 0; Loading.defaultProps = { time: 4000, loading: true, loop: true }; Loading.Simple = Simple; export default Loading;