dtd
Version:
根据数梦工场视觉规范打造的组件库,感谢react-components和ant design
1 lines • 2.21 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),React=_interopRequireWildcard(_react),_rcNotification=require("rc-notification"),_rcNotification2=_interopRequireDefault(_rcNotification),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return n.default=e,n}var defaultDuration=3,defaultTop=void 0,messageInstance=void 0,key=1,prefixCls="dt-message",getContainer=void 0;function getMessageInstance(n){messageInstance?n(messageInstance):_rcNotification2.default.newInstance({prefixCls:prefixCls,transitionName:"move-up",style:{top:defaultTop},getContainer:getContainer},function(e){n(messageInstance||(messageInstance=e))})}function notice(n){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:defaultDuration,i=arguments[2],o=arguments[3],r={info:"info-circle",success:"check-circle",error:"close-circle",warning:"exclamation-circle",loading:"loading"}[i];"function"==typeof t&&(o=t,t=defaultDuration);var a=key++;return getMessageInstance(function(e){e.notice({key:a,duration:t,style:{},content:React.createElement("div",{className:prefixCls+"-custom-content "+prefixCls+"-"+i},React.createElement(_icon2.default,{type:r}),React.createElement("span",null,n)),onClose:o})}),function(){messageInstance&&messageInstance.removeNotice(a)}}exports.default={info:function(e,n,t){return notice(e,n,"info",t)},success:function(e,n,t){return notice(e,n,"success",t)},error:function(e,n,t){return notice(e,n,"error",t)},warn:function(e,n,t){return notice(e,n,"warning",t)},warning:function(e,n,t){return notice(e,n,"warning",t)},loading:function(e,n,t){return notice(e,n,"loading",t)},config:function(e){void 0!==e.top&&(defaultTop=e.top,messageInstance=null),void 0!==e.duration&&(defaultDuration=e.duration),void 0!==e.prefixCls&&(prefixCls=e.prefixCls),void 0!==e.getContainer&&(getContainer=e.getContainer)},destroy:function(){messageInstance&&(messageInstance.destroy(),messageInstance=null)}},module.exports=exports.default;
;