Latest updates from IceHrmPro
This commit is contained in:
218
web/node_modules/antd/es/notification/index.js
generated
vendored
Normal file
218
web/node_modules/antd/es/notification/index.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
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); }
|
||||
|
||||
import * as React from 'react';
|
||||
import Notification from 'rc-notification';
|
||||
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
||||
import CheckCircleOutlined from '@ant-design/icons/CheckCircleOutlined';
|
||||
import CloseCircleOutlined from '@ant-design/icons/CloseCircleOutlined';
|
||||
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
|
||||
import InfoCircleOutlined from '@ant-design/icons/InfoCircleOutlined';
|
||||
import createUseNotification from './hooks/useNotification';
|
||||
var notificationInstance = {};
|
||||
var defaultDuration = 4.5;
|
||||
var defaultTop = 24;
|
||||
var defaultBottom = 24;
|
||||
var defaultPlacement = 'topRight';
|
||||
var defaultGetContainer;
|
||||
var defaultCloseIcon;
|
||||
|
||||
function setNotificationConfig(options) {
|
||||
var duration = options.duration,
|
||||
placement = options.placement,
|
||||
bottom = options.bottom,
|
||||
top = options.top,
|
||||
getContainer = options.getContainer,
|
||||
closeIcon = options.closeIcon;
|
||||
|
||||
if (duration !== undefined) {
|
||||
defaultDuration = duration;
|
||||
}
|
||||
|
||||
if (placement !== undefined) {
|
||||
defaultPlacement = placement;
|
||||
}
|
||||
|
||||
if (bottom !== undefined) {
|
||||
defaultBottom = bottom;
|
||||
}
|
||||
|
||||
if (top !== undefined) {
|
||||
defaultTop = top;
|
||||
}
|
||||
|
||||
if (getContainer !== undefined) {
|
||||
defaultGetContainer = getContainer;
|
||||
}
|
||||
|
||||
if (closeIcon !== undefined) {
|
||||
defaultCloseIcon = closeIcon;
|
||||
}
|
||||
}
|
||||
|
||||
function getPlacementStyle(placement) {
|
||||
var top = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTop;
|
||||
var bottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultBottom;
|
||||
var style;
|
||||
|
||||
switch (placement) {
|
||||
case 'topLeft':
|
||||
style = {
|
||||
left: 0,
|
||||
top: top,
|
||||
bottom: 'auto'
|
||||
};
|
||||
break;
|
||||
|
||||
case 'topRight':
|
||||
style = {
|
||||
right: 0,
|
||||
top: top,
|
||||
bottom: 'auto'
|
||||
};
|
||||
break;
|
||||
|
||||
case 'bottomLeft':
|
||||
style = {
|
||||
left: 0,
|
||||
top: 'auto',
|
||||
bottom: bottom
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
style = {
|
||||
right: 0,
|
||||
top: 'auto',
|
||||
bottom: bottom
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
function getNotificationInstance(args, callback) {
|
||||
var _args$placement = args.placement,
|
||||
placement = _args$placement === void 0 ? defaultPlacement : _args$placement,
|
||||
top = args.top,
|
||||
bottom = args.bottom,
|
||||
_args$getContainer = args.getContainer,
|
||||
getContainer = _args$getContainer === void 0 ? defaultGetContainer : _args$getContainer,
|
||||
_args$closeIcon = args.closeIcon,
|
||||
closeIcon = _args$closeIcon === void 0 ? defaultCloseIcon : _args$closeIcon;
|
||||
var outerPrefixCls = args.prefixCls || 'ant-notification';
|
||||
var prefixCls = "".concat(outerPrefixCls, "-notice");
|
||||
var cacheKey = "".concat(outerPrefixCls, "-").concat(placement);
|
||||
var cacheInstance = notificationInstance[cacheKey];
|
||||
|
||||
if (cacheInstance) {
|
||||
Promise.resolve(cacheInstance).then(function (instance) {
|
||||
callback({
|
||||
prefixCls: prefixCls,
|
||||
instance: instance
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var closeIconToRender = /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(outerPrefixCls, "-close-x")
|
||||
}, closeIcon || /*#__PURE__*/React.createElement(CloseOutlined, {
|
||||
className: "".concat(outerPrefixCls, "-close-icon")
|
||||
}));
|
||||
notificationInstance[cacheKey] = new Promise(function (resolve) {
|
||||
Notification.newInstance({
|
||||
prefixCls: outerPrefixCls,
|
||||
className: "".concat(outerPrefixCls, "-").concat(placement),
|
||||
style: getPlacementStyle(placement, top, bottom),
|
||||
getContainer: getContainer,
|
||||
closeIcon: closeIconToRender
|
||||
}, function (notification) {
|
||||
resolve(notification);
|
||||
callback({
|
||||
prefixCls: prefixCls,
|
||||
instance: notification
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var typeToIcon = {
|
||||
success: CheckCircleOutlined,
|
||||
info: InfoCircleOutlined,
|
||||
error: CloseCircleOutlined,
|
||||
warning: ExclamationCircleOutlined
|
||||
};
|
||||
|
||||
function getRCNoticeProps(args, prefixCls) {
|
||||
var duration = args.duration === undefined ? defaultDuration : args.duration;
|
||||
var iconNode = null;
|
||||
|
||||
if (args.icon) {
|
||||
iconNode = /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-icon")
|
||||
}, args.icon);
|
||||
} else if (args.type) {
|
||||
iconNode = React.createElement(typeToIcon[args.type] || null, {
|
||||
className: "".concat(prefixCls, "-icon ").concat(prefixCls, "-icon-").concat(args.type)
|
||||
});
|
||||
}
|
||||
|
||||
var autoMarginTag = !args.description && iconNode ? /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-message-single-line-auto-margin")
|
||||
}) : null;
|
||||
return {
|
||||
content: /*#__PURE__*/React.createElement("div", {
|
||||
className: iconNode ? "".concat(prefixCls, "-with-icon") : ''
|
||||
}, iconNode, /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(prefixCls, "-message")
|
||||
}, autoMarginTag, args.message), /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(prefixCls, "-description")
|
||||
}, args.description), args.btn ? /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-btn")
|
||||
}, args.btn) : null),
|
||||
duration: duration,
|
||||
closable: true,
|
||||
onClose: args.onClose,
|
||||
onClick: args.onClick,
|
||||
key: args.key,
|
||||
style: args.style || {},
|
||||
className: args.className
|
||||
};
|
||||
}
|
||||
|
||||
var api = {
|
||||
open: function open(args) {
|
||||
getNotificationInstance(args, function (_ref) {
|
||||
var prefixCls = _ref.prefixCls,
|
||||
instance = _ref.instance;
|
||||
instance.notice(getRCNoticeProps(args, prefixCls));
|
||||
});
|
||||
},
|
||||
close: function close(key) {
|
||||
Object.keys(notificationInstance).forEach(function (cacheKey) {
|
||||
return Promise.resolve(notificationInstance[cacheKey]).then(function (instance) {
|
||||
instance.removeNotice(key);
|
||||
});
|
||||
});
|
||||
},
|
||||
config: setNotificationConfig,
|
||||
destroy: function destroy() {
|
||||
Object.keys(notificationInstance).forEach(function (cacheKey) {
|
||||
Promise.resolve(notificationInstance[cacheKey]).then(function (instance) {
|
||||
instance.destroy();
|
||||
});
|
||||
delete notificationInstance[cacheKey]; // lgtm[js/missing-await]
|
||||
});
|
||||
}
|
||||
};
|
||||
['success', 'info', 'warning', 'error'].forEach(function (type) {
|
||||
api[type] = function (args) {
|
||||
return api.open(_extends(_extends({}, args), {
|
||||
type: type
|
||||
}));
|
||||
};
|
||||
});
|
||||
api.warn = api.warning;
|
||||
api.useNotification = createUseNotification(getNotificationInstance, getRCNoticeProps);
|
||||
export default api;
|
||||
Reference in New Issue
Block a user