@mdsfe/mds-ui
Version:
A set of enterprise-class Vue UI components.
709 lines (644 loc) • 20.4 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("./icon"), require("./_mixin/emitter"), require("./input"));
else if(typeof define === 'function' && define.amd)
define(["./icon", "./_mixin/emitter", "./input"], factory);
else {
var a = typeof exports === 'object' ? factory(require("./icon"), require("./_mixin/emitter"), require("./input")) : factory(root["./icon"], root["./_mixin/emitter"], root["./input"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function(__WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__17__) {
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 = 120);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 120:
/***/ (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/inputnumber/style/index.less
var inputnumber_style = __webpack_require__(188);
// CONCATENATED MODULE: ./components/inputnumber/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/inputnumber/inputnumber.vue?vue&type=template&id=6240322c&
var render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{
class: [
_vm.prefixCls + "-inputnumber",
_vm.prefixCls + "-inputnumber-" + _vm.size,
_vm.controlsPosition ? "is-control-right" : "",
_vm.disabled ? "disabled" : "",
],
on: { mouseenter: _vm.handleEnter, mouseleave: _vm.handleLeave },
},
[
!_vm.showHover
? _c(
"span",
{
class: [
_vm.prefixCls + "-inputnumber_decrease",
_vm.isMin ? "disabled" : "",
_vm.disabled ? "disabled" : "",
],
on: { click: _vm.handleDecrease },
},
[
!_vm.controlsPosition
? _c("mds-icon", { attrs: { type: "line-minus" } })
: _c("mds-icon", { attrs: { type: "line-caret-down" } }),
],
1
)
: _vm._e(),
!_vm.showHover
? _c(
"span",
{
class: [
_vm.prefixCls + "-inputnumber_increase",
_vm.isMax ? "disabled" : "",
_vm.disabled ? "disabled" : "",
],
on: { click: _vm.handleIncrease },
},
[
!_vm.controlsPosition
? _c("mds-icon", { attrs: { type: "line-plus" } })
: _c("mds-icon", { attrs: { type: "line-caret-up" } }),
],
1
)
: _vm._e(),
_c(
"div",
{
class: [
_vm.prefixCls + "-inputnumber-input",
_vm.disabled ? "disabled" : "",
],
},
[
_c("mds-input", {
attrs: {
value: _vm.formatterValue,
max: _vm.max,
min: _vm.min,
placeholder: _vm.placeholder,
disabled: _vm.disabled,
},
on: {
blur: _vm.handleBlur,
change: _vm.handleChange,
focus: _vm.handleFocus,
input: _vm.handleInput,
},
}),
],
1
),
]
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./components/inputnumber/inputnumber.vue?vue&type=template&id=6240322c&
// EXTERNAL MODULE: external "./icon"
var external_icon_ = __webpack_require__(7);
var external_icon_default = /*#__PURE__*/__webpack_require__.n(external_icon_);
// EXTERNAL MODULE: external "./input"
var external_input_ = __webpack_require__(17);
var external_input_default = /*#__PURE__*/__webpack_require__.n(external_input_);
// CONCATENATED MODULE: ./components/inputnumber/props.js
/* harmony default export */ var props = ({
props: {
value: {
type: [String, Number],
default: ''
},
min: {
type: Number,
default: -Infinity
},
max: {
type: Number,
default: Infinity
},
precision: {
type: Number,
default: 0,
validator: function validator(val) {
return val >= 0 && val === parseInt(val, 10);
}
},
hover: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ''
},
controlsPosition: {
type: String,
default: '',
validator: function validator(value) {
return ['right', ''].indexOf(value) !== -1;
}
},
step: {
type: Number,
default: 1
},
size: {
type: String,
validator: function validator(value) {
return ['large', 'medium', 'small', 'mini'].indexOf(value) !== -1;
},
default: 'medium'
},
disabled: {
type: Boolean,
default: false
},
prefixCls: {
type: String,
default: 'mds'
},
formatter: {
type: Function
},
parser: {
type: Function
},
change: {
type: Function,
default: function _default() {}
},
blur: {
type: Function,
default: function _default() {}
},
focus: {
type: Function,
default: function _default() {}
},
stepStrictly: Boolean
}
});
// 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/inputnumber/inputnumber.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var inputnumbervue_type_script_lang_js_ = ({
name: 'MdsInputnumber',
data: function data() {
return {
val: this.__percisionToRetain(this.value),
resetVal: '',
showHover: this.hover
};
},
components: {
MdsIcon: external_icon_default.a,
MdsInput: external_input_default.a
},
mixins: [props, emitter_default.a],
computed: {
isMax: function isMax() {
return parseFloat(this.val) >= this.max;
},
isMin: function isMin() {
return parseFloat(this.val) <= this.min;
},
precisionValue: {
get: function get() {
if (!this.val) return this.val;
return this.precision ? this.__addPercision(this.value) : this.val;
},
set: function set(value) {}
},
formatterValue: {
get: function get() {
if (this.formatter && this.precisionValue !== null) {
return this.formatter(this.precisionValue);
} else {
return this.precisionValue;
}
},
set: function set(value) {}
}
},
created: function created() {
this.resetVal = parseFloat(this.val);
this.checkCodeValue(this.val, true);
this.checkInitValue();
},
methods: {
checkStepStrictly: function checkStepStrictly() {},
checkInitValue: function checkInitValue() {
if (this.val === '') {
this.val = 0;
}
},
__toPrecision: function __toPrecision(val) {
return this.precision ? this.__percisionToRetain(Math.round(val * Math.pow(10, this.precision)) / Math.pow(10, this.precision)) : val;
},
__percisionToRetain: function __percisionToRetain(val) {
var value = typeof val === 'number' ? String(val) : val;
if (this.precision) {
return this.__addPercision(value);
} else {
return val;
}
},
__addPercision: function __addPercision(val) {
if (val.indexOf('.') !== -1) {
var num = val.length - val.indexOf('.') - 1;
if (num <= this.precision) {
return this.__loopRetain(this.precision - num, val);
} else {
console.error('precision should not be less than the decimal places of step');
}
} else {
return this.__loopRetain(this.precision, val + '.');
}
},
__loopRetain: function __loopRetain(val, str) {
var strNum = str;
for (var i = 0; i < val; i++) {
strNum += '0';
}
return strNum;
},
handleFocus: function handleFocus() {
this.$emit('focus', this);
},
handleBlur: function handleBlur() {
this.$emit('blur', this);
this.dispatch('MdsFormItem', 'formItemBlur', this.formatterValue);
},
checkCodeValue: function checkCodeValue(value, initFlag) {
var reg = /^[+-]?\d+(\.\d+)?$/;
var pattern = new RegExp(reg);
if (pattern.test(Number(value))) {
this.val = value;
} else {
this.val = this.__toPrecision(this.value);
}
if (value !== undefined) {
if (isNaN(value)) {
return;
}
}
if (this.stepStrictly) {
var valueString = value + '';
var dotPosition = valueString.indexOf('.');
var precision = 0;
if (dotPosition !== -1) {
precision = valueString.length - dotPosition - 1;
}
var precisionFactor = Math.pow(10, precision);
value = Math.round(value / this.step) * precisionFactor * this.step / precisionFactor;
}
if (value >= this.max) value = this.max;
if (value <= this.min) value = this.min;
this.val = value;
if (!initFlag) {
this.$emit('input', value);
this.$emit('change', value);
}
},
handleChange: function handleChange(e) {
this.val = e.target.value.trim();
if (this.parser) {
var reg = /^[+-]?\d+(\.\d+)?$/;
var pattern = new RegExp(reg);
if (pattern.test(Number(this.val))) {
e.target.value = this.parser(this.val);
} else {
e.target.value = this.parser(this.value);
}
} else {
this.checkCodeValue(this.val);
e.target.value = this.val;
this.resetVal = this.val;
}
this.dispatch('MdsFormItem', 'formItemChange', this.formatterValue);
},
handleInput: function handleInput(value) {
this.resetVal = value;
},
handleDecrease: function handleDecrease() {
if (this.disabled) return;
this.val = this.__toPrecision(!isNaN(parseFloat(this.val)) ? parseFloat(this.val) - this.step * 1 >= this.min ? parseFloat(this.val) - this.step * 1 : this.min : this.resetVal);
this.$emit('change', this.formatterValue);
this.dispatch('MdsFormItem', 'formItemChange', this.formatterValue);
},
handleIncrease: function handleIncrease() {
if (this.disabled) return;
this.val = this.__toPrecision(!isNaN(parseFloat(this.val)) ? parseFloat(this.val) + this.step * 1 <= this.max ? parseFloat(this.val) + this.step * 1 : this.max : this.resetVal);
this.$emit('change', this.formatterValue);
this.dispatch('MdsFormItem', 'formItemChange', this.formatterValue);
},
handleEnter: function handleEnter() {
if (this.disabled || !this.controlsPosition || !this.hover) return;
this.showHover = false;
},
handleLeave: function handleLeave() {
if (this.disabled || !this.controlsPosition || !this.hover) return;
this.showHover = true;
}
},
watch: {
val: function val(newVal) {
this.$emit('input', '' + newVal);
},
value: {
handler: function handler(newVal, oldVal) {
if (newVal !== oldVal) {
this.val = newVal;
}
},
immediate: true
}
}
});
// CONCATENATED MODULE: ./components/inputnumber/inputnumber.vue?vue&type=script&lang=js&
/* harmony default export */ var inputnumber_inputnumbervue_type_script_lang_js_ = (inputnumbervue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/inputnumber/inputnumber.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
inputnumber_inputnumbervue_type_script_lang_js_,
render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "components/inputnumber/inputnumber.vue"
/* harmony default export */ var inputnumber = (component.exports);
// CONCATENATED MODULE: ./components/inputnumber/index.js
/* istanbul ignore next */
inputnumber.install = function (Vue) {
Vue.component(inputnumber.name, inputnumber);
};
/* harmony default export */ var components_inputnumber = __webpack_exports__["default"] = (inputnumber);
/***/ }),
/***/ 14:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
/***/ }),
/***/ 142:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 17:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
/***/ }),
/***/ 188:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
/***/ })
/******/ });
});