element-ui
Version:
A Component Library for Vue.js.
539 lines (442 loc) • 13.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] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = 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;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(166);
/***/ },
/***/ 3:
/***/ function(module, exports) {
/* globals __VUE_SSR_CONTEXT__ */
// this module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle
module.exports = function normalizeComponent (
rawScriptExports,
compiledTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */
) {
var esModule
var scriptExports = rawScriptExports = rawScriptExports || {}
// ES6 modules interop
var type = typeof rawScriptExports.default
if (type === 'object' || type === 'function') {
esModule = rawScriptExports
scriptExports = rawScriptExports.default
}
// Vue.extend constructor export interop
var options = typeof scriptExports === 'function'
? scriptExports.options
: scriptExports
// render functions
if (compiledTemplate) {
options.render = compiledTemplate.render
options.staticRenderFns = compiledTemplate.staticRenderFns
}
// scopedId
if (scopeId) {
options._scopeId = scopeId
}
var hook
if (moduleIdentifier) { // server build
hook = function (context) {
// 2.3 injection
context = context || (this.$vnode && this.$vnode.ssrContext)
// 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 = injectStyles
}
if (hook) {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing
? [].concat(existing, hook)
: [hook]
}
return {
esModule: esModule,
exports: scriptExports,
options: options
}
}
/***/ },
/***/ 14:
/***/ function(module, exports) {
module.exports = require("element-ui/lib/mixins/emitter");
/***/ },
/***/ 166:
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _input = __webpack_require__(167);
var _input2 = _interopRequireDefault(_input);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* istanbul ignore next */
_input2.default.install = function (Vue) {
Vue.component(_input2.default.name, _input2.default);
};
exports.default = _input2.default;
/***/ },
/***/ 167:
/***/ function(module, exports, __webpack_require__) {
var Component = __webpack_require__(3)(
/* script */
__webpack_require__(168),
/* template */
__webpack_require__(171),
/* styles */
null,
/* scopeId */
null,
/* moduleIdentifier (server only) */
null
)
module.exports = Component.exports
/***/ },
/***/ 168:
/***/ function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _emitter = __webpack_require__(14);
var _emitter2 = _interopRequireDefault(_emitter);
var _calcTextareaHeight = __webpack_require__(169);
var _calcTextareaHeight2 = _interopRequireDefault(_calcTextareaHeight);
var _merge = __webpack_require__(170);
var _merge2 = _interopRequireDefault(_merge);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
name: 'ElInput',
componentName: 'ElInput',
mixins: [_emitter2.default],
data: function data() {
return {
currentValue: this.value,
textareaCalcStyle: {}
};
},
props: {
value: [String, Number],
placeholder: String,
size: String,
resize: String,
readonly: Boolean,
autofocus: Boolean,
icon: String,
disabled: Boolean,
type: {
type: String,
default: 'text'
},
name: String,
autosize: {
type: [Boolean, Object],
default: false
},
rows: {
type: Number,
default: 2
},
autoComplete: {
type: String,
default: 'off'
},
form: String,
maxlength: Number,
minlength: Number,
max: {},
min: {},
step: {},
validateEvent: {
type: Boolean,
default: true
},
onIconClick: Function
},
computed: {
validating: function validating() {
return this.$parent.validateState === 'validating';
},
textareaStyle: function textareaStyle() {
return (0, _merge2.default)({}, this.textareaCalcStyle, { resize: this.resize });
}
},
watch: {
'value': function value(val, oldValue) {
this.setCurrentValue(val);
}
},
methods: {
handleBlur: function handleBlur(event) {
this.$emit('blur', event);
if (this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.blur', [this.currentValue]);
}
},
inputSelect: function inputSelect() {
this.$refs.input.select();
},
resizeTextarea: function resizeTextarea() {
if (this.$isServer) return;
var autosize = this.autosize,
type = this.type;
if (!autosize || type !== 'textarea') return;
var minRows = autosize.minRows;
var maxRows = autosize.maxRows;
this.textareaCalcStyle = (0, _calcTextareaHeight2.default)(this.$refs.textarea, minRows, maxRows);
},
handleFocus: function handleFocus(event) {
this.$emit('focus', event);
},
handleInput: function handleInput(event) {
var value = event.target.value;
this.$emit('input', value);
this.setCurrentValue(value);
this.$emit('change', value);
},
handleIconClick: function handleIconClick(event) {
if (this.onIconClick) {
this.onIconClick(event);
}
this.$emit('click', event);
},
setCurrentValue: function setCurrentValue(value) {
var _this = this;
if (value === this.currentValue) return;
this.$nextTick(function (_) {
_this.resizeTextarea();
});
this.currentValue = value;
if (this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.change', [value]);
}
}
},
created: function created() {
this.$on('inputSelect', this.inputSelect);
},
mounted: function mounted() {
this.resizeTextarea();
}
}; //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/***/ },
/***/ 169:
/***/ function(module, exports) {
'use strict';
exports.__esModule = true;
exports.default = calcTextareaHeight;
var hiddenTextarea = void 0;
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-weight', 'font-size', 'text-rendering', 'text-transform', 'width', 'text-indent', 'padding-left', 'padding-right', 'border-width', 'box-sizing'];
function calculateNodeStyling(targetElement) {
var style = window.getComputedStyle(targetElement);
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 name + ':' + style.getPropertyValue(name);
}).join(';');
return { contextStyle: contextStyle, paddingSize: paddingSize, borderSize: borderSize, boxSizing: boxSizing };
}
function calcTextareaHeight(targetElement) {
var minRows = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var maxRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
}
var _calculateNodeStyling = calculateNodeStyling(targetElement),
paddingSize = _calculateNodeStyling.paddingSize,
borderSize = _calculateNodeStyling.borderSize,
boxSizing = _calculateNodeStyling.boxSizing,
contextStyle = _calculateNodeStyling.contextStyle;
hiddenTextarea.setAttribute('style', contextStyle + ';' + HIDDEN_STYLE);
hiddenTextarea.value = targetElement.value || targetElement.placeholder || '';
var height = hiddenTextarea.scrollHeight;
if (boxSizing === 'border-box') {
height = height + borderSize;
} else if (boxSizing === 'content-box') {
height = height - paddingSize;
}
hiddenTextarea.value = '';
var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
if (minRows !== null) {
var minHeight = singleRowHeight * minRows;
if (boxSizing === 'border-box') {
minHeight = minHeight + paddingSize + borderSize;
}
height = Math.max(minHeight, height);
}
if (maxRows !== null) {
var maxHeight = singleRowHeight * maxRows;
if (boxSizing === 'border-box') {
maxHeight = maxHeight + paddingSize + borderSize;
}
height = Math.min(maxHeight, height);
}
return { height: height + 'px' };
};
/***/ },
/***/ 170:
/***/ function(module, exports) {
module.exports = require("element-ui/lib/utils/merge");
/***/ },
/***/ 171:
/***/ function(module, exports) {
module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
return _c('div', {
class: [
_vm.type === 'textarea' ? 'el-textarea' : 'el-input',
_vm.size ? 'el-input--' + _vm.size : '', {
'is-disabled': _vm.disabled,
'el-input-group': _vm.$slots.prepend || _vm.$slots.append,
'el-input-group--append': _vm.$slots.append,
'el-input-group--prepend': _vm.$slots.prepend
}
]
}, [(_vm.type !== 'textarea') ? [(_vm.$slots.prepend) ? _c('div', {
staticClass: "el-input-group__prepend"
}, [_vm._t("prepend")], 2) : _vm._e(), _vm._t("icon", [(_vm.icon) ? _c('i', {
staticClass: "el-input__icon",
class: [
'el-icon-' + _vm.icon,
_vm.onIconClick ? 'is-clickable' : ''
],
on: {
"click": _vm.handleIconClick
}
}) : _vm._e()]), (_vm.type !== 'textarea') ? _c('input', _vm._b({
ref: "input",
staticClass: "el-input__inner",
attrs: {
"autocomplete": _vm.autoComplete
},
domProps: {
"value": _vm.currentValue
},
on: {
"input": _vm.handleInput,
"focus": _vm.handleFocus,
"blur": _vm.handleBlur
}
}, 'input', _vm.$props)) : _vm._e(), (_vm.validating) ? _c('i', {
staticClass: "el-input__icon el-icon-loading"
}) : _vm._e(), (_vm.$slots.append) ? _c('div', {
staticClass: "el-input-group__append"
}, [_vm._t("append")], 2) : _vm._e()] : _c('textarea', _vm._b({
ref: "textarea",
staticClass: "el-textarea__inner",
style: (_vm.textareaStyle),
domProps: {
"value": _vm.currentValue
},
on: {
"input": _vm.handleInput,
"focus": _vm.handleFocus,
"blur": _vm.handleBlur
}
}, 'textarea', _vm.$props))], 2)
},staticRenderFns: []}
/***/ }
/******/ });