"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var _ = require("lodash");
var antd_1 = require("antd");
var dva_1 = require("dva");
/**
 * Loading
*/
var LoadingContent = /** @class */ (function (_super) {
    __extends(LoadingContent, _super);
    function LoadingContent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    LoadingContent.prototype.render = function () {
        var style = {};
        if (_.isNumber(this.props.centerTop)) {
            style = { display: 'block', margin: this.props.centerTop + "px auto" };
        }
        var effect = this.props.effect;
        var loading = true;
        if (_.isString(effect)) {
            // @ts-ignore
            var effects = this.props._loading.effects;
            loading = effects[effect];
        }
        else if (_.isBoolean(effect)) {
            loading = effect;
        }
        return loading ? React.createElement(antd_1.Spin, { style: style }) : (this.props.content || this.props.children || []);
    };
    return LoadingContent;
}(React.PureComponent));
var Loading = dva_1.connect(function (_a) {
    var _loading = _a._loading;
    return ({ _loading: _loading });
})(LoadingContent);
exports.default = Loading;
