acud
Version:
acg react 组件库
44 lines • 2.41 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
/**
* @file 加载
* @author caifeng01
*/
import React, { useContext } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider';
import Icon from './icon';
var Loading = function Loading(_ref) {
var customizePrefixCls = _ref.prefixCls,
_ref$loading = _ref.loading,
loading = _ref$loading === void 0 ? true : _ref$loading,
children = _ref.children,
_ref$tip = _ref.tip,
tip = _ref$tip === void 0 ? '' : _ref$tip,
indicator = _ref.indicator,
_ref$tipPosition = _ref.tipPosition,
tipPosition = _ref$tipPosition === void 0 ? 'bottom' : _ref$tipPosition,
indicatorClassName = _ref.indicatorClassName,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 'middle' : _ref$size;
var _useContext = useContext(ConfigContext),
getPrefixCls = _useContext.getPrefixCls;
var prefixCls = getPrefixCls('loading', customizePrefixCls);
var contextClassname = classNames(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-loading-context"), true), "".concat(prefixCls, "-bottom"), tipPosition === 'bottom'), "".concat(prefixCls, "-zIndex"), !children));
var iconClassname = classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-default"), true), "".concat(prefixCls, "-lg"), size === 'large'), "".concat(prefixCls, "-sm"), size === 'small'), indicatorClassName, !!indicatorClassName));
var tipClassname = classNames(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-tip"), true), "".concat(prefixCls, "-tip-right"), tipPosition === 'right'));
var childrenClassname = classNames(_defineProperty({}, "".concat(prefixCls, "-children"), loading));
var loadingText = loading && /*#__PURE__*/React.createElement("div", {
className: contextClassname
}, indicator !== null && indicator !== void 0 ? indicator : /*#__PURE__*/React.createElement(Icon, {
prefixCls: prefixCls,
className: iconClassname
}), /*#__PURE__*/React.createElement("span", {
className: tipClassname
}, tip));
return children ? /*#__PURE__*/React.createElement("div", {
className: "".concat(prefixCls, "-loading-wrapper")
}, /*#__PURE__*/React.createElement("div", {
className: childrenClassname
}, children), loadingText) : loadingText;
};
export default Loading;