wot-design
Version:
Mobile UI components built on vue.js
1,439 lines (1,334 loc) • 35.6 kB
JavaScript
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 53);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
function normalizeComponent (
scriptExports,
render,
staticRenderFns,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier, /* server only */
shadowMode /* vue-cli only */
) {
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (render) {
options.render = render
options.staticRenderFns = staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = 'data-v-' + scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = shadowMode
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
: injectStyles
}
if (hook) {
if (options.functional) {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functioal component in vue file
var originalRender = options.render
options.render = function renderWithStyleInjection (h, context) {
hook.call(context)
return originalRender(h, context)
}
} else {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
}
}
return {
exports: scriptExports,
options: options
}
}
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = require("vue");
/***/ }),
/***/ 5:
/***/ (function(module, exports) {
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;
}
module.exports = _defineProperty;
/***/ }),
/***/ 53:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectSpread.js
var objectSpread = __webpack_require__(6);
var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
// EXTERNAL MODULE: external "vue"
var external_vue_ = __webpack_require__(2);
var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/toast/src/main.vue?vue&type=template&id=6a8eeda0&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "wd-toast", on: { touchmove: _vm.preventMove } },
[
_c("div", {
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.forbidClick && _vm.show,
expression: "forbidClick && show"
}
],
staticClass: "wd-toast__modal"
}),
_vm._v(" "),
_c("transition", { attrs: { name: "wd-fade" } }, [
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.show,
expression: "show"
}
],
staticClass: "wd-toast__container",
class: _vm.customClass
},
[
_c(
"div",
{ staticClass: "wd-toast__body" },
[
_vm.iconName === "loading"
? _c("wd-loading", {
staticClass: "wd-toast__icon",
attrs: {
type: _vm.loadingType,
color: _vm.loadingColor,
size: _vm.iconSize
}
})
: _vm._e(),
_vm._v(" "),
_vm.iconName && _vm.iconName !== "loading"
? _c("icon", {
staticClass: "wd-toast__icon",
attrs: { type: _vm.iconName, size: _vm.iconSize }
})
: _vm.iconClass
? _c("i", {
staticClass: "wd-toast__icon",
class: _vm.iconClass.split(" ")
})
: _vm._e(),
_vm._v(" "),
_c("div", { staticClass: "wd-toast__msg" }, [
_vm._v(_vm._s(_vm.msg))
])
],
1
)
]
)
])
],
1
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/toast/src/main.vue?vue&type=template&id=6a8eeda0&
// EXTERNAL MODULE: external "wot-design/lib/loading"
var loading_ = __webpack_require__(8);
var loading_default = /*#__PURE__*/__webpack_require__.n(loading_);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/toast/src/icon.vue?vue&type=template&id=c1854020&
var iconvue_type_template_id_c1854020_render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c("div", [
_vm.type === "info"
? _c("div", { style: { width: _vm.size, height: _vm.size } }, [
_c("svg", { attrs: { viewBox: "0 0 42 42" } }, [
_c("defs", [
_c(
"filter",
{
attrs: {
x: "-300%",
y: "-57.1%",
width: "700%",
height: "214.3%",
filterUnits: "objectBoundingBox",
id: "a"
}
},
[
_c("feOffset", {
attrs: {
dy: "2",
in: "SourceAlpha",
result: "shadowOffsetOuter1"
}
}),
_vm._v(" "),
_c("feGaussianBlur", {
attrs: {
stdDeviation: "2",
in: "shadowOffsetOuter1",
result: "shadowBlurOuter1"
}
}),
_vm._v(" "),
_c("feColorMatrix", {
attrs: {
values:
"0 0 0 0 0.362700096 0 0 0 0 0.409035039 0 0 0 0 0.520238904 0 0 0 1 0",
in: "shadowBlurOuter1",
result: "shadowMatrixOuter1"
}
}),
_vm._v(" "),
_c(
"feMerge",
[
_c("feMergeNode", {
attrs: { in: "shadowMatrixOuter1" }
}),
_vm._v(" "),
_c("feMergeNode", { attrs: { in: "SourceGraphic" } })
],
1
)
],
1
)
]),
_vm._v(" "),
_c("g", { attrs: { fill: "none", "fill-rule": "evenodd" } }, [
_c("circle", {
attrs: {
fill: "#909CB7",
opacity: ".4",
cx: "21",
cy: "21",
r: "20"
}
}),
_vm._v(" "),
_c("circle", {
attrs: { fill: "#909CB7", cx: "21", cy: "21", r: "16" }
}),
_vm._v(" "),
_c(
"g",
{
attrs: {
transform: "rotate(-180 11.246 15.002)",
filter: "url(#a)"
}
},
[
_c("rect", {
attrs: {
fill: "#FFF",
transform: "matrix(1 0 0 -1 0 14)",
width: "3",
height: "14",
rx: "1.5"
}
}),
_vm._v(" "),
_c("rect", {
attrs: {
fill: "#EEE",
transform: "matrix(1 0 0 -1 0 36)",
y: "16",
width: "3",
height: "4",
rx: "1.5"
}
})
]
)
])
])
])
: _vm._e(),
_vm._v(" "),
_vm.type === "warning"
? _c("div", { style: { width: _vm.size, height: _vm.size } }, [
_c("svg", { attrs: { viewBox: "0 0 42 42" } }, [
_c("defs", [
_c(
"filter",
{
attrs: {
x: "-240%",
y: "-60%",
width: "580%",
height: "220%",
filterUnits: "objectBoundingBox",
id: "a"
}
},
[
_c("feOffset", {
attrs: {
dy: "2",
in: "SourceAlpha",
result: "shadowOffsetOuter1"
}
}),
_vm._v(" "),
_c("feGaussianBlur", {
attrs: {
stdDeviation: "2",
in: "shadowOffsetOuter1",
result: "shadowBlurOuter1"
}
}),
_vm._v(" "),
_c("feColorMatrix", {
attrs: {
values:
"0 0 0 0 0.824756567 0 0 0 0 0.450356612 0 0 0 0 0.168550194 0 0 0 1 0",
in: "shadowBlurOuter1",
result: "shadowMatrixOuter1"
}
}),
_vm._v(" "),
_c(
"feMerge",
[
_c("feMergeNode", {
attrs: { in: "shadowMatrixOuter1" }
}),
_vm._v(" "),
_c("feMergeNode", { attrs: { in: "SourceGraphic" } })
],
1
)
],
1
)
]),
_vm._v(" "),
_c("g", { attrs: { fill: "none", "fill-rule": "evenodd" } }, [
_c("circle", {
attrs: {
fill: "#F0883A",
opacity: ".4",
cx: "21",
cy: "21",
r: "20"
}
}),
_vm._v(" "),
_c("circle", {
attrs: { fill: "#F0883A", cx: "21", cy: "21", r: "16" }
}),
_vm._v(" "),
_c(
"g",
{
attrs: {
filter: "url(#a)",
transform: "translate(18.5 10.8)"
}
},
[
_c("rect", {
attrs: {
fill: "#FFF",
transform: "matrix(1 0 0 -1 0 14.343)",
x: ".993",
y: ".955",
width: "3",
height: "12.432",
rx: "1.5"
}
}),
_vm._v(" "),
_c("rect", {
attrs: {
fill: "#FFDEC5",
transform: "matrix(1 0 0 -1 0 34.405)",
x: "1.009",
y: "15.201",
width: "3",
height: "4.004",
rx: "1.5"
}
})
]
)
])
])
])
: _vm._e(),
_vm._v(" "),
_vm.type === "success"
? _c("div", { style: { width: _vm.size, height: _vm.size } }, [
_c("svg", { attrs: { viewBox: "0 0 42 42" } }, [
_c(
"defs",
[
_c(
"filter",
{
attrs: {
x: "-63.2%",
y: "-80%",
width: "226.3%",
height: "260%",
filterUnits: "objectBoundingBox",
id: "a"
}
},
[
_c("feOffset", {
attrs: {
dy: "2",
in: "SourceAlpha",
result: "shadowOffsetOuter1"
}
}),
_vm._v(" "),
_c("feGaussianBlur", {
attrs: {
stdDeviation: "2",
in: "shadowOffsetOuter1",
result: "shadowBlurOuter1"
}
}),
_vm._v(" "),
_c("feColorMatrix", {
attrs: {
values:
"0 0 0 0 0.122733141 0 0 0 0 0.710852582 0 0 0 0 0.514812768 0 0 0 1 0",
in: "shadowBlurOuter1",
result: "shadowMatrixOuter1"
}
}),
_vm._v(" "),
_c(
"feMerge",
[
_c("feMergeNode", {
attrs: { in: "shadowMatrixOuter1" }
}),
_vm._v(" "),
_c("feMergeNode", { attrs: { in: "SourceGraphic" } })
],
1
)
],
1
),
_vm._v(" "),
_c("rect", {
attrs: {
id: "b",
x: "3.418",
y: "5.814",
width: "3",
height: "8.5",
rx: "1.5"
}
}),
_vm._v(" "),
_c(
"linearGradient",
{
attrs: {
x1: "50%",
y1: ".127%",
x2: "50%",
y2: "100%",
id: "c"
}
},
[
_c("stop", {
attrs: {
"stop-color": "#ACFFBD",
"stop-opacity": ".208",
offset: "0%"
}
}),
_vm._v(" "),
_c("stop", {
attrs: { "stop-color": "#10B87C", offset: "100%" }
})
],
1
)
],
1
),
_vm._v(" "),
_c("g", { attrs: { fill: "none", "fill-rule": "evenodd" } }, [
_c("circle", {
attrs: {
fill: "#34D19D",
opacity: ".4",
cx: "21",
cy: "21",
r: "20"
}
}),
_vm._v(" "),
_c("circle", {
attrs: { fill: "#34D19D", cx: "21", cy: "21", r: "16" }
}),
_vm._v(" "),
_c(
"g",
{
attrs: { filter: "url(#a)", transform: "translate(11.5 14)" }
},
[
_c("mask", { attrs: { id: "d", fill: "#fff" } }, [
_c("use", { attrs: { "xlink:href": "#b" } })
]),
_vm._v(" "),
_c("use", {
attrs: {
fill: "#C4FFEB",
transform: "rotate(-45 4.918 10.064)",
"xlink:href": "#b"
}
}),
_vm._v(" "),
_c("path", {
attrs: {
fill: "url(#c)",
mask: "url(#d)",
transform: "rotate(-45 6.216 11.372)",
d: "M4.716 9.523h3v3.699h-3z"
}
}),
_vm._v(" "),
_c("rect", {
attrs: {
fill: "#FFF",
transform: "scale(1 -1) rotate(-45 -5.825 0)",
x: "10.136",
y: "-1.022",
width: "3",
height: "16.509",
rx: "1.5"
}
})
]
)
])
])
])
: _vm._e(),
_vm._v(" "),
_vm.type === "error"
? _c("div", { style: { width: _vm.size, height: _vm.size } }, [
_c("svg", { attrs: { viewBox: "0 0 42 42" } }, [
_c(
"defs",
[
_c(
"linearGradient",
{
attrs: {
x1: "99.623%",
y1: "50.377%",
x2: ".377%",
y2: "50.377%",
id: "a"
}
},
[
_c("stop", {
attrs: { "stop-color": "#FFDFDF", offset: "0%" }
}),
_vm._v(" "),
_c("stop", {
attrs: { "stop-color": "#F9BEBE", offset: "100%" }
})
],
1
),
_vm._v(" "),
_c(
"linearGradient",
{
attrs: {
x1: ".377%",
y1: "50.377%",
x2: "99.623%",
y2: "50.377%",
id: "b"
}
},
[
_c("stop", {
attrs: { "stop-color": "#FFDFDF", offset: "0%" }
}),
_vm._v(" "),
_c("stop", {
attrs: { "stop-color": "#F9BEBE", offset: "100%" }
})
],
1
)
],
1
),
_vm._v(" "),
_c("g", { attrs: { fill: "none", "fill-rule": "evenodd" } }, [
_c("circle", {
attrs: {
fill: "#FA4350",
opacity: ".4",
cx: "21",
cy: "21",
r: "20"
}
}),
_vm._v(" "),
_c("circle", {
attrs: {
fill: "#FA4350",
opacity: ".9",
cx: "21",
cy: "21",
r: "16"
}
}),
_vm._v(" "),
_c("rect", {
attrs: {
fill: "#FFDFDF",
transform: "rotate(135 21.071 21.071)",
x: "12.571",
y: "19.571",
width: "17",
height: "3",
rx: "1.5"
}
}),
_vm._v(" "),
_c("path", {
attrs: {
fill: "url(#a)",
transform: "rotate(135 19.303 22.839)",
d: "M17.303 21.339h4v3h-4z"
}
}),
_vm._v(" "),
_c("path", {
attrs: {
fill: "url(#b)",
transform: "rotate(135 22.839 19.303)",
d: "M20.839 17.803h4v3h-4z"
}
}),
_vm._v(" "),
_c("rect", {
attrs: {
fill: "#FFF",
transform: "rotate(45 21.071 21.071)",
x: "12.571",
y: "19.571",
width: "17",
height: "3",
rx: "1.5"
}
})
])
])
])
: _vm._e()
])
}
var iconvue_type_template_id_c1854020_staticRenderFns = []
iconvue_type_template_id_c1854020_render._withStripped = true
// CONCATENATED MODULE: ./packages/toast/src/icon.vue?vue&type=template&id=c1854020&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/toast/src/icon.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var iconvue_type_script_lang_js_ = ({
name: 'icon',
props: {
type: String,
size: {
type: String,
default: '42px'
}
}
});
// CONCATENATED MODULE: ./packages/toast/src/icon.vue?vue&type=script&lang=js&
/* harmony default export */ var src_iconvue_type_script_lang_js_ = (iconvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./packages/toast/src/icon.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
src_iconvue_type_script_lang_js_,
iconvue_type_template_id_c1854020_render,
iconvue_type_template_id_c1854020_staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "packages/toast/src/icon.vue"
/* harmony default export */ var icon = (component.exports);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/toast/src/main.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'WdToast',
components: {
WdLoading: loading_default.a,
Icon: icon
},
data: function data() {
return {
forbidClick: false,
iconName: ''
};
},
props: {
iconClass: String,
msg: String,
position: {
type: String,
default: 'middle'
},
show: Boolean,
loadingType: {
type: String,
default: 'outline'
},
loadingColor: {
type: String,
default: '#4D80F0'
},
iconSize: {
type: String,
default: '42px'
},
onClose: Function
},
computed: {
customClass: function customClass() {
var classList = [];
switch (this.position) {
case 'top':
classList.push('wd-toast--top');
break;
case 'bottom':
classList.push('wd-toast--bottom');
break;
default:
classList.push('wd-toast--middle');
}
if (this.iconName === 'loading' && !this.msg) {
classList.push('wd-toast--loading');
} else if (this.iconName || this.iconClass) {
classList.push('wd-toast--with-icon');
}
return classList;
}
},
methods: {
preventMove: function preventMove(event) {
if (this.forbidClick) {
event.preventDefault();
}
}
}
});
// CONCATENATED MODULE: ./packages/toast/src/main.vue?vue&type=script&lang=js&
/* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
// CONCATENATED MODULE: ./packages/toast/src/main.vue
/* normalize component */
var main_component = Object(componentNormalizer["a" /* default */])(
src_mainvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var main_api; }
main_component.options.__file = "packages/toast/src/main.vue"
/* harmony default export */ var main = (main_component.exports);
// CONCATENATED MODULE: ./packages/toast/index.js
/**
* toast组件
* 使用:
* Toast({
* msg: String, // toast信息
* duration: Number, // 持续时间,默认2000
* iconName: String, // icon图标,可选值:'success', 'warn', 'forbid'(即X)
* iconClass: String, // icon自定义图表,传入类名,多个类名以空格连接
* position: String // toast位置,可选值:'top', 'middle', 'bottom',default: 'middle'
* })
*/
/**
* Todo: 需要优化调用方法。
*/
var ToastConstructor = external_vue_default.a.extend(main);
var toast;
ToastConstructor.prototype.close = function () {
this.show = false;
this.closed = true;
};
var toast_showToast = function showToast(instance, options) {
var duration = options.duration === 0 ? 0 : options.duration || 2000;
instance.closed = false;
clearTimeout(instance.timer);
instance.msg = typeof options === 'string' ? options : options.msg;
instance.position = options.position || 'middle';
instance.iconName = options.iconName || '';
instance.iconClass = options.iconClass || '';
instance.iconSize = options.iconSize || '42px';
instance.loadingType = options.loadingType || 'outline';
instance.loadingColor = options.loadingColor || '#4D80F0';
instance.onClose = options.onClose;
if (!instance.inited) {
document.body.appendChild(instance.$el);
instance.inited = true;
}
external_vue_default.a.nextTick(function () {
instance.show = true;
if (duration > 0) {
instance.timer = setTimeout(function () {
if (instance.closed) {
return;
}
instance.close();
instance.onClose && instance.onClose(instance);
}, duration);
}
});
return instance;
};
var Toast = function Toast(options) {
options = options || {};
switch (options.type) {
case 'success':
{
options.iconName = 'success';
options.duration = options.duration || 1500;
break;
}
case 'info':
{
options.iconName = 'info';
break;
}
case 'error':
{
options.iconName = 'error';
break;
}
case 'warning':
{
options.iconName = 'warning';
break;
}
case 'loading':
{
options.iconName = 'loading';
options.forbidClick = true;
options.duration = 0;
break;
}
default:
{}
}
if (!toast) {
toast = new ToastConstructor({
el: document.createElement('div')
});
}
return toast_showToast(toast, options);
};
Toast.close = function () {
if (toast) {
toast.close();
toast.onClose && toast.onClose(toast);
}
};
Toast._close = function () {
if (toast) {
toast.close();
}
};
Toast.success = function (options) {
if (typeof options === 'string') {
options = {
msg: options,
type: 'success'
};
} else {
options = objectSpread_default()({}, options, {
type: 'success'
});
}
return Toast(options);
};
Toast.info = function (options) {
if (typeof options === 'string') {
options = {
msg: options,
type: 'info'
};
} else {
options = objectSpread_default()({}, options, {
type: 'info'
});
}
return Toast(options);
};
Toast.error = function (options) {
if (typeof options === 'string') {
options = {
msg: options,
type: 'error'
};
} else {
options = objectSpread_default()({}, options, {
type: 'error'
});
}
return Toast(options);
};
Toast.warning = function (options) {
if (typeof options === 'string') {
options = {
type: 'warning',
msg: options
};
} else {
options = objectSpread_default()({}, options, {
type: 'warning'
});
}
return Toast(options);
};
Toast.loading = function (options) {
if (typeof options === 'string') {
options = {
type: 'loading',
msg: options
};
} else {
options = objectSpread_default()({}, options, {
type: 'loading'
});
}
return Toast(options);
};
window.addEventListener('popstate', Toast._close);
Toast.install = function (Vue) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$toastKey = _ref.toastKey,
toastKey = _ref$toastKey === void 0 ? '$toast' : _ref$toastKey;
Vue.prototype[toastKey] = Toast;
};
/* harmony default export */ var packages_toast = __webpack_exports__["default"] = (Toast);
/***/ }),
/***/ 6:
/***/ (function(module, exports, __webpack_require__) {
var defineProperty = __webpack_require__(5);
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
defineProperty(target, key, source[key]);
});
}
return target;
}
module.exports = _objectSpread;
/***/ }),
/***/ 8:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/loading");
/***/ })
/******/ });