Latest updates from IceHrmPro
This commit is contained in:
166
web/node_modules/antd/es/message/index.js
generated
vendored
Normal file
166
web/node_modules/antd/es/message/index.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import Notification from 'rc-notification';
|
||||
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
||||
import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';
|
||||
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
|
||||
import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';
|
||||
import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';
|
||||
var defaultDuration = 3;
|
||||
var defaultTop;
|
||||
var messageInstance;
|
||||
var key = 1;
|
||||
var prefixCls = 'ant-message';
|
||||
var transitionName = 'move-up';
|
||||
var getContainer;
|
||||
var maxCount;
|
||||
var rtl = false;
|
||||
|
||||
function getMessageInstance(callback) {
|
||||
if (messageInstance) {
|
||||
callback(messageInstance);
|
||||
return;
|
||||
}
|
||||
|
||||
Notification.newInstance({
|
||||
prefixCls: prefixCls,
|
||||
transitionName: transitionName,
|
||||
style: {
|
||||
top: defaultTop
|
||||
},
|
||||
getContainer: getContainer,
|
||||
maxCount: maxCount
|
||||
}, function (instance) {
|
||||
if (messageInstance) {
|
||||
callback(messageInstance);
|
||||
return;
|
||||
}
|
||||
|
||||
messageInstance = instance;
|
||||
callback(instance);
|
||||
});
|
||||
}
|
||||
|
||||
var iconMap = {
|
||||
info: InfoCircleFilled,
|
||||
success: CheckCircleFilled,
|
||||
error: CloseCircleFilled,
|
||||
warning: ExclamationCircleFilled,
|
||||
loading: LoadingOutlined
|
||||
};
|
||||
|
||||
function notice(args) {
|
||||
var _classNames;
|
||||
|
||||
var duration = args.duration !== undefined ? args.duration : defaultDuration;
|
||||
var IconComponent = iconMap[args.type];
|
||||
var messageClass = classNames("".concat(prefixCls, "-custom-content"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(args.type), args.type), _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), rtl === true), _classNames));
|
||||
var target = args.key || key++;
|
||||
var closePromise = new Promise(function (resolve) {
|
||||
var callback = function callback() {
|
||||
if (typeof args.onClose === 'function') {
|
||||
args.onClose();
|
||||
}
|
||||
|
||||
return resolve(true);
|
||||
};
|
||||
|
||||
getMessageInstance(function (instance) {
|
||||
instance.notice({
|
||||
key: target,
|
||||
duration: duration,
|
||||
style: {},
|
||||
content: /*#__PURE__*/React.createElement("div", {
|
||||
className: messageClass
|
||||
}, args.icon || IconComponent && /*#__PURE__*/React.createElement(IconComponent, null), /*#__PURE__*/React.createElement("span", null, args.content)),
|
||||
onClose: callback
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var result = function result() {
|
||||
if (messageInstance) {
|
||||
messageInstance.removeNotice(target);
|
||||
}
|
||||
};
|
||||
|
||||
result.then = function (filled, rejected) {
|
||||
return closePromise.then(filled, rejected);
|
||||
};
|
||||
|
||||
result.promise = closePromise;
|
||||
return result;
|
||||
}
|
||||
|
||||
function isArgsProps(content) {
|
||||
return Object.prototype.toString.call(content) === '[object Object]' && !!content.content;
|
||||
}
|
||||
|
||||
var api = {
|
||||
open: notice,
|
||||
config: function config(options) {
|
||||
if (options.top !== undefined) {
|
||||
defaultTop = options.top;
|
||||
messageInstance = null; // delete messageInstance for new defaultTop
|
||||
}
|
||||
|
||||
if (options.duration !== undefined) {
|
||||
defaultDuration = options.duration;
|
||||
}
|
||||
|
||||
if (options.prefixCls !== undefined) {
|
||||
prefixCls = options.prefixCls;
|
||||
}
|
||||
|
||||
if (options.getContainer !== undefined) {
|
||||
getContainer = options.getContainer;
|
||||
}
|
||||
|
||||
if (options.transitionName !== undefined) {
|
||||
transitionName = options.transitionName;
|
||||
messageInstance = null; // delete messageInstance for new transitionName
|
||||
}
|
||||
|
||||
if (options.maxCount !== undefined) {
|
||||
maxCount = options.maxCount;
|
||||
messageInstance = null;
|
||||
}
|
||||
|
||||
if (options.rtl !== undefined) {
|
||||
rtl = options.rtl;
|
||||
}
|
||||
},
|
||||
destroy: function destroy() {
|
||||
if (messageInstance) {
|
||||
messageInstance.destroy();
|
||||
messageInstance = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
['success', 'info', 'warning', 'error', 'loading'].forEach(function (type) {
|
||||
api[type] = function (content, duration, onClose) {
|
||||
if (isArgsProps(content)) {
|
||||
return api.open(_extends(_extends({}, content), {
|
||||
type: type
|
||||
}));
|
||||
}
|
||||
|
||||
if (typeof duration === 'function') {
|
||||
onClose = duration;
|
||||
duration = undefined;
|
||||
}
|
||||
|
||||
return api.open({
|
||||
content: content,
|
||||
duration: duration,
|
||||
type: type,
|
||||
onClose: onClose
|
||||
});
|
||||
};
|
||||
});
|
||||
api.warn = api.warning;
|
||||
export default api;
|
||||
Reference in New Issue
Block a user