a23bef378728e882dd94e69918db7109.json
18.7 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport RCNotification from 'rc-notification';\nimport LoadingOutlined from '@ant-design/icons/LoadingOutlined';\nimport ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';\nimport CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';\nimport CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';\nimport InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';\nimport createUseMessage from './hooks/useMessage';\nvar messageInstance;\nvar defaultDuration = 3;\nvar defaultTop;\nvar key = 1;\nvar localPrefixCls = 'ant-message';\nvar transitionName = 'move-up';\nvar getContainer;\nvar maxCount;\nvar rtl = false;\nexport function getKeyThenIncreaseKey() {\n return key++;\n}\n\nfunction setMessageConfig(options) {\n if (options.top !== undefined) {\n defaultTop = options.top;\n messageInstance = null; // delete messageInstance for new defaultTop\n }\n\n if (options.duration !== undefined) {\n defaultDuration = options.duration;\n }\n\n if (options.prefixCls !== undefined) {\n localPrefixCls = options.prefixCls;\n }\n\n if (options.getContainer !== undefined) {\n getContainer = options.getContainer;\n }\n\n if (options.transitionName !== undefined) {\n transitionName = options.transitionName;\n messageInstance = null; // delete messageInstance for new transitionName\n }\n\n if (options.maxCount !== undefined) {\n maxCount = options.maxCount;\n messageInstance = null;\n }\n\n if (options.rtl !== undefined) {\n rtl = options.rtl;\n }\n}\n\nfunction getRCNotificationInstance(args, callback) {\n var prefixCls = args.prefixCls || localPrefixCls;\n\n if (messageInstance) {\n callback({\n prefixCls: prefixCls,\n instance: messageInstance\n });\n return;\n }\n\n RCNotification.newInstance({\n prefixCls: prefixCls,\n transitionName: transitionName,\n style: {\n top: defaultTop\n },\n getContainer: getContainer,\n maxCount: maxCount\n }, function (instance) {\n if (messageInstance) {\n callback({\n prefixCls: prefixCls,\n instance: messageInstance\n });\n return;\n }\n\n messageInstance = instance;\n callback({\n prefixCls: prefixCls,\n instance: instance\n });\n });\n}\n\nvar typeToIcon = {\n info: InfoCircleFilled,\n success: CheckCircleFilled,\n error: CloseCircleFilled,\n warning: ExclamationCircleFilled,\n loading: LoadingOutlined\n};\n\nfunction getRCNoticeProps(args, prefixCls) {\n var _classNames;\n\n var duration = args.duration !== undefined ? args.duration : defaultDuration;\n var IconComponent = typeToIcon[args.type];\n 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));\n return {\n key: args.key,\n duration: duration,\n style: args.style || {},\n className: args.className,\n content: /*#__PURE__*/React.createElement(\"div\", {\n className: messageClass\n }, args.icon || IconComponent && /*#__PURE__*/React.createElement(IconComponent, null), /*#__PURE__*/React.createElement(\"span\", null, args.content)),\n onClose: args.onClose\n };\n}\n\nfunction notice(args) {\n var target = args.key || key++;\n var closePromise = new Promise(function (resolve) {\n var callback = function callback() {\n if (typeof args.onClose === 'function') {\n args.onClose();\n }\n\n return resolve(true);\n };\n\n getRCNotificationInstance(args, function (_ref) {\n var prefixCls = _ref.prefixCls,\n instance = _ref.instance;\n instance.notice(getRCNoticeProps(_extends(_extends({}, args), {\n key: target,\n onClose: callback\n }), prefixCls));\n });\n });\n\n var result = function result() {\n if (messageInstance) {\n messageInstance.removeNotice(target);\n }\n };\n\n result.then = function (filled, rejected) {\n return closePromise.then(filled, rejected);\n };\n\n result.promise = closePromise;\n return result;\n}\n\nfunction isArgsProps(content) {\n return Object.prototype.toString.call(content) === '[object Object]' && !!content.content;\n}\n\nvar api = {\n open: notice,\n config: setMessageConfig,\n destroy: function destroy(messageKey) {\n if (messageInstance) {\n if (messageKey) {\n var _messageInstance = messageInstance,\n removeNotice = _messageInstance.removeNotice;\n removeNotice(messageKey);\n } else {\n var _messageInstance2 = messageInstance,\n destroy = _messageInstance2.destroy;\n destroy();\n messageInstance = null;\n }\n }\n }\n};\nexport function attachTypeApi(originalApi, type) {\n originalApi[type] = function (content, duration, onClose) {\n if (isArgsProps(content)) {\n return originalApi.open(_extends(_extends({}, content), {\n type: type\n }));\n }\n\n if (typeof duration === 'function') {\n onClose = duration;\n duration = undefined;\n }\n\n return originalApi.open({\n content: content,\n duration: duration,\n type: type,\n onClose: onClose\n });\n };\n}\n['success', 'info', 'warning', 'error', 'loading'].forEach(function (type) {\n return attachTypeApi(api, type);\n});\napi.warn = api.warning;\napi.useMessage = createUseMessage(getRCNotificationInstance, getRCNoticeProps);\n/** @private test only function. Not work on production */\n\nexport var getInstance = function getInstance() {\n return process.env.NODE_ENV === 'test' ? messageInstance : null;\n};\nexport default api;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/message/index.js"],"names":["_extends","_defineProperty","React","classNames","RCNotification","LoadingOutlined","ExclamationCircleFilled","CloseCircleFilled","CheckCircleFilled","InfoCircleFilled","createUseMessage","messageInstance","defaultDuration","defaultTop","key","localPrefixCls","transitionName","getContainer","maxCount","rtl","getKeyThenIncreaseKey","setMessageConfig","options","top","undefined","duration","prefixCls","getRCNotificationInstance","args","callback","instance","newInstance","style","typeToIcon","info","success","error","warning","loading","getRCNoticeProps","_classNames","IconComponent","type","messageClass","concat","className","content","createElement","icon","onClose","notice","target","closePromise","Promise","resolve","_ref","result","removeNotice","then","filled","rejected","promise","isArgsProps","Object","prototype","toString","call","api","open","config","destroy","messageKey","_messageInstance","_messageInstance2","attachTypeApi","originalApi","forEach","warn","useMessage","getInstance","process","env","NODE_ENV"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,iBAA3B;AACA,OAAOC,eAAP,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AAAA,OAAO,EAAEA,OADa;AAEtBrB,MAAAA,QAAQ,EAAEA,QAFY;AAGtBiB,MAAAA,IAAI,EAAEA,IAHgB;AAItBO,MAAAA,OAAO,EAAEA;AAJa,KAAjB,CAAP;AAMD,GAlBD;AAmBD;AACD,CAAC,SAAD,EAAY,MAAZ,EAAoB,SAApB,EAA+B,OAA/B,EAAwC,SAAxC,EAAmD2B,OAAnD,CAA2D,UAAUlC,IAAV,EAAgB;AACzE,SAAOgC,aAAa,CAACP,GAAD,EAAMzB,IAAN,CAApB;AACD,CAFD;AAGAyB,GAAG,CAACU,IAAJ,GAAWV,GAAG,CAAC9B,OAAf;AACA8B,GAAG,CAACW,UAAJ,GAAiBpE,gBAAgB,CAACiB,yBAAD,EAA4BY,gBAA5B,CAAjC;AACA;;AAEA,OAAO,IAAIwC,WAAW,GAAG,SAASA,WAAT,GAAuB;AAC9C,SAAOC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,MAAzB,GAAkCvE,eAAlC,GAAoD,IAA3D;AACD,CAFM;AAGP,eAAewD,GAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport RCNotification from 'rc-notification';\nimport LoadingOutlined from '@ant-design/icons/LoadingOutlined';\nimport ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';\nimport CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';\nimport CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';\nimport InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';\nimport createUseMessage from './hooks/useMessage';\nvar messageInstance;\nvar defaultDuration = 3;\nvar defaultTop;\nvar key = 1;\nvar localPrefixCls = 'ant-message';\nvar transitionName = 'move-up';\nvar getContainer;\nvar maxCount;\nvar rtl = false;\nexport function getKeyThenIncreaseKey() {\n return key++;\n}\n\nfunction setMessageConfig(options) {\n if (options.top !== undefined) {\n defaultTop = options.top;\n messageInstance = null; // delete messageInstance for new defaultTop\n }\n\n if (options.duration !== undefined) {\n defaultDuration = options.duration;\n }\n\n if (options.prefixCls !== undefined) {\n localPrefixCls = options.prefixCls;\n }\n\n if (options.getContainer !== undefined) {\n getContainer = options.getContainer;\n }\n\n if (options.transitionName !== undefined) {\n transitionName = options.transitionName;\n messageInstance = null; // delete messageInstance for new transitionName\n }\n\n if (options.maxCount !== undefined) {\n maxCount = options.maxCount;\n messageInstance = null;\n }\n\n if (options.rtl !== undefined) {\n rtl = options.rtl;\n }\n}\n\nfunction getRCNotificationInstance(args, callback) {\n var prefixCls = args.prefixCls || localPrefixCls;\n\n if (messageInstance) {\n callback({\n prefixCls: prefixCls,\n instance: messageInstance\n });\n return;\n }\n\n RCNotification.newInstance({\n prefixCls: prefixCls,\n transitionName: transitionName,\n style: {\n top: defaultTop\n },\n getContainer: getContainer,\n maxCount: maxCount\n }, function (instance) {\n if (messageInstance) {\n callback({\n prefixCls: prefixCls,\n instance: messageInstance\n });\n return;\n }\n\n messageInstance = instance;\n callback({\n prefixCls: prefixCls,\n instance: instance\n });\n });\n}\n\nvar typeToIcon = {\n info: InfoCircleFilled,\n success: CheckCircleFilled,\n error: CloseCircleFilled,\n warning: ExclamationCircleFilled,\n loading: LoadingOutlined\n};\n\nfunction getRCNoticeProps(args, prefixCls) {\n var _classNames;\n\n var duration = args.duration !== undefined ? args.duration : defaultDuration;\n var IconComponent = typeToIcon[args.type];\n 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));\n return {\n key: args.key,\n duration: duration,\n style: args.style || {},\n className: args.className,\n content: /*#__PURE__*/React.createElement(\"div\", {\n className: messageClass\n }, args.icon || IconComponent && /*#__PURE__*/React.createElement(IconComponent, null), /*#__PURE__*/React.createElement(\"span\", null, args.content)),\n onClose: args.onClose\n };\n}\n\nfunction notice(args) {\n var target = args.key || key++;\n var closePromise = new Promise(function (resolve) {\n var callback = function callback() {\n if (typeof args.onClose === 'function') {\n args.onClose();\n }\n\n return resolve(true);\n };\n\n getRCNotificationInstance(args, function (_ref) {\n var prefixCls = _ref.prefixCls,\n instance = _ref.instance;\n instance.notice(getRCNoticeProps(_extends(_extends({}, args), {\n key: target,\n onClose: callback\n }), prefixCls));\n });\n });\n\n var result = function result() {\n if (messageInstance) {\n messageInstance.removeNotice(target);\n }\n };\n\n result.then = function (filled, rejected) {\n return closePromise.then(filled, rejected);\n };\n\n result.promise = closePromise;\n return result;\n}\n\nfunction isArgsProps(content) {\n return Object.prototype.toString.call(content) === '[object Object]' && !!content.content;\n}\n\nvar api = {\n open: notice,\n config: setMessageConfig,\n destroy: function destroy(messageKey) {\n if (messageInstance) {\n if (messageKey) {\n var _messageInstance = messageInstance,\n removeNotice = _messageInstance.removeNotice;\n removeNotice(messageKey);\n } else {\n var _messageInstance2 = messageInstance,\n destroy = _messageInstance2.destroy;\n destroy();\n messageInstance = null;\n }\n }\n }\n};\nexport function attachTypeApi(originalApi, type) {\n originalApi[type] = function (content, duration, onClose) {\n if (isArgsProps(content)) {\n return originalApi.open(_extends(_extends({}, content), {\n type: type\n }));\n }\n\n if (typeof duration === 'function') {\n onClose = duration;\n duration = undefined;\n }\n\n return originalApi.open({\n content: content,\n duration: duration,\n type: type,\n onClose: onClose\n });\n };\n}\n['success', 'info', 'warning', 'error', 'loading'].forEach(function (type) {\n return attachTypeApi(api, type);\n});\napi.warn = api.warning;\napi.useMessage = createUseMessage(getRCNotificationInstance, getRCNoticeProps);\n/** @private test only function. Not work on production */\n\nexport var getInstance = function getInstance() {\n return process.env.NODE_ENV === 'test' ? messageInstance : null;\n};\nexport default api;"]},"metadata":{},"sourceType":"module"}