@cw-devops/bk-magic-vue
Version:
基于蓝鲸 Magicbox 和 Vue 的前端组件库
1,531 lines (1,464 loc) • 72.2 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
(global = global || self, factory(global.library = {}, global.Vue));
}(this, function (exports, Vue) { 'use strict';
Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? Object(arguments[i]) : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}var normalMerge=["attrs","props","domProps"],toArrayMerge=["class","style","directives"],functionalMerge=["on","nativeOn"],mergeJsxProps=function(a){return a.reduce(function(c,a){for(var b in a)if(!c[b])c[b]=a[b];else if(-1!==normalMerge.indexOf(b))c[b]=_extends({},c[b],a[b]);else if(-1!==toArrayMerge.indexOf(b)){var d=c[b]instanceof Array?c[b]:[c[b]],e=a[b]instanceof Array?a[b]:[a[b]];c[b]=d.concat(e);}else if(-1!==functionalMerge.indexOf(b)){for(var f in a[b])if(c[b][f]){var g=c[b][f]instanceof Array?c[b][f]:[c[b][f]],h=a[b][f]instanceof Array?a[b][f]:[a[b][f]];c[b][f]=g.concat(h);}else c[b][f]=a[b][f];}else if("hook"==b)for(var i in a[b])c[b][i]=c[b][i]?mergeFn(c[b][i],a[b][i]):a[b][i];else c[b]=a[b];return c},{})},mergeFn=function(a,b){return function(){a&&a.apply(this,arguments),b&&b.apply(this,arguments);}};var helper=mergeJsxProps;
var _defined = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
var _toObject = function (it) {
return Object(_defined(it));
};
var hasOwnProperty = {}.hasOwnProperty;
var _has = function (it, key) {
return hasOwnProperty.call(it, key);
};
var toString = {}.toString;
var _cof = function (it) {
return toString.call(it).slice(8, -1);
};
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return _cof(it) == 'String' ? it.split('') : Object(it);
};
var _toIobject = function (it) {
return _iobject(_defined(it));
};
var ceil = Math.ceil;
var floor = Math.floor;
var _toInteger = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
var min = Math.min;
var _toLength = function (it) {
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0;
};
var max = Math.max;
var min$1 = Math.min;
var _toAbsoluteIndex = function (index, length) {
index = _toInteger(index);
return index < 0 ? max(index + length, 0) : min$1(index, length);
};
var _arrayIncludes = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = _toIobject($this);
var length = _toLength(O.length);
var index = _toAbsoluteIndex(fromIndex, length);
var value;
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++];
if (value != value) return true;
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
if (O[index] === el) return IS_INCLUDES || index || 0;
} return !IS_INCLUDES && -1;
};
};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.12' };
if (typeof __e == 'number') __e = core;
});
var _core_1 = _core.version;
var _global = createCommonjsModule(function (module) {
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self
: Function('return this')();
if (typeof __g == 'number') __g = global;
});
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: 'pure' ,
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
});
});
var id = 0;
var px = Math.random();
var _uid = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var shared = _shared('keys');
var _sharedKey = function (key) {
return shared[key] || (shared[key] = _uid(key));
};
var arrayIndexOf = _arrayIncludes(false);
var IE_PROTO = _sharedKey('IE_PROTO');
var _objectKeysInternal = function (object, names) {
var O = _toIobject(object);
var i = 0;
var result = [];
var key;
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
while (names.length > i) if (_has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
var _enumBugKeys = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
var _objectKeys = Object.keys || function keys(O) {
return _objectKeysInternal(O, _enumBugKeys);
};
var _aFunction = function (it) {
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
return it;
};
var _ctx = function (fn, that, length) {
_aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1: return function (a) {
return fn.call(that, a);
};
case 2: return function (a, b) {
return fn.call(that, a, b);
};
case 3: return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function () {
return fn.apply(that, arguments);
};
};
var _isObject = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
var _anObject = function (it) {
if (!_isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
var _fails = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
var _descriptors = !_fails(function () {
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
});
var document = _global.document;
var is = _isObject(document) && _isObject(document.createElement);
var _domCreate = function (it) {
return is ? document.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function () {
return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
});
var _toPrimitive$1 = function (it, S) {
if (!_isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
var dP = Object.defineProperty;
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
_anObject(O);
P = _toPrimitive$1(P, true);
_anObject(Attributes);
if (_ie8DomDefine) try {
return dP(O, P, Attributes);
} catch (e) { }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var _objectDp = {
f: f
};
var _propertyDesc = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var _hide = _descriptors ? function (object, key, value) {
return _objectDp.f(object, key, _propertyDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var IS_WRAP = type & $export.W;
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
var expProto = exports[PROTOTYPE];
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
var key, own, out;
if (IS_GLOBAL) source = name;
for (key in source) {
own = !IS_FORCED && target && target[key] !== undefined;
if (own && _has(exports, key)) continue;
out = own ? target[key] : source[key];
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
: IS_BIND && own ? _ctx(out, _global)
: IS_WRAP && target[key] == out ? (function (C) {
var F = function (a, b, c) {
if (this instanceof C) {
switch (arguments.length) {
case 0: return new C();
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
})(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
if (IS_PROTO) {
(exports.virtual || (exports.virtual = {}))[key] = out;
if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
}
}
};
$export.F = 1;
$export.G = 2;
$export.S = 4;
$export.P = 8;
$export.B = 16;
$export.W = 32;
$export.U = 64;
$export.R = 128;
var _export = $export;
var _objectSap = function (KEY, exec) {
var fn = (_core.Object || {})[KEY] || Object[KEY];
var exp = {};
exp[KEY] = exec(fn);
_export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
};
_objectSap('keys', function () {
return function keys(it) {
return _objectKeys(_toObject(it));
};
});
var keys = _core.Object.keys;
var keys$1 = keys;
var _isArray = Array.isArray || function isArray(arg) {
return _cof(arg) == 'Array';
};
_export(_export.S, 'Array', { isArray: _isArray });
var isArray = _core.Array.isArray;
var isArray$1 = isArray;
var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
var space = '[' + _stringWs + ']';
var non = '\u200b\u0085';
var ltrim = RegExp('^' + space + space + '*');
var rtrim = RegExp(space + space + '*$');
var exporter = function (KEY, exec, ALIAS) {
var exp = {};
var FORCE = _fails(function () {
return !!_stringWs[KEY]() || non[KEY]() != non;
});
var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY];
if (ALIAS) exp[ALIAS] = fn;
_export(_export.P + _export.F * FORCE, 'String', exp);
};
var trim = exporter.trim = function (string, TYPE) {
string = String(_defined(string));
if (TYPE & 1) string = string.replace(ltrim, '');
if (TYPE & 2) string = string.replace(rtrim, '');
return string;
};
var _stringTrim = exporter;
var $parseInt = _global.parseInt;
var $trim = _stringTrim.trim;
var hex = /^[-+]?0[xX]/;
var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) {
var string = $trim(String(str), 3);
return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
} : $parseInt;
_export(_export.G + _export.F * (parseInt != _parseInt), { parseInt: _parseInt });
var _parseInt$1 = _core.parseInt;
var _parseInt$2 = _parseInt$1;
var $JSON = _core.JSON || (_core.JSON = { stringify: JSON.stringify });
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
function hasOwn(obj, key) {
return hasOwnProperty$1.call(obj, key);
}
function getPropByPath(obj, path, strict) {
var tempObj = obj;
path = path.replace(/\[(\w+)\]/g, '.$1');
path = path.replace(/^\./, '');
var keyArr = path.split('.');
var i = 0;
for (var len = keyArr.length; i < len - 1; ++i) {
if (!tempObj && !strict) break;
var key = keyArr[i];
if (key in tempObj) {
tempObj = tempObj[key];
} else {
if (strict) {
throw new Error('please transfer a valid prop path to form item!');
}
break;
}
}
return {
o: tempObj,
k: keyArr[i],
v: tempObj ? tempObj[keyArr[i]] : null
};
}
function mergeOptions(defaults, config) {
var options = {};
var key;
for (key in defaults) {
options[key] = defaults[key];
}
for (key in config) {
if (hasOwn(config, key)) {
var value = config[key];
if (typeof value !== 'undefined') {
options[key] = value;
}
}
}
return options;
}
function parseWidth(width) {
if (width !== undefined) {
width = _parseInt$2(width, 10);
if (isNaN(width)) {
width = null;
}
}
return width;
}
function parseMinWidth(minWidth) {
if (typeof minWidth !== 'undefined') {
minWidth = parseWidth(minWidth);
if (isNaN(minWidth)) {
minWidth = 80;
}
}
return minWidth;
}
function compose() {
for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
funcs[_key2] = arguments[_key2];
}
if (funcs.length === 0) {
return function (arg) {
return arg;
};
}
if (funcs.length === 1) {
return funcs[0];
}
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(void 0, arguments));
};
});
}
function _broadcast(componentName, eventName, params) {
this.$children.forEach(function (child) {
var name = child.$options.componentName;
if (name === componentName) {
child.$emit.apply(child, [eventName].concat(params));
} else {
_broadcast.apply(child, [componentName, eventName].concat([params]));
}
});
}
var Emitter = {
methods: {
dispatch: function dispatch(componentName, eventName, params) {
var parent = this.$parent || this.$root;
var name = parent.$options.componentName;
while (parent && (!name || name !== componentName)) {
parent = parent.$parent;
if (parent) {
name = parent.$options.componentName;
}
}
if (parent) {
parent.$emit.apply(parent, [eventName].concat(params));
}
},
broadcast: function broadcast(componentName, eventName, params) {
_broadcast.call(this, componentName, eventName, params);
}
}
};
var script = {
name: 'BkCheckbox',
mixins: [Emitter],
inject: {
elForm: {
default: ''
},
elFormItem: {
default: ''
}
},
componentName: 'ElCheckbox',
props: {
value: {},
label: {},
indeterminate: Boolean,
disabled: Boolean,
checked: Boolean,
name: String,
trueLabel: [String, Number],
falseLabel: [String, Number],
id: String,
controls: String,
border: Boolean,
size: String
},
data: function data() {
return {
selfModel: false,
focus: false,
isLimitExceeded: false
};
},
computed: {
model: {
get: function get() {
return this.isGroup ? this.store : this.value !== undefined ? this.value : this.selfModel;
},
set: function set(val) {
if (this.isGroup) {
this.isLimitExceeded = false;
this._checkboxGroup.min !== undefined && val.length < this._checkboxGroup.min && (this.isLimitExceeded = true);
this._checkboxGroup.max !== undefined && val.length > this._checkboxGroup.max && (this.isLimitExceeded = true);
this.isLimitExceeded === false && this.dispatch('ElCheckboxGroup', 'input', [val]);
} else {
this.$emit('input', val);
this.selfModel = val;
}
}
},
isChecked: function isChecked() {
if ({}.toString.call(this.model) === '[object Boolean]') {
return this.model;
} else if (isArray$1(this.model)) {
return this.model.indexOf(this.label) > -1;
} else if (this.model !== null && this.model !== undefined) {
return this.model === this.trueLabel;
} else {
return false;
}
},
isGroup: function isGroup() {
var parent = this.$parent;
while (parent) {
if (parent.$options.componentName !== 'ElCheckboxGroup') {
parent = parent.$parent;
} else {
this._checkboxGroup = parent;
return true;
}
}
return false;
},
store: function store() {
return this._checkboxGroup ? this._checkboxGroup.value : this.value;
},
isLimitDisabled: function isLimitDisabled() {
var _this$_checkboxGroup = this._checkboxGroup,
max = _this$_checkboxGroup.max,
min = _this$_checkboxGroup.min;
return !!(max || min) && this.model.length >= max && !this.isChecked || this.model.length <= min && this.isChecked;
},
isDisabled: function isDisabled() {
return this.isGroup ? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled : this.disabled || (this.elForm || {}).disabled;
},
_elFormItemSize: function _elFormItemSize() {
return (this.elFormItem || {}).elFormItemSize;
},
checkboxSize: function checkboxSize() {
var temCheckboxSize = this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
return this.isGroup ? this._checkboxGroup.checkboxGroupSize || temCheckboxSize : temCheckboxSize;
}
},
watch: {
value: function value(_value) {
this.dispatch('ElFormItem', 'el.form.change', _value);
}
},
created: function created() {
this.checked && this.addToStore();
},
mounted: function mounted() {
if (this.indeterminate) {
this.$el.setAttribute('aria-controls', this.controls);
}
},
methods: {
addToStore: function addToStore() {
if (isArray$1(this.model) && this.model.indexOf(this.label) === -1) {
this.model.push(this.label);
} else {
this.model = this.trueLabel || true;
}
},
handleChange: function handleChange(ev) {
var _this = this;
if (this.isLimitExceeded) return;
var value;
if (ev.target.checked) {
value = this.trueLabel === undefined ? true : this.trueLabel;
} else {
value = this.falseLabel === undefined ? false : this.falseLabel;
}
this.$emit('change', value, ev);
this.$nextTick(function () {
if (_this.isGroup) {
_this.dispatch('ElCheckboxGroup', 'change', [_this._checkboxGroup.value]);
}
});
}
}
};
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
if (typeof shadowMode !== 'boolean') {
createInjectorSSR = createInjector;
createInjector = shadowMode;
shadowMode = false;
}
var options = typeof script === 'function' ? script.options : script;
if (template && template.render) {
options.render = template.render;
options.staticRenderFns = template.staticRenderFns;
options._compiled = true;
if (isFunctionalTemplate) {
options.functional = true;
}
}
if (scopeId) {
options._scopeId = scopeId;
}
var hook;
if (moduleIdentifier) {
hook = function hook(context) {
context = context ||
this.$vnode && this.$vnode.ssrContext ||
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__;
}
if (style) {
style.call(this, createInjectorSSR(context));
}
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
options._ssrRegister = hook;
} else if (style) {
hook = shadowMode ? function () {
style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
} : function (context) {
style.call(this, createInjector(context));
};
}
if (hook) {
if (options.functional) {
var originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
} else {
var existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return script;
}
var normalizeComponent_1 = normalizeComponent;
var __vue_script__ = script;
/* template */
var __vue_render__ = function __vue_render__() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('label', {
staticClass: "bk-checkbox-plus",
class: [_vm.border && _vm.checkboxSize ? 'bk-checkbox-plus--' + _vm.checkboxSize : '', {
'is-disabled': _vm.isDisabled
}, {
'is-bordered': _vm.border
}, {
'is-checked': _vm.isChecked
}],
attrs: {
"id": _vm.id
}
}, [_c('span', {
staticClass: "bk-checkbox-plus__input",
class: {
'is-disabled': _vm.isDisabled,
'is-checked': _vm.isChecked,
'is-indeterminate': _vm.indeterminate,
'is-focus': _vm.focus
},
attrs: {
"tabindex": _vm.indeterminate ? 0 : false,
"role": _vm.indeterminate ? 'checkbox' : false,
"aria-checked": _vm.indeterminate ? 'mixed' : false
}
}, [_c('span', {
staticClass: "bk-checkbox-plus__inner"
}), _vm.trueLabel || _vm.falseLabel ? _c('input', {
directives: [{
name: "model",
rawName: "v-model",
value: _vm.model,
expression: "model"
}],
staticClass: "bk-checkbox-plus__original",
attrs: {
"type": "checkbox",
"aria-hidden": _vm.indeterminate ? 'true' : 'false',
"name": _vm.name,
"disabled": _vm.isDisabled,
"true-value": _vm.trueLabel,
"false-value": _vm.falseLabel
},
domProps: {
"checked": isArray$1(_vm.model) ? _vm._i(_vm.model, null) > -1 : _vm._q(_vm.model, _vm.trueLabel)
},
on: {
"change": [function ($event) {
var $$a = _vm.model,
$$el = $event.target,
$$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel;
if (isArray$1($$a)) {
var $$v = null,
$$i = _vm._i($$a, $$v);
if ($$el.checked) {
$$i < 0 && (_vm.model = $$a.concat([$$v]));
} else {
$$i > -1 && (_vm.model = $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
}
} else {
_vm.model = $$c;
}
}, _vm.handleChange],
"focus": function focus($event) {
_vm.focus = true;
},
"blur": function blur($event) {
_vm.focus = false;
}
}
}) : _c('input', {
directives: [{
name: "model",
rawName: "v-model",
value: _vm.model,
expression: "model"
}],
staticClass: "bk-checkbox-plus__original",
attrs: {
"type": "checkbox",
"aria-hidden": _vm.indeterminate ? 'true' : 'false',
"disabled": _vm.isDisabled,
"name": _vm.name
},
domProps: {
"value": _vm.label,
"checked": isArray$1(_vm.model) ? _vm._i(_vm.model, _vm.label) > -1 : _vm.model
},
on: {
"change": [function ($event) {
var $$a = _vm.model,
$$el = $event.target,
$$c = $$el.checked ? true : false;
if (isArray$1($$a)) {
var $$v = _vm.label,
$$i = _vm._i($$a, $$v);
if ($$el.checked) {
$$i < 0 && (_vm.model = $$a.concat([$$v]));
} else {
$$i > -1 && (_vm.model = $$a.slice(0, $$i).concat($$a.slice($$i + 1)));
}
} else {
_vm.model = $$c;
}
}, _vm.handleChange],
"focus": function focus($event) {
_vm.focus = true;
},
"blur": function blur($event) {
_vm.focus = false;
}
}
})]), _vm.$slots.default || _vm.label ? _c('span', {
staticClass: "bk-checkbox-plus__label"
}, [_vm._t("default"), !_vm.$slots.default ? [_vm._v(_vm._s(_vm.label))] : _vm._e()], 2) : _vm._e()]);
};
var __vue_staticRenderFns__ = [];
/* style */
var __vue_inject_styles__ = undefined;
/* scoped */
var __vue_scope_id__ = undefined;
/* module identifier */
var __vue_module_identifier__ = undefined;
/* functional template */
var __vue_is_functional_template__ = false;
/* style inject */
/* style inject SSR */
/* style inject shadow dom */
var __vue_component__ = /*#__PURE__*/normalizeComponent_1({
render: __vue_render__,
staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
var cellStarts = {
default: {
order: ''
},
selection: {
width: 46,
minWidth: 46,
realWidth: 46,
order: '',
className: 'bk-table-plus-column--selection'
},
expand: {
width: 48,
minWidth: 48,
realWidth: 48,
order: ''
},
index: {
id: 46,
width: 46,
minWidth: 46,
realWidth: 46,
order: '',
label: '序列',
className: 'bk-table-plus-column--index'
}
};
var cellForced = {
selection: {
renderHeader: function renderHeader(h, _ref) {
var store = _ref.store;
return h(__vue_component__, {
"attrs": {
"disabled": store.states.data && store.states.data.length === 0,
"indeterminate": store.states.selection.length > 0 && !this.isAllSelected,
"value": this.isAllSelected
},
"on": {
"input": this.toggleAllSelection
}
});
},
renderCell: function renderCell(h, _ref2) {
var row = _ref2.row,
column = _ref2.column,
isSelected = _ref2.isSelected,
store = _ref2.store,
$index = _ref2.$index;
return h(__vue_component__, {
"nativeOn": {
"click": function click(event) {
return event.stopPropagation();
}
},
"attrs": {
"value": isSelected,
"disabled": column.selectable ? !column.selectable.call(null, row, $index) : false
},
"on": {
"input": function input() {
store.commit('rowSelectedChanged', row);
}
}
});
},
sortable: false,
resizable: false
},
index: {
renderHeader: function renderHeader(h, _ref3) {
var column = _ref3.column;
return column.label || '#';
},
renderCell: function renderCell(h, _ref4) {
var $index = _ref4.$index,
column = _ref4.column;
var i = $index + 1;
var index = column.index;
if (typeof index === 'number') {
i = $index + index;
} else if (typeof index === 'function') {
i = index($index);
}
return h("div", [i]);
},
sortable: false
},
expand: {
renderHeader: function renderHeader(h, _ref5) {
var column = _ref5.column;
return column.label || '';
},
renderCell: function renderCell(h, _ref6) {
var row = _ref6.row,
store = _ref6.store,
isExpanded = _ref6.isExpanded;
var classes = ['bk-table-plus__expand-icon'];
if (isExpanded) {
classes.push('bk-table-plus__expand-icon--expanded');
}
var callback = function callback(e) {
e.stopPropagation();
store.toggleRowExpansion(row);
};
return h("div", {
"class": classes,
"on": {
"click": callback
}
}, [h("i", {
"class": 'bk-icon icon-angle-right'
})]);
},
sortable: false,
resizable: false,
className: 'bk-table-plus__expand-column'
}
};
function defaultRenderCell(h, _ref7) {
var row = _ref7.row,
column = _ref7.column,
$index = _ref7.$index;
var property = column.property;
var value = property && getPropByPath(row, property).v;
if (column && column.formatter) {
return column.formatter(row, column, value, $index);
}
return value;
}
function treeCellPrefix(h, _ref8) {
var row = _ref8.row,
treeNode = _ref8.treeNode,
store = _ref8.store;
if (!treeNode) return null;
var ele = [];
var callback = function callback(e) {
e.stopPropagation();
store.loadOrToggle(row);
};
if (treeNode.indent) {
ele.push(h("span", {
"class": "bk-table-plus__indent",
"style": {
'padding-left': treeNode.indent + 'px'
}
}));
}
if (typeof treeNode.expanded === 'boolean' && !treeNode.noLazyChildren) {
var expandClasses = ['bk-table-plus__expand-icon', treeNode.expanded ? 'bk-table-plus__expand-icon--expanded' : ''];
var iconClasses = ['bk-icon icon-angle-right'];
if (treeNode.loading) {
iconClasses = ['table-plus-icon-loading'];
}
ele.push(h("div", {
"class": expandClasses,
"on": {
"click": callback
}
}, [h("i", {
"class": iconClasses
})]));
} else {
ele.push(h("span", {
"class": "bk-table-plus__placeholder"
}));
}
return ele;
}
var columnIdSeed = 1;
var bkTablePlusColumn = {
name: 'bk-table-plus-column',
props: {
type: {
type: String,
default: 'default'
},
label: String,
className: String,
labelClassName: String,
property: String,
prop: String,
width: {},
minWidth: {},
renderHeader: Function,
sortable: {
type: [Boolean, String],
default: false
},
sortMethod: Function,
sortBy: [String, Function, Array],
resizable: {
type: Boolean,
default: true
},
columnKey: String,
align: String,
headerAlign: String,
showTooltipWhenOverflow: Boolean,
showOverflowTooltip: Boolean,
fixed: [Boolean, String],
formatter: Function,
selectable: Function,
reserveSelection: Boolean,
filterMethod: Function,
filteredValue: Array,
filters: Array,
filterPlacement: String,
filterMultiple: {
type: Boolean,
default: true
},
index: [Number, Function],
sortOrders: {
type: Array,
default: function _default() {
return ['ascending', 'descending', null];
},
validator: function validator(val) {
return val.every(function (order) {
return ['ascending', 'descending', null].indexOf(order) > -1;
});
}
}
},
data: function data() {
return {
isSubColumn: false,
columns: []
};
},
computed: {
owner: function owner() {
var parent = this.$parent;
while (parent && !parent.tableId) {
parent = parent.$parent;
}
return parent;
},
columnOrTableParent: function columnOrTableParent() {
var parent = this.$parent;
while (parent && !parent.tableId && !parent.columnId) {
parent = parent.$parent;
}
return parent;
},
realWidth: function realWidth() {
return parseWidth(this.width);
},
realMinWidth: function realMinWidth() {
return parseMinWidth(this.minWidth);
},
realAlign: function realAlign() {
return this.align ? 'is-' + this.align : null;
},
realHeaderAlign: function realHeaderAlign() {
return this.headerAlign ? 'is-' + this.headerAlign : this.realAlign;
}
},
methods: {
getPropsData: function getPropsData() {
var _this = this;
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
props[_key] = arguments[_key];
}
return props.reduce(function (prev, cur) {
if (isArray$1(cur)) {
cur.forEach(function (key) {
prev[key] = _this[key];
});
}
return prev;
}, {});
},
getColumnElIndex: function getColumnElIndex(children, child) {
return [].indexOf.call(children, child);
},
setColumnWidth: function setColumnWidth(column) {
if (this.realWidth) {
column.width = this.realWidth;
}
if (this.realMinWidth) {
column.minWidth = this.realMinWidth;
}
if (!column.minWidth) {
column.minWidth = 80;
}
column.realWidth = column.width === undefined ? column.minWidth : column.width;
return column;
},
setColumnForcedProps: function setColumnForcedProps(column) {
var type = column.type;
var source = cellForced[type] || {};
keys$1(source).forEach(function (prop) {
var value = source[prop];
if (value !== undefined) {
column[prop] = prop === 'className' ? "".concat(column[prop], " ").concat(value) : value;
}
});
return column;
},
setColumnRenders: function setColumnRenders(column) {
var _this2 = this;
var h = this.$createElement;
if (this.renderHeader) {
console.warn('[Element Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header.');
} else if (column.type !== 'selection') {
column.renderHeader = function (h, scope) {
var renderHeader = _this2.$scopedSlots.header;
return renderHeader ? renderHeader(scope) : column.label;
};
}
var originRenderCell = column.renderCell;
if (column.type === 'expand') {
column.renderCell = function (h, data) {
return h("div", {
"class": "cell"
}, [originRenderCell(h, data)]);
};
this.owner.renderExpanded = function (h, data) {
return _this2.$scopedSlots.default ? _this2.$scopedSlots.default(data) : _this2.$slots.default;
};
} else {
originRenderCell = originRenderCell || defaultRenderCell;
column.renderCell = function (h, data) {
var children = null;
if (_this2.$scopedSlots.default) {
children = _this2.$scopedSlots.default(data);
} else {
children = originRenderCell(h, data);
}
var prefix = treeCellPrefix(h, data);
var props = {
class: 'cell',
style: {}
};
if (column.showOverflowTooltip) {
props.style = {
width: (data.column.realWidth || data.column.width) - 1 + 'px'
};
}
return h("div", helper([{}, props]), [prefix, children]);
};
}
return column;
},
registerNormalWatchers: function registerNormalWatchers() {
var _this3 = this;
var props = ['label', 'property', 'filters', 'filterMultiple', 'sortable', 'index', 'formatter', 'className', 'labelClassName', 'showOverflowTooltip'];
var aliases = {
prop: 'property',
realAlign: 'align',
realHeaderAlign: 'headerAlign',
realWidth: 'width'
};
var allAliases = props.reduce(function (prev, cur) {
prev[cur] = cur;
return prev;
}, aliases);
keys$1(allAliases).forEach(function (key) {
var columnKey = aliases[key];
_this3.$watch(key, function (newVal) {
_this3.columnConfig[columnKey] = newVal;
});
});
},
registerComplexWatchers: function registerComplexWatchers() {
var _this4 = this;
var props = ['fixed'];
var aliases = {
realWidth: 'width',
realMinWidth: 'minWidth'
};
var allAliases = props.reduce(function (prev, cur) {
prev[cur] = cur;
return prev;
}, aliases);
keys$1(allAliases).forEach(function (key) {
var columnKey = aliases[key];
_this4.$watch(key, function (newVal) {
_this4.columnConfig[columnKey] = newVal;
var updateColumns = columnKey === 'fixed';
_this4.owner.store.scheduleLayout(updateColumns);
});
});
}
},
components: {
ElCheckbox: __vue_component__
},
beforeCreate: function beforeCreate() {
this.row = {};
this.column = {};
this.$index = 0;
this.columnId = '';
},
created: function created() {
var parent = this.columnOrTableParent;
this.isSubColumn = this.owner !== parent;
this.columnId = (parent.tableId || parent.columnId) + '_column_' + columnIdSeed++;
var type = this.type || 'default';
var sortable = this.sortable === '' ? true : this.sortable;
var defaults = _objectSpread({}, cellStarts[type], {
id: this.columnId,
type: type,
property: this.prop || this.property,
align: this.realAlign,
headerAlign: this.realHeaderAlign,
showOverflowTooltip: this.showOverflowTooltip || this.showTooltipWhenOverflow,
filterable: this.filters || this.filterMethod,
filteredValue: [],
filterPlacement: '',
isColumnGroup: false,
filterOpened: false,
sortable: sortable,
index: this.index
});
var basicProps = ['columnKey', 'label', 'className', 'labelClassName', 'type', 'renderHeader', 'formatter', 'fixed', 'resizable'];
var sortProps = ['sortMethod', 'sortBy', 'sortOrders'];
var selectProps = ['selectable', 'reserveSelection'];
var filterProps = ['filterMethod', 'filters', 'filterMultiple', 'filterOpened', 'filteredValue', 'filterPlacement'];
var column = this.getPropsData(basicProps, sortProps, selectProps, filterProps);
column = mergeOptions(defaults, column);
var chains = compose(this.setColumnRenders, this.setColumnWidth, this.setColumnForcedProps);
column = chains(column);
this.columnConfig = column;
this.registerNormalWatchers();
this.registerComplexWatchers();
},
mounted: function mounted() {
var owner = this.owner;
var parent = this.columnOrTableParent;
var children = this.isSubColumn ? parent.$el.children : parent.$refs.hiddenColumns.children;
var columnIndex = this.getColumnElIndex(children, this.$el);
owner.store.commit('insertColumn', this.columnConfig, columnIndex, this.isSubColumn ? parent.columnConfig : null);
},
destroyed: function destroyed() {
if (!this.$parent) return;
var parent = this.$parent;
this.owner.store.commit('removeColumn', this.columnConfig, this.isSubColumn ? parent.columnConfig : null);
},
render: function render(h) {
return h('div', this.$slots.default);
}
};
function setInstaller (component, afterInstall) {
component.install = function (Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var props = component.props || {};
keys$1(options).forEach(function (key) {
if (props.hasOwnProperty(key)) {
if (typeof props[key] === 'function' || props[key] instanceof Array) {
props[key] = {
type: props[key],
default: options[key]
};
} else {
props[key].default = options[key];
}
}
});
component.name = options.namespace ? component.name.replace('bk', options.namespace) : component.name;
Vue.component(component.name, component);
typeof afterInstall === 'function' && afterInstall(Vue, options);
};
}
setInstaller(bkTablePlusColumn);
exports.default = bkTablePlusColumn;
Object.defineProperty(exports, '__esModule', { value: true });
}));
&& v8.indexOf('6.6') !== 0
&& _userAgent.indexOf('Chrome/66') === -1;
} catch (e) { }
}();
var isThenable = function (it) {
var then;
return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
};
var notify = function (promise, isReject) {
if (promise._n) return;
promise._n = true;
var chain = promise._c;
microtask(function () {
var value = promise._v;
var ok = promise._s == 1;
var i = 0;
var run = function (reaction) {
var handler = ok ? reaction.ok : reaction.fail;
var resolve = reaction.resolve;
var reject = reaction.reject;
var domain = reaction.domain;
var result, then, exited;
try {
if (handler) {
if (!ok) {
if (promise._h == 2) onHandleUnhandled(promise);
promise._h = 1;
}
if (handler === true) result = value;
else {
if (domain) domain.enter();
result = handler(value);
if (domain) {
domain.exit();
exited = true;
}
}
if (result === reaction.promise) {
reject(TypeError$1('Promise-chain cycle'));
} else if (then = isThenable(result)) {
then.call(result, resolve, reject);
} else resolve(result);
} else reject(value);
} catch (e) {
if (domain && !exited) domain.exit();
reject(e);
}
};
while (chain.length > i) run(chain[i++]);
promise._c = [];
promise._n = false;
if (isReject && !promise._h) onUnhandled(promise);
});
};
var onUnhandled = function (promise) {
task.call(_global, function () {
var value = promise._v;
var unhandled = isUnhandled(promise);
var result, handler, console;
if (unhandled) {
result = _perform(function () {
if (isNode$1) {
process$2.emit('unhandledRejection', value, promise);
} else if (handler = _global.onunhandledrejection) {
handler({ promise: promise, reason: value });
} else if ((console = _global.console) && console.error) {
console.error('Unhandled promise rejection', value);
}
});
promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
} promise._a = undefined;
if (unhandled && result.e) throw result.v;
});
};
var isUnhandled = function (promise) {
return promise._h !== 1 && (promise._a || promise._c).length === 0;
};
var onHandleUnhandled = function (promise) {
task.call(_global, function () {
var handler;
if (isNode$1) {
process$2.emit('rejectionHandled', promise);
} else if (handler = _global.onrejectionhandled) {
handler({ promise: promise, reason: promise._v });
}
});
};
var $reject = function (value) {
var promise = this;
if (promise._d) return;
promise._d = true;
promise = promise._w || promise;
promise._v = value;
promise._s = 2;
if (!promise._a) promise._a = promise._c.slice();
notify(promise, true);
};
var $resolve = function (value) {
var promise = this;
var then;
if (promise._d) return;
promise._d = true;
promise = promise._w || promise;
try {
if (promise === value) throw TypeError$1("Promise can't be resolved itself");
if (then = isThenable(value)) {
microtask(function () {
var wrapper = { _w: promise, _d: false };
try {
then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
} catch (e) {
$reject.call(wrapper, e);
}
});
} else {
promise._v = value;
promise._s = 1;
notify(promise, false);
}
} catch (e) {
$reject.call({ _w: promise, _d: false }, e);
}
};
if (!USE_NATIVE) {
$Promise = function Promise(executor) {
_anInstance(this, $Promise, PROMISE, '_h');
_aFunction(executor);
Internal.call(this);
try {
executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
} catch (err) {
$reject.call(this, err);
}
};
Internal = function Promise(executor) {
this._c = [];
this._a = undefined;
this._s = 0;
this._d = false;
this._v = undefined;
this._h = 0;
this._n = false;
};
Internal.prototype = _redefineAll($Promise.prototype, {
then: function then(onFulfilled, onRejected) {
var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
reaction.fail = typeof onRejected == 'function' && onRejected;
reaction.domain = isNode$1 ? process$2.domain : undefined;
this._c.push(reaction);
if (this._a) this._a.push(reaction);
if (this._s) notify(this, false);
return reaction.promise;
},
'catch': function (onRejected) {
return this.then(undefined, onRejected);
}
});
OwnPromiseCapability = function () {
var promise = new Internal();
this.promise = promise;
this.resolve = _ctx($resolve, promise, 1);
this.reject = _ctx($reject, promise, 1);
};
_newPromiseCapability.f = newPromiseCapability = function (C) {
return C === $Promise || C === Wrapper
? new OwnPromiseCapability(C)
: newGenericPromiseCapability(C);
};
}
_export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });
_setToStringTag($Promise, PROMISE);
_setSpecies(PROMISE);
Wrapper = _core[PROMISE];
_export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
reject: function reject(r) {
var capability = newPromiseCapability(this);
var $$reject = capability.reject;
$$reject(r);
return capability.promise;
}
});
_export(_export.S + _export.F * (_library ), PROMISE, {
resolve: function resolve(x) {
return _promiseResolve( this === Wrapper ? $Promise : this, x);
}
});
_export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
$Promise.all(iter)['catch'](empty);
})), PROMISE, {
all: function all(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var resolve = capability.resolve;
var reject = capability.reject;
var result = _perform(function () {
var values = [];
var index = 0;
var remaining = 1;
_forOf(iterable, false, function (promise) {
var $index = index++;
var alreadyCalled = false;
values.push(undefined);
remaining++;
C.resolve(promise).then(function (value) {
if (alreadyCalled) return;
alreadyCalled = true;
values[$index] = value;
--remaining || resolve(values);
}, reject);
});
--remaining || resolve(values);
});
if (result.e) reject(result.v);
return capability.promise;
},
race: function race(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var reject = capability.reject;
var r