wot-design
Version:
Mobile UI components built on vue.js
1,092 lines (981 loc) • 30.1 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 = 56);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/button");
/***/ }),
/***/ 17:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/action-sheet");
/***/ }),
/***/ 4:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/mixins/locale");
/***/ }),
/***/ 44:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/checkbox");
/***/ }),
/***/ 45:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/checkbox-group");
/***/ }),
/***/ 46:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/radio");
/***/ }),
/***/ 47:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/radio-group");
/***/ }),
/***/ 48:
/***/ (function(module, exports) {
module.exports = require("wot-design/lib/search");
/***/ }),
/***/ 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;
/***/ }),
/***/ 56:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/select-picker/src/main.vue?vue&type=template&id=493d97d8&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ staticClass: "wd-col-picker wd-select-picker" },
[
_c(
"div",
{ staticClass: "wd-col-picker__field", on: { click: _vm.open } },
[
_vm._t("default", [
_c(
"div",
{
staticClass: "wd-col-picker__cell",
class: [
{
"is-disabled": _vm.disabled,
"is-readonly": _vm.readonly,
"is-align-right": _vm.alignRight,
"is-error": _vm.error
},
_vm.size ? "is-" + _vm.size : ""
]
},
[
_vm.label || _vm.$slots.label
? _c(
"div",
{
staticClass: "wd-col-picker__label",
class: {
"is-required": _vm.required
},
style: _vm.labelWidth
? "min-width: " +
_vm.labelWidth +
"; max-width: " +
_vm.labelWidth
: ""
},
[_vm._t("label", [_vm._v(_vm._s(_vm.label))])],
2
)
: _vm._e(),
_vm._v(" "),
_c(
"div",
{
staticClass: "wd-col-picker__value",
class: {
"wd-col-picker__value--placeholder":
!_vm.value ||
(_vm.value instanceof Array && !_vm.value.length),
"is-ellipsis": _vm.ellipsis
}
},
[
_vm._v(
_vm._s(
(!_vm.value ||
(_vm.value instanceof Array && !_vm.value.length)
? _vm.placeholder
: _vm.showValue) || _vm.t("wd.colPicker.placeholder")
)
)
]
),
_vm._v(" "),
!_vm.disabled && !_vm.readonly
? _c("i", {
staticClass: "wd-col-picker__arrow wd-icon-arrow-right"
})
: _vm._e()
]
)
])
],
2
),
_vm._v(" "),
_c(
"wd-action-sheet",
{
attrs: {
teleport: _vm.teleport,
duration: 250,
title: _vm.title || _vm.t("wd.colPicker.title"),
"close-on-click-modal": _vm.closeOnClickModal,
"close-on-popstate": _vm.closeOnPopstate,
"safe-area-inset-bottom": _vm.safeAreaInsetBottom
},
on: { close: _vm.handlePickerClose },
model: {
value: _vm.pickerShow,
callback: function($$v) {
_vm.pickerShow = $$v
},
expression: "pickerShow"
}
},
[
_vm.filterable
? _c("wd-search", {
attrs: {
placeholder: _vm.filterPlaceholder,
"placeholder-left": "",
"hide-cancel": ""
},
model: {
value: _vm.filterVal,
callback: function($$v) {
_vm.filterVal = $$v
},
expression: "filterVal"
}
})
: _vm._e(),
_vm._v(" "),
_c(
"div",
{
staticClass: "wd-select-picker__wrapper",
class: { "is-filterable": _vm.filterable },
style: _vm.inputFocus
? "height: " +
_vm.focusHeight +
"; max-height: " +
_vm.focusHeight
: ""
},
[
_vm.type === "checkbox"
? _c(
"wd-checkbox-group",
{
attrs: {
cell: "",
size: _vm.selectSize,
"checked-color": _vm.checkedColor,
min: _vm.min,
max: _vm.max
},
on: { change: _vm.handleChange },
model: {
value: _vm.selectList,
callback: function($$v) {
_vm.selectList = $$v
},
expression: "selectList"
}
},
_vm._l(_vm.filterColumns, function(item, index) {
return _c(
"wd-checkbox",
{
key: index,
attrs: {
value: item[_vm.valueKey],
disabled: item.disabled
}
},
[
_vm.filterable && _vm.filterVal
? [
_vm._l(
_vm.getFilterText(item[_vm.labelKey]),
function(text, index) {
return [
text.type === "active"
? _c(
"span",
{
key: index,
staticClass:
"wd-select-picker__text-active"
},
[_vm._v(_vm._s(text.label))]
)
: _c("span", { key: index }, [
_vm._v(_vm._s(text.label))
])
]
}
)
]
: [_vm._v(_vm._s(item[_vm.labelKey]))]
],
2
)
}),
1
)
: _vm._e(),
_vm._v(" "),
_vm.type === "radio"
? _c(
"wd-radio-group",
{
attrs: {
cell: "",
size: _vm.selectSize,
"checked-color": _vm.checkedColor
},
on: { change: _vm.handleChange },
model: {
value: _vm.selectList,
callback: function($$v) {
_vm.selectList = $$v
},
expression: "selectList"
}
},
_vm._l(_vm.filterColumns, function(item, index) {
return _c(
"wd-radio",
{
key: index,
attrs: {
value: item[_vm.valueKey],
disabled: item.disabled
}
},
[
_vm.filterable && _vm.filterVal
? [
_vm._l(
_vm.getFilterText(item[_vm.labelKey]),
function(text, index) {
return [
text.type === "active"
? _c(
"span",
{
key: index,
staticClass:
"wd-select-picker__text-active"
},
[_vm._v(_vm._s(text.label))]
)
: _c("span", { key: index }, [
_vm._v(_vm._s(text.label))
])
]
}
)
]
: [_vm._v(_vm._s(item[_vm.labelKey]))]
],
2
)
}),
1
)
: _vm._e(),
_vm._v(" "),
_vm.loading
? _c(
"div",
{
staticClass: "wd-picker-view__loading",
on: {
touchmove: function($event) {
$event.stopPropagation()
$event.preventDefault()
}
}
},
[_c("wd-loading", { attrs: { color: _vm.loadingColor } })],
1
)
: _vm._e()
],
1
),
_vm._v(" "),
!_vm.inputFocus
? _c(
"footer",
{ staticClass: "wd-select-picker__footer" },
[
_c(
"wd-button",
{
attrs: {
block: "",
size: "large",
disabled: _vm.loading
},
on: { click: _vm.onConfirm }
},
[
_vm._v(
_vm._s(
_vm.confirmButtonText || _vm.t("wd.picker.confirm")
)
)
]
)
],
1
)
: _vm._e()
],
1
)
],
1
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/select-picker/src/main.vue?vue&type=template&id=493d97d8&
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(5);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
// 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 "wot-design/lib/mixins/locale"
var locale_ = __webpack_require__(4);
var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
// EXTERNAL MODULE: external "wot-design/lib/action-sheet"
var action_sheet_ = __webpack_require__(17);
var action_sheet_default = /*#__PURE__*/__webpack_require__.n(action_sheet_);
// EXTERNAL MODULE: external "wot-design/lib/checkbox"
var checkbox_ = __webpack_require__(44);
var checkbox_default = /*#__PURE__*/__webpack_require__.n(checkbox_);
// EXTERNAL MODULE: external "wot-design/lib/checkbox-group"
var checkbox_group_ = __webpack_require__(45);
var checkbox_group_default = /*#__PURE__*/__webpack_require__.n(checkbox_group_);
// EXTERNAL MODULE: external "wot-design/lib/radio"
var radio_ = __webpack_require__(46);
var radio_default = /*#__PURE__*/__webpack_require__.n(radio_);
// EXTERNAL MODULE: external "wot-design/lib/radio-group"
var radio_group_ = __webpack_require__(47);
var radio_group_default = /*#__PURE__*/__webpack_require__.n(radio_group_);
// 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/search"
var search_ = __webpack_require__(48);
var search_default = /*#__PURE__*/__webpack_require__.n(search_);
// CONCATENATED MODULE: ./packages/select-picker/src/cellProps.js
/* harmony default export */ var cellProps = ({
label: String,
labelWidth: String,
disabled: Boolean,
readonly: Boolean,
placeholder: String,
title: String,
alignRight: Boolean,
error: Boolean,
required: Boolean,
size: String
});
// CONCATENATED MODULE: ./packages/select-picker/src/selectProps.js
/* harmony default export */ var selectProps = ({
checkedColor: String,
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: 0
},
selectSize: {
type: String,
default: 'large'
},
loading: Boolean,
loadingColor: String
});
// EXTERNAL MODULE: external "wot-design/lib/loading"
var loading_ = __webpack_require__(8);
var loading_default = /*#__PURE__*/__webpack_require__.n(loading_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/select-picker/src/main.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'WdSelectPicker',
mixins: [locale_default.a],
components: {
WdActionSheet: action_sheet_default.a,
WdCheckbox: checkbox_default.a,
WdCheckboxGroup: checkbox_group_default.a,
WdRadio: radio_default.a,
WdRadioGroup: radio_group_default.a,
WdButton: button_default.a,
WdLoading: loading_default.a,
WdSearch: search_default.a
},
data: function data() {
return {
pickerShow: false,
selectList: this.valueFormat(this.value),
showValue: '',
isConfirm: false,
lastSelectList: [],
filterVal: '',
winHeight: 0,
inputFocus: false
};
},
props: objectSpread_default()({}, cellProps, selectProps, {
columns: {
type: Array,
default: function _default() {
return [];
}
},
value: [Array, String, Number, Boolean],
// type: checkbox/radio
type: {
type: String,
default: 'checkbox'
},
teleport: [String, Object],
displayFormat: Function,
beforeConfirm: Function,
valueKey: {
type: String,
default: 'value'
},
labelKey: {
type: String,
default: 'label'
},
confirmButtonText: {
type: String,
default: '确定'
},
closeOnClickModal: {
type: Boolean,
default: true
},
closeOnPopstate: {
type: Boolean,
default: true
},
safeAreaInsetBottom: {
type: Boolean,
default: true
},
filterable: Boolean,
filterPlaceholder: String,
ellipsis: Boolean
}),
computed: {
filterColumns: function filterColumns() {
var _this = this;
if (this.filterable && this.filterVal) {
return this.columns.filter(function (item) {
var visible = item[_this.labelKey].indexOf(_this.filterVal) > -1;
return visible;
});
}
return this.columns;
}
},
watch: {
value: {
handler: function handler(val) {
this.selectList = this.valueFormat(val);
this.lastSelectList = this.selectList;
this.setShowValue(this.selectList);
},
immediate: true
}
},
mounted: function mounted() {
// fix android keyboard
this.winHeight = document.documentElement.clientHeight;
window.addEventListener('resize', this.resizeListener);
},
beforeDestroy: function beforeDestroy() {
window.removeEventListener('resize', this.resizeListener);
},
methods: {
resizeListener: function resizeListener() {
var currentHeight = document.documentElement.clientHeight; // wrapper's height add footer's height, and sub keyboard's height
this.focusHeight = 314 + 92 - (this.winHeight - currentHeight) + 'px';
this.inputFocus = currentHeight < this.winHeight;
},
getSelectedItem: function getSelectedItem(value) {
var _this2 = this,
_ref;
var selecteds = this.columns.filter(function (item) {
return item[_this2.valueKey] === value;
});
if (selecteds.length > 0) {
return selecteds[0];
}
return _ref = {}, defineProperty_default()(_ref, this.valueKey, value), defineProperty_default()(_ref, this.labelKey, ''), _ref;
},
valueFormat: function valueFormat(value) {
return this.type === 'checkbox' ? Array.prototype.slice.call(value) : value;
},
handleChange: function handleChange(val) {
this.$emit('change', val);
},
handlePickerClose: function handlePickerClose() {
// 未确定选项时,数据还原复位
if (!this.isConfirm) {
this.selectList = this.valueFormat(this.lastSelectList);
}
this.$emit('cancel');
},
/**
* @description 外部可调用方法,打开弹框
*/
open: function open() {
if (this.disabled || this.readonly) return;
this.selectList = this.valueFormat(this.value);
this.pickerShow = true;
this.isConfirm = false;
},
/**
* @description 外部可调用方法,关闭弹框
*/
close: function close() {
this.pickerShow = false;
this.handlePickerClose();
},
onConfirm: function onConfirm() {
var _this3 = this;
if (this.loading) {
this.pickerShow = false;
this.$emit('confirm', this.valueFormat(this.selectList));
return;
}
if (this.beforeConfirm) {
this.beforeConfirm(this.selectList, function (isPass) {
isPass && _this3.handleConfirm();
});
} else {
this.handleConfirm();
}
},
handleConfirm: function handleConfirm() {
this.isConfirm = true;
this.pickerShow = false;
this.lastSelectList = this.valueFormat(this.selectList);
this.$emit('input', this.lastSelectList);
this.$emit('confirm', this.lastSelectList);
this.setShowValue(this.lastSelectList);
},
setShowValue: function setShowValue(value) {
var _this4 = this;
if (this.displayFormat) {
this.showValue = this.displayFormat(value);
} else {
var showValue = '';
if (this.type === 'checkbox') {
var selectedItems = value.map(function (item) {
return _this4.getSelectedItem(item);
});
showValue = selectedItems.map(function (item) {
return item[_this4.labelKey];
}).join(', ');
} else if (this.type === 'radio') {
var selectedItem = this.getSelectedItem(value);
showValue = selectedItem[this.labelKey];
} else {
showValue = value;
}
this.showValue = showValue;
}
},
getFilterText: function getFilterText(label) {
var _this5 = this;
var reg = new RegExp("(".concat(this.filterVal, ")"), 'g');
return label.split(reg).map(function (text) {
return {
type: text === _this5.filterVal ? 'active' : 'normal',
label: text
};
});
}
}
});
// CONCATENATED MODULE: ./packages/select-picker/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/select-picker/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/select-picker/src/main.vue"
/* harmony default export */ var main = (component.exports);
// CONCATENATED MODULE: ./packages/select-picker/index.js
main.install = function (Vue) {
Vue.component(main.name, main);
};
/* harmony default export */ var select_picker = __webpack_exports__["default"] = (main);
/***/ }),
/***/ 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");
/***/ })
/******/ });