wot-design
Version:
Mobile UI components built on vue.js
867 lines (811 loc) • 25.3 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 = 57);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 57:
/***/ (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/input/src/main.vue?vue&type=template&id=19e66f26&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{
staticClass: "wd-input",
class: [
{
"is-textarea": _vm.type === "textarea",
"is-disabled": _vm.disabled,
"is-error": _vm.error,
"is-cell": _vm.label || _vm.$slots.label,
"is-center": _vm.center,
"is-right": _vm.alignRight,
"is-not-empty": _vm.value && _vm.value.length !== 0,
"is-no-border": _vm.noBorder
},
_vm.size ? "is-" + _vm.size : ""
]
},
[
_vm.label || _vm.$slots.label
? _c(
"div",
{
staticClass: "wd-input__label",
class: {
"is-required": _vm.required
},
style: _vm.labelWidth
? "min-width: " +
_vm.labelWidth +
";max-width: " +
_vm.labelWidth
: ""
},
[
_vm.prefixIcon || _vm.$slots.prefix
? _c(
"div",
{ staticClass: "wd-input__prefix" },
[
_vm._t("prefix"),
_vm._v(" "),
_vm.prefixIcon
? _c("i", {
staticClass: "wd-input__icon",
class: _vm.prefixIcon,
on: { click: _vm.onClickPrefixIcon }
})
: _vm._e()
],
2
)
: _vm._e(),
_vm._v(" "),
_c(
"div",
{ staticClass: "wd-input__label-inner" },
[_vm._t("label", [_vm._v(_vm._s(_vm.label))])],
2
)
]
)
: _vm._e(),
_vm._v(" "),
_vm.type === "textarea" || (_vm.type === "text" && _vm.autosize)
? [
_c(
"div",
{
staticClass: "wd-input__textarea",
class: {
"is-show-limit": _vm.showWordCount,
"is-text-auto": _vm.type === "text" && _vm.autosize
}
},
[
_c("textarea", {
ref: "textarea",
staticClass: "wd-input__textarea-inner",
class: {
"is-suffix": _vm.showClear
},
style: _vm.textareaStyle,
attrs: {
placeholder: _vm.placeholder,
disabled: _vm.disabled,
readonly: _vm.readonly,
minlength: _vm.minlength,
maxlength: _vm.maxlength,
rows: _vm.rows,
autofocus: _vm.autofocus
},
domProps: { value: _vm.value },
on: {
input: _vm.handleInput,
change: _vm.handleChange,
focus: _vm.handleFocus,
blur: _vm.handleBlur
}
}),
_vm._v(" "),
_c("div", { staticClass: "wd-input__textarea-suffix" }, [
_c("i", {
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showClear,
expression: "showClear"
}
],
staticClass:
"wd-input__textarea-icon wd-input__clear wd-icon-error-fill",
on: { click: _vm.clear }
}),
_vm._v(" "),
_vm.showWordCount
? _c("span", { staticClass: "wd-input__textarea-count" }, [
_c(
"span",
{
class: [
{
"is-error":
_vm.value &&
_vm.value.length > parseInt(_vm.maxlength)
},
_vm.value && _vm.value.length > 0
? "wd-input__textarea-count-current"
: ""
]
},
[_vm._v(_vm._s((_vm.value && _vm.value.length) || 0))]
),
_vm._v(
"\n /" + _vm._s(_vm.maxlength) + "\n "
)
])
: _vm._e()
])
]
)
]
: _c("div", { staticClass: "wd-input__block" }, [
(_vm.prefixIcon || _vm.$slots.prefix) &&
!_vm.label &&
!_vm.$slots.label
? _c(
"div",
{ staticClass: "wd-input__prefix" },
[
_vm._t("prefix"),
_vm._v(" "),
_vm.prefixIcon
? _c("i", {
staticClass: "wd-input__icon",
class: _vm.prefixIcon,
on: { click: _vm.onClickPrefixIcon }
})
: _vm._e()
],
2
)
: _vm._e(),
_vm._v(" "),
_c("input", {
ref: "input",
staticClass: "wd-input__inner",
attrs: {
type: _vm.showPassword
? _vm.isPwdVisible
? "text"
: "password"
: _vm.type,
placeholder: _vm.placeholder,
readonly: _vm.readonly,
disabled: _vm.disabled,
minlength: _vm.minlength,
maxlength: _vm.maxlength,
step: _vm.step,
autofocus: _vm.autofocus
},
domProps: { value: _vm.value },
on: {
input: _vm.handleInput,
change: _vm.handleChange,
focus: _vm.handleFocus,
blur: _vm.handleBlur
}
}),
_vm._v(" "),
_vm.showClear ||
_vm.showPwdVisible ||
_vm.suffixIcon ||
_vm.$slots.suffix ||
_vm.showWordCount
? _c(
"div",
{ staticClass: "wd-input__suffix" },
[
_vm.showClear
? _c("i", {
staticClass:
"wd-input__icon wd-input__clear wd-icon-error-fill ",
on: { click: _vm.clear }
})
: _vm._e(),
_vm._v(" "),
_vm.showPwdVisible
? _c("i", {
staticClass: "wd-input__icon",
class: _vm.isPwdVisible
? "wd-icon-view"
: "wd-icon-eye-close",
on: { click: _vm.togglePwdVisible }
})
: _vm._e(),
_vm._v(" "),
_vm.showWordCount
? _c("span", { staticClass: "wd-input__count" }, [
_c(
"span",
{
class: [
{
"is-error":
_vm.value &&
_vm.value.length > _vm.maxlength
},
_vm.value && _vm.value.length > 0
? "wd-input__textarea-count-current"
: ""
]
},
[
_vm._v(
_vm._s((_vm.value && _vm.value.length) || 0)
)
]
),
_vm._v(
"\n /" + _vm._s(_vm.maxlength) + "\n "
)
])
: _vm._e(),
_vm._v(" "),
_vm.suffixIcon
? _c("i", {
staticClass: "wd-input__icon",
class: _vm.suffixIcon,
on: { click: _vm.onClickSuffixIcon }
})
: _vm._e(),
_vm._v(" "),
_vm._t("suffix")
],
2
)
: _vm._e()
])
],
2
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/input/src/main.vue?vue&type=template&id=19e66f26&
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
var helpers_typeof = __webpack_require__(9);
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
// CONCATENATED MODULE: ./packages/input/src/calcTextareaHeight.js
var hiddenTextarea;
var HIDDEN_STYLE = "\n height: 0 !important;\n visibility: hidden !important;\n overflow: hidden !important;\n position: absolute !important;\n z-index: -1000 !important;\n top: 0 !important;\n right: 0 !important;\n";
var CONTEXT_STYLE = ['letter-spacing', 'line-height', 'padding-top', 'padding-bottom', 'font-family', 'font-size', 'text-rendering', 'text-transform', 'width', 'text-indent', 'padding-left', 'padding-right', 'border-width', 'box-sizing'];
var calculateNodeStyling = function calculateNodeStyling(element) {
var style = window.getComputedStyle(element);
var boxSizing = style.getPropertyValue('box-sizing');
var paddingSize = parseFloat(style.getPropertyValue('padding-bottom')) + parseFloat(style.getPropertyValue('padding-top'));
var borderSize = parseFloat(style.getPropertyValue('border-bottom-width')) + parseFloat(style.getPropertyValue('border-top-width'));
var contextStyle = CONTEXT_STYLE.map(function (name) {
return "".concat(name, ": ").concat(style.getPropertyValue(name));
}).join(';');
return {
contextStyle: contextStyle,
paddingSize: paddingSize,
borderSize: borderSize,
boxSizing: boxSizing
};
};
function calcTextareaHeight(element) {
var minRows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var maxRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
var _calculateNodeStyling = calculateNodeStyling(element),
paddingSize = _calculateNodeStyling.paddingSize,
borderSize = _calculateNodeStyling.borderSize,
boxSizing = _calculateNodeStyling.boxSizing,
contextStyle = _calculateNodeStyling.contextStyle;
hiddenTextarea.setAttribute('style', "".concat(contextStyle, ";").concat(HIDDEN_STYLE, "}"));
hiddenTextarea.value = element.value || element.placeholder || '';
var height = hiddenTextarea.scrollHeight;
var result = {};
if (boxSizing === 'border-box') {
height = height + borderSize;
} else if (boxSizing === 'content-box') {
height = height - paddingSize;
}
hiddenTextarea.value = '';
var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
var minHeight = singleRowHeight * minRows;
if (boxSizing === 'border-box') {
minHeight = minHeight + paddingSize + borderSize;
}
height = Math.max(minHeight, height);
result.minHeight = "".concat(minHeight, "px");
if (maxRows !== null) {
var maxHeight = singleRowHeight * maxRows;
if (boxSizing === 'border-box') {
maxHeight = maxHeight + paddingSize + borderSize;
}
height = Math.min(maxHeight, height);
}
result.height = "".concat(height, "px");
hiddenTextarea.parentNode && hiddenTextarea.parentNode.removeChild(hiddenTextarea);
hiddenTextarea = null;
return result;
}
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/input/src/main.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'WdInput',
data: function data() {
return {
focused: false,
isPwdVisible: false,
textareaCalcStyle: {}
};
},
props: {
type: {
type: String,
default: 'text'
},
value: [String, Number],
placeholder: String,
clearable: Boolean,
maxlength: String,
minlength: String,
showPassword: Boolean,
disabled: Boolean,
readonly: Boolean,
prefixIcon: String,
suffixIcon: String,
showWordLimit: Boolean,
step: String,
rows: {
type: [String, Number],
default: '3'
},
autosize: [Boolean, Object],
resize: {
type: String,
default: 'none'
},
autofocus: Boolean,
error: Boolean,
label: String,
labelWidth: {
type: String,
default: '33%'
},
size: String,
center: Boolean,
alignRight: Boolean,
noBorder: Boolean,
required: Boolean
},
watch: {
value: {
immediate: true,
handler: function handler(value) {
this.$nextTick(this.resizeTextarea);
}
}
},
computed: {
showClear: function showClear() {
return !this.disabled && !this.readonly && this.clearable && this.value;
},
showPwdVisible: function showPwdVisible() {
return !this.disabled && !this.readonly && this.showPassword;
},
showWordCount: function showWordCount() {
return !this.disabled && !this.readonly && this.maxlength && this.showWordLimit;
},
textareaStyle: function textareaStyle() {
return Object.assign({}, this.textareaCalcStyle, {
resize: this.resize
});
}
},
methods: {
focus: function focus() {
this.getInput().focus();
},
blur: function blur() {
this.getInput().blur();
},
select: function select() {
this.getInput().select();
},
handleInput: function handleInput(event) {
this.$emit('input', event.target.value);
},
handleChange: function handleChange(event) {
this.$emit('change', event.target.value);
},
clear: function clear() {
this.$emit('input', '');
this.$emit('clear');
this.focus();
},
handleFocus: function handleFocus() {
this.focused = true;
this.$emit('focus');
},
handleBlur: function handleBlur() {
this.focused = false;
this.$emit('blur');
},
getInput: function getInput() {
return this.$refs.input || this.$refs.textarea;
},
togglePwdVisible: function togglePwdVisible() {
this.isPwdVisible = !this.isPwdVisible;
},
resizeTextarea: function resizeTextarea() {
if (this.type === 'textarea' || this.type === 'text' && this.autosize) {
if (!this.autosize) {
this.textareaCalcStyle = {
minHeight: calcTextareaHeight(this.getInput()).minHeight
};
return;
}
var minRows;
var maxRows;
if (typeof_default()(this.autosize) === 'object') {
minRows = this.autosize.minRows;
maxRows = this.autosize.maxRows;
}
this.textareaCalcStyle = calcTextareaHeight(this.getInput(), minRows, maxRows);
}
},
onClickSuffixIcon: function onClickSuffixIcon() {
this.$emit('click-suffix-icon');
},
onClickPrefixIcon: function onClickPrefixIcon() {
this.$emit('click-prefix-icon');
}
}
});
// CONCATENATED MODULE: ./packages/input/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/input/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/input/src/main.vue"
/* harmony default export */ var main = (component.exports);
// CONCATENATED MODULE: ./packages/input/index.js
main.install = function (Vue) {
Vue.component(main.name, main);
};
/* harmony default export */ var input = __webpack_exports__["default"] = (main);
/***/ }),
/***/ 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;
/***/ })
/******/ });