UNPKG

@cw-devops/bk-magic-vue

Version:

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

1,461 lines (1,406 loc) 53.6 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('bk-magic-vue/lib/locale'), require('vue')) : typeof define === 'function' && define.amd ? define(['exports', 'bk-magic-vue/lib/locale', 'vue'], factory) : (global = global || self, factory(global.library = {}, global.locale, global.Vue)); }(this, function (exports, locale, Vue) { 'use strict'; locale = locale && locale.hasOwnProperty('default') ? locale['default'] : locale; Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue; function _regeneratorRuntime() { _regeneratorRuntime = function () { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function (t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function (t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function (e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function (e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function (t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function (t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function (e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } 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 _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 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 $parseFloat = _global.parseFloat; var $trim = _stringTrim.trim; var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) { var string = $trim(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 $parseInt = _global.parseInt; var $trim$1 = _stringTrim.trim; var hex = /^[-+]?0[xX]/; var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) { var string = $trim$1(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 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; function addClass(node, className) { var classNames = className.split(' '); if (node.nodeType === 1) { if (!node.className && classNames.length === 1) { node.className = className; } else { var setClass = ' ' + node.className + ' '; classNames.forEach(function (cl) { if (setClass.indexOf(' ' + cl + ' ') < 0) { setClass += cl + ' '; } }); var rtrim = /^\s+|\s+$/; node.className = setClass.replace(rtrim, ''); } } } function removeClass(node, className) { var classNames = className.split(' '); if (node.nodeType === 1) { var setClass = ' ' + node.className + ' '; classNames.forEach(function (cl) { setClass = setClass.replace(' ' + cl + ' ', ' '); }); var rtrim = /^\s+|\s+$/; node.className = setClass.replace(rtrim, ''); } } var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); }; var cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) { window.clearTimeout(id); }; function uuid() { var id = ''; var randomNum = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); for (var i = 0; i < 7; i++) { id += randomNum; } return id; } var requestFrame = function () { var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) { return window.setTimeout(fn, 20); }; return function (fn) { return raf(fn); }; }(); var cancelFrame = function () { var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.clearTimeout; return function (id) { return cancel(id); }; }(); var resetTrigger = function resetTrigger(element) { var trigger = element.__resizeTrigger__; var expand = trigger.firstElementChild; var contract = trigger.lastElementChild; var expandChild = expand.firstElementChild; contract.scrollLeft = contract.scrollWidth; contract.scrollTop = contract.scrollHeight; expandChild.style.width = expand.offsetWidth + 1 + 'px'; expandChild.style.height = expand.offsetHeight + 1 + 'px'; expand.scrollLeft = expand.scrollWidth; expand.scrollTop = expand.scrollHeight; }; var checkTriggers = function checkTriggers(element) { return element.offsetWidth !== element.__resizeLast__.width || element.offsetHeight !== element.__resizeLast__.height; }; var scrollListener = function scrollListener(event) { var _this = this; resetTrigger(this); if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__); this.__resizeRAF__ = requestFrame(function () { if (checkTriggers(_this)) { _this.__resizeLast__.width = _this.offsetWidth; _this.__resizeLast__.height = _this.offsetHeight; _this.__resizeListeners__.forEach(function (fn) { fn.call(_this, event); }); } }); }; var attachEvent = document.attachEvent; var DOM_PREFIXES = 'Webkit Moz O ms'.split(' '); var START_EVENTS = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '); var RESIZE_ANIMATION_NAME = 'resizeanim'; var animation = false; var keyFramePrefix = ''; var animationStartEvent = 'animationstart'; if (!attachEvent) { var testElement = document.createElement('fakeelement'); if (testElement.style.animationName !== undefined) { animation = true; } if (animation === false) { var prefix = ''; for (var i = 0; i < DOM_PREFIXES.length; i++) { if (testElement.style[DOM_PREFIXES[i] + 'AnimationName'] !== undefined) { prefix = DOM_PREFIXES[i]; keyFramePrefix = '-' + prefix.toLowerCase() + '-'; animationStartEvent = START_EVENTS[i]; animation = true; break; } } } } var stylesCreated = false; var createStyles = function createStyles() { if (!stylesCreated) { var animationKeyframes = "@".concat(keyFramePrefix, "keyframes ").concat(RESIZE_ANIMATION_NAME, " { from { opacity: 0; } to { opacity: 0; } } "); var animationStyle = "".concat(keyFramePrefix, "animation: 1ms ").concat(RESIZE_ANIMATION_NAME, ";"); var css = "".concat(animationKeyframes, "\n .resize-triggers { ").concat(animationStyle, " visibility: hidden; opacity: 0; }\n .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1 }\n .resize-triggers > div { background: #eee; overflow: auto; }\n .contract-trigger:before { width: 200%; height: 200%; }"); var head = document.head || document.getElementsByTagName('head')[0]; var style = document.createElement('style'); style.type = 'text/css'; if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); stylesCreated = true; } }; var addResizeListener = function addResizeListener(element, fn) { var useCapture = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; console.log('000000 => ', '我是输出'); if (attachEvent) { element.attachEvent('onresize', fn); } else { if (!element.__resizeTrigger__) { if (getComputedStyle(element).position === 'static') { element.style.position = 'relative'; } createStyles(); element.__resizeLast__ = {}; element.__resizeListeners__ = []; var resizeTrigger = element.__resizeTrigger__ = document.createElement('div'); resizeTrigger.className = 'resize-triggers'; resizeTrigger.innerHTML = '<div class="expand-trigger"><div></div></div><div class="contract-trigger"></div>'; element.appendChild(resizeTrigger); resetTrigger(element); element.addEventListener('scroll', scrollListener, useCapture); if (animationStartEvent) { resizeTrigger.addEventListener(animationStartEvent, function (event) { if (event.animationName === RESIZE_ANIMATION_NAME) { resetTrigger(element); } }); } } element.__resizeListeners__.push(fn); } }; var removeResizeListener = function removeResizeListener(element, fn) { if (!element || !element.__resizeListeners__) return; if (attachEvent) { element.detachEvent('onresize', fn); } else { element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); if (!element.__resizeListeners__.length) { element.removeEventListener('scroll', scrollListener); element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__); } } }; _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 hasInitZIndex = false; var zIndex; (function () { if (!window['__bk_zIndex_manager']) { var zIndexManager = { nextZIndex: function nextZIndex() { var zIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; return zIndex === 'default' ? zIndexManager.zIndex++ : zIndex; }, nextTickIndex: function nextTickIndex() { var tick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; var zIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; if (zIndex === 'default') { zIndexManager.zIndex += tick; return zIndexManager.zIndex; } return zIndex; } }; defineProperty$1(zIndexManager, 'zIndex', { configurable: true, get: function get() { if (!hasInitZIndex) { zIndex = zIndex || (Vue.prototype.$BK_EL || {}).zIndex || 2000; hasInitZIndex = true; } return zIndex; }, set: function set(value) { zIndex = value; } }); window['__bk_zIndex_manager'] = zIndexManager; } })(); var zIndexManager = window['__bk_zIndex_manager']; _export(_export.S, 'Number', { isNaN: function isNaN(number) { return number != number; } }); var isNan = _core.Number.isNaN; var isNan$1 = isNan; (function () { if (!window['__bk_pop_manager']) { var __containerId = "bk_pop_".concat(new Date().getTime()); var __maskId = "bk_pop_mask_".concat(new Date().getTime()); var __defaultKey = "bk_pop_key_".concat(new Date().getTime()); var __popInstances = []; var popManager = { containerId: __containerId, maskId: __maskId, defaultKey: __defaultKey, formatKey: function formatKey(key) { return String(key).replace(/#/g, '_'); }, show: function show(key, instance) { var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { tplAction: 'keepAll', zIndex: '', beforeHide: function beforeHide() {}, ignoreExistMask: false, appendToBody: false }; key = key === undefined || key === null || isNan$1(key) ? this.defaultKey : key; key = this.formatKey(key); var uid = uuid(); var isAppendToBody = false; if (options.tplAction === 'onlyone') { this.clearByTpl(key); } if (this.shouldAppendToBody(key)) { isAppendToBody = true; this.showModalMask(options.zIndex); !options.appendToBody && this.container.append(instance); } else { isAppendToBody = false; var lastInsZindex = options.zIndex; this.showModalMask(lastInsZindex); } var beforeHide = options.beforeHide, zIndex = options.zIndex, ignoreExistMask = options.ignoreExistMask; this.instances.push({ uid: uid, ins: instance, tplName: key, beforeHide: beforeHide, zIndex: zIndex, ignoreExistMask: ignoreExistMask, isAppendToBody: isAppendToBody }); return "".concat(uid, "#").concat(key); }, shouldAppendToBody: function shouldAppendToBody(tplName) { return this.instances.some(function (item) { return item.tplName === tplName; }); }, hide: function hide(popId, options) { options = options || { action: 'hideUid' }; switch (options.action) { case 'hideAll': this.clearAll(); break; case 'hideUid': this.clearByUid(popId); break; case 'hideSameTpl': this.clearByTpl(popId); break; default: this.autoClear(popId); break; } this.updateModalMaskIndex(); }, updateModalMaskIndex: function updateModalMaskIndex() { if (this.instances.length) { var lastIns = this.instances.slice(-1)[0]; var lastInsZindex = lastIns.isAppendToBody ? lastIns.zIndex : lastIns.zIndex - 1; this.showModalMask(lastInsZindex); } else { this.hideModalMask(); } }, autoClear: function autoClear() { var uid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; if (uid.indexOf('#') > 0) { this.clearByUid(uid); } else { this.clearByTpl(); } }, clearByTpl: function clearByTpl(uid) { var _this = this; var keyStr = uid.split('#'); var tplName = keyStr.slice(-1)[0]; this.instances = this.instances.filter(function (item) { if (item.tplName === tplName) { _this.__hideInstance(item); return false; } else { return true; } }); }, clearByUid: function clearByUid(uid) { var keyStr = uid.split('#'); var instanceUid = keyStr[0]; var tplName = keyStr[1]; var index = this.instances.findIndex(function (ins) { return ins.uid === instanceUid && ins.tplName === tplName; }); if (index >= 0) { this.__hideInstance(this.instances[index]); this.instances.splice(index, 1); } else { console.warn('Can not find pop instance with index ' + index); } }, clearAll: function clearAll() { var _this2 = this; this.instances.forEach(function (item) { return _this2.__hideInstance(item); }); this.instances = []; }, showModalMask: function showModalMask(zIndex) { this.dialogMask.setAttribute('style', "z-index:".concat(zIndex, ";")); document.body.style.overflow = 'hidden'; this.dialogMask.classList.remove('hide-active'); this.dialogMask.classList.add('show-active'); }, hideModalMask: function hideModalMask() { this.dialogMask.classList.remove('show-active'); this.dialogMask.classList.add('hide-active'); document.body.style.overflow = ''; }, __hideInstance: function __hideInstance(instance) { if (typeof instance.beforeHide === 'function') { instance.beforeHide(); setTimeout(function () { if (instance.isAppendToBody) { instance.ins.remove(); } }); } else { if (instance.isAppendToBody) { instance.ins.remove(); } } }, isMaskShown: function isMaskShown() { var mask = document.querySelector('[data-bkpop-mask]'); if (mask) { return mask.classList.contains('show-active'); } return false; } }; defineProperty$1(popManager, 'container', { get: function get() { var container = document.querySelector('[data-bkpop-container]'); if (!container) { container = document.createElement('div'); container.setAttribute('id', this.containerId); container.setAttribute('data-bkpop-container', 'true'); document.body.append(container); } return container; } }); defineProperty$1(popManager, 'dialogMask', { get: function get() { var mask = document.querySelector('[data-bkpop-mask]'); if (!mask) { mask = document.createElement('div'); mask.setAttribute('id', this.maskId); mask.setAttribute('class', 'bk-dialog-mask'); mask.setAttribute('data-bkpop-mask', 'true'); this.container.append(mask); } return mask; } }); defineProperty$1(popManager, 'instances', { get: function get() { return __popInstances; }, set: function set(val) { __popInstances = val; } }); window['__bk_pop_manager'] = popManager; window['__bk_pop_manager'].__container = popManager.container; } })(); var popManager = window['__bk_pop_manager']; function getTarget(node) { if (node === void 0) { node = document.body; } if (node === true) { return document.body; } return node instanceof window.Node ? node : document.querySelector(node); } var transferDom = { inserted: function inserted(el, _ref, vnode) { var value = _ref.value; if (el.dataset.transfer !== 'true') { return false; } el.className = el.className ? el.className + ' v-transfer-dom' : 'v-transfer-dom'; var parentNode = el.parentNode; if (!parentNode) { return; } var home = document.createComment(''); var hasMovedOut = false; if (value !== false) { parentNode.replaceChild(home, el); getTarget(value).appendChild(el); hasMovedOut = true; } if (!el.__transferDomData) { el.__transferDomData = { parentNode: parentNode, home: home, target: getTarget(value), hasMovedOut: hasMovedOut }; } }, componentUpdated: function componentUpdated(el, _ref2) { var value = _ref2.value; if (el.dataset.transfer !== 'true') { return false; } var ref$1 = el.__transferDomData; if (!ref$1) { return; } var parentNode = ref$1.parentNode; var home = ref$1.home; var hasMovedOut = ref$1.hasMovedOut; if (!hasMovedOut && value) { parentNode.replaceChild(home, el); getTarget(value).appendChild(el); el.__transferDomData = _extends({}, el.__transferDomData, { hasMovedOut: true, target: getTarget(value) }); } else if (hasMovedOut && value === false) { parentNode.replaceChild(el, home); el.__transferDomData = _extends({}, el.__transferDomData, { hasMovedOut: false, target: getTarget(value) }); } else if (value) { getTarget(value).appendChild(el); } }, unbind: function unbind(el) { if (el.dataset.transfer !== 'true') { return false; } el.className = el.className.replace('v-transfer-dom', ''); var ref$1 = el.__transferDomData; if (!ref$1) { return; } if (el.__transferDomData.hasMovedOut === true) { el.__transferDomData.parentNode && el.__transferDomData.parentNode.appendChild(el); } el.__transferDomData = null; } }; transferDom.install = function (Vue) { Vue.directive('bk-transfer-dom', transferDom); }; var script = { name: 'bk-sideslider', directives: { transferDom: transferDom }, mixins: [locale.mixin], props: { isShow: { type: Boolean, default: false }, title: { type: String, default: '' }, quickClose: { type: Boolean, default: false }, showMask: { type: Boolean, default: true }, width: { type: [String, Number], default: 400 }, beforeClose: { type: Function, default: function _default(res) { return true; } }, direction: { type: String, default: 'right', validator: function validator(value) { return ['left', 'right'].indexOf(value) > -1; } }, extCls: { type: String, default: '' }, zIndex: { type: [Number, String], default: 'default' }, multiInstance: { type: Boolean, default: true }, transfer: { type: Boolean, default: false }, appendToBody: { type: Boolean, default: false } }, data: function data() { return { needBorder: false, localZIndex: zIndexManager.nextTickIndex(2), popUid: '' }; }, computed: { calcWidth: function calcWidth() { if (/^\d+$/.test(this.width)) { return "".concat(this.width, "px"); } return this.width; }, calcDirection: function calcDirection() { return this.direction === 'left' ? 'right' : 'left'; } }, watch: { isShow: function isShow(val) { var _this = this; var root = document.documentElement; if (val) { this.localZIndex = zIndexManager.nextTickIndex(2); addClass(root, 'bk-sideslider-show'); if (this.isScrollY()) { addClass(root, 'has-sideslider-padding'); } if (this.showMask) { this.generatePopUid(); } this.$nextTick(function () { if (_this.$refs.content) { addResizeListener(_this.$refs.content, _this.handleContentResize, false); } }); setTimeout(function () { _this.$emit('shown'); }, 200); } else { removeClass(root, 'bk-sideslider-show has-sideslider-padding'); if (this.popUid) { popManager.hide(this.popUid); this.popUid = ''; } setTimeout(function () { _this.$emit('hidden'); }, 200); } } }, mounted: function mounted() {}, destroyed: function destroyed() { var root = document.querySelector('html'); removeClass(root, 'bk-sideslider-show'); removeResizeListener(this.$refs.content, this.handleContentResize); if (this.$el && this.$el.parentNode) { this.$el.parentNode.removeChild(this.$el); } }, beforeDestroy: function beforeDestroy() { this.isShow && this.popUid && popManager.hide(this.popUid); }, methods: { generatePopUid: function generatePopUid() { this.popUid = popManager.show('bk-sideslider', this.$el, { zIndex: this.localZIndex - 1, tplAction: this.multiInstance && 'keepAll' || 'onlyone', appendToBody: this.transfer }); }, isScrollY: function isScrollY() { return document.documentElement.offsetHeight > document.documentElement.clientHeight; }, show: function show() { var root = document.documentElement; addClass(root, 'bk-sideslider-show'); this.isShow = true; }, hide: function hide() { var root = document.querySelector('html'); removeClass(root, 'bk-sideslider-show'); this.isShow = false; }, handleClose: function handleClose() { var _this2 = this; return _asyncToGenerator( _regeneratorRuntime().mark(function _callee() { var shouldClose; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: shouldClose = true; if (!(typeof _this2.beforeClose === 'function')) { _context.next = 5; break; } _context.next = 4; return _this2.beforeClose(); case 4: shouldClose = _context.sent; case 5: if (shouldClose) { _this2.$emit('update:isShow', false); setTimeout(function () { _this2.$emit('animation-end'); }, 250); } case 6: case "end": return _context.stop(); } }, _callee); }))(); }, handleQuickClose: function handleQuickClose() { if (this.quickClose) { this.handleClose(); } }, handleContentResize: function handleContentResize() { var ref = this.$refs.content; this.needBorder = ref.scrollHeight > ref.clientHeight; } } }; 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; /* script */ 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('transition', { attrs: { "name": "slide" } }, [_vm.isShow ? _c('article', { directives: [{ name: "transfer-dom", rawName: "v-transfer-dom" }], staticClass: "bk-sideslider", class: _vm.extCls, style: { zIndex: _vm.localZIndex }, attrs: { "data-transfer": _vm.transfer }, on: { "mousedown": function mousedown($event) { if ($event.target !== $event.currentTarget) { return null; } return _vm.handleQuickClose($event); } } }, [_c('section', { staticClass: "bk-sideslider-wrapper", class: [{ left: _vm.direction === 'left', right: _vm.direction === 'right' }], style: { width: _vm.calcWidth } }, [_c('div', { staticClass: "bk-sideslider-header" }, [_c('div', { staticClass: "bk-sideslider-closer", style: { float: _vm.calcDirection }, on: { "click": _vm.handleClose } }, [_c('i', { staticClass: "bk-icon", class: 'icon-angle-' + _vm.direction })]), _c('div', { staticClass: "bk-sideslider-title", style: { padding: _vm.calcDirection === 'left' ? '0 0 0 50px' : '0 0 0 30px' } }, [_vm._t("header", [_c('div', { staticClass: "title-content" }, [_vm._v(_vm._s(_vm.title || _vm.t('bk.sideslider.title')))])])], 2)]), _c('div', { ref: "content", staticClass: "bk-sideslider-content", style: { height: _vm.$slots.footer ? 'calc(100vh - 120px)' : 'calc(100vh - 60px)' } }, [_vm._t("content")], 2), _vm.$slots.footer ? _c('div', { staticClass: "bk-sideslider-footer", style: { borderTopColor: !_vm.needBorder ? 'transparent' : '#dcdee5', backgroundColor: !_vm.needBorder ? '#fafbfd' : '#ffffff' } }, [_vm._t("footer")], 2) : _vm._e()])]) : _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 _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