PromoCursed/node_modules/antd/lib/button/LoadingIcon.js

84 lines
2.5 KiB
JavaScript
Raw Normal View History

2024-08-20 23:25:37 +04:00
"use strict";
"use client";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _LoadingOutlined = _interopRequireDefault(require("@ant-design/icons/LoadingOutlined"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcMotion = _interopRequireDefault(require("rc-motion"));
var _IconWrapper = _interopRequireDefault(require("./IconWrapper"));
const InnerLoadingIcon = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
const {
prefixCls,
className,
style,
iconClassName
} = props;
const mergedIconCls = (0, _classnames.default)(`${prefixCls}-loading-icon`, className);
return /*#__PURE__*/_react.default.createElement(_IconWrapper.default, {
prefixCls: prefixCls,
className: mergedIconCls,
style: style,
ref: ref
}, /*#__PURE__*/_react.default.createElement(_LoadingOutlined.default, {
className: iconClassName
}));
});
const getCollapsedWidth = () => ({
width: 0,
opacity: 0,
transform: 'scale(0)'
});
const getRealWidth = node => ({
width: node.scrollWidth,
opacity: 1,
transform: 'scale(1)'
});
const LoadingIcon = props => {
const {
prefixCls,
loading,
existIcon,
className,
style
} = props;
const visible = !!loading;
if (existIcon) {
return /*#__PURE__*/_react.default.createElement(InnerLoadingIcon, {
prefixCls: prefixCls,
className: className,
style: style
});
}
return /*#__PURE__*/_react.default.createElement(_rcMotion.default, {
visible: visible,
// We do not really use this motionName
motionName: `${prefixCls}-loading-icon-motion`,
motionLeave: visible,
removeOnLeave: true,
onAppearStart: getCollapsedWidth,
onAppearActive: getRealWidth,
onEnterStart: getCollapsedWidth,
onEnterActive: getRealWidth,
onLeaveStart: getRealWidth,
onLeaveActive: getCollapsedWidth
}, (_ref, ref) => {
let {
className: motionCls,
style: motionStyle
} = _ref;
return /*#__PURE__*/_react.default.createElement(InnerLoadingIcon, {
prefixCls: prefixCls,
className: className,
style: Object.assign(Object.assign({}, style), motionStyle),
ref: ref,
iconClassName: motionCls
});
});
};
var _default = exports.default = LoadingIcon;