zent
Version:
一套前端设计语言和基于React的实现
26 lines (25 loc) • 1.71 kB
JavaScript
import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import cx from 'classnames';
import useDelayed from './hooks/useDelayed';
import LoadingMask from './components/LoadingMask';
import { Portal } from '../portal';
var NO_STYLE = {};
var DEFAULT_ICON_SIZE_BG = 24;
var DEFAULT_TEXT_SIZE_BG = 14;
var DEFAULT_ICON_SIZE = 32;
var DEFAULT_TEXT_SIZE = 20;
export function FullScreenLoading(props) {
var _a = props.loading, loading = _a === void 0 ? false : _a, _b = props.delay, delay = _b === void 0 ? 0 : _b, className = props.className, _c = props.icon, icon = _c === void 0 ? 'circle' : _c, size = props.iconSize, iconText = props.iconText, _d = props.textPosition, textPosition = _d === void 0 ? 'bottom' : _d, zIndex = props.zIndex, _e = props.colorPreset, colorPreset = _e === void 0 ? 'primary' : _e, showBackground = props.showBackground, fontSize = props.textSize;
var delayed = useDelayed({ loading: loading, delay: delay });
var iconSize = size || showBackground ? DEFAULT_ICON_SIZE_BG : DEFAULT_ICON_SIZE;
var textSize = fontSize || showBackground ? DEFAULT_TEXT_SIZE_BG : DEFAULT_TEXT_SIZE;
if (delayed || !loading) {
return null;
}
var style = typeof zIndex === 'number' ? { zIndex: zIndex } : NO_STYLE;
return (_jsx(Portal, __assign({ className: cx('zent-loading', 'zent-loading--fullscreen', className, {
'zent-loading--show-background': showBackground,
}), style: style, blockPageScroll: true }, { children: _jsx(LoadingMask, { icon: icon, size: iconSize, text: iconText, textPosition: textPosition, colorPreset: colorPreset, textSize: textSize }, void 0) }), void 0));
}
export default FullScreenLoading;