@cw-devops/bk-magic-vue
Version:
基于蓝鲸 Magicbox 和 Vue 的前端组件库
1,457 lines (1,356 loc) • 66.1 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('bk-magic-vue/lib/locale'), require('json-formatter-js'), require('clipboard')) :
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'bk-magic-vue/lib/locale', 'json-formatter-js', 'clipboard'], factory) :
(global = global || self, factory(global.library = {}, global.Vue, global.locale, global.JSONFormatter, global.ClipboardJS));
}(this, function (exports, Vue, locale, JSONFormatter, ClipboardJS) { 'use strict';
Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
locale = locale && locale.hasOwnProperty('default') ? locale['default'] : locale;
JSONFormatter = JSONFormatter && JSONFormatter.hasOwnProperty('default') ? JSONFormatter['default'] : JSONFormatter;
ClipboardJS = ClipboardJS && ClipboardJS.hasOwnProperty('default') ? ClipboardJS['default'] : ClipboardJS;
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
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 _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.12' };
if (typeof __e == 'number') __e = core;
});
var _core_1 = _core.version;
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$1 = _global.document;
var is = _isObject(document$1) && _isObject(document$1.createElement);
var _domCreate = function (it) {
return is ? document$1.createElement(it) : {};
};
var _ie8DomDefine = !_descriptors && !_fails(function () {
return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
});
var _toPrimitive = 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(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 hasOwnProperty = {}.hasOwnProperty;
var _has = function (it, key) {
return hasOwnProperty.call(it, key);
};
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 _defined = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
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;
_export(_export.S, 'Date', { now: function () { return new Date().getTime(); } });
var now = _core.Date.now;
var now$1 = now;
var $JSON = _core.JSON || (_core.JSON = { stringify: JSON.stringify });
var stringify = function stringify(it) {
return $JSON.stringify.apply($JSON, arguments);
};
var stringify$1 = stringify;
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
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 _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _toPrimitive$1(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$1(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
var rApply = (_global.Reflect || {}).apply;
var fApply = Function.apply;
_export(_export.S + _export.F * !_fails(function () {
rApply(function () { });
}), 'Reflect', {
apply: function apply(target, thisArgument, argumentsList) {
var T = _aFunction(target);
var L = _anObject(argumentsList);
return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);
}
});
var apply = _core.Reflect.apply;
var apply$1 = apply;
var _iterStep = function (done, value) {
return { value: value, done: !!done };
};
var _iterators = {};
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 _redefine = _hide;
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;
};
};
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 _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
_anObject(O);
var keys = _objectKeys(Properties);
var length = keys.length;
var i = 0;
var P;
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
return O;
};
var document$2 = _global.document;
var _html = document$2 && document$2.documentElement;
var IE_PROTO$1 = _sharedKey('IE_PROTO');
var Empty = function () { };
var PROTOTYPE$1 = 'prototype';
var createDict = function () {
var iframe = _domCreate('iframe');
var i = _enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
_html.appendChild(iframe);
iframe.src = 'javascript:';
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
return createDict();
};
var _objectCreate = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE$1] = _anObject(O);
result = new Empty();
Empty[PROTOTYPE$1] = null;
result[IE_PROTO$1] = O;
} else result = createDict();
return Properties === undefined ? result : _objectDps(result, Properties);
};
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
var Symbol = _global.Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
};
$exports.store = store;
});
var def = _objectDp.f;
var TAG = _wks('toStringTag');
var _setToStringTag = function (it, tag, stat) {
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
};
var IteratorPrototype = {};
_hide(IteratorPrototype, _wks('iterator'), function () { return this; });
var _iterCreate = function (Constructor, NAME, next) {
Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
_setToStringTag(Constructor, NAME + ' Iterator');
};
var _toObject = function (it) {
return Object(_defined(it));
};
var IE_PROTO$2 = _sharedKey('IE_PROTO');
var ObjectProto = Object.prototype;
var _objectGpo = Object.getPrototypeOf || function (O) {
O = _toObject(O);
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
} return O instanceof Object ? ObjectProto : null;
};
var ITERATOR = _wks('iterator');
var BUGGY = !([].keys && 'next' in [].keys());
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function () { return this; };
var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
_iterCreate(Constructor, NAME, next);
var getMethod = function (kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS: return function keys() { return new Constructor(this, kind); };
case VALUES: return function values() { return new Constructor(this, kind); };
} return function entries() { return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype;
if ($anyNative) {
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
_setToStringTag(IteratorPrototype, TAG, true);
}
}
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() { return $native.call(this); };
}
if (( FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
_hide(proto, ITERATOR, $default);
}
_iterators[NAME] = $default;
_iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) _redefine(proto, key, methods[key]);
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
this._t = _toIobject(iterated);
this._i = 0;
this._k = kind;
}, function () {
var O = this._t;
var kind = this._k;
var index = this._i++;
if (!O || index >= O.length) {
this._t = undefined;
return _iterStep(1);
}
if (kind == 'keys') return _iterStep(0, index);
if (kind == 'values') return _iterStep(0, O[index]);
return _iterStep(0, [index, O[index]]);
}, 'values');
_iterators.Arguments = _iterators.Array;
var TO_STRING_TAG = _wks('toStringTag');
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
'TextTrackList,TouchList').split(',');
for (var i = 0; i < DOMIterables.length; i++) {
var NAME = DOMIterables[i];
var Collection = _global[NAME];
var proto = Collection && Collection.prototype;
if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
_iterators[NAME] = _iterators.Array;
}
var _isArray = Array.isArray || function isArray(arg) {
return _cof(arg) == 'Array';
};
var SPECIES = _wks('species');
var _arraySpeciesConstructor = function (original) {
var C;
if (_isArray(original)) {
C = original.constructor;
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
if (_isObject(C)) {
C = C[SPECIES];
if (C === null) C = undefined;
}
} return C === undefined ? Array : C;
};
var _arraySpeciesCreate = function (original, length) {
return new (_arraySpeciesConstructor(original))(length);
};
var _arrayMethods = function (TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
var IS_FIND_INDEX = TYPE == 6;
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
var create = $create || _arraySpeciesCreate;
return function ($this, callbackfn, that) {
var O = _toObject($this);
var self = _iobject(O);
var f = _ctx(callbackfn, that, 3);
var length = _toLength(self.length);
var index = 0;
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
var val, res;
for (;length > index; index++) if (NO_HOLES || index in self) {
val = self[index];
res = f(val, index, O);
if (TYPE) {
if (IS_MAP) result[index] = res;
else if (res) switch (TYPE) {
case 3: return true;
case 5: return val;
case 6: return index;
case 2: result.push(val);
} else if (IS_EVERY) return false;
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
var _meta = createCommonjsModule(function (module) {
var META = _uid('meta');
var setDesc = _objectDp.f;
var id = 0;
var isExtensible = Object.isExtensible || function () {
return true;
};
var FREEZE = !_fails(function () {
return isExtensible(Object.preventExtensions({}));
});
var setMeta = function (it) {
setDesc(it, META, { value: {
i: 'O' + ++id,
w: {}
} });
};
var fastKey = function (it, create) {
if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
if (!_has(it, META)) {
if (!isExtensible(it)) return 'F';
if (!create) return 'E';
setMeta(it);
} return it[META].i;
};
var getWeak = function (it, create) {
if (!_has(it, META)) {
if (!isExtensible(it)) return true;
if (!create) return false;
setMeta(it);
} return it[META].w;
};
var onFreeze = function (it) {
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
return it;
};
var meta = module.exports = {
KEY: META,
NEED: false,
fastKey: fastKey,
getWeak: getWeak,
onFreeze: onFreeze
};
});
var _meta_1 = _meta.KEY;
var _meta_2 = _meta.NEED;
var _meta_3 = _meta.fastKey;
var _meta_4 = _meta.getWeak;
var _meta_5 = _meta.onFreeze;
var f$1 = Object.getOwnPropertySymbols;
var _objectGops = {
f: f$1
};
var f$2 = {}.propertyIsEnumerable;
var _objectPie = {
f: f$2
};
var $assign = Object.assign;
var _objectAssign = !$assign || _fails(function () {
var A = {};
var B = {};
var S = Symbol();
var K = 'abcdefghijklmnopqrst';
A[S] = 7;
K.split('').forEach(function (k) { B[k] = k; });
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
}) ? function assign(target, source) {
var T = _toObject(target);
var aLen = arguments.length;
var index = 1;
var getSymbols = _objectGops.f;
var isEnum = _objectPie.f;
while (aLen > index) {
var S = _iobject(arguments[index++]);
var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) {
key = keys[j++];
if (!_descriptors || isEnum.call(S, key)) T[key] = S[key];
}
} return T;
} : $assign;
var _redefineAll = function (target, src, safe) {
for (var key in src) {
if (safe && target[key]) target[key] = src[key];
else _hide(target, key, src[key]);
} return target;
};
var _anInstance = function (it, Constructor, name, forbiddenField) {
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
throw TypeError(name + ': incorrect invocation!');
} return it;
};
var _iterCall = function (iterator, fn, value, entries) {
try {
return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
} catch (e) {
var ret = iterator['return'];
if (ret !== undefined) _anObject(ret.call(iterator));
throw e;
}
};
var ITERATOR$1 = _wks('iterator');
var ArrayProto = Array.prototype;
var _isArrayIter = function (it) {
return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it);
};
var TAG$1 = _wks('toStringTag');
var ARG = _cof(function () { return arguments; }()) == 'Arguments';
var tryGet = function (it, key) {
try {
return it[key];
} catch (e) { }
};
var _classof = function (it) {
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
: typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
: ARG ? _cof(O)
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
var ITERATOR$2 = _wks('iterator');
var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
if (it != undefined) return it[ITERATOR$2]
|| it['@@iterator']
|| _iterators[_classof(it)];
};
var _forOf = createCommonjsModule(function (module) {
var BREAK = {};
var RETURN = {};
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
var f = _ctx(fn, that, entries ? 2 : 1);
var index = 0;
var length, step, iterator, result;
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
if (result === BREAK || result === RETURN) return result;
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
result = _iterCall(iterator, f, step.value, entries);
if (result === BREAK || result === RETURN) return result;
}
};
exports.BREAK = BREAK;
exports.RETURN = RETURN;
});
var _validateCollection = function (it, TYPE) {
if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
return it;
};
var getWeak = _meta.getWeak;
var arrayFind = _arrayMethods(5);
var arrayFindIndex = _arrayMethods(6);
var id$1 = 0;
var uncaughtFrozenStore = function (that) {
return that._l || (that._l = new UncaughtFrozenStore());
};
var UncaughtFrozenStore = function () {
this.a = [];
};
var findUncaughtFrozen = function (store, key) {
return arrayFind(store.a, function (it) {
return it[0] === key;
});
};
UncaughtFrozenStore.prototype = {
get: function (key) {
var entry = findUncaughtFrozen(this, key);
if (entry) return entry[1];
},
has: function (key) {
return !!findUncaughtFrozen(this, key);
},
set: function (key, value) {
var entry = findUncaughtFrozen(this, key);
if (entry) entry[1] = value;
else this.a.push([key, value]);
},
'delete': function (key) {
var index = arrayFindIndex(this.a, function (it) {
return it[0] === key;
});
if (~index) this.a.splice(index, 1);
return !!~index;
}
};
var _collectionWeak = {
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
var C = wrapper(function (that, iterable) {
_anInstance(that, C, NAME, '_i');
that._t = NAME;
that._i = id$1++;
that._l = undefined;
if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that);
});
_redefineAll(C.prototype, {
'delete': function (key) {
if (!_isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key);
return data && _has(data, this._i) && delete data[this._i];
},
has: function has(key) {
if (!_isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key);
return data && _has(data, this._i);
}
});
return C;
},
def: function (that, key, value) {
var data = getWeak(_anObject(key), true);
if (data === true) uncaughtFrozenStore(that).set(key, value);
else data[that._i] = value;
return that;
},
ufstore: uncaughtFrozenStore
};
var dP$1 = _objectDp.f;
var each = _arrayMethods(0);
var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
var Base = _global[NAME];
var C = Base;
var ADDER = IS_MAP ? 'set' : 'add';
var proto = C && C.prototype;
var O = {};
if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
new C().entries().next();
}))) {
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
_redefineAll(C.prototype, methods);
_meta.NEED = true;
} else {
C = wrapper(function (target, iterable) {
_anInstance(target, C, NAME, '_c');
target._c = new Base();
if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target);
});
each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
var IS_ADDER = KEY == 'add' || KEY == 'set';
if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) {
_anInstance(this, C, KEY);
if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false;
var result = this._c[KEY](a === 0 ? 0 : a, b);
return IS_ADDER ? this : result;
});
});
IS_WEAK || dP$1(C.prototype, 'size', {
get: function () {
return this._c.size;
}
});
}
_setToStringTag(C, NAME);
O[NAME] = C;
_export(_export.G + _export.W + _export.F, O);
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
return C;
};
var es6_weakMap = createCommonjsModule(function (module) {
var each = _arrayMethods(0);
var NATIVE_WEAK_MAP = _validateCollection;
var IS_IE11 = !_global.ActiveXObject && 'ActiveXObject' in _global;
var WEAK_MAP = 'WeakMap';
var getWeak = _meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = _collectionWeak.ufstore;
var InternalMap;
var wrapper = function (get) {
return function WeakMap() {
return get(this, arguments.length > 0 ? arguments[0] : undefined);
};
};
var methods = {
get: function get(key) {
if (_isObject(key)) {
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key);
return data ? data[this._i] : undefined;
}
},
set: function set(key, value) {
return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value);
}
};
var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true);
if (NATIVE_WEAK_MAP && IS_IE11) {
InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP);
_objectAssign(InternalMap.prototype, methods);
_meta.NEED = true;
each(['delete', 'has', 'get', 'set'], function (key) {
var proto = $WeakMap.prototype;
var method = proto[key];
_redefine(proto, key, function (a, b) {
if (_isObject(a) && !isExtensible(a)) {
if (!this._f) this._f = new InternalMap();
var result = this._f[key](a, b);
return key == 'set' ? this : result;
} return method.call(this, a, b);
});
});
}
});
var _setCollectionOf = function (COLLECTION) {
_export(_export.S, COLLECTION, { of: function of() {
var length = arguments.length;
var A = new Array(length);
while (length--) A[length] = arguments[length];
return new this(A);
} });
};
_setCollectionOf('WeakMap');
var _setCollectionFrom = function (COLLECTION) {
_export(_export.S, COLLECTION, { from: function from(source ) {
var mapFn = arguments[1];
var mapping, A, n, cb;
_aFunction(this);
mapping = mapFn !== undefined;
if (mapping) _aFunction(mapFn);
if (source == undefined) return new this();
A = [];
if (mapping) {
n = 0;
cb = _ctx(mapFn, arguments[2], 2);
_forOf(source, false, function (nextItem) {
A.push(cb(nextItem, n++));
});
} else {
_forOf(source, false, A.push, A);
}
return new this(A);
} });
};
_setCollectionFrom('WeakMap');
var weakMap = _core.WeakMap;
var weakMap$1 = weakMap;
var $parseFloat = _global.parseFloat;
var $trim$1 = _stringTrim.trim;
var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) {
var string = $trim$1(String(str), 3);
var result = $parseFloat(string);
return result === 0 && string.charAt(0) == '-' ? -0 : result;
} : $parseFloat;
_export(_export.G + _export.F * (parseFloat != _parseFloat), { parseFloat: _parseFloat });
var _parseFloat$1 = _core.parseFloat;
var _parseFloat$2 = _parseFloat$1;
_export(_export.S, 'Array', { isArray: _isArray });
var isArray = _core.Array.isArray;
var isArray$1 = isArray;
var requestAnimationFrame$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
window.setTimeout(callback, 1000 / 60);
};
var cancelAnimationFrame$1 = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) {
window.clearTimeout(id);
};
var copyText = function copyText(text) {
var textarea = document.createElement('textarea');
document.body.appendChild(textarea);
textarea.value = text;
textarea.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
} else {
console.warn('unsupported this function, please use Google Chrome.');
}
document.body.removeChild(textarea);
};
function checkOverflow(el) {
if (!el) return false;
var createDom = function createDom(el, css) {
var dom = document.createElement('div');
var width = _parseFloat$2(css['width']) ? Math.ceil(_parseFloat$2(css['width'])) + 'px' : css['width'];
dom.style.cssText = "\n width: ".concat(width, ";\n line-height: ").concat(css['line-height'], ";\n font-size: ").concat(css['font-size'], ";\n word-break: ").concat(css['word-break'], ";\n padding: ").concat(css['padding'], ";\n ");
dom.textContent = el.textContent;
return dom;
};
var isOverflow = false;
try {
var css = window.getComputedStyle(el, null);
var lineClamp = css.webkitLineClamp;
if (lineClamp !== 'none') {
var targetHeight = _parseFloat$2(css.height);
var dom = createDom(el, css);
document.body.appendChild(dom);
var domHeight = window.getComputedStyle(dom, null)['height'];
document.body.removeChild(dom);
isOverflow = targetHeight < _parseFloat$2(domHeight);
} else {
isOverflow = el.clientWidth < el.scrollWidth || el.clientHeight < el.scrollHeight;
}
} catch (e) {
console.warn('There is an error when check element overflow state: ', e);
}
return isOverflow;
}
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 IMessageActionType = {
ASSISTANT: 'assistant',
DETAILS: 'details',
FIX: 'fix',
CLOSE: 'close'
};
var MessageContentType = {
KEY_VALUE: 'key-value',
JSON: 'json'
};
var sortActionIdList = [IMessageActionType.ASSISTANT, IMessageActionType.DETAILS, IMessageActionType.FIX, IMessageActionType.CLOSE];
var MessageAdvanced = {
name: 'bk-message-advanced',
mixins: [locale.mixin],
props: {
message: {
type: Object,
default: function _default() {
return {};
}
},
actions: {
type: Array,
default: function _default() {
return [];
}
},
tipsIcon: {
type: String,
default: ''
}
},
data: function data() {
return {
toolOperation: {
isFix: false,
isDetailShow: false
},
isInstallClipboardJS: false,
copyStatus: '',
copyStatusTimer: null
};
},
mounted: function mounted() {
this.addMouseKeyEvent();
},
beforeDestroy: function beforeDestroy() {
this.addMouseKeyEvent(true);
},
computed: {
defActionList: function defActionList() {
var _this = this,
_ref;
return _ref = {}, _defineProperty(_ref, IMessageActionType.ASSISTANT, {
id: IMessageActionType.ASSISTANT,
icon: function icon(h) {
return h('span', {
class: 'bk-icon icon-assistant'
});
},
text: function text() {
return _this.t('bk.message.assistant');
},
onClick: function onClick(e) {
return _this.handleHeplerClick(e);
}
}), _defineProperty(_ref, IMessageActionType.DETAILS, {
id: IMessageActionType.DETAILS,
icon: function icon(h) {
return _this.toolOperation.isDetailShow ? h('span', {
class: 'bk-icon icon-angle-double-up'
}) : h('span', {
class: 'bk-icon icon-angle-double-down'
});
},
text: function text() {
return _this.t('bk.message.details');
},
onClick: function onClick(e) {
return _this.setDetailsShow(e);
}
}), _defineProperty(_ref, IMessageActionType.FIX, {
id: IMessageActionType.FIX,
icon: function icon(h) {
return _this.toolOperation.isFix ? h('span', {
class: 'bk-icon icon-fix-shape'
}) : h('span', {
class: 'bk-icon icon-fix-line'
});
},
classList: this.toolOperation.isFix ? 'fixed' : '',
onClick: function onClick(e) {
return _this.fixMesage(e);
}
}), _defineProperty(_ref, IMessageActionType.CLOSE, {
id: IMessageActionType.CLOSE,
classList: 'normal-color',
icon: function icon(h) {
return h('span', {
class: 'bk-message-close'
}, [h('i', {
class: 'bk-icon icon-close'
})]);
},
onClick: this.handleCloseClick
}), _ref;
},
actionList: function actionList() {
var _this2 = this;
if (this.actions && this.actions.length > 0) {
var resultList = this.actions.map(function (action) {
var id = action.id.toLocaleLowerCase();
var defAction = _this2.defActionList[id];
var defClickFn = defAction.onClick;
var target = _extends({}, _this2.defActionList[id] || {}, action);
target.id = id;
if (action.classList !== undefined) {
var classList = isArray$1(action.classList) ? action.classList : [action.classList];
var defClassList = [];
if (defAction.classList !== undefined) {
defClassList = isArray$1(defAction.classList) ? defAction.classList : [defAction.classList];
}
target.classList = [].concat(_toConsumableArray(defClassList), _toConsumableArray(classList));
}
if (typeof action.onClick === 'function') {
target.onClick = function () {
var resp = apply$1(action.onClick, _this2, []);
if ((typeof resp === 'undefined' || resp) && typeof defClickFn === 'function') {
apply$1(defClickFn, _this2, []);
}
};
return target;
}
target.onClick = defClickFn;
return target;
});
var appendList = sortActionIdList.filter(function (id) {
return !resultList.some(function (action) {
return action.id === id;
});
}).map(function (id) {
return _this2.defActionList[id];
});
resultList.push.apply(resultList, _toConsumableArray(appendList));
return resultList;
}
return sortActionIdList.map(function (id) {
return _this2.defActionList[id];
});
},
isDetailShow: function isDetailShow() {
return this.toolOperation.isDetailShow;
}
},
methods: {
addMouseKeyEvent: function addMouseKeyEvent() {
var remove = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (remove) {
document.removeEventListener('keydown', this.handleMouseKeyEvent);
return;
}
document.addEventListener('keydown', this.handleMouseKeyEvent);
},
handleMouseKeyEvent: function handleMouseKeyEvent(e) {
var ctrlKey = e.ctrlKey,
altKey = e.altKey,
keyCode = e.keyCode;
var isFix = this.toolOperation.isFix;
if (ctrlKey && altKey && keyCode === 80) {
isFix && this.fixMesage(e, false);
return;
}
if (altKey && keyCode === 80) {
!isFix && this.fixMesage(e, true);
}
},
handleCloseClick: function handleCloseClick() {
this.$emit('close');
},
handleHeplerClick: function handleHeplerClick(e) {
if (this.message.assistant) {
window.open(this.message.assistant, '_blank');
}
},
setDetailsShow: function setDetailsShow(e, isShow) {
var _this3 = this;
this.toolOperation.isDetailShow = isShow !== undefined ? isShow : !this.isDetailShow;
this.$emit('message-show', this.isDetailShow);
this.fixMesage(e, this.isDetailShow);
if (this.isDetailShow && _typeof(this.message) === 'object' && !this.message.hasOwnProperty('componentOptions')) {
if (this.message.type === MessageContentType.JSON || !this.message.type) {
var targetJson = this.parseJson(this.message.details);
var formatter = new JSONFormatter(targetJson);
setTimeout(function () {
if (_this3.$refs.refJsonContent) {
_this3.$refs.refJsonContent.innerHTML = '';
_this3.$refs.refJsonContent.append(formatter.render());
}
_this3.copyMessage();
});
}
if (this.message.type === MessageContentType.KEY_VALUE) {
setTimeout(function () {
_this3.copyMessage();
_this3.setCopyValueItems();
});
}
}
},
fixMesage: function fixMesage(e, isFix) {
this.toolOperation.isFix = isFix !== undefined ? isFix : !this.toolOperation.isFix;
this.$emit('fix-message', this.toolOperation.isFix);
},
parseJson: function parseJson(value) {
var targetJson = value;
if (typeof value === 'string') {
try {
targetJson = JSON.parse(value);
} catch (e) {
console.error("Format Json Error: ".concat(e));
}
}
return targetJson;
},
setCopyValueItems: function setCopyValueItems() {
var copyInstance = new ClipboardJS(this.$refs.refJsonContent.querySelectorAll('span.copy-value'), {
text: function text(trigger) {
return trigger.innerHTML;
}
});
this.registerCopyCallback(copyInstance);
},
registerCopyCallback: function registerCopyCallback(copyInstance, complete) {
var _this4 = this;
['success', 'error'].forEach(function (theme) {
copyInstance.on(theme, function (e) {
console.log('registerCopyCallback theme', theme);
var target = _this4.$refs.refCopyStatus;
_this4.copyStatus = theme;
_this4.$nextTick(function () {
if (target) {
var _target$classList, _target$classList2;
var _e$trigger = e.trigger,
offsetLeft = _e$trigger.offsetLeft,
offsetWidth = _e$trigger.offsetWidth,
offsetTop = _e$trigger.offsetTop;
(_target$classList = target.classList).remove.apply(_target$classList, ['success', 'error', 'is-hidden']);
(_target$classList2 = target.classList).add.apply(_target$classList2, [theme, 'is-show']);
var msgTree = e.trigger.closest('.message-tree');
var msgTreeScrollTop = msgTree ? msgTree.scrollTop : 0;
var transX = offsetLeft + offsetWidth / 2 - 41;
var transY = offsetTop - msgTreeScrollTop - 40;
target.style.setProperty('transform', "translate(".concat(transX, "px, ").concat(transY, "px"));
_this4.copyStatusTimer && clearTimeout(_this4.copyStatusTimer);
_this4.copyStatusTimer = setTimeout(function () {
var _target$classList3, _target$classList4;
(_target$classList3 = target.classList).remove.apply(_target$classList3, ['is-show']);
(_target$classList4 = target.classList).add.apply(_target$classList4, ['is-hidden']);
}, 2000);
}
if (typeof complete === 'function') {
complete();
}
});
});
});
},
parseToString: function parseToString(value) {
var targetStr = value;
if (_typeof(value) === 'object') {
try {
targetStr = stringify$1(value);
} catch (e) {
console.error("JSON.stringify Error: ".concat(e));
}
}
return targetStr;
},
copyMessage: function copyMessage() {
var _this5 = this;
var copyInstance = new ClipboardJS(this.$refs.refCopyMsgDiv, {
text: function text() {
return _this5.parseToString(_this5.message.details);
}
});
this.registerCopyCallback(copyInstance);
}
},
render: function render(h) {
var _this6 = this;
var renderMsgDetail = function renderMsgDetail(msg) {
if (msg.type === MessageContentType.KEY_VALUE) {
var target = _this6.parseJson(msg.details || {});
var keys = keys$1(target);
return keys.map(function (key) {
return h('div', {
class: 'message-row'
}, [h('label', key), h('span', {
class: 'copy-value'
}, target[key])]);
});
}
return null;
};
var renderMessageActions = function renderMessageActions() {
var renderIcon = function renderIcon(_ref2) {
var icon = _ref2.icon;
if (typeof icon === 'function') {
return apply$1(icon, _this6, [h]);
}
return h('span', {
class: icon
});
};
var renderText = function renderText(_ref3) {
var text = _ref3.text;
var content;
if (typeof text === 'function') {
content = apply$1(text, _this6, [h]);
}
if (content === undefined) {
return;
}
if (typeof content === 'string') {
return h('span', {
class: 'message-action-text'
}, [content]);
}
return content;
};
var handleActionClick = function handleActionClick(e, action) {
if (action.readonly || action.disabled) {
return;
}
if (typeof action.onClick === 'function') {
apply$1(action.onClick, _this6, [e, action]);
}
};
var renderActionList = function renderActionList() {
return _this6.actionList.map(function (action) {
if (action.disabled) {
return null;
}
if (typeof action.render === 'function') {
return apply$1(action.render, _this6, []);