@mdsfe/mds-ui
Version:
A set of enterprise-class Vue UI components.
1,269 lines (1,135 loc) • 34.8 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("./icon"), require("./_mixin/emitter"));
else if(typeof define === 'function' && define.amd)
define(["./icon", "./_mixin/emitter"], factory);
else {
var a = typeof exports === 'object' ? factory(require("./icon"), require("./_mixin/emitter")) : factory(root["./icon"], root["./_mixin/emitter"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function(__WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__14__) {
return /******/ (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 = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 101);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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,
(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
}
}
/***/ }),
/***/ 101:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./components/style/index.less
var style = __webpack_require__(142);
// EXTERNAL MODULE: ./components/text/style/index.less
var text_style = __webpack_require__(267);
// CONCATENATED MODULE: ./components/text/style/index.js
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/text/text.vue?vue&type=template&id=0c79aab8&
var render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"span",
{ class: ["mds-text", _vm.classNames] },
[
_vm.icon.length > 0
? _c("mds-icon", { attrs: { type: _vm.icon } })
: _vm._e(),
_vm._t("default"),
],
2
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./components/text/text.vue?vue&type=template&id=0c79aab8&
// EXTERNAL MODULE: external "./icon"
var external_icon_ = __webpack_require__(7);
var external_icon_default = /*#__PURE__*/__webpack_require__.n(external_icon_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/text/text.vue?vue&type=script&lang=js&
//
//
//
//
//
//
/* harmony default export */ var textvue_type_script_lang_js_ = ({
name: 'MdsText',
components: {
MdsIcon: external_icon_default.a
},
props: {
type: {
type: String,
default: 'primary'
},
mark: {
type: Boolean,
default: false
},
code: {
type: Boolean,
default: false
},
underline: {
type: Boolean,
default: false
},
delete: {
type: Boolean,
default: false
},
strong: {
type: Boolean,
default: false
},
icon: {
type: String,
default: ''
}
},
data: function data() {
return {
editing: false,
copied: false,
textContent: ''
};
},
computed: {
classNames: function classNames() {
var res = [];
var pre = 'mds-text-';
switch (this.type) {
case 'primary':
res.push(pre + 'primary');
break;
case 'secondary':
res.push(pre + 'secondary');
break;
case 'dark':
res.push(pre + 'dark');
break;
case 'disabled':
res.push(pre + 'disabled');
break;
case 'danger':
res.push(pre + 'danger');
break;
case 'success':
res.push(pre + 'success');
break;
case 'warning':
res.push(pre + 'warning');
break;
case 'info':
res.push(pre + 'info');
break;
default:
break;
}
if (this.mark) {
res.push(pre + 'mark');
}
if (this.code) {
res.push(pre + 'code');
}
if (this.underline) {
res.push(pre + 'underline');
}
if (this.delete) {
res.push(pre + 'delete');
}
if (this.strong) {
res.push(pre + 'strong');
}
return res;
}
},
methods: {},
mounted: function mounted() {}
});
// CONCATENATED MODULE: ./components/text/text.vue?vue&type=script&lang=js&
/* harmony default export */ var text_textvue_type_script_lang_js_ = (textvue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/text/text.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
text_textvue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "components/text/text.vue"
/* harmony default export */ var text_text = (component.exports);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/text/link.vue?vue&type=template&id=7cc366f1&
var linkvue_type_template_id_7cc366f1_render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"a",
{
class: ["mds-link", _vm.underline ? "has-underline" : ""],
attrs: { href: _vm.url, target: _vm.target },
},
[_vm._t("default")],
2
)
}
var linkvue_type_template_id_7cc366f1_staticRenderFns = []
linkvue_type_template_id_7cc366f1_render._withStripped = true
// CONCATENATED MODULE: ./components/text/link.vue?vue&type=template&id=7cc366f1&
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/text/link.vue?vue&type=script&lang=js&
//
//
//
//
//
//
/* harmony default export */ var linkvue_type_script_lang_js_ = ({
name: 'MdsLink',
props: {
url: {
type: String,
default: ''
},
underline: {
type: Boolean,
default: false
},
target: {
type: String,
default: '_self'
}
},
data: function data() {
return {};
},
methods: {},
mounted: function mounted() {}
});
// CONCATENATED MODULE: ./components/text/link.vue?vue&type=script&lang=js&
/* harmony default export */ var text_linkvue_type_script_lang_js_ = (linkvue_type_script_lang_js_);
// CONCATENATED MODULE: ./components/text/link.vue
/* normalize component */
var link_component = Object(componentNormalizer["a" /* default */])(
text_linkvue_type_script_lang_js_,
linkvue_type_template_id_7cc366f1_render,
linkvue_type_template_id_7cc366f1_staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var link_api; }
link_component.options.__file = "components/text/link.vue"
/* harmony default export */ var text_link = (link_component.exports);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/text/customize.vue?vue&type=template&id=56d05148&
var customizevue_type_template_id_56d05148_render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"span",
{ staticClass: "mds-text" },
[
_vm.editable
? [
!_vm.editing
? _vm._t("default")
: _c("mds-input-textarea", {
ref: "textarea",
attrs: { id: "editTextarea", rows: "1" },
nativeOn: {
keyup: function ($event) {
if (
!$event.type.indexOf("key") &&
_vm._k($event.keyCode, "enter", 13, $event.key, "Enter")
) {
return null
}
return _vm.finishEdit($event)
},
blur: function ($event) {
return _vm.finishEdit($event)
},
},
model: {
value: _vm.textContent,
callback: function ($$v) {
_vm.textContent = $$v
},
expression: "textContent",
},
}),
_c(
"mds-tooltip",
{ attrs: { title: "编辑", mouseLeaveDelay: 0 } },
[
_c("mds-icon", {
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.editable && !_vm.editing,
expression: "editable && !editing",
},
],
staticClass: "edit-icon",
attrs: { type: "line-format-border-color" },
nativeOn: {
click: function ($event) {
return _vm.handleEdit($event)
},
},
}),
],
1
),
]
: _vm.copyable
? [
_c(
"span",
{ attrs: { id: "copy-target" } },
[_vm._t("default")],
2
),
_c(
"mds-tooltip",
{
attrs: {
title: _vm.copied ? "复制成功" : "复制",
mouseLeaveDelay: 0,
},
},
[
_c("mds-icon", {
attrs: {
type: _vm.copied ? "line-check" : "line-swap-stroke",
},
nativeOn: {
click: function ($event) {
return _vm.handleCopy($event)
},
},
}),
],
1
),
]
: _vm._e(),
],
2
)
}
var customizevue_type_template_id_56d05148_staticRenderFns = []
customizevue_type_template_id_56d05148_render._withStripped = true
// CONCATENATED MODULE: ./components/text/customize.vue?vue&type=template&id=56d05148&
// EXTERNAL MODULE: ./components/input/textarea.vue + 5 modules
var input_textarea = __webpack_require__(45);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/text/customize.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var customizevue_type_script_lang_js_ = ({
name: 'MdsTextCustomize',
components: {
MdsIcon: external_icon_default.a,
MdsInputTextarea: input_textarea["a" /* default */]
},
props: {
editable: {
type: Boolean,
default: false
},
copyable: {
type: Boolean,
default: false
}
},
data: function data() {
return {
editing: false,
copied: false,
textContent: ''
};
},
methods: {
handleEdit: function handleEdit() {
this.textContent = this.$slots.default[0].text;
this.editing = true;
this.$nextTick(function () {
// this.$refs.textarea.focus()
document.querySelector('#editTextarea').focus();
});
},
finishEdit: function finishEdit() {
this.editing = false;
this.$slots.default[0].text = this.textContent;
},
handleCopy: function handleCopy() {
if (!this.copied) {
var copyContent = document.querySelector('#copy-target').textContent;
var that = this;
this.$copyText(copyContent).then(function () {
that.copied = true;
});
}
}
},
mounted: function mounted() {}
});
// CONCATENATED MODULE: ./components/text/customize.vue?vue&type=script&lang=js&
/* harmony default export */ var text_customizevue_type_script_lang_js_ = (customizevue_type_script_lang_js_);
// CONCATENATED MODULE: ./components/text/customize.vue
/* normalize component */
var customize_component = Object(componentNormalizer["a" /* default */])(
text_customizevue_type_script_lang_js_,
customizevue_type_template_id_56d05148_render,
customizevue_type_template_id_56d05148_staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var customize_api; }
customize_component.options.__file = "components/text/customize.vue"
/* harmony default export */ var customize = (customize_component.exports);
// CONCATENATED MODULE: ./components/text/index.js
/* istanbul ignore next */
text_text.install = function (Vue) {
Vue.component(text_text.name, text_text);
Vue.component(text_link.name, text_link);
Vue.component(customize.name, customize);
};
/* harmony default export */ var components_text = __webpack_exports__["default"] = (text_text);
/***/ }),
/***/ 14:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
/***/ }),
/***/ 142:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 267:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 45:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/input/textarea.vue?vue&type=template&id=5786ca5a&
var render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ class: _vm.prefixCls + "-content " + (_vm.disabled ? "disable" : "") },
[
_vm.showLimitPosition === "inside"
? _c("div", { staticClass: "mds-input-textarea-wrapper" }, [
_c("textarea", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.valueData,
expression: "valueData",
},
],
ref: "textAreaRef",
class: [
_vm.prefixCls + " " + _vm.prefixCls + "-textarea",
_vm.disabled ? "mds-input-disabled" : "",
],
style: _vm.textareaStyles,
attrs: {
maxlength: _vm.max_length,
minlength: _vm.min_length,
rows: _vm.rows,
placeholder: _vm.placeholder,
disabled: _vm.disabled,
},
domProps: { value: _vm.valueData },
on: {
input: [
function ($event) {
if ($event.target.composing) {
return
}
_vm.valueData = $event.target.value
},
_vm.handleInput,
],
keypress: _vm.handleKeyDown,
change: _vm.handleChange,
focus: _vm.handleFocus,
blur: _vm.handleBlur,
},
}),
_vm.max_length
? _c(
"span",
{
class: [
"mds-input-show-limit",
"mds-input-show-limit--inside",
],
},
[_vm._v(_vm._s(_vm.number) + "/" + _vm._s(_vm.max_length))]
)
: _vm._e(),
])
: _vm.showLimitPosition === "outside"
? [
_c("textarea", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.valueData,
expression: "valueData",
},
],
ref: "textAreaRef",
class: [
_vm.prefixCls + " " + _vm.prefixCls + "-textarea",
_vm.disabled ? "mds-input-disabled" : "",
],
style: _vm.textareaStyles,
attrs: {
maxlength: _vm.max_length,
minlength: _vm.min_length,
rows: _vm.rows,
placeholder: _vm.placeholder,
disabled: _vm.disabled,
},
domProps: { value: _vm.valueData },
on: {
input: [
function ($event) {
if ($event.target.composing) {
return
}
_vm.valueData = $event.target.value
},
_vm.handleInput,
],
keypress: _vm.handleKeyDown,
change: _vm.handleChange,
focus: _vm.handleFocus,
blur: _vm.handleBlur,
},
}),
_vm.max_length
? _c("span", { class: ["mds-input-show-limit"] }, [
_vm._v(_vm._s(_vm.number) + "/" + _vm._s(_vm.max_length)),
])
: _vm._e(),
]
: [
_c("textarea", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.valueData,
expression: "valueData",
},
],
ref: "textAreaRef",
class: [
_vm.prefixCls + " " + _vm.prefixCls + "-textarea",
_vm.disabled ? "mds-input-disabled" : "",
],
style: _vm.textareaStyles,
attrs: {
maxlength: _vm.max_length,
minlength: _vm.min_length,
rows: _vm.rows,
placeholder: _vm.placeholder,
disabled: _vm.disabled,
},
domProps: { value: _vm.valueData },
on: {
input: [
function ($event) {
if ($event.target.composing) {
return
}
_vm.valueData = $event.target.value
},
_vm.handleInput,
],
keypress: _vm.handleKeyDown,
change: _vm.handleChange,
focus: _vm.handleFocus,
blur: _vm.handleBlur,
},
}),
],
],
2
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./components/input/textarea.vue?vue&type=template&id=5786ca5a&
// CONCATENATED MODULE: ./components/input/calculateNodeHeight.js
// Thanks to https://github.com/andreypopp/react-textarea-autosize/
/**
* calculateNodeHeight(uiTextNode, useCache = false)
*/
var HIDDEN_TEXTAREA_STYLE = '\n min-height:0 !important;\n max-height:none !important;\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 SIZING_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'];
var computedStyleCache = {};
var hiddenTextarea = void 0;
function calculateNodeStyling(node) {
var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var nodeRef = node.getAttribute('id') || node.getAttribute('data-reactid') || node.getAttribute('name');
if (useCache && computedStyleCache[nodeRef]) {
return computedStyleCache[nodeRef];
}
var style = window.getComputedStyle(node);
var boxSizing = style.getPropertyValue('box-sizing') || style.getPropertyValue('-moz-box-sizing') || style.getPropertyValue('-webkit-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 sizingStyle = SIZING_STYLE.map(function (name) {
return name + ':' + style.getPropertyValue(name);
}).join(';');
var nodeInfo = {
sizingStyle: sizingStyle,
paddingSize: paddingSize,
borderSize: borderSize,
boxSizing: boxSizing
};
if (useCache && nodeRef) {
computedStyleCache[nodeRef] = nodeInfo;
}
return nodeInfo;
}
function calculateNodeHeight(uiTextNode) {
var useCache = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var minRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var maxRows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
}
// Fix wrap="off" issue
// https://github.com/mds-design/mds-design/issues/6577
if (uiTextNode.getAttribute('wrap')) {
hiddenTextarea.setAttribute('wrap', uiTextNode.getAttribute('wrap'));
} else {
hiddenTextarea.removeAttribute('wrap');
}
// Copy all CSS properties that have an impact on the height of the content in
// the textbox
var _calculateNodeStyling = calculateNodeStyling(uiTextNode, useCache),
paddingSize = _calculateNodeStyling.paddingSize,
borderSize = _calculateNodeStyling.borderSize,
boxSizing = _calculateNodeStyling.boxSizing,
sizingStyle = _calculateNodeStyling.sizingStyle;
// Need to have the overflow attribute to hide the scrollbar otherwise
// text-lines will not calculated properly as the shadow will technically be
// narrower for content
hiddenTextarea.setAttribute('style', sizingStyle + ';' + HIDDEN_TEXTAREA_STYLE);
hiddenTextarea.value = uiTextNode.value || uiTextNode.placeholder || '';
var minHeight = -Infinity;
var maxHeight = Infinity;
var height = hiddenTextarea.scrollHeight;
var overflowY = void 0;
if (boxSizing === 'border-box') {
// border-box: add border, since height = content + padding + border
height = height + borderSize;
} else if (boxSizing === 'content-box') {
// remove padding, since height = content
height = height - paddingSize;
}
if (minRows !== null || maxRows !== null) {
// measure height of a textarea with a single row
hiddenTextarea.value = '';
var singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
if (minRows !== null) {
minHeight = singleRowHeight * minRows;
if (boxSizing === 'border-box') {
minHeight = minHeight + paddingSize + borderSize;
}
height = Math.max(minHeight, height);
}
if (maxRows !== null) {
maxHeight = singleRowHeight * maxRows;
if (boxSizing === 'border-box') {
maxHeight = maxHeight + paddingSize + borderSize;
}
overflowY = height > maxHeight ? '' : 'hidden';
height = Math.min(maxHeight, height);
}
}
// Remove scroll bar flash when autosize without maxRows
if (!maxRows) {
overflowY = 'hidden';
}
return { height: height + 'px', minHeight: minHeight + 'px', maxHeight: maxHeight + 'px', overflowY: overflowY };
}
// EXTERNAL MODULE: external "./_mixin/emitter"
var emitter_ = __webpack_require__(14);
var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/input/textarea.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
function onNextFrame(cb) {
if (window.requestAnimationFrame) {
return window.requestAnimationFrame(cb);
}
return window.setTimeout(cb, 1);
}
function clearNextFrameAction(nextFrameId) {
if (window.cancelAnimationFrame) {
window.cancelAnimationFrame(nextFrameId);
} else {
window.clearTimeout(nextFrameId);
}
}
/* harmony default export */ var textareavue_type_script_lang_js_ = ({
name: 'MdsInputTextarea',
mixins: [emitter_default.a],
props: {
autosize: {
type: [Boolean, Object],
default: false
},
prefixCls: {
type: String,
default: 'mds-input'
},
maxlength: {
type: Number
},
minlength: {
type: Number
},
rows: {
type: Number,
default: 4
},
showLimit: {
type: [Boolean, String],
default: undefined
},
placeholder: {
type: String,
default: ''
},
disabled: {
type: Boolean,
default: false
},
value: null
},
data: function data() {
return {
textareaStyles: {},
number: 0
};
},
computed: {
valueData: {
get: function get() {
return this.value || '';
},
set: function set(value) {
this.$emit('input', value);
}
},
max_length: function max_length() {
return this.$attrs.maxlength || this.maxlength;
},
min_length: function min_length() {
return this.$attrs.minlength || this.minlength;
},
showLimitPosition: function showLimitPosition() {
if (this.showLimit === 'outside') return 'outside';
if (this.showLimit === true || this.showLimit === 'inside') return 'inside';
return null; // 不显示
}
},
watch: {
valueData: {
immediate: true,
handler: function handler(newVal) {
var _this = this;
this.$nextTick(function () {
_this.resizeTextarea();
});
if (newVal.length > this.maxlength) {
return false;
} else {
this.number = newVal.length;
}
}
}
},
created: function created() {
this.number = this.valueData.length;
},
methods: {
handleChange: function handleChange(e) {
this.$emit('change', e);
},
handleInput: function handleInput(e) {
if (this.nextFrameActionId) {
clearNextFrameAction(this.nextFrameActionId);
}
this.nextFrameActionId = onNextFrame(this.resizeTextarea);
this.$emit('input', e.target.value);
this.dispatch('MdsFormItem', 'formItemChange', e.target.value);
},
handleKeyDown: function handleKeyDown(e) {
if (e.keyCode === 13) {
this.$emit('press-enter', e);
}
this.$emit('keydown', e);
},
resizeTextarea: function resizeTextarea() {
if (!this.autosize) {
return false;
}
var minRows = this.autosize ? this.autosize.minRows : null;
var maxRows = this.autosize ? this.autosize.maxRows : null;
this.textareaStyles = calculateNodeHeight(this.$refs.textAreaRef, false, minRows, maxRows);
},
handleFocus: function handleFocus(e) {
this.$emit('focus', e);
},
handleBlur: function handleBlur(e) {
this.$emit('blur', e);
this.dispatch('MdsFormItem', 'formItemBlur', e);
},
focus: function focus() {
this.getInput().focus();
},
blur: function blur() {
this.getInput().blur();
},
getInput: function getInput() {
return this.$refs.textAreaRef;
}
},
mounted: function mounted() {
this.resizeTextarea();
}
});
// CONCATENATED MODULE: ./components/input/textarea.vue?vue&type=script&lang=js&
/* harmony default export */ var input_textareavue_type_script_lang_js_ = (textareavue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/input/textarea.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
input_textareavue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "components/input/textarea.vue"
/* harmony default export */ var input_textarea = __webpack_exports__["a"] = (component.exports);
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
/***/ })
/******/ });
});