UNPKG

bk-magic-vue

Version:

基于蓝鲸 Magicbox 和 Vue 的前端组件库

1,462 lines (1,401 loc) 99.2 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('bk-magic-vue/lib/locale')) : typeof define === 'function' && define.amd ? define(['exports', 'bk-magic-vue/lib/locale'], factory) : (global = global || self, factory(global.library = {}, global.locale)); }(this, function (exports, locale) { 'use strict'; locale = locale && locale.hasOwnProperty('default') ? locale['default'] : locale; function _regeneratorRuntime() { _regeneratorRuntime = function () { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function (obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function (skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function () { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function (exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function (type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function (record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function (finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function (tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function (iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } 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 _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 _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(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 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$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 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 toString = {}.toString; var _cof = function (it) { return toString.call(it).slice(8, -1); }; 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 id = 0; var px = Math.random(); var _uid = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; 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 _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); }; var meta = _meta.onFreeze; _objectSap('freeze', function ($freeze) { return function freeze(it) { return $freeze && _isObject(it) ? $freeze(meta(it)) : it; }; }); var freeze = _core.Object.freeze; var freeze$1 = freeze; 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 + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f }); var $Object = _core.Object; var defineProperty = function defineProperty(it, key, desc) { return $Object.defineProperty(it, key, desc); }; var defineProperty$1 = defineProperty; var _toObject = function (it) { return Object(_defined(it)); }; 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; }; }; 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 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); }; _objectSap('keys', function () { return function keys(it) { return _objectKeys(_toObject(it)); }; }); var keys = _core.Object.keys; var keys$1 = keys; var getNodeId = function getNodeId(data, tree) { var idKey = tree.nodeOptions.idKey; if (typeof idKey === 'function') { return idKey(data); } return data[idKey]; }; var getNodeIcon = function getNodeIcon(data, tree) { var icon = { expand: tree.expandIcon, collapse: tree.collapseIcon, node: tree.nodeIcon }; if (typeof icon.node === 'function') { icon.node = icon.node(data); } return icon; }; var isNullOrUndefined = function isNullOrUndefined(value) { return value === null || value === undefined; }; var convertToArray = function convertToArray(value) { return isArray$1(value) ? value : [value]; }; var checkIsLazy = function checkIsLazy(node, tree) { if (typeof tree.lazyMethod !== 'function') { return false; } if (typeof tree.lazyDisabled === 'boolean') { return !tree.lazyDisabled; } else if (typeof tree.lazyDisabled === 'function') { return !tree.lazyDisabled(node); } return true; }; var TreeNode = function () { function TreeNode(data, options, tree) { var _this = this; _classCallCheck(this, TreeNode); var folderKey = tree.nodeOptions['folderKey']; var isFolder = folderKey && data[folderKey]; var sealData = { data: data, tree: tree, _vNode: null, id: getNodeId(data, tree), icon: getNodeIcon(data, tree), line: 0, level: options.level, index: options.index, childIndex: options.childIndex || 0, parent: options.parent, children: [], timer: null, isFolder: isFolder }; keys$1(sealData).forEach(function (key) { defineProperty$1(_this, key, { enumerable: true, configurable: tree.configurable, writable: true, value: sealData[key] }); }); this.state = { checked: false, expanded: tree.defaultExpandAll, disabled: false, disableCheck: false, visible: true, matched: true, loading: false, lazy: checkIsLazy(this, tree) }; } _createClass(TreeNode, [{ key: "uid", get: function get() { return "".concat(this.tree.id, "-node-").concat(this.index); } }, { key: "name", get: function get() { return this.data[this.tree.nodeOptions.nameKey]; } }, { key: "vNode", get: function get() { return this._vNode; } , set: function set(vNode) { this._vNode = vNode; if (this.expanded) { this.recalculateLinkLine(); } } }, { key: "parents", get: function get() { if (!this.parent) { return []; } return [].concat(_toConsumableArray(this.parent.parents), [this.parent]); } }, { key: "descendants", get: function get() { var descendants = []; this.children.forEach(function (node) { descendants.push(node); descendants.push.apply(descendants, _toConsumableArray(node.descendants)); }); return descendants; } }, { key: "isLeaf", get: function get() { return !this.lazy && !this.loading && !this.children.length; } }, { key: "lazy", get: function get() { return this.state.lazy && !this.children.length; } }, { key: "loading", get: function get() { return this.state.loading; } }, { key: "hasCheckbox", get: function get() { var showCheckbox = this.tree.showCheckbox; if (typeof showCheckbox === 'function') { return showCheckbox(this.data); } return showCheckbox; } }, { key: "disableCheck", get: function get() { return this.state.disableCheck; }, set: function set(disableCheck) { this.setState('disableCheck', disableCheck); } }, { key: "collapseIcon", get: function get() { return this.icon.collapse; } }, { key: "selected", get: function get() { return this.tree.selectable && this.tree.selected === this.id; } }, { key: "expandIcon", get: function get() { return this.icon.expand; } }, { key: "nodeIcon", get: function get() { return this.icon.node; } }, { key: "checked", get: function get() { return this.state.checked; }, set: function set(checked) { if (this.state.checked === checked && !this.indeterminate) { return false; } this.setState('checked', checked); if (this.tree.checkStrictly) { this.children.forEach(function (child) { if (child.checkable) { child.checked = checked; } }); if (this.parent) { this.parents.reverse().forEach(function (parent) { if (checked) { var parentChecked = !parent.children.some(function (node) { return !node.checked; }); parent.setState('checked', parentChecked); } else { parent.setState('checked', false); } }); } } } }, { key: "checkable", get: function get() { if (this.disabled || this.disableCheck) { return false; } if (this.tree.inSearch && this.tree.checkOnlyAvailableStrictly) { if (this.tree.displayMatchedNodeDescendants) { return this.matched || this.childrenMatched || this.parentsMatched; } return this.matched || this.childrenMatched; } return true; } }, { key: "expanded", get: function get() { return this.state.expanded; }, set: function set(expanded) { var _this2 = this; if (this.state.expanded === expanded) { return false; } this.setState('expanded', expanded); if (expanded && this.parent) { this.parent.expanded = true; } this.children.forEach(function (node) { node.visible = expanded; }); this.tree.$nextTick( _asyncToGenerator( _regeneratorRuntime().mark(function _callee() { var _yield$_this2$tree$la, _yield$_this2$tree$la2, leaf, _yield$_this2$tree$la3, data, newNodes; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (!(expanded && _this2.lazy)) { _context.next = 21; break; } _this2.setState('loading', true); _this2.setState('lazy', false); _context.prev = 3; _context.next = 6; return _this2.tree.lazyMethod(_this2); case 6: _yield$_this2$tree$la = _context.sent; _yield$_this2$tree$la2 = _yield$_this2$tree$la.leaf; leaf = _yield$_this2$tree$la2 === void 0 ? [] : _yield$_this2$tree$la2; _yield$_this2$tree$la3 = _yield$_this2$tree$la.data; data = _yield$_this2$tree$la3 === void 0 ? [] : _yield$_this2$tree$la3; newNodes = _this2.tree.addNode(data, _this2.id); newNodes.forEach(function (node) { if (leaf.includes(node.id)) { node.setState('lazy', false); } }); _context.next = 18; break; case 15: _context.prev = 15; _context.t0 = _context["catch"](3); console.error(_context.t0); case 18: _context.prev = 18; _this2.setState('loading', false); return _context.finish(18); case 21: case "end": return _context.stop(); } }, _callee, null, [[3, 15, 18, 21]]); }))); this.recalculateLinkLine(); } }, { key: "disabled", get: function get() { return this.state.disabled; }, set: function set(disabled) { if (this.state.disabled === disabled) { return false; } this.setState('disabled', disabled); if (this.tree.disableStrictly) { this.descendants.forEach(function (descendant) { descendant.disabled = disabled; }); } } }, { key: "matched", get: function get() { return this.state.matched; }, set: function set(matched) { this.setState('matched', matched); } }, { key: "childrenMatched", get: function get() { return this.children.some(function (child) { return child.matched || child.childrenMatched; }); } }, { key: "parentsMatched", get: function get() { return this.parents.some(function (parent) { return parent.matched; }); } }, { key: "visible", get: function get() { var basicVisible = this.parent ? this.parent.expanded && this.state.visible : this.state.visible; if (!this.tree.inSearch) { return basicVisible; } var searchVisible = basicVisible && (this.matched || this.childrenMatched); if (this.tree.displayMatchedNodeDescendants) { var parentMatchedVisible = basicVisible && this.parentsMatched; return searchVisible || parentMatchedVisible; } return searchVisible; }, set: function set(visible) { if (this.state.visible === visible) { return false; } this.setState('visible', visible); this.children.forEach(function (node) { node.visible = visible; }); } }, { key: "indeterminate", get: function get() { if (this.tree.checkStrictly) { var childrenIndeterminate = this.children.some(function (child) { return child.indeterminate; }); if (childrenIndeterminate) { return true; } var checkedChildren = this.children.filter(function (child) { return child.checked; }); return !!checkedChildren.length && checkedChildren.length !== this.children.length; } return false; } }, { key: "setState", value: function setState(key, value) { if (this.state.hasOwnProperty(key)) { this.state[key] = value; } } }, { key: "recalculateLinkLine", value: function recalculateLinkLine() { if (this.tree.hasLine) { var needsCalculateNodes = _toConsumableArray(this.tree.needsCalculateNodes); if (needsCalculateNodes.includes(this)) { return false; } needsCalculateNodes.push(this); this.tree.needsCalculateNodes = freeze$1(needsCalculateNodes); this.parent && this.parent.recalculateLinkLine(); } } }, { key: "appendChild", value: function appendChild(node, offset, options) { var _this$children; var nodes = isArray$1(node) ? node : [node]; (_this$children = this.children).splice.apply(_this$children, [offset, 0].concat(_toConsumableArray(nodes))); this.children.slice(offset).forEach(function (node, index) { node.childIndex = offset + index; }); this.expanded = options.expandParent; this.recalculateLinkLine(); return nodes; } }, { key: "removeChild", value: function removeChild(node) { var _this3 = this; var nodes = isArray$1(node) ? node : [node]; var removedChildIndex = []; var removedIndex = []; nodes.forEach(function (node) { var childIndex = node.childIndex; removedChildIndex.push(childIndex); removedIndex.push(node.index); _this3.children.splice(childIndex, 1); }); var minIndex = Math.min.apply(Math, removedChildIndex); this.children.slice(minIndex).forEach(function (node, index) { node.childIndex = minIndex + index; }); this.recalculateLinkLine(); return nodes; } }]); return TreeNode; }(); function throttle (delay, noTrailing, callback, debounceMode) { var timeoutID; var cancelled = false; var lastExec = 0; function clearExistingTimeout() { if (timeoutID) { clearTimeout(timeoutID); } } function cancel() { clearExistingTimeout(); cancelled = true; } if (typeof noTrailing !== 'boolean') { debounceMode = callback; callback = noTrailing; noTrailing = undefined; } function wrapper() { var self = this; var elapsed = Date.now() - lastExec; var args = arguments; if (cancelled) { return; } function exec() { lastExec = Date.now(); callback.apply(self, args); } function clear() { timeoutID = undefined; } if (debounceMode && !timeoutID) { exec(); } clearExistingTimeout(); if (debounceMode === undefined && elapsed > delay) { exec(); } else if (noTrailing !== true) { timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay); } } wrapper.cancel = cancel; return wrapper; } var RenderSlot = { props: { data: Object, height: { type: Number, default: 0 }, top: { type: Number, default: 0 }, left: { type: Number, default: 0 }, renderItem: Function }, created: function created() { this.style = { height: "".concat(this.height, "px"), top: "".concat(this.top, "px"), left: "".concat(this.left, "px") }; }, render: function render(h) { return h('li', { style: this.style }, this.renderItem(this.data)); } }; var script = { name: 'bk-virtual-scroll', components: { RenderSlot: RenderSlot }, props: { itemHeight: { type: Number, default: 16 }, showIndex: { type: Boolean, default: false }, list: { type: Array, default: function _default() { return []; } }, extCls: { type: String, default: '' } }, data: function data() { return { ulHeight: 0, allListData: [], offscreenCanvas: '', indexList: [], listData: [], worker: {}, mainWidth: 0, mainLeft: 0, totalHeight: 0, itemNumber: 0, totalNumber: 0, visHeight: 0, visWidth: 0, totalScrollHeight: 0, startMinMapMove: false, tempVal: 0, minMapTop: 0, minNavTop: 0, navHeight: 0, mapHeight: 0, moveRate: 0, bottomScrollWidth: Infinity, bottomScrollDis: 0, itemWidth: 0, isScrolling: false, isBottomMove: false, downPreDefault: false, upPreDefault: false, indexWidth: 0, observer: {} }; }, watch: { list: { handler: function handler(list) { this.setListData(list); }, deep: true } }, created: function created() { this.calcList = throttle(30, this.calcData); }, mounted: function mounted() { this.initStatus(); this.initEvent(); if (this.list.length > 0) this.setListData(this.list); }, beforeDestroy: function beforeDestroy() { document.removeEventListener('mousemove', this.minNavMove); document.removeEventListener('mouseup', this.moveEnd); window.removeEventListener('resize', this.resize); if (MutationObserver) this.observer.disconnect(); this.observer = {}; }, methods: { initStatus: function initStatus() { var mainEle = this.$refs.scrollHome; var scrollEle = this.$refs.scrollMain; this.visHeight = mainEle.offsetHeight || 300; this.visWidth = mainEle.offsetWidth || 300; var scrollWidth = scrollEle.scrollWidth || 0; this.itemWidth = scrollWidth; this.bottomScrollWidth = this.visWidth * this.visWidth / scrollWidth < 20 ? 20 : this.visWidth * this.visWidth / scrollWidth; var dpr = window.devicePixelRatio || 1; this.$refs.minNav.width = 8 * dpr; this.$refs.minNav.height = this.visHeight * dpr; this.$refs.minNav.getContext('2d').setTransform(dpr, 0, 0, dpr, 0, 0); }, initEvent: function initEvent() { document.addEventListener('mousemove', this.minNavMove); document.addEventListener('mouseup', this.moveEnd); window.addEventListener('resize', this.resize); if (MutationObserver) { this.observer = new MutationObserver(this.resize); this.observer.observe(this.$el, { attributes: true, attributeFilter: ['style'] }); } }, renderItem: function renderItem(data) { if (this.$scopedSlots && this.$scopedSlots.default) { return this.$scopedSlots.default({ data: data }); } return null; }, resize: function resize(event) { var _this = this; this.slowExec(function () { var lastHeight = _this.visHeight; _this.initStatus(); _this.setStatus(); _this.minMapTop = _thi