You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
2.8 KiB
1 lines
2.8 KiB
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames2=_interopRequireDefault(require("../helpers/classNames")),_index=require("../index"),_utils=require("./utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _toast=null;(0,_baseComponent.default)({useFunc:!0,data:_utils.defaults,computed:{classes:["prefixCls, icon",function(e,t){return{wrap:(0,_classNames2.default)(e),content:(0,_classNames2.default)("".concat(e,"__content"),_defineProperty({},"".concat(e,"__content--has-icon"),t)),icon:"".concat(e,"__icon"),text:"".concat(e,"__text")}}]},methods:{hide:function(){if(this.removed)return!1;this.removed=!0,_toast&&(clearTimeout(_toast.timeout),_toast=null),this.$$setData({in:!1}),this.$wuxBackdrop&&this.$wuxBackdrop.release(),"function"==typeof this.fns.success&&this.fns.success()},show:function(r,e){var s=this;"string"==typeof r&&(r=Object.assign({},{text:arguments[0]},e));function t(){_toast&&_toast.hide.call(s)}var n=new Promise(function(e){var t=s.$$mergeOptionsAndBindMethods(Object.assign({},_utils.defaults,r)),n=_utils.iconTypes[t.type]||t.icon;t.icon=n,s.removed=!1,s.$$setData(_objectSpread({in:!0},t)),s.$wuxBackdrop&&s.$wuxBackdrop.retain(),_toast&&(clearTimeout(_toast.timeout),_toast=null),(_toast={hide:s.hide}).timeout=setTimeout(function(){return s.hide(),e(!0)},Math.max(0,t.duration))});return t.then=function(e,t){return n.then(e,t)},t.promise=n,t},success:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign(_objectSpread({},e,{type:"success"})))},warning:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign(_objectSpread({},e,{type:"forbidden"})))},error:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign(_objectSpread({},e,{type:"cancel"})))},info:function(e,t){return"string"==typeof e&&(e=Object.assign({},{text:arguments[0]},t)),this.show(Object.assign(_objectSpread({},e,{type:"text"})))}},created:function(){this.data.mask&&(this.$wuxBackdrop=(0,_index.$wuxBackdrop)("#wux-backdrop",this))}});
|