@mdsfe/mds-ui
Version:
A set of enterprise-class Vue UI components.
818 lines (725 loc) • 24.7 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("vue"), require("./icon"), require("./transition"), require("./button"));
else if(typeof define === 'function' && define.amd)
define(["vue", "./icon", "./transition", "./button"], factory);
else {
var a = typeof exports === 'object' ? factory(require("vue"), require("./icon"), require("./transition"), require("./button")) : factory(root["Vue"], root["./icon"], root["./transition"], root["./button"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function(__WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__13__) {
return /******/ (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 = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 111);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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,
(options.functional ? this.parent : 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 functional 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
}
}
/***/ }),
/***/ 111:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./components/style/index.less
var style = __webpack_require__(142);
// EXTERNAL MODULE: ./components/notification/style/index.less
var notification_style = __webpack_require__(200);
// CONCATENATED MODULE: ./components/notification/style/index.js
// EXTERNAL MODULE: external {"root":"Vue","commonjs":"vue","commonjs2":"vue","amd":"vue"}
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_ = __webpack_require__(2);
var external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default = /*#__PURE__*/__webpack_require__.n(external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/notification/notification.vue?vue&type=template&id=872f1938&
var render = function () {
var _obj
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"mds-transition",
{ attrs: { type: "slide", motion: _vm.moveFrom } },
[
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.visible,
expression: "visible",
},
],
class: [_vm.prefixCls + "-notice", _vm.prefixCls + "-closable"],
},
[
_c("div", { class: _vm.prefixCls + "-notice-content" }, [
_c(
"div",
{
class:
((_obj = {}),
(_obj[_vm.prefixCls + "-notice-with-icon"] =
_vm.type || _vm.icon),
_obj),
},
[
_vm.type || _vm.icon
? _c("mds-icon", {
class:
_vm.prefixCls +
"-notice-icon " +
_vm.prefixCls +
"-notice-icon-" +
_vm.type +
" " +
_vm.iconClass,
style: _vm.iconStyle,
attrs: { type: _vm.typeIcon },
})
: _vm._e(),
_c("div", { class: _vm.prefixCls + "-notice-title" }, [
_vm._v(_vm._s(_vm.title)),
]),
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.content,
expression: "content",
},
],
class: _vm.prefixCls + "-notice-desc",
},
[
!_vm.useHTML
? _c("p", [_vm._v(_vm._s(_vm.content))])
: _c("p", {
domProps: { innerHTML: _vm._s(_vm.content) },
}),
]
),
],
1
),
_vm.btn
? _c(
"div",
{ class: _vm.prefixCls + "-notice-btn" },
[
_c(
"mds-button",
{
attrs: { type: _vm.btnType },
on: { click: _vm.handleOnClick },
},
[_vm._v(_vm._s(_vm.btn))]
),
],
1
)
: _vm._e(),
]),
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showClose,
expression: "showClose",
},
],
class: _vm.prefixCls + "-notice-close-btn",
on: { click: _vm.handleClose },
},
[_c("mds-icon", { attrs: { type: "line-close" } })],
1
),
]
),
]
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./components/notification/notification.vue?vue&type=template&id=872f1938&
// EXTERNAL MODULE: external "./icon"
var external_icon_ = __webpack_require__(7);
var external_icon_default = /*#__PURE__*/__webpack_require__.n(external_icon_);
// EXTERNAL MODULE: external "./button"
var external_button_ = __webpack_require__(13);
var external_button_default = /*#__PURE__*/__webpack_require__.n(external_button_);
// EXTERNAL MODULE: external "./transition"
var external_transition_ = __webpack_require__(12);
var external_transition_default = /*#__PURE__*/__webpack_require__.n(external_transition_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/notification/notification.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var notificationvue_type_script_lang_js_ = ({
name: 'MdsNotification',
props: {
prefixCls: {
type: String,
default: 'mds-notification'
},
title: {
type: String,
default: '提示'
},
content: {
type: String,
default: '这是一个提示'
},
useHTML: {
type: Boolean,
default: false
},
duration: {
type: Number,
default: 4.5
},
onClose: {
type: Function
},
type: {
type: String,
default: ''
},
iconClass: {
type: String,
default: ''
},
icon: {
type: String,
default: ''
},
iconStyle: {
type: Object
},
btn: {
type: String,
default: ''
},
btnType: {
type: String,
validator: function validator(value) {
return ['primary', 'default', 'dashed', 'danger'].includes(value);
},
default: 'primary'
},
onClick: {
type: Function
},
showClose: {
type: Boolean,
default: true
},
moveFrom: {
type: String,
validator: function validator(value) {
return ['left', 'right'].includes(value);
}
}
},
data: function data() {
return {
visible: false,
closed: false,
timer: null,
test: false
};
},
computed: {
durationMS: function durationMS() {
return this.duration * 1000;
},
typeIcon: function typeIcon() {
var typeToIcon = {
info: 'line-info-circle',
success: 'fill-solid-right-circle',
error: 'fill-solid-wrong-circle',
warning: 'fill-solid-exclamation-circle'
};
if (this.type) return typeToIcon[this.type];else if (this.icon) return this.icon;
}
},
components: {
MdsIcon: external_icon_default.a,
MdsButton: external_button_default.a,
MdsTransition: external_transition_default.a
},
watch: {
closed: function closed(newVal) {
if (newVal) {
this.visible = false;
this.$el.parentNode && this.$el.parentNode.removeChild(this.$el);
}
}
},
methods: {
destroyElement: function destroyElement() {
this.$destroy(true);
this.$el.parentNode && this.$el.parentNode.removeChild(this.$el);
},
handleOnClick: function handleOnClick() {
if (this.onClick) {
this.onClick();
}
this.handleClose();
},
handleClose: function handleClose() {
this.closed = true;
this.onClose();
},
clearTimer: function clearTimer() {
this.test = true;
clearTimeout(this.timer);
},
startTimer: function startTimer() {
var _this = this;
this.test = false;
if (this.duration > 0) {
this.timer = setTimeout(function () {
if (!_this.closed) {
_this.handleClose();
}
}, this.durationMS);
}
}
},
mounted: function mounted() {
this.startTimer();
}
});
// CONCATENATED MODULE: ./components/notification/notification.vue?vue&type=script&lang=js&
/* harmony default export */ var notification_notificationvue_type_script_lang_js_ = (notificationvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/notification/notification.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
notification_notificationvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "components/notification/notification.vue"
/* harmony default export */ var notification = (component.exports);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/notification/notification-box.vue?vue&type=template&id=0f7fb0e2&scoped=true&
var notification_boxvue_type_template_id_0f7fb0e2_scoped_true_render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ class: _vm.prefixCls + " " + _vm.prefixCls + "-" + _vm.placement },
[_c("span")]
)
}
var notification_boxvue_type_template_id_0f7fb0e2_scoped_true_staticRenderFns = []
notification_boxvue_type_template_id_0f7fb0e2_scoped_true_render._withStripped = true
// CONCATENATED MODULE: ./components/notification/notification-box.vue?vue&type=template&id=0f7fb0e2&scoped=true&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/notification/notification-box.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
/* harmony default export */ var notification_boxvue_type_script_lang_js_ = ({
name: 'MdsNotificationBox',
props: {
prefixCls: {
type: String,
default: 'mds-notification'
},
placement: {
type: String,
validator: function validator(value) {
return ['topLeft', 'topRight', 'bottomRight', 'bottomLeft'].includes(value);
},
default: 'bottomRight'
}
}
});
// CONCATENATED MODULE: ./components/notification/notification-box.vue?vue&type=script&lang=js&
/* harmony default export */ var notification_notification_boxvue_type_script_lang_js_ = (notification_boxvue_type_script_lang_js_);
// EXTERNAL MODULE: ./components/notification/notification-box.vue?vue&type=style&index=0&id=0f7fb0e2&lang=less&scoped=true&
var notification_boxvue_type_style_index_0_id_0f7fb0e2_lang_less_scoped_true_ = __webpack_require__(81);
// CONCATENATED MODULE: ./components/notification/notification-box.vue
/* normalize component */
var notification_box_component = Object(componentNormalizer["a" /* default */])(
notification_notification_boxvue_type_script_lang_js_,
notification_boxvue_type_template_id_0f7fb0e2_scoped_true_render,
notification_boxvue_type_template_id_0f7fb0e2_scoped_true_staticRenderFns,
false,
null,
"0f7fb0e2",
null
)
/* hot reload */
if (false) { var notification_box_api; }
notification_box_component.options.__file = "components/notification/notification-box.vue"
/* harmony default export */ var notification_box = (notification_box_component.exports);
// CONCATENATED MODULE: ./components/notification/index.js
/*
* @Descripttion:
* @version:
* @Author: liangshuang
*/
var NotificationBoxConstructor = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.extend(notification_box);
var NotificationConstructor = external_root_Vue_commonjs_vue_commonjs2_vue_amd_vue_default.a.extend(notification);
var boxInstances = {};
var boxEls = {};
var notificationInstances = [];
var seed = 1;
var prefixCls = 'mds-notification';
var defaultPlacement = 'bottomRight'; // 位置
var defaultDuration = 4.5; // 延时时间
var getContainer = void 0;
var getBoxEl = function getBoxEl(opt) {
var placement = opt.placement;
boxInstances[placement] = boxInstances[placement] || new NotificationBoxConstructor({
propsData: {
prefixCls: prefixCls,
placement: placement
}
});
boxInstances[placement].vm = boxInstances[placement].$mount();
boxEls[placement] = boxInstances[placement].vm.$el;
if (getContainer) {
getContainer().appendChild(boxInstances[placement].vm.$el);
} else {
document.body.appendChild(boxInstances[placement].vm.$el);
}
return boxEls[placement];
};
var notice = function notice(opt) {
opt.duration = opt.duration !== undefined ? opt.duration : defaultDuration;
opt.placement = opt.placement || defaultPlacement;
var userOnClose = opt.onClose;
opt.onClose = function () {
notification_close(id, userOnClose);
};
opt.moveFrom = /Right$/.test(opt.placement) ? 'right' : 'left';
var boxEl = getBoxEl(opt);
var id = '' + prefixCls + seed++;
var notificationInstance = new NotificationConstructor({
propsData: opt
});
notificationInstance.id = id;
notificationInstance.vm = notificationInstance.$mount();
boxEl.querySelector('span').appendChild(notificationInstance.vm.$el);
notificationInstance.vm.visible = true;
notificationInstances.push(notificationInstance);
return function () {
notificationInstance.vm.visible = false;
};
};
var notification_close = function close(id, userOnClose) {
for (var i = 0, len = notificationInstances.length; i < len; i++) {
if (id === notificationInstances[i].id) {
if (typeof userOnClose === 'function') {
userOnClose(notificationInstances[i]);
}
notificationInstances.splice(i, 1);
break;
}
}
};
var notify = function notify(options) {
if (typeof options === 'string') {
options.content = options;
}
return notice(options);
};
['info', 'success', 'error', 'warning'].forEach(function (type) {
notify[type] = function (opt) {
if (typeof opt === 'string') {
opt.content = opt;
}
opt.type = type;
return notice(opt);
};
});
notify.config = function (options) {
if (options.placement !== undefined) {
defaultPlacement = options.placement;
}
if (options.duration !== undefined) {
defaultDuration = options.duration;
}
if (options.prefixCls !== undefined) {
prefixCls = options.prefixCls;
}
if (options.getContainer !== undefined) {
getContainer = options.getContainer;
}
};
notify.destroy = function () {
for (var key in boxInstances) {
if (boxInstances[key]) {
boxInstances[key].vm.$destroy(true);
boxEls[key].parentNode.removeChild(boxEls[key]);
}
boxInstances[key] = null;
}
};
/* harmony default export */ var components_notification = __webpack_exports__["default"] = (notify);
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
/***/ }),
/***/ 13:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
/***/ }),
/***/ 142:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
/***/ }),
/***/ 200:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 202:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
/***/ }),
/***/ 81:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _node_modules_extract_text_webpack_plugin_dist_loader_js_ref_4_0_node_modules_style_loader_index_js_node_modules_css_loader_index_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_less_loader_dist_cjs_js_node_modules_vue_loader_lib_index_js_vue_loader_options_notification_box_vue_vue_type_style_index_0_id_0f7fb0e2_lang_less_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(202);
/* harmony import */ var _node_modules_extract_text_webpack_plugin_dist_loader_js_ref_4_0_node_modules_style_loader_index_js_node_modules_css_loader_index_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_less_loader_dist_cjs_js_node_modules_vue_loader_lib_index_js_vue_loader_options_notification_box_vue_vue_type_style_index_0_id_0f7fb0e2_lang_less_scoped_true___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_extract_text_webpack_plugin_dist_loader_js_ref_4_0_node_modules_style_loader_index_js_node_modules_css_loader_index_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_less_loader_dist_cjs_js_node_modules_vue_loader_lib_index_js_vue_loader_options_notification_box_vue_vue_type_style_index_0_id_0f7fb0e2_lang_less_scoped_true___WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */
/***/ })
/******/ });
});