wot-design
Version:
Mobile UI components built on vue.js
899 lines (796 loc) • 23.2 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 = 82);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 11:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/popup");
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/button");
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
module.exports = require("vue");
/***/ }),
/***/ 4:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/mixins/locale");
/***/ }),
/***/ 42:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/input");
/***/ }),
/***/ 82:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
var helpers_typeof = __webpack_require__(9);
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
// 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/message-box/src/main.vue?vue&type=template&id=6b29b012&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"wd-popup",
{
staticClass: "wd-message-box",
staticStyle: { overflow: "hidden" },
attrs: {
teleport: _vm.teleport,
"lock-scroll": _vm.lockScroll,
value: _vm.show,
"close-on-click-modal": _vm.closeOnClickModal,
"close-on-popstate": _vm.closeOnPopstate,
transition: "wd-zoom-in",
duration: 200
},
on: {
"click-modal": function($event) {
return _vm.toggleModal("modal")
},
popstate: function($event) {
return _vm.toggleModal("cancel")
},
opened: _vm.handleOpened,
closed: _vm.handleClosed
}
},
[
_c(
"div",
{
staticClass: "wd-message-box__body",
class: {
"is-no-title": !_vm.title,
"is-prompt": _vm.type === "prompt"
}
},
[
_vm.title
? _c("div", { staticClass: "wd-message-box__title" }, [
_vm._v(_vm._s(_vm.title))
])
: _vm._e(),
_vm._v(" "),
_c(
"div",
{ staticClass: "wd-message-box__content" },
[
_vm.type !== "prompt"
? _vm._t("default", [
_c("div", {
staticClass: "wd-message-box__content-text",
domProps: { innerHTML: _vm._s(_vm.msg) }
})
])
: [
_c(
"div",
{ staticClass: "wd-message-box__input-container" },
[
_c("wd-input", {
attrs: {
type: _vm.inputType,
size: "large",
placeholder:
_vm.inputPlaceholder ||
_vm.t("wd.messageBox.inputPlaceholder")
},
model: {
value: _vm.inputValue,
callback: function($$v) {
_vm.inputValue = $$v
},
expression: "inputValue"
}
})
],
1
),
_vm._v(" "),
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showErr,
expression: "showErr"
}
],
staticClass: "wd-message-box__input-error"
},
[
_vm._v(
_vm._s(
_vm.inputError ||
_vm.t("wd.messageBox.inputNoValidate")
)
)
]
)
]
],
2
)
]
),
_vm._v(" "),
_c(
"div",
{ staticClass: "wd-message-box__actions" },
[
_vm.showCancelButton
? _c(
"wd-button",
{
attrs: { type: "info", block: "" },
on: {
click: function($event) {
return _vm.toggleModal("cancel")
}
}
},
[
_vm._v(
_vm._s(
_vm.cancelButtonText || _vm.t("wd.messageBox.cancel")
)
)
]
)
: _vm._e(),
_vm._v(" "),
_vm.showConfirmButton
? _c(
"wd-button",
{
attrs: { block: "" },
on: {
click: function($event) {
return _vm.toggleModal("confirm")
}
}
},
[
_vm._v(
_vm._s(
_vm.confirmButtonText || _vm.t("wd.messageBox.confirm")
)
)
]
)
: _vm._e()
],
1
)
]
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/message-box/src/main.vue?vue&type=template&id=6b29b012&
// EXTERNAL MODULE: external "wot-design/lib/popup"
var popup_ = __webpack_require__(11);
var popup_default = /*#__PURE__*/__webpack_require__.n(popup_);
// EXTERNAL MODULE: external "wot-design/lib/input"
var input_ = __webpack_require__(42);
var input_default = /*#__PURE__*/__webpack_require__.n(input_);
// EXTERNAL MODULE: external "wot-design/lib/button"
var button_ = __webpack_require__(12);
var button_default = /*#__PURE__*/__webpack_require__.n(button_);
// EXTERNAL MODULE: external "wot-design/lib/mixins/locale"
var locale_ = __webpack_require__(4);
var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/message-box/src/main.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'WdMessageBox',
mixins: [locale_default.a],
components: {
WdPopup: popup_default.a,
WdButton: button_default.a,
WdInput: input_default.a
},
data: function data() {
return {
msg: '',
type: '',
showInput: false,
inputType: 'text',
inputValue: '',
inputPlaceholder: '',
inputError: '',
inputPattern: '',
inputValidate: '',
showErr: false
};
},
props: {
title: String,
showConfirmButton: {
type: Boolean,
default: true
},
showCancelButton: {
type: Boolean,
default: false
},
show: {
type: Boolean,
default: false
},
confirmButtonText: String,
cancelButtonText: String,
closeOnClickModal: {
type: Boolean,
default: true
},
closeOnPopstate: {
type: Boolean,
default: true
},
lockScroll: {
type: Boolean,
default: true
},
teleport: [String, Object]
},
watch: {
inputValue: function inputValue(value, oldValue) {
if (this.type === 'prompt' && this.showErr && oldValue !== value) {
this.showErr = false;
}
},
show: function show(val) {
!this.show && (this.showErr = false);
var type = this.value ? 'open' : 'close';
this.$emit(type);
}
},
methods: {
toggleModal: function toggleModal(action) {
if (action === 'modal' && !this.closeOnClickModal) {
return;
}
if (this.type === 'prompt' && action === 'confirm' && !this.validate()) {
return;
}
if (this.callback) {
this.show = !this.show;
this.callback(action);
}
this.$emit('action', action);
},
validate: function validate() {
if (this.inputPattern && !this.inputPattern.test(this.inputValue)) {
this.showErr = true;
return false;
}
if (typeof this.inputValidate === 'function') {
var validateResult = this.inputValidate(this.inputValue);
if (!validateResult) {
this.showErr = true;
return false;
}
}
this.showErr = false;
return true;
},
handleOpened: function handleOpened() {
this.$emit('opened');
},
handleClosed: function handleClosed() {
this.$emit('closed');
}
}
});
// CONCATENATED MODULE: ./packages/message-box/src/main.vue?vue&type=script&lang=js&
/* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./packages/message-box/src/main.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
src_mainvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "packages/message-box/src/main.vue"
/* harmony default export */ var main = (component.exports);
// CONCATENATED MODULE: ./packages/message-box/index.js
var _arguments = arguments;
/**
* MessageBox组件,提供alert,confirm,prompt格式
* 使用:
* Message.alert(message[, title, options])
* Message.confirm(message[, title, options])
* Message.prompt(message[, title, options])
*/
var defaults = {
title: '',
msg: '',
// message可以是html格式
type: 'alert',
showInput: false,
closeOnClickModal: true,
// 是否可以点击幕布关闭
closeOnPopstate: true,
// 是否返回时关闭
inputType: 'text',
// prompt中input类型
inputValue: '',
// prompt中input数据
inputPattern: '',
// prompt中验证input数据的正则表达式
inputValidate: '',
// prompt中验证input数据的函数
showConfirmButton: true,
showCancelButton: false,
confirmButtonText: '',
cancelButtonText: '',
inputError: '',
lockScroll: true
};
var merge = function merge(target) {
for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
var source = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
if (source) {
for (var key in source) {
target[key] = source[key];
}
}
}
return target;
};
var currentMsg;
var instance;
var msgQueue = [];
var defaultCallback = function defaultCallback(action) {
if (currentMsg) {
instance.show = false;
var callback = currentMsg.callback;
if (typeof callback === 'function') {
if (instance.showInput) {
callback(instance.inputValue, action);
} else {
callback(action);
}
}
if (currentMsg.resolve) {
var type = currentMsg.options.type;
if (type === 'confirm' || type === 'prompt') {
if (action === 'confirm') {
if (instance.showInput) {
currentMsg.resolve({
value: instance.inputValue,
action: action
});
} else {
currentMsg.resolve(action);
}
} else if (action === 'cancel' && currentMsg.reject) {
currentMsg.reject(action);
}
} else {
currentMsg.resolve(action);
}
}
}
};
var MessageBoxContructor = external_vue_default.a.extend(main);
var initInstance = function initInstance() {
instance = new MessageBoxContructor({
el: document.createElement('div')
});
instance.callback = defaultCallback;
};
var message_box_showNextMsg = function showNextMsg() {
if (!instance) {
initInstance();
}
if (!instance.show) {
if (msgQueue.length > 0) {
currentMsg = msgQueue.shift();
var options = currentMsg.options;
for (var key in options) {
instance[key] = options[key];
}
if (options.callback === undefined) {
instance.callback = defaultCallback;
}
if (instance.closeOnClickModal === undefined) {
instance.closeOnClickModal = true;
}
document.body.appendChild(instance.$el);
external_vue_default.a.nextTick(function () {
instance.show = true;
});
}
}
};
/* eslint-disable */
var MessageBox = function MessageBox(options, callback) {
if (typeof options === 'string') {
options = {
title: options
};
if (_arguments[1]) {
options.msg = _arguments[1];
}
if (_arguments[2]) {
options.type = _arguments[2];
}
} else if (options.callback && !callback) {
callback = options.callback;
}
if (options.type === 'alert') {
options = merge({
closeOnClickModal: false
}, options);
} else if (options.type === 'confirm') {
options = merge({
showCancelButton: true
}, options);
} else if (options.type === 'prompt') {
options = merge({
showCancelButton: true,
showInput: true
}, options);
}
if (typeof Promise !== 'undefined') {
return new Promise(function (resolve, reject) {
msgQueue.push({
options: merge({}, defaults, options),
callback: callback,
resolve: resolve,
reject: reject
});
message_box_showNextMsg();
});
} else {
msgQueue.push({
options: merge({}, defaults, options),
callback: callback
});
message_box_showNextMsg();
}
};
/* eslint-disable */
MessageBox.alert = function (msg, title, options) {
if (typeof_default()(title) === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
msg: msg,
type: 'alert'
}, options));
};
MessageBox.confirm = function (msg, title, options) {
if (typeof_default()(title) === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
msg: msg,
type: 'confirm'
}, options));
};
MessageBox.prompt = function (title, options) {
if (typeof_default()(title) === 'object') {
options = title;
title = '';
}
return MessageBox(merge({
title: title,
type: 'prompt'
}, options));
};
MessageBox.close = function () {
if (!instance) {
return;
}
instance.show = false;
msgQueue = [];
currentMsg = null;
};
/* harmony default export */ var message_box = __webpack_exports__["default"] = ({
install: function install(Vue) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$messageBoxKey = _ref.messageBoxKey,
messageBoxKey = _ref$messageBoxKey === void 0 ? '$messageBox' : _ref$messageBoxKey;
Vue.component(main.name, main);
Vue.prototype[messageBoxKey] = MessageBox;
},
wdMessageBox: main,
MessageBox: MessageBox
});
/***/ }),
/***/ 9:
/***/ (function(module, exports) {
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
function _typeof(obj) {
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
module.exports = _typeof = function _typeof(obj) {
return _typeof2(obj);
};
} else {
module.exports = _typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
};
}
return _typeof(obj);
}
module.exports = _typeof;
/***/ })
/******/ });