UNPKG

bk-vue-cec

Version:

一个为运维业务场景而生,好看易用的Vue2原创组件库,由T-inside Design进行托管社区化运作

1,700 lines (1,528 loc) 1.85 MB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('path')) : typeof define === 'function' && define.amd ? define(['exports', 'vue', 'path'], factory) : (global = global || self, factory(global.bkMagicVue = {}, global.Vue, global.path)); }(this, function (exports, Vue, path) { 'use strict'; Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue; path = path && path.hasOwnProperty('default') ? path['default'] : path; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _defineProperty(obj, key, value) { 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 || 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 _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } 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 _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function () {}; return { s: F, n: function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (e) { throw e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function () { it = it.call(o); }, n: function () { var step = it.next(); normalCompletion = step.done; return step; }, e: function (e) { didErr = true; err = e; }, f: function () { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function getCjsExportFromNamespace (n) { return n && n['default'] || n; } 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 toString$1 = {}.toString; var _cof = function (it) { return toString$1.call(it).slice(8, -1); }; var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return _cof(it) == 'String' ? it.split('') : Object(it); }; var _defined = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return 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 _library = true; 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 f$1 = {}.propertyIsEnumerable; var _objectPie = { f: f$1 }; var isEnum = _objectPie.f; var _objectToArray = function (isEntries) { return function (it) { var O = _toIobject(it); var keys = _objectKeys(O); var length = keys.length; var i = 0; var result = []; var key; while (length > i) { key = keys[i++]; if (!_descriptors || isEnum.call(O, key)) { result.push(isEntries ? [key, O[key]] : O[key]); } } return result; }; }; var $values = _objectToArray(false); _export(_export.S, 'Object', { values: function values(it) { return $values(it); } }); var values = _core.Object.values; var values$1 = values; _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']; 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; } function debounce (delay, atBegin, callback) { return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false); } var script = { name: 'bk-back-top', props: { bottom: { type: Number, default: 40 }, right: { type: Number, default: 40 }, target: { type: String, default: '' }, visibilityHeight: { type: Number, default: 200 } }, data: function data() { return { visible: false, zIndex: 0, container: document, el: document.documentElement }; }, computed: { positionStyle: function positionStyle() { return "right: ".concat(this.right, "px;\n bottom: ").concat(this.bottom, "px;\n z-index: ").concat(this.zIndex); } }, watch: { visible: function visible(val) { if (val) { this.zIndex = zIndexManager.nextTickIndex(2); } } }, mounted: function mounted() { this._lazyScrollHandler = throttle(30, this.scrollHandler); if (this.target) { this.el = document.querySelector(this.target); if (!this.el) { throw new Error('target does not exist'); } this.container = this.el; } this.container.addEventListener('scroll', this._lazyScrollHandler); }, methods: { clickHandler: function clickHandler() { this.$emit('click'); }, scrollTop: function scrollTop() { this.el.scrollTo({ top: 0, behavior: 'smooth' }); }, scrollHandler: function scrollHandler() { this.visible = this.el.scrollTop >= this.visibilityHeight; } } }; 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": "bk-fade-in-linear" } }, [_vm.visible ? _c('div', { staticClass: "bk-back-to-top", style: _vm.positionStyle, on: { "click": _vm.scrollTop } }, [_vm._t("default", [_c('i', { staticClass: "bk-icon icon-angle-up-line" })])], 2) : _vm._e()]); }; var __vue_staticRenderFns__ = []; /* style */ var __vue_inject_styles__ = undefined; /* scoped */ var __vue_scope_id__ = undefined; /* module identifier */ var __vue_module_identifier__ = undefined; /* functional template */ var __vue_is_functional_template__ = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__ = /*#__PURE__*/normalizeComponent_1({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined); var _toObject = function (it) { return Object(_defined(it)); }; 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; function setInstaller (component, afterInstall) { component.install = function (Vue) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var props = component.props || {}; keys$1(options).forEach(function (key) { if (props.hasOwnProperty(key)) { if (typeof props[key] === 'function' || props[key] instanceof Array) { props[key] = { type: props[key], default: options[key] }; } else { props[key].default = options[key]; } } }); component.name = options.namespace ? component.name.replace('bk', options.namespace) : component.name; Vue.component(component.name, component); typeof afterInstall === 'function' && afterInstall(Vue, options); }; } setInstaller(__vue_component__); var on = function () { if (document.addEventListener) { return function (element, event, handler) { if (element && event && handler) { element.addEventListener(event, handler, true); } }; } else { return function (element, event, handler) { if (element && event && handler) { element.attachEvent('on' + event, handler); } }; } }(); var off = function () { if (document.removeEventListener) { return function (element, event, handler) { if (element && event) { element.removeEventListener(event, handler, true); } }; } else { return function (element, event, handler) { if (element && event) { element.detachEvent('on' + event, handler); } }; } }(); var script$1 = { name: 'bk-affix', props: { offsetTop: { type: Number, default: 0 }, offsetBottom: { type: Number }, target: { type: String, default: '' }, zIndex: { type: Number, default: 1000 } }, data: function data() { return { affix: false, styles: {} }; }, computed: { offsetType: function offsetType() { var type = 'top'; if (this.offsetBottom >= 0) { type = 'bottom'; } return type; } }, mounted: function mounted() { var _this = this; this.targetEl = this.target ? document.querySelector(this.target) : window; this.$refs.point.style.zIndex = this.zIndex; on(this.targetEl, 'scroll', this.listenScroll); on(this.targetEl, 'resize', this.listenScroll); this.$nextTick(function () { _this.handleScroll(); }); }, beforeDestroy: function beforeDestroy() { off(this.targetEl, 'scroll', this.listenScroll); off(this.targetEl, 'resize', this.listenScroll); off(window, 'scroll', this.setTargetLoop); }, methods: { setTargetLoop: function setTargetLoop() { if (this.offsetType === 'top') { this.styles = { top: "".concat(this.targetEl.getBoundingClientRect().top + this.offsetTop, "px") }; } else { this.styles = { bottom: "".concat(window.innerHeight - this.targetEl.getBoundingClientRect().bottom + this.offsetBottom, "px") }; } }, listenScroll: function listenScroll() { this.throttle(this.handleScroll, 100); }, throttle: function throttle(method, delay) { var previous = 0; var timer = null; var now = new Date(); var self = this; var interval = delay - (now - previous); var args = arguments; if (interval <= 0) { method.apply.apply(method, [self].concat(_toConsumableArray(args))); previous = new Date(); } else if (!timer) { timer = setTimeout(function () { clearTimeout(timer); timer = null; method.apply.apply(method, [self].concat(_toConsumableArray(args))); previous = new Date(); }, interval); } }, getOffset: function getOffset(element) { var rect = element.getBoundingClientRect(); var rect2 = this.targetEl === window ? { top: 0, left: 0 } : this.targetEl.getBoundingClientRect(); var clientTop = this.targetEl.clientTop || 0; var clientLeft = this.targetEl.clientLeft || 0; return { top: rect.top - rect2.top - clientTop, left: rect.left - rect2.left - clientLeft }; }, handleScroll: function handleScroll() { var rect = this.targetEl === window ? { top: 0, left: 0, bottom: window.innerHeight } : this.targetEl.getBoundingClientRect(); var elOffset = this.getOffset(this.$refs.root); var windowHeight = this.targetEl === window ? this.targetEl.innerHeight : this.targetEl.clientHeight; var elHeight = this.$refs.point.offsetHeight; if (elOffset.top < this.offsetTop && this.offsetType === 'top' && !this.affix) { this.affix = true; this.styles = { position: 'fixed', top: "".concat(rect.top + this.offsetTop, "px"), left: "".concat(rect.left + elOffset.left, "px"), width: "".concat(this.$el.offsetWidth, "px") }; if (this.targetEl !== window) { on(window, 'scroll', this.setTargetLoop); } this.$emit('change', true); } else if (elOffset.top > this.offsetTop && this.offsetType === 'top' && this.affix) { this.affix = false; this.styles = null; this.$emit('change', false); } if (elOffset.top + this.offsetBottom + elHeight > windowHeight && this.offsetType === 'bottom' && !this.affix) { this.affix = true; this.styles = { bottom: "".concat(window.innerHeight - rect.bottom + this.offsetBottom, "px"), left: "".concat(rect.left + elOffset.left, "px"), width: "".concat(this.$el.offsetWidth, "px") }; if (this.targetEl !== window) { on(window, 'scroll', this.setTargetLoop); } this.$emit('change', true); } else if (elOffset.top + this.offsetBottom + elHeight < windowHeight && this.offsetType === 'bottom' && this.affix) { this.affix = false; this.styles = null; this.$emit('change', false); } } } }; /* script */ var __vue_script__$1 = script$1; /* template */ var __vue_render__$1 = function __vue_render__() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { ref: "root" }, [_c('div', { ref: "point", class: { 'bk-affix': _vm.affix }, style: _vm.styles }, [_vm._t("default")], 2)]); }; var __vue_staticRenderFns__$1 = []; /* style */ var __vue_inject_styles__$1 = undefined; /* scoped */ var __vue_scope_id__$1 = undefined; /* module identifier */ var __vue_module_identifier__$1 = undefined; /* functional template */ var __vue_is_functional_template__$1 = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__$1 = /*#__PURE__*/normalizeComponent_1({ render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, undefined, undefined, undefined); setInstaller(__vue_component__$1); var script$2 = { name: 'bk-fixed-navbar', props: { navItems: { type: Array, default: function _default() { return []; } }, extCls: { type: String, default: '' }, position: { type: String, default: 'middle' } }, data: function data() { return { localZIndex: zIndexManager.nextTickIndex(2) }; }, computed: { navConfig: function navConfig() { var config = this.navItems.map(function (item) { return _extends({ tooltip: { disabled: true }, action: function action() {} }, item); }); return config; } } }; /* script */ var __vue_script__$2 = script$2; /* template */ var __vue_render__$2 = function __vue_render__() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { staticClass: "bk-fixed-navbar-wrapper", class: [_vm.extCls, _vm.position], style: { zIndex: _vm.localZIndex } }, _vm._l(_vm.navConfig, function (item, index) { return _c('div', { directives: [{ name: "bk-tooltips", rawName: "v-bk-tooltips", value: item.tooltip, expression: "item.tooltip" }], key: index, staticClass: "fixed-navbar-item", on: { "click": item.action } }, [_c('i', { class: ['bk-icon', item.icon] }), _c('span', { staticClass: "text" }, [_vm._v(_vm._s(item.text))])]); }), 0); }; var __vue_staticRenderFns__$2 = []; /* style */ var __vue_inject_styles__$2 = undefined; /* scoped */ var __vue_scope_id__$2 = undefined; /* module identifier */ var __vue_module_identifier__$2 = undefined; /* functional template */ var __vue_is_functional_template__$2 = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__$2 = /*#__PURE__*/normalizeComponent_1({ render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, false, undefined, undefined, undefined); setInstaller(__vue_component__$2); function isVNode(node) { return node && _typeof(node) === 'object' && node.hasOwnProperty('componentOptions'); } function addEvent(elem, type, handler) { if (!elem) { return; } if (elem.addEventListener) { elem.addEventListener(type, handler, false); } else if (elem.attachEvent) { elem.attachEvent('on' + type, handler); } else { elem['on' + type] = handler; } } function removeEvent(elem, type, handler) { if (!elem) { return; } if (elem.removeEventListener) { elem.removeEventListener(type, handler, false); } else if (elem.detachEvent) { elem.detachEvent('on' + type, handler); } else { elem['on' + type] = null; } } var cachedScrollBarSize; function getScrollBarWidth(fromCache) { if (fromCache && cachedScrollBarSize !== undefined) { return cachedScrollBarSize; } var inner = document.createElement('div'); inner.style.width = '100%'; inner.style.height = '200px'; var outer = document.createElement('div'); var outerStyle = outer.style; outerStyle.position = 'absolute'; outerStyle.top = 0; outerStyle.left = 0; outerStyle.pointerEvents = 'none'; outerStyle.visibility = 'hidden'; outerStyle.width = '200px'; outerStyle.height = '100px'; outerStyle.overflowY = 'scroll'; outer.appendChild(inner); document.body.appendChild(outer); var widthContained = inner.offsetWidth; var widthScroll = inner.offsetWidth; if (widthContained === widthScroll) { widthScroll = outer.clientWidth; } document.body.removeChild(outer); cachedScrollBarSize = widthContained - widthScroll; return cachedScrollBarSize; } 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); }; function findChildComponents(context, componentName) { return context.$children.reduce(function (components, child) { if (child.$options.name === componentName) { components.push(child); } var foundChilds = findChildComponents(child, componentName); return components.concat(foundChilds); }, []); } var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; var MOZ_HACK_REGEXP = /^moz([A-Z])/; var trim = function trim(string) { return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ''); }; var camelCase = function camelCase(name) { return name.replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) { return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, 'Moz$1'); }; function hasClass(el, cls) { if (!el || !cls) return false; if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.'); if (el.classList) { return el.classList.contains(cls); } else { return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; } } function addClass(el, cls) { if (!el) return; var curClass = el.className; var classes = (cls || '').split(' '); for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.add(clsName); } else if (!hasClass(el, clsName)) { curClass += ' ' + clsName; } } if (!el.classList) { el.className = curClass; } } function removeClass(el, cls) { if (!el || !cls) return; var classes = cls.split(' '); var curClass = ' ' + el.className + ' '; for (var i = 0, j = classes.length; i < j; i++) { var clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.remove(clsName); } else if (hasClass(el, clsName)) { curClass = curClass.replace(' ' + clsName + ' ', ' '); } } if (!el.classList) { el.className = trim(curClass); } } var getStyle = Number(document.documentMode) < 9 ? function (element, styleName) { if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'styleFloat'; } try { switch (styleName) { case 'opacity': try { return element.filters.item('alpha').opacity / 100; } catch (e) { return 1.0; } default: return element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null; } } catch (e) { return element.style[styleName]; } } : function (element, styleName) { if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === 'float') { styleName = 'cssFloat'; } try { var computed = document.defaultView.getComputedStyle(element, ''); return element.style[styleName] || computed ? computed[styleName] : null; } catch (e) { return element.style[styleName]; } }; function scrollTop(el) { var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var to = arguments.length > 2 ? arguments[2] : undefined; var duration = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500; var endCallback = arguments.length > 4 ? arguments[4] : undefined; var difference = Math.abs(from - to); var step = Math.ceil(difference / duration * 50); function scroll(start, end, step) { if (start === end) { endCallback && endCallback(); return; } var d = start + step > end ? end : start + step; if (start > end) { d = start - step < end ? end : start - step; } if (el === window) { window.scrollTo(d, d); } else { el.scrollTop = d; } window.requestAnimationFrame(function () { return scroll(d, end, step); }); } scroll(from, to, step); } var isInContainer = function isInContainer(el, container) { if (!el || !container) return false; var elRect = el.getBoundingClientRect(); var containerRect; if ([window, document, document.documentElement, null, undefined].includes(container)) { containerRect = { top: 0, right: window.innerWidth, bottom: window.innerHeight, left: 0 }; } else { containerRect = container.getBoundingClientRect(); } return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right; }; var transition = { beforeEnter: function beforeEnter(el) { addClass(el, 'collapse-transition'); if (!el.dataset) { el.dataset = {}; } el.dataset.oldPaddingTop = el.style.paddingTop; el.dataset.oldPaddingBottom = el.style.paddingBottom; el.style.height = '0'; el.style.paddingTop = 0; el.style.paddingBottom = 0; }, enter: function enter(el) { el.dataset.oldOverflow = el.style.overflow; if (el.scrollHeight !== 0) { el.style.height = el.scrollHeight + 'px'; el.style.paddingTop = el.dataset.oldPaddingTop; el.style.paddingBottom = el.dataset.oldPaddingBottom; } else { el.style.height = ''; el.style.paddingTop = el.dataset.oldPaddingTop; el.style.paddingBottom = el.dataset.oldPaddingBottom; } el.style.overflow = 'hidden'; }, afterEnter: function afterEnter(el) { removeClass(el, 'collapse-transition'); el.style.height = ''; el.style.overflow = el.dataset.oldOverflow; }, beforeLeave: function beforeLeave(el) { if (!el.dataset) el.dataset = {}; el.dataset.oldPaddingTop = el.style.paddingTop; el.dataset.oldPaddingBottom = el.style.paddingBottom; el.dataset.oldOverflow = el.style.overflow; el.style.height = el.scrollHeight + 'px'; el.style.overflow = 'hidden'; }, leave: function leave(el) { if (el.scrollHeight !== 0) { addClass(el, 'collapse-transition'); el.style.height = 0; el.style.paddingTop = 0; el.style.paddingBottom = 0; } }, afterLeave: function afterLeave(el) { removeClass(el, 'collapse-transition'); el.style.height = ''; el.style.overflow = el.dataset.oldOverflow; el.style.paddingTop = el.dataset.oldPaddingTop; el.style.paddingBottom = el.dataset.oldPaddingBottom; } }; var CollapseTransition = { name: 'CollapseTransition', functional: true, render: function render(h, _ref) { var children = _ref.children; var data = { on: transition }; return h('transition', data, children); } }; var script$3 = { name: 'bk-transition', components: { CollapseTransition: CollapseTransition }, props: { name: { type: String, default: '' }, durationTime: { type: String, default: '.3s' }, durationType: { type: String, default: 'linear' } }, computed: { transitionName: function transitionName() { return this.isCollapse ? '' : this.name; }, isCollapse: function isCollapse() { return this.name === 'collapse'; } }, mounted: function mounted() { var slot = this.getSlot(); slot.elm.style.transitionDuration = this.durationTime; slot.elm.style.transitionTimingFunction = this.durationType; }, methods: { getSlot: function getSlot() { return this.$slots.default[0]; } } }; /* script */ var __vue_script__$3 = script$3; /* template */ var __vue_render__$3 = function __vue_render__() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('transition', { staticClass: "bk-transition", attrs: { "name": _vm.transitionName } }, [_vm.name === 'collapse' ? _c('CollapseTransition', [_vm._t("default")], 2) : _vm._t("default")], 2); }; var __vue_staticRenderFns__$3 = []; /* style */ var __vue_inject_styles__$3 = undefined; /* scoped */ var __vue_scope_id__$3 = undefined; /* module identifier */ var __vue_module_identifier__$3 = undefined; /* functional template */ var __vue_is_functional_template__$3 = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__$3 = /*#__PURE__*/normalizeComponent_1({ render: __vue_render__$3, staticRenderFns: __vue_staticRenderFns__$3 }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, false, undefined, undefined, undefined); setInstaller(__vue_component__$3); var script$4 = { name: 'bk-alert', props: { type: { type: String, default: 'info' }, title: { type: String, default: '' }, closable: { type: Boolean, default: false }, closeText: { type: String }, showIcon: { type: Boolean, default: true } }, data: function data() { return { visible: true }; }, computed: { typeClass: function typeClass() { return "bk-alert-".concat(this.type); }, closeClasses: function closeClasses() { var classes = {}; if (this.closeText) { classes['close-text'] = true; } else { classes['bk-icon'] = true; classes['icon-close'] = true; } return classes; } }, methods: { beforeLeave: function beforeLeave(el) { var _el$getBoundingClient = el.getBoundingClientRect(), height = _el$getBoundingClient.height; el.style.height = "".concat(height, "px"); }, leave: function leave(el) { setTimeout(function () { el.style.height = 0; }); }, afterLeave: function afterLeave(el) { el.style.height = ''; }, handleClose: function handleClose() { this.visible = false; this.$emit('close'); } } }; /* script */ var __vue_script__$4 = script$4; /* template */ var __vue_render__$4 = function __vue_render__() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('transition', { attrs: { "name": "bk-alert-leave" }, on: { "before-leave": _vm.beforeLeave, "leave": _vm.leave, "after-leave": _vm.afterLeave } }, [_vm.visible ? _c('div', { staticClass: "bk-alert", class: _vm.typeClass }, [_c('div', { staticClass: "bk-alert-wraper" }, [_vm.showIcon ? _c('i', { staticClass: "bk-icon icon-info" }) : _vm._e(), _c('div', { staticClass: "bk-alert-content" }, [_c('div', { staticClass: "bk-alert-title" }, [_vm._t("title", [_vm._v("\n " + _vm._s(_vm.title)