"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Loading", {
    enumerable: true,
    get: function() {
        return Loading;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _iconsreacttaro = require("@nutui/icons-react-taro");
var _components = require("@tarojs/components");
var _typings = require("../../utils/typings");
// 方便以后扩展设置为键值对形式
var loadingMap = {
    circular: _iconsreacttaro.Loading1,
    spinner: _iconsreacttaro.Loading
};
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    // 对比一下,个人感觉还是Loading1比较好看一些,所以用它作为了默认的loading图标
    type: 'circular',
    direction: 'horizontal'
});
var Loading = /*#__PURE__*/ _react.default.forwardRef(function(props, ref) {
    var _ref = (0, _object_spread._)({}, defaultProps, props), className = _ref.className, style = _ref.style, children = _ref.children, direction = _ref.direction, icon = _ref.icon, rest = (0, _object_without_properties._)(_ref, [
        "className",
        "style",
        "children",
        "direction",
        "icon"
    ]);
    var classPrefix = 'nut-loading';
    var getLoadingIcon = function getLoadingIcon() {
        var LoadingIcon = loadingMap[rest.type] || _iconsreacttaro.Loading1;
        return /*#__PURE__*/ _react.default.createElement(LoadingIcon, {
            className: "".concat(classPrefix, "-icon")
        });
    };
    var iconboxClassName = function iconboxClassName() {
        return !icon ? "".concat(classPrefix, "-icon-box") : '';
    };
    return /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: (0, _classnames.default)(classPrefix, direction === 'vertical' ? "".concat(classPrefix, "-vertical") : '', className),
        style: style
    }, /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: iconboxClassName()
    }, icon || getLoadingIcon()), children ? /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: "".concat(classPrefix, "-text")
    }, children) : null);
});
Loading.displayName = 'NutLoading';
