bk-magic-vue 2.5.6 → 2.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/bk-magic-vue.css +240 -2
  2. package/dist/bk-magic-vue.js +1137 -182
  3. package/dist/bk-magic-vue.min.css +1 -1
  4. package/dist/bk-magic-vue.min.css.gz +0 -0
  5. package/dist/bk-magic-vue.min.css.map +1 -1
  6. package/dist/bk-magic-vue.min.js +1 -1
  7. package/dist/bk-magic-vue.min.js.gz +0 -0
  8. package/dist/bk-magic-vue.min.js.map +1 -1
  9. package/dist/fonts/iconcool.eot +0 -0
  10. package/dist/fonts/iconcool.svg +27 -0
  11. package/dist/fonts/iconcool.ttf +0 -0
  12. package/dist/fonts/iconcool.woff +0 -0
  13. package/lib/cascade.js +35 -32
  14. package/lib/locale/lang/en-US.js +5 -1
  15. package/lib/locale/lang/zh-CN.js +5 -1
  16. package/lib/message.js +1182 -623
  17. package/lib/option.js +692 -63
  18. package/lib/pagination.js +383 -105
  19. package/lib/search-select.js +1604 -1288
  20. package/lib/select.js +321 -43
  21. package/lib/table.js +17 -2
  22. package/lib/ui/bk-magic-vue.css +240 -2
  23. package/lib/ui/bk-magic-vue.min.css +1 -1
  24. package/lib/ui/bk-magic-vue.min.css.gz +0 -0
  25. package/lib/ui/bk-magic-vue.min.css.map +1 -1
  26. package/lib/ui/common.css +36 -0
  27. package/lib/ui/common.min.css +1 -1
  28. package/lib/ui/common.min.css.map +1 -1
  29. package/lib/ui/fonts/iconcool.eot +0 -0
  30. package/lib/ui/fonts/iconcool.svg +27 -0
  31. package/lib/ui/fonts/iconcool.ttf +0 -0
  32. package/lib/ui/fonts/iconcool.woff +0 -0
  33. package/lib/ui/iconfont.css +36 -0
  34. package/lib/ui/iconfont.min.css +1 -1
  35. package/lib/ui/iconfont.min.css.map +1 -1
  36. package/lib/ui/message.css +233 -1
  37. package/lib/ui/message.min.css +1 -1
  38. package/lib/ui/message.min.css.map +1 -1
  39. package/lib/ui/search-select-menu.css +7 -1
  40. package/lib/ui/search-select-menu.min.css +1 -1
  41. package/lib/ui/search-select-menu.min.css.map +1 -1
  42. package/lib/ui/search-select.css +5 -0
  43. package/lib/ui/search-select.min.css +1 -1
  44. package/lib/ui/search-select.min.css.map +1 -1
  45. package/lib/ui/select.css +4 -0
  46. package/lib/ui/select.min.css +1 -1
  47. package/lib/ui/select.min.css.map +1 -1
  48. package/package.json +4 -2
package/lib/message.js CHANGED
@@ -1,626 +1,1185 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('bk-magic-vue/lib/locale')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'vue', 'bk-magic-vue/lib/locale'], factory) :
4
- (global = global || self, factory(global.library = {}, global.Vue, global.locale));
5
- }(this, function (exports, Vue, locale) { 'use strict';
6
-
7
- Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
8
- locale = locale && locale.hasOwnProperty('default') ? locale['default'] : locale;
9
-
10
- function _typeof(obj) {
11
- "@babel/helpers - typeof";
12
-
13
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14
- return typeof obj;
15
- } : function (obj) {
16
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17
- }, _typeof(obj);
18
- }
19
-
20
- function createCommonjsModule(fn, module) {
21
- return module = { exports: {} }, fn(module, module.exports), module.exports;
22
- }
23
-
24
- var _global = createCommonjsModule(function (module) {
25
- var global = module.exports = typeof window != 'undefined' && window.Math == Math
26
- ? window : typeof self != 'undefined' && self.Math == Math ? self
27
- : Function('return this')();
28
- if (typeof __g == 'number') __g = global;
29
- });
30
-
31
- var _core = createCommonjsModule(function (module) {
32
- var core = module.exports = { version: '2.6.12' };
33
- if (typeof __e == 'number') __e = core;
34
- });
35
- var _core_1 = _core.version;
36
-
37
- var _aFunction = function (it) {
38
- if (typeof it != 'function') throw TypeError(it + ' is not a function!');
39
- return it;
40
- };
41
-
42
- var _ctx = function (fn, that, length) {
43
- _aFunction(fn);
44
- if (that === undefined) return fn;
45
- switch (length) {
46
- case 1: return function (a) {
47
- return fn.call(that, a);
48
- };
49
- case 2: return function (a, b) {
50
- return fn.call(that, a, b);
51
- };
52
- case 3: return function (a, b, c) {
53
- return fn.call(that, a, b, c);
54
- };
55
- }
56
- return function () {
57
- return fn.apply(that, arguments);
58
- };
59
- };
60
-
61
- var _isObject = function (it) {
62
- return typeof it === 'object' ? it !== null : typeof it === 'function';
63
- };
64
-
65
- var _anObject = function (it) {
66
- if (!_isObject(it)) throw TypeError(it + ' is not an object!');
67
- return it;
68
- };
69
-
70
- var _fails = function (exec) {
71
- try {
72
- return !!exec();
73
- } catch (e) {
74
- return true;
75
- }
76
- };
77
-
78
- var _descriptors = !_fails(function () {
79
- return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
80
- });
81
-
82
- var document$1 = _global.document;
83
- var is = _isObject(document$1) && _isObject(document$1.createElement);
84
- var _domCreate = function (it) {
85
- return is ? document$1.createElement(it) : {};
86
- };
87
-
88
- var _ie8DomDefine = !_descriptors && !_fails(function () {
89
- return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
90
- });
91
-
92
- var _toPrimitive = function (it, S) {
93
- if (!_isObject(it)) return it;
94
- var fn, val;
95
- if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
96
- if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
97
- if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
98
- throw TypeError("Can't convert object to primitive value");
99
- };
100
-
101
- var dP = Object.defineProperty;
102
- var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
103
- _anObject(O);
104
- P = _toPrimitive(P, true);
105
- _anObject(Attributes);
106
- if (_ie8DomDefine) try {
107
- return dP(O, P, Attributes);
108
- } catch (e) { }
109
- if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
110
- if ('value' in Attributes) O[P] = Attributes.value;
111
- return O;
112
- };
113
- var _objectDp = {
114
- f: f
115
- };
116
-
117
- var _propertyDesc = function (bitmap, value) {
118
- return {
119
- enumerable: !(bitmap & 1),
120
- configurable: !(bitmap & 2),
121
- writable: !(bitmap & 4),
122
- value: value
123
- };
124
- };
125
-
126
- var _hide = _descriptors ? function (object, key, value) {
127
- return _objectDp.f(object, key, _propertyDesc(1, value));
128
- } : function (object, key, value) {
129
- object[key] = value;
130
- return object;
131
- };
132
-
133
- var hasOwnProperty = {}.hasOwnProperty;
134
- var _has = function (it, key) {
135
- return hasOwnProperty.call(it, key);
136
- };
137
-
138
- var PROTOTYPE = 'prototype';
139
- var $export = function (type, name, source) {
140
- var IS_FORCED = type & $export.F;
141
- var IS_GLOBAL = type & $export.G;
142
- var IS_STATIC = type & $export.S;
143
- var IS_PROTO = type & $export.P;
144
- var IS_BIND = type & $export.B;
145
- var IS_WRAP = type & $export.W;
146
- var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
147
- var expProto = exports[PROTOTYPE];
148
- var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
149
- var key, own, out;
150
- if (IS_GLOBAL) source = name;
151
- for (key in source) {
152
- own = !IS_FORCED && target && target[key] !== undefined;
153
- if (own && _has(exports, key)) continue;
154
- out = own ? target[key] : source[key];
155
- exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
156
- : IS_BIND && own ? _ctx(out, _global)
157
- : IS_WRAP && target[key] == out ? (function (C) {
158
- var F = function (a, b, c) {
159
- if (this instanceof C) {
160
- switch (arguments.length) {
161
- case 0: return new C();
162
- case 1: return new C(a);
163
- case 2: return new C(a, b);
164
- } return new C(a, b, c);
165
- } return C.apply(this, arguments);
166
- };
167
- F[PROTOTYPE] = C[PROTOTYPE];
168
- return F;
169
- })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
170
- if (IS_PROTO) {
171
- (exports.virtual || (exports.virtual = {}))[key] = out;
172
- if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
173
- }
174
- }
175
- };
176
- $export.F = 1;
177
- $export.G = 2;
178
- $export.S = 4;
179
- $export.P = 8;
180
- $export.B = 16;
181
- $export.W = 32;
182
- $export.U = 64;
183
- $export.R = 128;
184
- var _export = $export;
185
-
186
- var _defined = function (it) {
187
- if (it == undefined) throw TypeError("Can't call method on " + it);
188
- return it;
189
- };
190
-
191
- var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
192
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
193
-
194
- var space = '[' + _stringWs + ']';
195
- var non = '\u200b\u0085';
196
- var ltrim = RegExp('^' + space + space + '*');
197
- var rtrim = RegExp(space + space + '*$');
198
- var exporter = function (KEY, exec, ALIAS) {
199
- var exp = {};
200
- var FORCE = _fails(function () {
201
- return !!_stringWs[KEY]() || non[KEY]() != non;
202
- });
203
- var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY];
204
- if (ALIAS) exp[ALIAS] = fn;
205
- _export(_export.P + _export.F * FORCE, 'String', exp);
206
- };
207
- var trim = exporter.trim = function (string, TYPE) {
208
- string = String(_defined(string));
209
- if (TYPE & 1) string = string.replace(ltrim, '');
210
- if (TYPE & 2) string = string.replace(rtrim, '');
211
- return string;
212
- };
213
- var _stringTrim = exporter;
214
-
215
- var $parseInt = _global.parseInt;
216
- var $trim = _stringTrim.trim;
217
- var hex = /^[-+]?0[xX]/;
218
- var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) {
219
- var string = $trim(String(str), 3);
220
- return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
221
- } : $parseInt;
222
-
223
- _export(_export.G + _export.F * (parseInt != _parseInt), { parseInt: _parseInt });
224
-
225
- var _parseInt$1 = _core.parseInt;
226
-
227
- var _parseInt$2 = _parseInt$1;
228
-
229
- _export(_export.S, 'Date', { now: function () { return new Date().getTime(); } });
230
-
231
- var now = _core.Date.now;
232
-
233
- var now$1 = now;
234
-
235
- var $parseFloat = _global.parseFloat;
236
- var $trim$1 = _stringTrim.trim;
237
- var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) {
238
- var string = $trim$1(String(str), 3);
239
- var result = $parseFloat(string);
240
- return result === 0 && string.charAt(0) == '-' ? -0 : result;
241
- } : $parseFloat;
242
-
243
- _export(_export.G + _export.F * (parseFloat != _parseFloat), { parseFloat: _parseFloat });
244
-
245
- var _parseFloat$1 = _core.parseFloat;
246
-
247
- var _parseFloat$2 = _parseFloat$1;
248
-
249
- var toString = {}.toString;
250
- var _cof = function (it) {
251
- return toString.call(it).slice(8, -1);
252
- };
253
-
254
- var _isArray = Array.isArray || function isArray(arg) {
255
- return _cof(arg) == 'Array';
256
- };
257
-
258
- _export(_export.S, 'Array', { isArray: _isArray });
259
-
260
- var isArray = _core.Array.isArray;
261
-
262
- var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
263
- window.setTimeout(callback, 1000 / 60);
264
- };
265
- var cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) {
266
- window.clearTimeout(id);
267
- };
268
- var copyText = function copyText(text) {
269
- var textarea = document.createElement('textarea');
270
- document.body.appendChild(textarea);
271
- textarea.value = text;
272
- textarea.select();
273
- if (document.execCommand('copy')) {
274
- document.execCommand('copy');
275
- } else {
276
- console.warn('unsupported this function, please use Google Chrome.');
277
- }
278
- document.body.removeChild(textarea);
279
- };
280
- function checkOverflow(el) {
281
- if (!el) return false;
282
- var createDom = function createDom(el, css) {
283
- var dom = document.createElement('div');
284
- var width = _parseFloat$2(css['width']) ? Math.ceil(_parseFloat$2(css['width'])) + 'px' : css['width'];
285
- dom.style.cssText = "\n width: ".concat(width, ";\n line-height: ").concat(css['line-height'], ";\n font-size: ").concat(css['font-size'], ";\n word-break: ").concat(css['word-break'], ";\n padding: ").concat(css['padding'], ";\n ");
286
- dom.textContent = el.textContent;
287
- return dom;
288
- };
289
- var isOverflow = false;
290
- try {
291
- var css = window.getComputedStyle(el, null);
292
- var lineClamp = css.webkitLineClamp;
293
- if (lineClamp !== 'none') {
294
- var targetHeight = _parseFloat$2(css.height);
295
- var dom = createDom(el, css);
296
- document.body.appendChild(dom);
297
- var domHeight = window.getComputedStyle(dom, null)['height'];
298
- document.body.removeChild(dom);
299
- isOverflow = targetHeight < _parseFloat$2(domHeight);
300
- } else {
301
- isOverflow = el.clientWidth < el.scrollWidth || el.clientHeight < el.scrollHeight;
302
- }
303
- } catch (e) {
304
- console.warn('There is an error when check element overflow state: ', e);
305
- }
306
- return isOverflow;
307
- }
308
-
309
- var ICONS = {
310
- primary: 'icon-info-circle-shape',
311
- error: 'icon-close-circle-shape',
312
- warning: 'icon-exclamation-circle-shape',
313
- success: 'icon-check-circle-shape'
314
- };
315
- var script = {
316
- name: 'bk-message',
317
- mixins: [locale.mixin],
318
- data: function data() {
319
- return {
320
- theme: 'primary',
321
- message: '',
322
- delay: 3000,
323
- icon: '',
324
- dismissable: true,
325
- verticalOffset: 0,
326
- horizonOffset: 0,
327
- visible: false,
328
- countID: null,
329
- onClose: function onClose() {},
330
- extCls: '',
331
- copied: false,
332
- ellipsisCopy: false,
333
- showCopyText: false
334
- };
335
- },
336
- computed: {
337
- themeClass: function themeClass() {
338
- return "bk-message-".concat(this.theme);
339
- },
340
- verticalStyle: function verticalStyle() {
341
- return {
342
- top: "".concat(this.verticalOffset, "px")
343
- };
344
- },
345
- tipsIcon: function tipsIcon() {
346
- return this.icon || ICONS[this.theme];
347
- },
348
- singleEllipsis: function singleEllipsis() {
349
- return this.ellipsisLine === 1;
350
- },
351
- multiEllipsis: function multiEllipsis() {
352
- return this.ellipsisLine > 1;
353
- },
354
- ellipsisStyle: function ellipsisStyle() {
355
- return {
356
- '--line': this.ellipsisLine
357
- };
358
- },
359
- localeCopyText: function localeCopyText() {
360
- return this.copied ? this.t('bk.message.copied') : this.t('bk.message.copy');
361
- }
362
- },
363
- mounted: function mounted() {
364
- this.startCountDown();
365
- },
366
- methods: {
367
- destroyEl: function destroyEl() {
368
- this.$destroy();
369
- this.$el.parentNode && this.$el.parentNode.removeChild(this.$el);
370
- },
371
- startCountDown: function startCountDown() {
372
- var _this = this;
373
- if (this.delay > 0) {
374
- this.countID = setTimeout(function () {
375
- _this.visible && _this.close();
376
- }, this.delay);
377
- }
378
- },
379
- stopCountDown: function stopCountDown() {
380
- clearTimeout(this.countID);
381
- },
382
- close: function close() {
383
- this.visible = false;
384
- typeof this.onClose === 'function' && this.onClose();
385
- },
386
- copyContent: function copyContent() {
387
- if (!this.$refs.content || this.copied) return;
388
- var text = this.$refs.content.textContent;
389
- copyText(text);
390
- this.copied = true;
391
- },
392
- setShowCopyText: function setShowCopyText() {
393
- this.showCopyText = this.ellipsisCopy && checkOverflow(this.$refs.content);
394
- }
395
- }
396
- };
397
-
398
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
399
- , shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
400
- if (typeof shadowMode !== 'boolean') {
401
- createInjectorSSR = createInjector;
402
- createInjector = shadowMode;
403
- shadowMode = false;
404
- }
405
- var options = typeof script === 'function' ? script.options : script;
406
- if (template && template.render) {
407
- options.render = template.render;
408
- options.staticRenderFns = template.staticRenderFns;
409
- options._compiled = true;
410
- if (isFunctionalTemplate) {
411
- options.functional = true;
412
- }
413
- }
414
- if (scopeId) {
415
- options._scopeId = scopeId;
416
- }
417
- var hook;
418
- if (moduleIdentifier) {
419
- hook = function hook(context) {
420
- context = context ||
421
- this.$vnode && this.$vnode.ssrContext ||
422
- this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
423
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
424
- context = __VUE_SSR_CONTEXT__;
425
- }
426
- if (style) {
427
- style.call(this, createInjectorSSR(context));
428
- }
429
- if (context && context._registeredComponents) {
430
- context._registeredComponents.add(moduleIdentifier);
431
- }
432
- };
433
- options._ssrRegister = hook;
434
- } else if (style) {
435
- hook = shadowMode ? function () {
436
- style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
437
- } : function (context) {
438
- style.call(this, createInjector(context));
439
- };
440
- }
441
- if (hook) {
442
- if (options.functional) {
443
- var originalRender = options.render;
444
- options.render = function renderWithStyleInjection(h, context) {
445
- hook.call(context);
446
- return originalRender(h, context);
447
- };
448
- } else {
449
- var existing = options.beforeCreate;
450
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
451
- }
452
- }
453
- return script;
454
- }
455
- var normalizeComponent_1 = normalizeComponent;
456
-
457
- /* script */
458
- var __vue_script__ = script;
459
- /* template */
460
- var __vue_render__ = function __vue_render__() {
461
- var _vm = this;
462
- var _h = _vm.$createElement;
463
- var _c = _vm._self._c || _h;
464
- return _c('transition', {
465
- attrs: {
466
- "name": "vertical-move"
467
- },
468
- on: {
469
- "after-leave": _vm.destroyEl,
470
- "enter": _vm.setShowCopyText
471
- }
472
- }, [_c('div', {
473
- directives: [{
474
- name: "show",
475
- rawName: "v-show",
476
- value: _vm.visible,
477
- expression: "visible"
478
- }],
479
- class: ['bk-message', _vm.themeClass, _vm.extCls],
480
- style: _vm.verticalStyle,
481
- on: {
482
- "mouseenter": _vm.stopCountDown,
483
- "mouseleave": _vm.startCountDown
484
- }
485
- }, [_c('div', {
486
- staticClass: "bk-message-icon"
487
- }, [_c('i', {
488
- class: ['bk-icon', _vm.tipsIcon]
489
- })]), _c('div', {
490
- ref: "content",
491
- class: ['bk-message-content', {
492
- 'multi-ellipsis': _vm.multiEllipsis,
493
- 'ellipsis': _vm.singleEllipsis
494
- }],
495
- style: _vm.ellipsisStyle
496
- }, [_vm._t("default", function () {
497
- return [_vm._v(_vm._s(_vm.message))];
498
- })], 2), _vm.showCopyText ? _c('div', {
499
- class: ['bk-message-copy', {
500
- 'copied': _vm.copied
501
- }],
502
- on: {
503
- "click": _vm.copyContent
504
- }
505
- }, [_vm._v("\n " + _vm._s(_vm.localeCopyText) + "\n ")]) : _vm._e(), _vm.dismissable ? _c('div', {
506
- staticClass: "bk-message-close"
507
- }, [_c('i', {
508
- class: ['bk-icon icon-close', _vm.showCopyText ? 'ml10' : 'ml30'],
509
- on: {
510
- "click": function click($event) {
511
- $event.stopPropagation();
512
- return _vm.close.apply(null, arguments);
513
- }
514
- }
515
- })]) : _vm._e()])]);
516
- };
517
- var __vue_staticRenderFns__ = [];
518
-
519
- /* style */
520
- var __vue_inject_styles__ = undefined;
521
- /* scoped */
522
- var __vue_scope_id__ = undefined;
523
- /* module identifier */
524
- var __vue_module_identifier__ = undefined;
525
- /* functional template */
526
- var __vue_is_functional_template__ = false;
527
- /* style inject */
528
-
529
- /* style inject SSR */
530
-
531
- /* style inject shadow dom */
532
-
533
- var __vue_component__ = /*#__PURE__*/normalizeComponent_1({
534
- render: __vue_render__,
535
- staticRenderFns: __vue_staticRenderFns__
536
- }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
537
-
538
- var MessageComponent = Vue.extend(__vue_component__);
539
- var messageList = [];
540
- var seed = 0;
541
- var BkMessage = function BkMessage(config) {
542
- if (config.limit === 0) {
543
- BkMessage.batchClose();
544
- return;
545
- }
546
- if (config.limit > 0) {
547
- BkMessage.batchClose(config.limit);
548
- }
549
- var instanceId = "messageInstance_".concat(now$1(), "_").concat(seed++);
550
- var offsetY = _parseInt$2(config.offsetY) || 30;
551
- var spacing = _parseInt$2(config.spacing) || 10;
552
- if (config.ellipsisLine === null || config.ellipsisLine === undefined || config.ellipsisLine === '' || isNaN(config.ellipsisLine)) {
553
- config.ellipsisLine = 1;
554
- }
555
- var ellipsisLine = config.ellipsisLine;
556
- var verticalOffset = offsetY;
557
- if (typeof config === 'string' || typeof config === 'number') {
558
- config = {
559
- message: config
560
- };
561
- }
562
- var configClose = config.onClose;
563
- config.onClose = function () {
564
- BkMessage.close(instanceId, configClose);
565
- };
566
- var instance = new MessageComponent({
567
- data: config
568
- });
569
- if (config.message !== null && _typeof(config.message) === 'object' && config.message.hasOwnProperty('componentOptions')) {
570
- instance.$slots.default = [config.message];
571
- instance.message = null;
572
- }
573
- instance.id = instanceId;
574
- instance.spacing = spacing;
575
- instance.ellipsisLine = ellipsisLine;
576
- instance.verticalOffset = 0;
577
- instance.$mount();
578
- instance.dom = instance.$el;
579
- document.body.appendChild(instance.$el);
580
- messageList.forEach(function (item) {
581
- verticalOffset += _parseInt$2(item.$el.offsetHeight) + _parseInt$2(spacing);
582
- });
583
- instance.verticalOffset = verticalOffset;
584
- instance.horizonOffset = spacing;
585
- instance.visible = true;
586
- messageList.push(instance);
587
- return instance;
588
- };
589
- BkMessage.close = function (id, configClose) {
590
- var instanceIndex = -1;
591
- messageList.some(function (item, index) {
592
- if (item.id === id) {
593
- instanceIndex = index;
594
- return true;
595
- }
596
- });
597
- if (instanceIndex > -1) {
598
- var instance = messageList[instanceIndex];
599
- if (typeof configClose === 'function') {
600
- configClose(instance);
601
- }
602
- messageList.forEach(function (item, i) {
603
- if (i > instanceIndex) {
604
- item.verticalOffset -= instance.dom.offsetHeight + instance.spacing;
605
- }
606
- });
607
- messageList.splice(instanceIndex, 1);
608
- }
609
- };
610
- BkMessage.batchClose = function () {
611
- var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
612
- var len = messageList.length;
613
- if (limit <= len) {
614
- var InstancesShouldClose = messageList.slice(0, len - limit + 1);
615
- InstancesShouldClose.forEach(function (item) {
616
- item.close();
617
- });
618
- }
619
- };
620
- Vue.prototype.$bkMessage = BkMessage;
621
-
622
- exports.default = BkMessage;
623
-
624
- Object.defineProperty(exports, '__esModule', { value: true });
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('bk-magic-vue/lib/locale'), require('json-formatter-js'), require('clipboard')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'vue', 'bk-magic-vue/lib/locale', 'json-formatter-js', 'clipboard'], factory) :
4
+ (global = global || self, factory(global.library = {}, global.Vue, global.locale, global.JSONFormatter, global.ClipboardJS));
5
+ }(this, function (exports, Vue, locale, JSONFormatter, ClipboardJS) { 'use strict';
6
+
7
+ Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
8
+ locale = locale && locale.hasOwnProperty('default') ? locale['default'] : locale;
9
+ JSONFormatter = JSONFormatter && JSONFormatter.hasOwnProperty('default') ? JSONFormatter['default'] : JSONFormatter;
10
+ ClipboardJS = ClipboardJS && ClipboardJS.hasOwnProperty('default') ? ClipboardJS['default'] : ClipboardJS;
11
+
12
+ function createCommonjsModule(fn, module) {
13
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
14
+ }
15
+
16
+ var _global = createCommonjsModule(function (module) {
17
+ var global = module.exports = typeof window != 'undefined' && window.Math == Math
18
+ ? window : typeof self != 'undefined' && self.Math == Math ? self
19
+ : Function('return this')();
20
+ if (typeof __g == 'number') __g = global;
21
+ });
22
+
23
+ var _core = createCommonjsModule(function (module) {
24
+ var core = module.exports = { version: '2.6.12' };
25
+ if (typeof __e == 'number') __e = core;
26
+ });
27
+ var _core_1 = _core.version;
28
+
29
+ var _aFunction = function (it) {
30
+ if (typeof it != 'function') throw TypeError(it + ' is not a function!');
31
+ return it;
32
+ };
33
+
34
+ var _ctx = function (fn, that, length) {
35
+ _aFunction(fn);
36
+ if (that === undefined) return fn;
37
+ switch (length) {
38
+ case 1: return function (a) {
39
+ return fn.call(that, a);
40
+ };
41
+ case 2: return function (a, b) {
42
+ return fn.call(that, a, b);
43
+ };
44
+ case 3: return function (a, b, c) {
45
+ return fn.call(that, a, b, c);
46
+ };
47
+ }
48
+ return function () {
49
+ return fn.apply(that, arguments);
50
+ };
51
+ };
52
+
53
+ var _isObject = function (it) {
54
+ return typeof it === 'object' ? it !== null : typeof it === 'function';
55
+ };
56
+
57
+ var _anObject = function (it) {
58
+ if (!_isObject(it)) throw TypeError(it + ' is not an object!');
59
+ return it;
60
+ };
61
+
62
+ var _fails = function (exec) {
63
+ try {
64
+ return !!exec();
65
+ } catch (e) {
66
+ return true;
67
+ }
68
+ };
69
+
70
+ var _descriptors = !_fails(function () {
71
+ return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
72
+ });
73
+
74
+ var document$1 = _global.document;
75
+ var is = _isObject(document$1) && _isObject(document$1.createElement);
76
+ var _domCreate = function (it) {
77
+ return is ? document$1.createElement(it) : {};
78
+ };
79
+
80
+ var _ie8DomDefine = !_descriptors && !_fails(function () {
81
+ return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
82
+ });
83
+
84
+ var _toPrimitive = function (it, S) {
85
+ if (!_isObject(it)) return it;
86
+ var fn, val;
87
+ if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
88
+ if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
89
+ if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
90
+ throw TypeError("Can't convert object to primitive value");
91
+ };
92
+
93
+ var dP = Object.defineProperty;
94
+ var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
95
+ _anObject(O);
96
+ P = _toPrimitive(P, true);
97
+ _anObject(Attributes);
98
+ if (_ie8DomDefine) try {
99
+ return dP(O, P, Attributes);
100
+ } catch (e) { }
101
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
102
+ if ('value' in Attributes) O[P] = Attributes.value;
103
+ return O;
104
+ };
105
+ var _objectDp = {
106
+ f: f
107
+ };
108
+
109
+ var _propertyDesc = function (bitmap, value) {
110
+ return {
111
+ enumerable: !(bitmap & 1),
112
+ configurable: !(bitmap & 2),
113
+ writable: !(bitmap & 4),
114
+ value: value
115
+ };
116
+ };
117
+
118
+ var _hide = _descriptors ? function (object, key, value) {
119
+ return _objectDp.f(object, key, _propertyDesc(1, value));
120
+ } : function (object, key, value) {
121
+ object[key] = value;
122
+ return object;
123
+ };
124
+
125
+ var hasOwnProperty = {}.hasOwnProperty;
126
+ var _has = function (it, key) {
127
+ return hasOwnProperty.call(it, key);
128
+ };
129
+
130
+ var PROTOTYPE = 'prototype';
131
+ var $export = function (type, name, source) {
132
+ var IS_FORCED = type & $export.F;
133
+ var IS_GLOBAL = type & $export.G;
134
+ var IS_STATIC = type & $export.S;
135
+ var IS_PROTO = type & $export.P;
136
+ var IS_BIND = type & $export.B;
137
+ var IS_WRAP = type & $export.W;
138
+ var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
139
+ var expProto = exports[PROTOTYPE];
140
+ var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
141
+ var key, own, out;
142
+ if (IS_GLOBAL) source = name;
143
+ for (key in source) {
144
+ own = !IS_FORCED && target && target[key] !== undefined;
145
+ if (own && _has(exports, key)) continue;
146
+ out = own ? target[key] : source[key];
147
+ exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
148
+ : IS_BIND && own ? _ctx(out, _global)
149
+ : IS_WRAP && target[key] == out ? (function (C) {
150
+ var F = function (a, b, c) {
151
+ if (this instanceof C) {
152
+ switch (arguments.length) {
153
+ case 0: return new C();
154
+ case 1: return new C(a);
155
+ case 2: return new C(a, b);
156
+ } return new C(a, b, c);
157
+ } return C.apply(this, arguments);
158
+ };
159
+ F[PROTOTYPE] = C[PROTOTYPE];
160
+ return F;
161
+ })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
162
+ if (IS_PROTO) {
163
+ (exports.virtual || (exports.virtual = {}))[key] = out;
164
+ if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
165
+ }
166
+ }
167
+ };
168
+ $export.F = 1;
169
+ $export.G = 2;
170
+ $export.S = 4;
171
+ $export.P = 8;
172
+ $export.B = 16;
173
+ $export.W = 32;
174
+ $export.U = 64;
175
+ $export.R = 128;
176
+ var _export = $export;
177
+
178
+ var _defined = function (it) {
179
+ if (it == undefined) throw TypeError("Can't call method on " + it);
180
+ return it;
181
+ };
182
+
183
+ var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
184
+ '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
185
+
186
+ var space = '[' + _stringWs + ']';
187
+ var non = '\u200b\u0085';
188
+ var ltrim = RegExp('^' + space + space + '*');
189
+ var rtrim = RegExp(space + space + '*$');
190
+ var exporter = function (KEY, exec, ALIAS) {
191
+ var exp = {};
192
+ var FORCE = _fails(function () {
193
+ return !!_stringWs[KEY]() || non[KEY]() != non;
194
+ });
195
+ var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY];
196
+ if (ALIAS) exp[ALIAS] = fn;
197
+ _export(_export.P + _export.F * FORCE, 'String', exp);
198
+ };
199
+ var trim = exporter.trim = function (string, TYPE) {
200
+ string = String(_defined(string));
201
+ if (TYPE & 1) string = string.replace(ltrim, '');
202
+ if (TYPE & 2) string = string.replace(rtrim, '');
203
+ return string;
204
+ };
205
+ var _stringTrim = exporter;
206
+
207
+ var $parseInt = _global.parseInt;
208
+ var $trim = _stringTrim.trim;
209
+ var hex = /^[-+]?0[xX]/;
210
+ var _parseInt = $parseInt(_stringWs + '08') !== 8 || $parseInt(_stringWs + '0x16') !== 22 ? function parseInt(str, radix) {
211
+ var string = $trim(String(str), 3);
212
+ return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
213
+ } : $parseInt;
214
+
215
+ _export(_export.G + _export.F * (parseInt != _parseInt), { parseInt: _parseInt });
216
+
217
+ var _parseInt$1 = _core.parseInt;
218
+
219
+ var _parseInt$2 = _parseInt$1;
220
+
221
+ _export(_export.S, 'Date', { now: function () { return new Date().getTime(); } });
222
+
223
+ var now = _core.Date.now;
224
+
225
+ var now$1 = now;
226
+
227
+ var $JSON = _core.JSON || (_core.JSON = { stringify: JSON.stringify });
228
+ var stringify = function stringify(it) {
229
+ return $JSON.stringify.apply($JSON, arguments);
230
+ };
231
+
232
+ var stringify$1 = stringify;
233
+
234
+ function _typeof(obj) {
235
+ "@babel/helpers - typeof";
236
+
237
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
238
+ return typeof obj;
239
+ } : function (obj) {
240
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
241
+ }, _typeof(obj);
242
+ }
243
+ function _defineProperty(obj, key, value) {
244
+ if (key in obj) {
245
+ Object.defineProperty(obj, key, {
246
+ value: value,
247
+ enumerable: true,
248
+ configurable: true,
249
+ writable: true
250
+ });
251
+ } else {
252
+ obj[key] = value;
253
+ }
254
+ return obj;
255
+ }
256
+ function _extends() {
257
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
258
+ for (var i = 1; i < arguments.length; i++) {
259
+ var source = arguments[i];
260
+ for (var key in source) {
261
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
262
+ target[key] = source[key];
263
+ }
264
+ }
265
+ }
266
+ return target;
267
+ };
268
+ return _extends.apply(this, arguments);
269
+ }
270
+ function _toConsumableArray(arr) {
271
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
272
+ }
273
+ function _arrayWithoutHoles(arr) {
274
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
275
+ }
276
+ function _iterableToArray(iter) {
277
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
278
+ }
279
+ function _unsupportedIterableToArray(o, minLen) {
280
+ if (!o) return;
281
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
282
+ var n = Object.prototype.toString.call(o).slice(8, -1);
283
+ if (n === "Object" && o.constructor) n = o.constructor.name;
284
+ if (n === "Map" || n === "Set") return Array.from(o);
285
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
286
+ }
287
+ function _arrayLikeToArray(arr, len) {
288
+ if (len == null || len > arr.length) len = arr.length;
289
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
290
+ return arr2;
291
+ }
292
+ function _nonIterableSpread() {
293
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
294
+ }
295
+
296
+ var $parseFloat = _global.parseFloat;
297
+ var $trim$1 = _stringTrim.trim;
298
+ var _parseFloat = 1 / $parseFloat(_stringWs + '-0') !== -Infinity ? function parseFloat(str) {
299
+ var string = $trim$1(String(str), 3);
300
+ var result = $parseFloat(string);
301
+ return result === 0 && string.charAt(0) == '-' ? -0 : result;
302
+ } : $parseFloat;
303
+
304
+ _export(_export.G + _export.F * (parseFloat != _parseFloat), { parseFloat: _parseFloat });
305
+
306
+ var _parseFloat$1 = _core.parseFloat;
307
+
308
+ var _parseFloat$2 = _parseFloat$1;
309
+
310
+ var toString = {}.toString;
311
+ var _cof = function (it) {
312
+ return toString.call(it).slice(8, -1);
313
+ };
314
+
315
+ var _isArray = Array.isArray || function isArray(arg) {
316
+ return _cof(arg) == 'Array';
317
+ };
318
+
319
+ _export(_export.S, 'Array', { isArray: _isArray });
320
+
321
+ var isArray = _core.Array.isArray;
322
+
323
+ var isArray$1 = isArray;
324
+
325
+ var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
326
+ window.setTimeout(callback, 1000 / 60);
327
+ };
328
+ var cancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) {
329
+ window.clearTimeout(id);
330
+ };
331
+ var copyText = function copyText(text) {
332
+ var textarea = document.createElement('textarea');
333
+ document.body.appendChild(textarea);
334
+ textarea.value = text;
335
+ textarea.select();
336
+ if (document.execCommand('copy')) {
337
+ document.execCommand('copy');
338
+ } else {
339
+ console.warn('unsupported this function, please use Google Chrome.');
340
+ }
341
+ document.body.removeChild(textarea);
342
+ };
343
+ function checkOverflow(el) {
344
+ if (!el) return false;
345
+ var createDom = function createDom(el, css) {
346
+ var dom = document.createElement('div');
347
+ var width = _parseFloat$2(css['width']) ? Math.ceil(_parseFloat$2(css['width'])) + 'px' : css['width'];
348
+ dom.style.cssText = "\n width: ".concat(width, ";\n line-height: ").concat(css['line-height'], ";\n font-size: ").concat(css['font-size'], ";\n word-break: ").concat(css['word-break'], ";\n padding: ").concat(css['padding'], ";\n ");
349
+ dom.textContent = el.textContent;
350
+ return dom;
351
+ };
352
+ var isOverflow = false;
353
+ try {
354
+ var css = window.getComputedStyle(el, null);
355
+ var lineClamp = css.webkitLineClamp;
356
+ if (lineClamp !== 'none') {
357
+ var targetHeight = _parseFloat$2(css.height);
358
+ var dom = createDom(el, css);
359
+ document.body.appendChild(dom);
360
+ var domHeight = window.getComputedStyle(dom, null)['height'];
361
+ document.body.removeChild(dom);
362
+ isOverflow = targetHeight < _parseFloat$2(domHeight);
363
+ } else {
364
+ isOverflow = el.clientWidth < el.scrollWidth || el.clientHeight < el.scrollHeight;
365
+ }
366
+ } catch (e) {
367
+ console.warn('There is an error when check element overflow state: ', e);
368
+ }
369
+ return isOverflow;
370
+ }
371
+
372
+ var _toObject = function (it) {
373
+ return Object(_defined(it));
374
+ };
375
+
376
+ var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
377
+ return _cof(it) == 'String' ? it.split('') : Object(it);
378
+ };
379
+
380
+ var _toIobject = function (it) {
381
+ return _iobject(_defined(it));
382
+ };
383
+
384
+ var ceil = Math.ceil;
385
+ var floor = Math.floor;
386
+ var _toInteger = function (it) {
387
+ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
388
+ };
389
+
390
+ var min = Math.min;
391
+ var _toLength = function (it) {
392
+ return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0;
393
+ };
394
+
395
+ var max = Math.max;
396
+ var min$1 = Math.min;
397
+ var _toAbsoluteIndex = function (index, length) {
398
+ index = _toInteger(index);
399
+ return index < 0 ? max(index + length, 0) : min$1(index, length);
400
+ };
401
+
402
+ var _arrayIncludes = function (IS_INCLUDES) {
403
+ return function ($this, el, fromIndex) {
404
+ var O = _toIobject($this);
405
+ var length = _toLength(O.length);
406
+ var index = _toAbsoluteIndex(fromIndex, length);
407
+ var value;
408
+ if (IS_INCLUDES && el != el) while (length > index) {
409
+ value = O[index++];
410
+ if (value != value) return true;
411
+ } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
412
+ if (O[index] === el) return IS_INCLUDES || index || 0;
413
+ } return !IS_INCLUDES && -1;
414
+ };
415
+ };
416
+
417
+ var _shared = createCommonjsModule(function (module) {
418
+ var SHARED = '__core-js_shared__';
419
+ var store = _global[SHARED] || (_global[SHARED] = {});
420
+ (module.exports = function (key, value) {
421
+ return store[key] || (store[key] = value !== undefined ? value : {});
422
+ })('versions', []).push({
423
+ version: _core.version,
424
+ mode: 'pure' ,
425
+ copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
426
+ });
427
+ });
428
+
429
+ var id = 0;
430
+ var px = Math.random();
431
+ var _uid = function (key) {
432
+ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
433
+ };
434
+
435
+ var shared = _shared('keys');
436
+ var _sharedKey = function (key) {
437
+ return shared[key] || (shared[key] = _uid(key));
438
+ };
439
+
440
+ var arrayIndexOf = _arrayIncludes(false);
441
+ var IE_PROTO = _sharedKey('IE_PROTO');
442
+ var _objectKeysInternal = function (object, names) {
443
+ var O = _toIobject(object);
444
+ var i = 0;
445
+ var result = [];
446
+ var key;
447
+ for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
448
+ while (names.length > i) if (_has(O, key = names[i++])) {
449
+ ~arrayIndexOf(result, key) || result.push(key);
450
+ }
451
+ return result;
452
+ };
453
+
454
+ var _enumBugKeys = (
455
+ 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
456
+ ).split(',');
457
+
458
+ var _objectKeys = Object.keys || function keys(O) {
459
+ return _objectKeysInternal(O, _enumBugKeys);
460
+ };
461
+
462
+ var _objectSap = function (KEY, exec) {
463
+ var fn = (_core.Object || {})[KEY] || Object[KEY];
464
+ var exp = {};
465
+ exp[KEY] = exec(fn);
466
+ _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
467
+ };
468
+
469
+ _objectSap('keys', function () {
470
+ return function keys(it) {
471
+ return _objectKeys(_toObject(it));
472
+ };
473
+ });
474
+
475
+ var keys = _core.Object.keys;
476
+
477
+ var keys$1 = keys;
478
+
479
+ var rApply = (_global.Reflect || {}).apply;
480
+ var fApply = Function.apply;
481
+ _export(_export.S + _export.F * !_fails(function () {
482
+ rApply(function () { });
483
+ }), 'Reflect', {
484
+ apply: function apply(target, thisArgument, argumentsList) {
485
+ var T = _aFunction(target);
486
+ var L = _anObject(argumentsList);
487
+ return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);
488
+ }
489
+ });
490
+
491
+ var apply = _core.Reflect.apply;
492
+
493
+ var apply$1 = apply;
494
+
495
+ var IMessageActionType = {
496
+ ASSISTANT: 'assistant',
497
+ DETAILS: 'details',
498
+ FIX: 'fix',
499
+ CLOSE: 'close'
500
+ };
501
+ var MessageContentType = {
502
+ KEY_VALUE: 'key-value',
503
+ JSON: 'json'
504
+ };
505
+ var sortActionIdList = [IMessageActionType.ASSISTANT, IMessageActionType.DETAILS, IMessageActionType.FIX, IMessageActionType.CLOSE];
506
+ var MessageAdvanced = {
507
+ name: 'bk-message-advanced',
508
+ mixins: [locale.mixin],
509
+ props: {
510
+ message: {
511
+ type: Object,
512
+ default: function _default() {
513
+ return {};
514
+ }
515
+ },
516
+ actions: {
517
+ type: Array,
518
+ default: function _default() {
519
+ return [];
520
+ }
521
+ },
522
+ tipsIcon: {
523
+ type: String,
524
+ default: ''
525
+ }
526
+ },
527
+ data: function data() {
528
+ return {
529
+ toolOperation: {
530
+ isFix: false,
531
+ isDetailShow: false
532
+ },
533
+ isInstallClipboardJS: false,
534
+ copyStatus: '',
535
+ copyStatusTimer: null
536
+ };
537
+ },
538
+ computed: {
539
+ defActionList: function defActionList() {
540
+ var _this = this,
541
+ _ref;
542
+ return _ref = {}, _defineProperty(_ref, IMessageActionType.ASSISTANT, {
543
+ id: IMessageActionType.ASSISTANT,
544
+ icon: function icon(h) {
545
+ return h('span', {
546
+ class: 'bk-icon icon-weixin-pro'
547
+ });
548
+ },
549
+ text: function text() {
550
+ return _this.t('bk.message.assistant');
551
+ },
552
+ onClick: function onClick(e) {
553
+ return _this.handleHeplerClick(e);
554
+ }
555
+ }), _defineProperty(_ref, IMessageActionType.DETAILS, {
556
+ id: IMessageActionType.DETAILS,
557
+ icon: function icon(h) {
558
+ return _this.toolOperation.isDetailShow ? h('span', {
559
+ class: 'bk-icon icon-angle-double-up'
560
+ }) : h('span', {
561
+ class: 'bk-icon icon-angle-double-down'
562
+ });
563
+ },
564
+ text: function text() {
565
+ return _this.t('bk.message.details');
566
+ },
567
+ onClick: function onClick(e) {
568
+ return _this.setDetailsShow(e);
569
+ }
570
+ }), _defineProperty(_ref, IMessageActionType.FIX, {
571
+ id: IMessageActionType.FIX,
572
+ icon: function icon(h) {
573
+ return _this.toolOperation.isFix ? h('span', {
574
+ class: 'bk-icon icon-fix-shape'
575
+ }) : h('span', {
576
+ class: 'bk-icon icon-fix-line'
577
+ });
578
+ },
579
+ classList: this.toolOperation.isFix ? 'fixed' : '',
580
+ onClick: function onClick(e) {
581
+ return _this.fixMesage(e);
582
+ }
583
+ }), _defineProperty(_ref, IMessageActionType.CLOSE, {
584
+ id: IMessageActionType.CLOSE,
585
+ classList: 'normal-color',
586
+ icon: function icon(h) {
587
+ return h('span', {
588
+ class: 'bk-message-close'
589
+ }, [h('i', {
590
+ class: 'bk-icon icon-close'
591
+ })]);
592
+ },
593
+ onClick: this.handleCloseClick
594
+ }), _ref;
595
+ },
596
+ actionList: function actionList() {
597
+ var _this2 = this;
598
+ if (this.actions && this.actions.length > 0) {
599
+ var resultList = this.actions.map(function (action) {
600
+ var id = action.id.toLocaleLowerCase();
601
+ var defAction = _this2.defActionList[id];
602
+ var defClickFn = defAction.onClick;
603
+ var target = _extends({}, _this2.defActionList[id] || {}, action);
604
+ target.id = id;
605
+ if (action.classList !== undefined) {
606
+ var classList = isArray$1(action.classList) ? action.classList : [action.classList];
607
+ var defClassList = [];
608
+ if (defAction.classList !== undefined) {
609
+ defClassList = isArray$1(defAction.classList) ? defAction.classList : [defAction.classList];
610
+ }
611
+ target.classList = [].concat(_toConsumableArray(defClassList), _toConsumableArray(classList));
612
+ }
613
+ if (typeof action.onClick === 'function') {
614
+ target.onClick = function () {
615
+ var resp = apply$1(action.onClick, _this2, []);
616
+ if ((typeof resp === 'undefined' || resp) && typeof defClickFn === 'function') {
617
+ apply$1(defClickFn, _this2, []);
618
+ }
619
+ };
620
+ return target;
621
+ }
622
+ target.onClick = defClickFn;
623
+ return target;
624
+ });
625
+ var appendList = sortActionIdList.filter(function (id) {
626
+ return !resultList.some(function (action) {
627
+ return action.id === id;
628
+ });
629
+ }).map(function (id) {
630
+ return _this2.defActionList[id];
631
+ });
632
+ resultList.push.apply(resultList, _toConsumableArray(appendList));
633
+ return resultList;
634
+ }
635
+ return sortActionIdList.map(function (id) {
636
+ return _this2.defActionList[id];
637
+ });
638
+ }
639
+ },
640
+ methods: {
641
+ handleCloseClick: function handleCloseClick() {
642
+ this.$emit('close');
643
+ },
644
+ handleHeplerClick: function handleHeplerClick(e) {
645
+ if (this.message.assistant) {
646
+ window.open(this.message.assistant, '_blank');
647
+ }
648
+ },
649
+ setDetailsShow: function setDetailsShow(e, isShow) {
650
+ var _this3 = this;
651
+ this.toolOperation.isDetailShow = isShow !== undefined ? isShow : !this.toolOperation.isDetailShow;
652
+ this.fixMesage(e, this.toolOperation.isDetailShow);
653
+ if (this.toolOperation.isDetailShow && _typeof(this.message) === 'object' && (this.message.type === MessageContentType.JSON || !this.message.type)) {
654
+ var targetJson = this.parseJson(this.message.details);
655
+ var formatter = new JSONFormatter(targetJson);
656
+ setTimeout(function () {
657
+ if (_this3.$refs.refJsonContent) {
658
+ _this3.$refs.refJsonContent.innerHTML = '';
659
+ _this3.$refs.refJsonContent.append(formatter.render());
660
+ }
661
+ });
662
+ }
663
+ },
664
+ fixMesage: function fixMesage(e, isFix) {
665
+ this.toolOperation.isFix = isFix !== undefined ? isFix : !this.toolOperation.isFix;
666
+ this.$emit('fix-message', this.toolOperation.isFix);
667
+ },
668
+ parseJson: function parseJson(value) {
669
+ var targetJson = value;
670
+ if (typeof value === 'string') {
671
+ try {
672
+ targetJson = JSON.parse(value);
673
+ } catch (e) {
674
+ console.error("Format Json Error: ".concat(e));
675
+ }
676
+ }
677
+ return targetJson;
678
+ },
679
+ copyMessage: function copyMessage() {
680
+ var _this4 = this;
681
+ if (this.isInstallClipboardJS) {
682
+ return;
683
+ }
684
+ var copyInstance = new ClipboardJS(this.$refs.refCopyMsgDiv, {
685
+ text: function text() {
686
+ return _this4.message.details;
687
+ }
688
+ });
689
+ ['success', 'error'].forEach(function (theme) {
690
+ copyInstance.on(theme, function () {
691
+ var target = _this4.$refs.refCopyStatus;
692
+ _this4.copyStatus = theme;
693
+ if (target) {
694
+ var _target$classList, _target$classList2;
695
+ (_target$classList = target.classList).remove.apply(_target$classList, ['success', 'error', 'is-hidden']);
696
+ (_target$classList2 = target.classList).add.apply(_target$classList2, [theme, 'is-show']);
697
+ _this4.copyStatusTimer && clearTimeout(_this4.copyStatusTimer);
698
+ _this4.copyStatusTimer = setTimeout(function () {
699
+ var _target$classList3, _target$classList4;
700
+ (_target$classList3 = target.classList).remove.apply(_target$classList3, ['is-show']);
701
+ (_target$classList4 = target.classList).add.apply(_target$classList4, ['is-hidden']);
702
+ }, 2000);
703
+ }
704
+ });
705
+ _this4.isInstallClipboardJS = true;
706
+ setTimeout(function () {
707
+ _this4.$refs.refCopyMsgDiv.click();
708
+ });
709
+ });
710
+ }
711
+ },
712
+ render: function render(h) {
713
+ var _this5 = this;
714
+ var renderMsgDetail = function renderMsgDetail(msg) {
715
+ if (msg.type === MessageContentType.KEY_VALUE) {
716
+ var target = _this5.parseJson(msg.details || {});
717
+ var keys = keys$1(target);
718
+ return keys.map(function (key) {
719
+ return h('div', {
720
+ class: 'message-row'
721
+ }, [h('label', key), target[key]]);
722
+ });
723
+ }
724
+ return null;
725
+ };
726
+ var renderMessageActions = function renderMessageActions() {
727
+ var renderIcon = function renderIcon(_ref2) {
728
+ var icon = _ref2.icon;
729
+ if (typeof icon === 'function') {
730
+ return apply$1(icon, _this5, [h]);
731
+ }
732
+ return h('span', {
733
+ class: icon
734
+ });
735
+ };
736
+ var renderText = function renderText(_ref3) {
737
+ var text = _ref3.text;
738
+ var content;
739
+ if (typeof text === 'function') {
740
+ content = apply$1(text, _this5, [h]);
741
+ }
742
+ if (content === undefined) {
743
+ return;
744
+ }
745
+ if (typeof content === 'string') {
746
+ return h('span', {
747
+ class: 'message-action-text'
748
+ }, [content]);
749
+ }
750
+ return content;
751
+ };
752
+ var handleActionClick = function handleActionClick(e, action) {
753
+ if (action.readonly || action.disabled) {
754
+ return;
755
+ }
756
+ if (typeof action.onClick === 'function') {
757
+ apply$1(action.onClick, _this5, [e, action]);
758
+ }
759
+ };
760
+ var renderActionList = function renderActionList() {
761
+ return _this5.actionList.map(function (action) {
762
+ if (action.disabled) {
763
+ return null;
764
+ }
765
+ if (typeof action.render === 'function') {
766
+ return apply$1(action.render, _this5, []);
767
+ }
768
+ var classList = isArray$1(action.classList) ? action.classList.join(' ') : action.classList;
769
+ return h('div', {
770
+ class: ['tool', action.id, classList],
771
+ on: {
772
+ click: function click(e) {
773
+ return handleActionClick(e, action);
774
+ }
775
+ }
776
+ }, [renderIcon(action), renderText(action)]);
777
+ });
778
+ };
779
+ return renderActionList();
780
+ };
781
+ var iconMap = {
782
+ success: 'bk-icon icon-check-circle-shape',
783
+ error: 'bk-icon icon-close-circle-shape'
784
+ };
785
+ return h('div', {
786
+ class: 'bk-message-content multi'
787
+ }, [h('div', {
788
+ class: 'overview'
789
+ }, [h('div', {
790
+ class: 'left-content'
791
+ }, [h('div', {
792
+ class: 'bk-message-icon'
793
+ }, [h('i', {
794
+ class: ['bk-icon', this.tipsIcon]
795
+ })]), h('div', {
796
+ class: 'describe'
797
+ }, this.message.title || "\u3010".concat(this.message.code, "\u3011").concat(this.message.overview, " ").concat(this.message.suggestion))]), h('div', {
798
+ class: 'tools'
799
+ }, [renderMessageActions()])]), this.toolOperation.isDetailShow ? h('div', {
800
+ class: 'message-detail'
801
+ }, [h('div', {
802
+ class: 'message-copy',
803
+ ref: 'refCopyMsgDiv',
804
+ on: {
805
+ click: this.copyMessage
806
+ }
807
+ }, [h('span', {
808
+ class: 'bk-icon icon-copy-shape'
809
+ }), h('div', {
810
+ class: ['copy-status', this.copyStatus],
811
+ ref: 'refCopyStatus'
812
+ }, [h('div', {
813
+ class: 'inner'
814
+ }, [h('span', {
815
+ class: [iconMap[this.copyStatus], this.copyStatus]
816
+ }), this.copyStatus === 'success' ? this.t('bk.message.copySuccess') : this.t('bk.message.copyFailed')])])]), h('div', {
817
+ class: 'message-tree',
818
+ ref: 'refJsonContent'
819
+ }, [renderMsgDetail(this.message)])]) : null]);
820
+ }
821
+ };
822
+
823
+ var ICONS = {
824
+ primary: 'icon-info-circle-shape',
825
+ error: 'icon-close-circle-shape',
826
+ warning: 'icon-exclamation-circle-shape',
827
+ success: 'icon-check-circle-shape'
828
+ };
829
+ var script = {
830
+ name: 'bk-message',
831
+ components: {
832
+ MessageAdvanced: MessageAdvanced
833
+ },
834
+ mixins: [locale.mixin],
835
+ data: function data() {
836
+ return {
837
+ theme: 'primary',
838
+ message: '',
839
+ delay: 3000,
840
+ icon: '',
841
+ dismissable: true,
842
+ verticalOffset: 0,
843
+ zIndex: 2500,
844
+ horizonOffset: 0,
845
+ visible: false,
846
+ countID: null,
847
+ onClose: function onClose() {},
848
+ extCls: '',
849
+ copied: false,
850
+ ellipsisCopy: false,
851
+ showCopyText: false,
852
+ showAdvanced: false,
853
+ actions: [],
854
+ isFixed: false,
855
+ width: 560
856
+ };
857
+ },
858
+ computed: {
859
+ themeClass: function themeClass() {
860
+ return "bk-message-".concat(this.theme);
861
+ },
862
+ verticalStyle: function verticalStyle() {
863
+ return {
864
+ top: "".concat(this.verticalOffset, "px"),
865
+ width: "".concat(this.width, "px"),
866
+ zIndex: this.zIndex
867
+ };
868
+ },
869
+ tipsIcon: function tipsIcon() {
870
+ return this.icon || ICONS[this.theme];
871
+ },
872
+ singleEllipsis: function singleEllipsis() {
873
+ return this.ellipsisLine === 1;
874
+ },
875
+ multiEllipsis: function multiEllipsis() {
876
+ return this.ellipsisLine > 1;
877
+ },
878
+ ellipsisStyle: function ellipsisStyle() {
879
+ return {
880
+ '--line': this.ellipsisLine
881
+ };
882
+ },
883
+ localeCopyText: function localeCopyText() {
884
+ return this.copied ? this.t('bk.message.copied') : this.t('bk.message.copy');
885
+ }
886
+ },
887
+ mounted: function mounted() {
888
+ this.startCountDown();
889
+ },
890
+ methods: {
891
+ handleFixMessage: function handleFixMessage(isFixed) {
892
+ this.isFixed = isFixed;
893
+ console.log('handleFixMessage', isFixed);
894
+ if (isFixed) {
895
+ this.stopCountDown();
896
+ } else {
897
+ this.startCountDown();
898
+ }
899
+ },
900
+ destroyEl: function destroyEl() {
901
+ this.$destroy();
902
+ this.$el.parentNode && this.$el.parentNode.removeChild(this.$el);
903
+ },
904
+ startCountDown: function startCountDown() {
905
+ var _this = this;
906
+ if (this.delay > 0 && !this.isFixed) {
907
+ this.countID = setTimeout(function () {
908
+ console.log('--Close');
909
+ _this.visible && _this.close();
910
+ }, this.delay);
911
+ }
912
+ },
913
+ stopCountDown: function stopCountDown() {
914
+ console.log('--stopCountDown');
915
+ clearTimeout(this.countID);
916
+ },
917
+ close: function close() {
918
+ this.visible = false;
919
+ typeof this.onClose === 'function' && this.onClose();
920
+ },
921
+ copyContent: function copyContent() {
922
+ if (!this.$refs.content || this.copied) return;
923
+ var text = this.$refs.content.textContent;
924
+ copyText(text);
925
+ this.copied = true;
926
+ },
927
+ setShowCopyText: function setShowCopyText() {
928
+ this.showCopyText = this.ellipsisCopy && checkOverflow(this.$refs.content);
929
+ }
930
+ }
931
+ };
932
+
933
+ function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
934
+ , shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
935
+ if (typeof shadowMode !== 'boolean') {
936
+ createInjectorSSR = createInjector;
937
+ createInjector = shadowMode;
938
+ shadowMode = false;
939
+ }
940
+ var options = typeof script === 'function' ? script.options : script;
941
+ if (template && template.render) {
942
+ options.render = template.render;
943
+ options.staticRenderFns = template.staticRenderFns;
944
+ options._compiled = true;
945
+ if (isFunctionalTemplate) {
946
+ options.functional = true;
947
+ }
948
+ }
949
+ if (scopeId) {
950
+ options._scopeId = scopeId;
951
+ }
952
+ var hook;
953
+ if (moduleIdentifier) {
954
+ hook = function hook(context) {
955
+ context = context ||
956
+ this.$vnode && this.$vnode.ssrContext ||
957
+ this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
958
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
959
+ context = __VUE_SSR_CONTEXT__;
960
+ }
961
+ if (style) {
962
+ style.call(this, createInjectorSSR(context));
963
+ }
964
+ if (context && context._registeredComponents) {
965
+ context._registeredComponents.add(moduleIdentifier);
966
+ }
967
+ };
968
+ options._ssrRegister = hook;
969
+ } else if (style) {
970
+ hook = shadowMode ? function () {
971
+ style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
972
+ } : function (context) {
973
+ style.call(this, createInjector(context));
974
+ };
975
+ }
976
+ if (hook) {
977
+ if (options.functional) {
978
+ var originalRender = options.render;
979
+ options.render = function renderWithStyleInjection(h, context) {
980
+ hook.call(context);
981
+ return originalRender(h, context);
982
+ };
983
+ } else {
984
+ var existing = options.beforeCreate;
985
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
986
+ }
987
+ }
988
+ return script;
989
+ }
990
+ var normalizeComponent_1 = normalizeComponent;
991
+
992
+ /* script */
993
+ var __vue_script__ = script;
994
+ /* template */
995
+ var __vue_render__ = function __vue_render__() {
996
+ var _vm = this;
997
+ var _h = _vm.$createElement;
998
+ var _c = _vm._self._c || _h;
999
+ return _c('transition', {
1000
+ attrs: {
1001
+ "name": "vertical-move"
1002
+ },
1003
+ on: {
1004
+ "after-leave": _vm.destroyEl,
1005
+ "enter": _vm.setShowCopyText
1006
+ }
1007
+ }, [_c('div', {
1008
+ directives: [{
1009
+ name: "show",
1010
+ rawName: "v-show",
1011
+ value: _vm.visible,
1012
+ expression: "visible"
1013
+ }],
1014
+ class: ['bk-message', _vm.themeClass, _vm.extCls],
1015
+ style: _vm.verticalStyle,
1016
+ on: {
1017
+ "mouseenter": _vm.stopCountDown,
1018
+ "mouseleave": _vm.startCountDown
1019
+ }
1020
+ }, [_vm.showAdvanced ? [_c('message-advanced', {
1021
+ attrs: {
1022
+ "message": _vm.message,
1023
+ "actions": _vm.actions,
1024
+ "tips-icon": _vm.tipsIcon
1025
+ },
1026
+ on: {
1027
+ "fix-message": _vm.handleFixMessage,
1028
+ "close": _vm.close
1029
+ }
1030
+ })] : [_c('div', {
1031
+ staticClass: "bk-message-icon"
1032
+ }, [_c('i', {
1033
+ class: ['bk-icon', _vm.tipsIcon]
1034
+ })]), _c('div', {
1035
+ ref: "content",
1036
+ class: ['bk-message-content', {
1037
+ 'multi-ellipsis': _vm.multiEllipsis,
1038
+ 'ellipsis': _vm.singleEllipsis
1039
+ }],
1040
+ style: _vm.ellipsisStyle
1041
+ }, [_vm._t("default", function () {
1042
+ return [_vm._v(_vm._s(_vm.message))];
1043
+ })], 2), _vm.showCopyText ? _c('div', {
1044
+ class: ['bk-message-copy', {
1045
+ 'copied': _vm.copied
1046
+ }],
1047
+ on: {
1048
+ "click": _vm.copyContent
1049
+ }
1050
+ }, [_vm._v("\n " + _vm._s(_vm.localeCopyText) + "\n ")]) : _vm._e(), _vm.dismissable ? _c('div', {
1051
+ staticClass: "bk-message-close"
1052
+ }, [_c('i', {
1053
+ class: ['bk-icon icon-close', _vm.showCopyText ? 'ml10' : 'ml30'],
1054
+ on: {
1055
+ "click": function click($event) {
1056
+ $event.stopPropagation();
1057
+ return _vm.close.apply(null, arguments);
1058
+ }
1059
+ }
1060
+ })]) : _vm._e()]], 2)]);
1061
+ };
1062
+ var __vue_staticRenderFns__ = [];
1063
+
1064
+ /* style */
1065
+ var __vue_inject_styles__ = undefined;
1066
+ /* scoped */
1067
+ var __vue_scope_id__ = undefined;
1068
+ /* module identifier */
1069
+ var __vue_module_identifier__ = undefined;
1070
+ /* functional template */
1071
+ var __vue_is_functional_template__ = false;
1072
+ /* style inject */
1073
+
1074
+ /* style inject SSR */
1075
+
1076
+ /* style inject shadow dom */
1077
+
1078
+ var __vue_component__ = /*#__PURE__*/normalizeComponent_1({
1079
+ render: __vue_render__,
1080
+ staticRenderFns: __vue_staticRenderFns__
1081
+ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
1082
+
1083
+ var MessageComponent = Vue.extend(__vue_component__);
1084
+ var messageList = [];
1085
+ var seed = 0;
1086
+ var BkMessage = function BkMessage(config) {
1087
+ var originConfig = _typeof(config) === 'object' ? JSON.parse(stringify$1(config)) : config;
1088
+ if (config.limit === 0) {
1089
+ BkMessage.batchClose();
1090
+ return;
1091
+ }
1092
+ if (config.limit > 0) {
1093
+ BkMessage.batchClose(config.limit);
1094
+ }
1095
+ var instanceId = "messageInstance_".concat(now$1(), "_").concat(seed++);
1096
+ var offsetY = _parseInt$2(config.offsetY) || 30;
1097
+ var spacing = _parseInt$2(config.spacing) || 10;
1098
+ if (config.ellipsisLine === null || config.ellipsisLine === undefined || config.ellipsisLine === '' || isNaN(config.ellipsisLine)) {
1099
+ config.ellipsisLine = 1;
1100
+ }
1101
+ var ellipsisLine = config.ellipsisLine;
1102
+ var verticalOffset = offsetY;
1103
+ if (typeof config === 'string' || typeof config === 'number') {
1104
+ config = {
1105
+ message: config
1106
+ };
1107
+ }
1108
+ var configClose = config.onClose;
1109
+ config.onClose = function () {
1110
+ BkMessage.close(instanceId, configClose);
1111
+ };
1112
+ var instance = new MessageComponent({
1113
+ data: config
1114
+ });
1115
+ if (originConfig.message !== null && _typeof(originConfig.message) === 'object' && originConfig.message.hasOwnProperty('componentOptions')) {
1116
+ instance.$slots.default = [config.message];
1117
+ instance.message = null;
1118
+ }
1119
+ if (!originConfig.width) {
1120
+ instance.width = 560;
1121
+ }
1122
+ if (originConfig.message !== null && _typeof(originConfig.message) === 'object' && !originConfig.message.hasOwnProperty('componentOptions')) {
1123
+ instance.showAdvanced = true;
1124
+ instance.actions = originConfig.actions || [];
1125
+ if (!originConfig.width) {
1126
+ instance.width = 800;
1127
+ }
1128
+ if (!originConfig.delay) {
1129
+ instance.delay = 8000;
1130
+ }
1131
+ }
1132
+ instance.id = instanceId;
1133
+ instance.spacing = spacing;
1134
+ instance.ellipsisLine = ellipsisLine;
1135
+ instance.verticalOffset = 0;
1136
+ instance.$mount();
1137
+ instance.dom = instance.$el;
1138
+ document.body.appendChild(instance.$el);
1139
+ messageList.forEach(function (item) {
1140
+ verticalOffset += _parseInt$2(item.$el.offsetHeight) + _parseInt$2(spacing);
1141
+ });
1142
+ instance.verticalOffset = verticalOffset;
1143
+ instance.horizonOffset = spacing;
1144
+ instance.visible = true;
1145
+ messageList.push(instance);
1146
+ return instance;
1147
+ };
1148
+ BkMessage.close = function (id, configClose) {
1149
+ var instanceIndex = -1;
1150
+ messageList.some(function (item, index) {
1151
+ if (item.id === id) {
1152
+ instanceIndex = index;
1153
+ return true;
1154
+ }
1155
+ });
1156
+ if (instanceIndex > -1) {
1157
+ var instance = messageList[instanceIndex];
1158
+ if (typeof configClose === 'function') {
1159
+ configClose(instance);
1160
+ }
1161
+ messageList.forEach(function (item, i) {
1162
+ if (i > instanceIndex) {
1163
+ item.verticalOffset -= instance.dom.offsetHeight + instance.spacing;
1164
+ }
1165
+ });
1166
+ messageList.splice(instanceIndex, 1);
1167
+ }
1168
+ };
1169
+ BkMessage.batchClose = function () {
1170
+ var limit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1171
+ var len = messageList.length;
1172
+ if (limit <= len) {
1173
+ var InstancesShouldClose = messageList.slice(0, len - limit + 1);
1174
+ InstancesShouldClose.forEach(function (item) {
1175
+ item.close();
1176
+ });
1177
+ }
1178
+ };
1179
+ Vue.prototype.$bkMessage = BkMessage;
1180
+
1181
+ exports.default = BkMessage;
1182
+
1183
+ Object.defineProperty(exports, '__esModule', { value: true });
625
1184
 
626
1185
  }));