@bic-fe/mds-ui
Version:
A set of enterprise-class Vue UI components.
762 lines (666 loc) • 21.3 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("./_util/proptype"), require("./_mixin/emitter"));
else if(typeof define === 'function' && define.amd)
define(["./_util/proptype", "./_mixin/emitter"], factory);
else {
var a = typeof exports === 'object' ? factory(require("./_util/proptype"), require("./_mixin/emitter")) : factory(root["./_util/proptype"], 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__12__) {
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 = 103);
/******/ })
/************************************************************************/
/******/ ({
/***/ 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
}
}
/***/ }),
/***/ 103:
/***/ (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__(139);
// EXTERNAL MODULE: ./components/radio/style/index.less
var radio_style = __webpack_require__(207);
// CONCATENATED MODULE: ./components/radio/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/radio/radio.vue?vue&type=template&id=0cfde37c&
var radiovue_type_template_id_0cfde37c_render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c("label", { class: _vm.classes, on: { click: _vm.handleClick } }, [
_c("span", { class: _vm.spanClasses }, [
_c("input", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.model,
expression: "model",
},
],
class: this.prefixCls + "-input",
attrs: { type: "radio", name: _vm.name },
domProps: { value: _vm.value, checked: _vm._q(_vm.model, _vm.value) },
on: {
change: function ($event) {
_vm.model = _vm.value
},
},
}),
_c("span", { class: this.prefixCls + "-inner" }),
]),
_c("span", [_vm._t("default")], 2),
])
}
var staticRenderFns = []
radiovue_type_template_id_0cfde37c_render._withStripped = true
// CONCATENATED MODULE: ./components/radio/radio.vue?vue&type=template&id=0cfde37c&
// EXTERNAL MODULE: external "babel-runtime/helpers/defineProperty"
var defineProperty_ = __webpack_require__(3);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/radio/radio.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var radiovue_type_script_lang_js_ = ({
name: 'MdsRadio',
props: {
checked: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
name: {
type: String,
default: ''
},
prefixCls: {
type: String,
default: 'mds-radio'
},
modelValue: null,
value: null,
check: null
},
model: {
prop: 'modelValue',
event: 'input'
},
data: function data() {
return {
checkedValue: this.checked,
_radioGroup: null,
parent: null
};
},
computed: {
classes: function classes() {
var _ref;
return [this.prefixCls + '-wrapper', (_ref = {}, defineProperty_default()(_ref, this.prefixCls + '-wrapper-checked', this.checkedValue), defineProperty_default()(_ref, this.prefixCls + '-wrapper-disabled', this.isDisabled), _ref)];
},
spanClasses: function spanClasses() {
var _ref2;
return [this.prefixCls, (_ref2 = {}, defineProperty_default()(_ref2, this.prefixCls + '-checked', this.checkedValue), defineProperty_default()(_ref2, this.prefixCls + '-disabled', this.isDisabled), _ref2)];
},
isDisabled: function isDisabled() {
return this.isRadioGroup ? this._radioGroup.disabled || this.disabled : this.disabled;
},
isRadioGroup: function isRadioGroup() {
this.parent = this.$parent;
while (this.parent) {
if (this.parent.$options.name !== 'MdsRadioGroup') {
this.parent = this.parent.$parent;
} else {
this._radioGroup = this.parent;
return true;
}
}
return false;
},
model: {
get: function get() {
this.checkedValue = this.modelValue === this.value;
return this.modelValue;
},
set: function set(val) {}
}
},
methods: {
handleClick: function handleClick() {
var _this = this;
if (this.checkedValue === true) {
return;
}
if (!this.isDisabled) {
this.checkedValue = true;
}
if (this.isRadioGroup && this.isDisabled !== true) {
this.parent.change(this.value);
} else if (!this.isRadioGroup && this.isDisabled !== true) {
this.$emit('input', this.value);
this.$nextTick(function () {
_this.$emit('change', _this.model);
});
}
},
checkChange: function checkChange(value) {
this.checkedValue = value;
}
},
watch: {
check: function check() {
this.checkedValue = this.checked === this.value;
},
value: {
handler: function handler(val) {
this.checkedValue = this.checked === this.value;
if (this.isRadioGroup) {
this.parent.checkModel(this.value);
}
},
immediate: true
}
}
});
// CONCATENATED MODULE: ./components/radio/radio.vue?vue&type=script&lang=js&
/* harmony default export */ var radio_radiovue_type_script_lang_js_ = (radiovue_type_script_lang_js_);
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(0);
// CONCATENATED MODULE: ./components/radio/radio.vue
/* normalize component */
var component = Object(componentNormalizer["a" /* default */])(
radio_radiovue_type_script_lang_js_,
radiovue_type_template_id_0cfde37c_render,
staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var api; }
component.options.__file = "components/radio/radio.vue"
/* harmony default export */ var radio_radio = (component.exports);
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./components/radio/group.vue?vue&type=template&id=23243800&
var groupvue_type_template_id_23243800_render = function () {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ class: _vm.classes },
[
_vm.isOptions
? _c(
"div",
_vm._l(_vm.options, function (option, index) {
return _c(
"span",
{ key: index },
[
_c(
"radio",
{
attrs: {
value: _vm.calculateValue(option),
disabled: _vm.calculateDisabled(option),
name: _vm.name,
},
},
[_vm._v(_vm._s(_vm.calculateLabel(option)))]
),
],
1
)
}),
0
)
: _vm._e(),
!_vm.isOptions ? _vm._t("default") : _vm._e(),
],
2
)
}
var groupvue_type_template_id_23243800_staticRenderFns = []
groupvue_type_template_id_23243800_render._withStripped = true
// CONCATENATED MODULE: ./components/radio/group.vue?vue&type=template&id=23243800&
// EXTERNAL MODULE: external "babel-runtime/helpers/typeof"
var typeof_ = __webpack_require__(9);
var typeof_default = /*#__PURE__*/__webpack_require__.n(typeof_);
// EXTERNAL MODULE: external "./_util/proptype"
var proptype_ = __webpack_require__(7);
// EXTERNAL MODULE: external "./_mixin/emitter"
var emitter_ = __webpack_require__(12);
var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./components/radio/group.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var groupvue_type_script_lang_js_ = ({
name: 'MdsRadioGroup',
mixins: [emitter_default.a],
props: {
disabled: {
type: Boolean,
default: undefined
},
name: {
type: String,
default: ''
},
options: {
type: Array,
default: function _default() {
return [];
}
},
prefixCls: {
type: String,
default: 'mds-radio'
},
size: {
type: String,
default: 'default',
validator: function validator(value) {
return Object(proptype_["oneOf"])(value, ['large', 'default', 'small']);
}
},
value: null
},
data: function data() {
return {
currentValue: this.value,
valueList: [],
radioList: []
};
},
computed: {
classes: function classes() {
return [this.prefixCls + '-group', defineProperty_default()({}, this.prefixCls + '-group-' + this.size, this.size)];
},
isOptions: function isOptions() {
return this.options.length !== 0;
}
},
methods: {
checkModel: function checkModel(val) {
var _this = this;
this.initValueList();
if (val === this.value) {
this.$nextTick(function () {
_this.change(val, true);
});
}
},
change: function change(val, firstRenderFlag) {
// 在子组件调用,点击子组件,当其父组件为groupRadio时,会出发此事件
this.currentValue = val;
this.judge();
this.$emit('input', val);
if (!firstRenderFlag) {
this.$emit('change', this.currentValue);
}
this.dispatch('MdsFormItem', 'formItemChange', val);
},
initValueList: function initValueList() {
// 获取子组件的values列表
this.radioList = this.$children.filter(function (item) {
return item.$options.name === 'MdsRadio';
});
this.valueList = this.radioList.map(function (item) {
return item.value;
});
this.disableChildren();
this.judge();
},
judge: function judge() {
var _this2 = this;
// 判断点击的是哪一个子组件并为其设置选中状态
this.valueList.forEach(function (item, index) {
if (item === _this2.currentValue) {
_this2.radioList[index].checkChange(true);
} else {
_this2.radioList[index].checkChange(false);
}
});
},
calculateValue: function calculateValue(option) {
var type = option ? typeof option === 'undefined' ? 'undefined' : typeof_default()(option) : '';
if (type === 'object') {
return option.value;
} else {
return option;
}
},
calculateLabel: function calculateLabel(option) {
var type = option ? typeof option === 'undefined' ? 'undefined' : typeof_default()(option) : '';
if (type === 'object') {
return option.label;
} else {
return option;
}
},
calculateDisabled: function calculateDisabled(option) {
if (typeof option.disabled === 'undefined') {
return false;
} else {
return option.disabled;
}
},
disableChildren: function disableChildren() {
if (this.disabled === undefined) {
return '';
}
// 如果处于禁用状态,为子slot设上disable
if (this.disabled) {
this.radioList.forEach(function (item) {
item.$data.disabledValue = true;
});
} else {
this.radioList.forEach(function (item) {
item.$data.disabledValue = false;
});
}
}
},
watch: {
value: function value(val) {
this.currentValue = val;
this.judge();
// this.$emit('change', this.currentValue)
},
disabled: function disabled() {
this.disableChildren();
},
options: function options() {
var _this3 = this;
this.$nextTick(function () {
_this3.initValueList();
});
}
},
mounted: function mounted() {
this.initValueList();
},
beforeUpdate: function beforeUpdate() {
this.initValueList();
},
components: {
Radio: radio_radio
}
});
// CONCATENATED MODULE: ./components/radio/group.vue?vue&type=script&lang=js&
/* harmony default export */ var radio_groupvue_type_script_lang_js_ = (groupvue_type_script_lang_js_);
// CONCATENATED MODULE: ./components/radio/group.vue
/* normalize component */
var group_component = Object(componentNormalizer["a" /* default */])(
radio_groupvue_type_script_lang_js_,
groupvue_type_template_id_23243800_render,
groupvue_type_template_id_23243800_staticRenderFns,
false,
null,
null,
null
)
/* hot reload */
if (false) { var group_api; }
group_component.options.__file = "components/radio/group.vue"
/* harmony default export */ var group = (group_component.exports);
// CONCATENATED MODULE: ./components/radio/radio-button.js
/* harmony default export */ var radio_button = ({
name: 'MdsRadioBtn',
functional: true,
render: function render(h, ctx) {
ctx.props.prefixCls = ctx.props.prefixCls || 'mds-radio-button';
return h(radio_radio, ctx, ctx.children);
}
});
// CONCATENATED MODULE: ./components/radio/index.js
/**
* Created by echaoo on 17/10/5.
*/
radio_radio.Group = group;
radio_radio.Button = radio_button;
/* istanbul ignore next */
radio_radio.install = function (Vue) {
Vue.component(radio_radio.name, radio_radio);
Vue.component(group.name, group);
Vue.component(radio_button.name, radio_button);
};
/* harmony default export */ var components_radio = __webpack_exports__["default"] = (radio_radio);
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
/***/ }),
/***/ 139:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 207:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
module.exports = require("babel-runtime/helpers/defineProperty");
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
/***/ }),
/***/ 9:
/***/ (function(module, exports) {
module.exports = require("babel-runtime/helpers/typeof");
/***/ })
/******/ });
});