ten-design-vue
Version:
ten-vue
695 lines (636 loc) • 20 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 = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = require("../icon");
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__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!./src/components/input/input.vue?vue&type=template&id=84adb7d8&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._g({class:_vm.className},_vm.othersEvent),[(_vm.hasPrefix)?_c('span',{staticClass:"ten-input__prefix"},[_vm._t("prefix",function(){return [_vm._v(_vm._s(_vm.prefix))]})],2):_vm._e(),_c('div',{class:_vm.inputWrapperClassName,on:{"click":_vm.focus}},[(_vm.hasPrefixIcon)?_c('span',{staticClass:"ten-input__input-icon ten-input__input-icon--prefix"},[_vm._t("prefixIcon",function(){return [_c('ten-icon',{attrs:{"icon":_vm.prefixIcon}})]})],2):_vm._e(),(this.$scopedSlots.inputPrefix)?_c('span',{ref:"refInputPrefix",staticClass:"ten-input__input-prefix"},[_vm._t("inputPrefix")],2):_vm._e(),(this.$scopedSlots.inputPrefixRaw)?_c('span',[_vm._t("inputPrefixRaw")],2):_vm._e(),_c('input',_vm._g(_vm._b({ref:"refInputElem",staticClass:"ten-input__input-input",on:{"compositionstart":_vm.onCompositionstart,"compositionend":_vm.onCompositionend,"input":_vm.onInput,"change":_vm.onChange,"blur":_vm.onBlur,"focus":_vm.onFocus,"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onEnter.apply(null, arguments)}}},'input',_vm.inputProps,false),_vm.inputEvents)),(this.$scopedSlots.inputSuffix)?_c('span',{ref:"refInputSuffix",staticClass:"ten-input__input-suffix"},[_vm._t("inputSuffix")],2):_vm._e(),(_vm.hasSuffixIcon)?_c('span',{staticClass:"ten-input__input-icon ten-input__input-icon--suffix"},[(_vm.showClear)?_c('ten-icon',{staticClass:"ten-input__input-close",attrs:{"icon":"circle_clear"},on:{"mousedown":function($event){$event.preventDefault();},"click":function($event){$event.stopPropagation();return _vm.onClear.apply(null, arguments)}}}):_vm._t("suffixIcon",function(){return [_c('ten-icon',{attrs:{"icon":_vm.suffixIcon}})]})],2):_vm._e()]),(_vm.hasSuffix)?_c('span',{staticClass:"ten-input__suffix"},[_vm._t("suffix",function(){return [_vm._v(_vm._s(_vm.suffix))]})],2):_vm._e()])}
var staticRenderFns = []
// CONCATENATED MODULE: ./src/components/input/input.vue?vue&type=template&id=84adb7d8&
// EXTERNAL MODULE: external "../icon"
var external_icon_ = __webpack_require__(0);
var external_icon_default = /*#__PURE__*/__webpack_require__.n(external_icon_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--1!./node_modules/vue-loader/lib??vue-loader-options!./src/components/input/input.vue?vue&type=script&lang=js&
var _excluded = ["keydown", "keyup", "keypress", "change", "input", "focus", "blur"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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; }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var inputvue_type_script_lang_js_name = 'ten-input';
/* harmony default export */ var inputvue_type_script_lang_js_ = ({
name: inputvue_type_script_lang_js_name,
components: {
TenIcon: external_icon_default.a
},
inheritAttrs: false,
inject: {
group: {
default: undefined
},
formItem: {
from: 'tenFormItem',
default: null
}
},
props: {
/**
* @model
*
* value 值
*/
value: {
type: [String, Number]
},
/**
* 默认 value 值
*/
defaultValue: [String, Number],
/**
* 前缀,支持同名slot
*/
prefix: {
type: String
},
/**
* 后缀,支持同名slot
*/
suffix: {
type: String
},
/**
* 前缀Icon,支持同名slot
*/
prefixIcon: {
type: String
},
/**
* 后缀Icon,支持同名slot
*/
suffixIcon: {
type: String
},
/**
* 原生属性
*/
placeholder: {
type: String
},
/**
* 原生属性
*/
name: {
type: String
},
/**
* 原生属性
*/
type: {
type: String
},
/**
* 尺寸
*
* @member default | small
*/
size: {
type: String,
default: 'default',
validator: function validator(v) {
return ['default', 'small'].indexOf(v) > -1;
}
},
/**
* 是否为错误状态
*/
error: {
type: Boolean,
default: false
},
/**
* 禁用
*/
disabled: {
type: Boolean,
default: false
},
/**
* 是否显示清除按钮
*/
clearable: {
type: Boolean,
default: false
},
/**
* 获取原生input Dom
* @ignore
*/
getInput: {
type: Function
}
},
data: function data() {
return {
focused: false
};
},
computed: {
hasPrefix: function hasPrefix() {
return !!(this.$scopedSlots.prefix || this.prefix);
},
hasSuffix: function hasSuffix() {
return !!(this.$scopedSlots.suffix || this.suffix);
},
hasPrefixIcon: function hasPrefixIcon() {
return !!(this.$scopedSlots.prefixIcon || this.prefixIcon);
},
hasSuffixIcon: function hasSuffixIcon() {
return !!(this.$scopedSlots.suffixIcon || this.suffixIcon || this.showClear);
},
showClear: function showClear() {
return this.value && !this.disabled && this.clearable;
},
className: function className() {
return ['ten-input', "ten-input--size-".concat(this.group ? this.group.size : this.size), {
'ten-input--status-error': this.error,
'ten-input--disabled': this.disabled,
'ten-input--focused': this.focused,
'ten-input--with-prefix': this.hasPrefix,
'ten-input--with-suffix': this.hasSuffix
}];
},
inputWrapperClassName: function inputWrapperClassName() {
return ['ten-input__input', {
'ten-input__input--status-error': this.error,
'ten-input__input--focused': this.focused,
'ten-input__input--disabled': this.disabled,
'ten-input__input--prefixicon': this.hasPrefixIcon,
'ten-input__input--suffixicon': this.hasSuffixIcon
}];
},
inputEvents: function inputEvents() {
var _this$$listeners = this.$listeners,
keydown = _this$$listeners.keydown,
keyup = _this$$listeners.keyup,
keypress = _this$$listeners.keypress;
var events = {
keydown: keydown,
keyup: keyup,
keypress: keypress
};
Object.keys(events).forEach(function (e) {
if (!events[e]) delete events[e];
});
return events;
},
inputProps: function inputProps() {
return _objectSpread(_objectSpread({}, this.$attrs), {}, {
name: this.name,
placeholder: this.placeholder,
disabled: this.disabled,
clearable: this.clearable,
type: this.type || 'text'
});
},
othersEvent: function othersEvent() {
var _this$$listeners2 = this.$listeners,
keydown = _this$$listeners2.keydown,
keyup = _this$$listeners2.keyup,
keypress = _this$$listeners2.keypress,
change = _this$$listeners2.change,
input = _this$$listeners2.input,
focus = _this$$listeners2.focus,
blur = _this$$listeners2.blur,
others = _objectWithoutProperties(_this$$listeners2, _excluded);
return others;
}
},
watch: {
value: {
handler: function handler(v) {
if (this.$refs.refInputElem) {
this.setInputValue(v);
}
},
immediate: true
}
},
mounted: function mounted() {
this.setInputValue(this.value);
this.getInput && this.getInput(this.$refs.refInputElem);
},
created: function created() {
this.blurT = null;
},
beforeDestroy: function beforeDestroy() {
clearTimeout(this.blurT);
},
methods: {
setInputValue: function setInputValue() {
var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var input = this.$refs.refInputElem;
var sV = String(v);
if (!input) {
return;
}
if (input.value !== sV) {
input.value = sV;
}
},
onCompositionstart: function onCompositionstart() {
this.isComposing = true;
},
onCompositionend: function onCompositionend(e) {
if (this.isComposing) {
this.isComposing = false;
this.onInput(e);
}
},
onChange: function onChange(e) {
/**
* change 回调
*
* @param {Object} e 事件对象
*/
this.$emit('change', e);
},
onInput: function onInput(e) {
var _this = this;
if (this.isComposing) return;
/**
* input 回调
*
* @param {String} value 输入值
*/
this.$emit('input', e.target.value);
this.$nextTick(function () {
_this.formItem && _this.formItem.$emit('form.change');
}); // 受控
this.$nextTick(function () {
return _this.setInputValue(_this.value);
});
},
onFocus: function onFocus(e) {
clearTimeout(this.blurT);
this.focused = true;
this.readyBlur = false;
/**
* 聚焦回调
*
* @param {Object} e 事件对象
*/
this.$emit('focus', e);
},
onBlur: function onBlur(e) {
var _this2 = this;
this.readyBlur = true;
this.blurT = setTimeout(function () {
if (_this2.readyBlur && _this2.focused) {
_this2.focused = false;
}
}, 150);
/**
* 失焦回调
*
* @param {Object} e 事件对象
*/
this.$emit('blur', e);
this.formItem && this.formItem.$emit('form.blur');
},
onClear: function onClear() {
/**
* 点击清空按钮后触发
*/
this.$emit('clear');
this.$emit('input', '');
},
onEnter: function onEnter(e) {
if (this.isComposing) return;
/**
*
* 按下 enter 确认键后的回调事件
* @param {Object} e 事件对象
*/
this.$emit('enter', e);
},
/**
* @public
*
* 使输入框获得焦点, 支持使用 v-focus 指令
* @param {boolean}
*/
focus: function focus() {
this.$refs.refInputElem && this.$refs.refInputElem.focus();
},
/**
* @public
*
* 使输入框获失去焦点
*/
blur: function blur() {
this.$refs.refInputElem && this.$refs.refInputElem.blur();
},
/**
* @public
*
* 选中输入框文本
*/
select: function select() {
this.$refs.refInputElem && this.$refs.refInputElem.select();
}
}
});
// CONCATENATED MODULE: ./src/components/input/input.vue?vue&type=script&lang=js&
/* harmony default export */ var input_inputvue_type_script_lang_js_ = (inputvue_type_script_lang_js_);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* 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
}
}
// CONCATENATED MODULE: ./src/components/input/input.vue
/* normalize component */
var component = normalizeComponent(
input_inputvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* harmony default export */ var input = __webpack_exports__["default"] = (component.exports);
/***/ })
/******/ ]);