kingdot
Version:
A UI Components Library For Vue
431 lines (403 loc) • 13.9 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 = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 40);
/******/ })
/************************************************************************/
/******/ ({
/***/ 10:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var src_mixin_lang_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
/* harmony default export */ __webpack_exports__["a"] = ({
name: 'KdButton',
mixins: [src_mixin_lang_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]],
props: {
value: {
type: [Number, String]
},
type: {
type: String,
default: 'default'
},
disabled: {
type: Boolean,
default: false
},
icon: {
type: String,
default: ''
},
loading: {
type: Boolean,
default: false
},
size: {
type: String,
default: 'middle'
},
shape: {
type: String,
default: ''
},
hollow: {
type: Boolean,
default: false
},
split: {
type: Boolean,
default: false
},
nativeType: {
type: String,
default: 'button'
},
authid: {
type: String,
default: ''
},
clickDelay: {
type: Boolean,
default: false
},
delayTime: {
type: Number,
default: 3000
},
href: {
type: String,
default: null
},
target: {
type: String,
default: '_self'
}
},
data: function data() {
return {
isActive: false,
disabledStatus: this.disabled,
authAbled: true,
delayDisable: false,
link: null,
linkTarget: '_self',
isShow: true
};
},
computed: {
// 所有样式类
allClassList: function allClassList() {
var allClassAry = ['kd-btn', 'kd-btn-' + this.type, this.shape ? 'kd-btn-' + this.shape : '', this.size ? 'kd-btn-' + this.size : '', {
'kd-btn-active': this.isActive,
'kd-btn-split': this.split,
'kd-btn-disabled': this.disabledStatus || !this.authAbled,
'kd-btn-hollow': this.hollow,
'kd-btn-loading': this.loading
}];
return allClassAry;
},
enableStatus: function enableStatus() {
if (this.authid) {
return this.$KD && this.$KD.getEnabledStatus ? this.$KD.getEnabledStatus(this.authid) : true;
} else {
return true;
}
},
btnShowStatus: function btnShowStatus() {
return this.$KD && this.$KD.setBtnEnableType ? this.$KD.setBtnEnableType() === 'disabled' : true;
}
},
watch: {
disabled: {
immediate: true,
handler: function handler(v) {
this.checkAuth();
this.handleHerf();
this.disabledStatus = v;
}
},
authid: function authid() {
var _this = this;
this.$nextTick(function () {
_this.checkAuth();
});
},
href: {
immediate: true,
handler: function handler(v) {
this.link = v;
this.handleHerf();
}
},
target: {
immediate: true,
handler: function handler(v) {
this.linkTarget = v;
this.handleHerf();
}
}
},
mounted: function mounted() {
this.initActive();
},
methods: {
checkAuth: function checkAuth() {
if (!this.authid) return;
if (this.enableStatus) {
this.isShow = true;
this.authAbled = !this.disabled;
} else {
if (this.btnShowStatus) {
this.authAbled = false;
this.isShow = true;
} else {
this.isShow = false;
}
}
},
handleHerf: function handleHerf() {
if (!this.authAbled || this.disabled) {
this.link = null;
this.linkTarget = '_self';
this.disabledStatus = true;
} else {
this.linkTarget = this.target;
if (this.$KD && this.$KD.setButtonLink) {
this.link = this.$KD.setButtonLink(this.href);
}
}
},
initActive: function initActive() {
var _this2 = this;
var parent = this.$parent;
if (!parent) return;
if (parent.$options._componentTag === 'kd-button-group') {
if (parent.checkType === 'radio') {
if (parent.value === this.value) this.isActive = true;
} else if (parent.checkType === 'checkbox') {
parent.value.forEach(function (item) {
if (item === _this2.value) _this2.isActive = true;
});
}
if (parent.disabledStatus) this.disabledStatus = true;
}
},
// 点击事件
handleClick: function handleClick(e) {
var _this3 = this;
if (!this.authAbled || this.disabled || this.loading) {
return;
}
this.$emit('click', e);
if (this.clickDelay) {
this.disabledStatus = true;
window.setTimeout(function () {
_this3.disabledStatus = false;
}, this.delayTime);
}
var parent = this.$parent;
if (!parent) return;
if (parent.$options._componentTag === 'kd-button-group') {
this.$parent.emit(this.value, this.isActive);
}
},
active: function active() {
this.isActive = true;
},
showLoading: function showLoading() {
this.loading = true;
this.disabled = true;
},
hideLoading: function hideLoading() {
this.loading = false;
this.disabled = false;
}
},
render: function render(h, ctx) {
if (this.isShow) {
if (this.type !== 'text') {
return h(
'button',
{
'class': this.allClassList,
attrs: { type: this.nativeType
},
on: {
'click': this.handleClick
}
},
[this.loading ? h(
'span',
{
'class': ['kd-btn-loading-icon', { 'kd-icon-left': this.$slots.default }]
},
[h(
'svg',
{
attrs: { viewBox: '0 0 120 120' }
},
[h('circle', {
attrs: {
cx: '60',
cy: '60',
r: '57'
},
'class': 'kd-spin-circle' })]
)]
) : '', this.icon ? h('i', { 'class': this.icon }) : '', this.$slots.default ? h(
'span',
{ 'class': [{ 'kd-icon-right': this.icon && this.$slots.default[0].text }] },
[this.$slots.default]
) : '']
);
} else {
return h(
'a',
{
attrs: {
href: this.link,
target: this.linkTarget
},
'class': this.allClassList, on: {
'click': this.handleClick
}
},
[this.$slots.default]
);
}
}
}
});
/***/ }),
/***/ 4:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// CONCATENATED MODULE: ./src/lang/zh-CN/index.js
/* harmony default export */ var zh_CN = ({
button: {
confirm: '确定'
}
});
// CONCATENATED MODULE: ./src/lang/index.js
var defaultComponentWords = zh_CN;
var currentComponentWords = defaultComponentWords;
var lang_translate = function translate(path) {
if (i18nHandler) {
// 支持vue-i18n 改写组件语言
return i18nHandler.apply(this, arguments) || '';
}
var currentLang = currentComponentWords;
var array = path.split('.');
return currentLang[array[0]][array[1]];
};
var i18nHandler = void 0;
var i18n = function i18n(fn) {
i18nHandler = fn;
};
var use = function use(wordsMap) {
currentComponentWords = wordsMap || defaultComponentWords;
};
// CONCATENATED MODULE: ./src/mixin/lang.js
/* harmony default export */ var lang = __webpack_exports__["a"] = ({
methods: {
translate: function translate() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return lang_translate.apply(this, args);
}
}
});
/***/ }),
/***/ 40:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _button_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
_button_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].install = function (Vue) {
Vue.component(_button_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].name, _button_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]);
};
/* harmony default export */ __webpack_exports__["default"] = (_button_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]);
/***/ })
/******/ })["default"];