@94ai/common-ui 3.3.4 → 3.3.11

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent } from "vue-demi";
1
+ import { defineComponent, Vue2 } from "vue-demi";
2
2
  import NfMenu from "@94ai/nf-menu";
3
3
  import { default as default2 } from "@94ai/nf-menu";
4
4
  import NfInfiniteMenu from "@94ai/nf-infinite-menu";
@@ -47,6 +47,8 @@ import NfDrawer from "@94ai/nf-drawer";
47
47
  import { default as default24 } from "@94ai/nf-drawer";
48
48
  import NfMessage from "@94ai/nf-message";
49
49
  import { default as default25 } from "@94ai/nf-message";
50
+ import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
51
+ import Vue from "vue";
50
52
  import NfNotification from "@94ai/nf-notification";
51
53
  import { default as default26 } from "@94ai/nf-notification";
52
54
  import NfConfirm from "@94ai/nf-confirm";
@@ -79,6 +81,882 @@ import NfTransferSelect from "@94ai/nf-transfer-select";
79
81
  import { default as default40 } from "@94ai/nf-transfer-select";
80
82
  import NfAddressSelect from "@94ai/nf-address-select";
81
83
  import { default as default41 } from "@94ai/nf-address-select";
84
+ const typeMap$2 = {
85
+ success: "success",
86
+ info: "info",
87
+ warning: "warning",
88
+ error: "error"
89
+ };
90
+ const _sfc_main$2 = defineComponent({
91
+ name: "nf-message",
92
+ data() {
93
+ return {
94
+ visible: false,
95
+ message: "",
96
+ duration: 3e3,
97
+ type: "info",
98
+ iconClass: "",
99
+ customClass: "",
100
+ onClose: null,
101
+ showClose: false,
102
+ closed: false,
103
+ verticalOffset: 20,
104
+ timer: null,
105
+ dangerouslyUseHTMLString: false,
106
+ center: false
107
+ };
108
+ },
109
+ computed: {
110
+ typeClass() {
111
+ return this.type && !this.iconClass ? `nf-message__icon el-icon-${typeMap$2[this.type]}` : "";
112
+ },
113
+ positionStyle() {
114
+ return {
115
+ "top": `${this.verticalOffset}px`
116
+ };
117
+ }
118
+ },
119
+ watch: {
120
+ closed(newVal) {
121
+ if (newVal) {
122
+ this.visible = false;
123
+ }
124
+ }
125
+ },
126
+ methods: {
127
+ handleAfterLeave() {
128
+ this.$destroy(true);
129
+ this.$el.parentNode.removeChild(this.$el);
130
+ },
131
+ close() {
132
+ this.closed = true;
133
+ if (typeof this.onClose === "function") {
134
+ this.onClose(this);
135
+ }
136
+ },
137
+ clearTimer() {
138
+ clearTimeout(this.timer);
139
+ },
140
+ startTimer() {
141
+ if (this.duration > 0) {
142
+ this.timer = setTimeout(() => {
143
+ if (!this.closed) {
144
+ this.close();
145
+ }
146
+ }, this.duration);
147
+ }
148
+ },
149
+ keydown(e) {
150
+ if (e.keyCode === 27) {
151
+ if (!this.closed) {
152
+ this.close();
153
+ }
154
+ }
155
+ }
156
+ },
157
+ mounted() {
158
+ this.startTimer();
159
+ document.addEventListener("keydown", this.keydown);
160
+ },
161
+ beforeDestroy() {
162
+ document.removeEventListener("keydown", this.keydown);
163
+ }
164
+ });
165
+ var _sfc_render$2 = function render() {
166
+ var _vm = this, _c = _vm._self._c;
167
+ _vm._self._setupProxy;
168
+ return _c("transition", {
169
+ attrs: {
170
+ "name": "nf-message-fade"
171
+ },
172
+ on: {
173
+ "after-leave": _vm.handleAfterLeave
174
+ }
175
+ }, [_c("div", {
176
+ directives: [{
177
+ name: "show",
178
+ rawName: "v-show",
179
+ value: _vm.visible,
180
+ expression: "visible"
181
+ }],
182
+ class: ["nf-message", _vm.type && !_vm.iconClass ? `nf-message--${_vm.type}` : "", _vm.center ? "is-center" : "", _vm.showClose ? "is-closable" : "", _vm.customClass],
183
+ style: _vm.positionStyle,
184
+ attrs: {
185
+ "role": "alert"
186
+ },
187
+ on: {
188
+ "mouseenter": _vm.clearTimer,
189
+ "mouseleave": _vm.startTimer
190
+ }
191
+ }, [_vm.iconClass ? _c("i", {
192
+ class: _vm.iconClass
193
+ }) : _c("i", {
194
+ class: _vm.typeClass
195
+ }), _vm._t("default", function() {
196
+ return [!_vm.dangerouslyUseHTMLString ? _c("p", {
197
+ staticClass: "nf-message__content"
198
+ }, [_vm._v(_vm._s(_vm.message))]) : _c("p", {
199
+ staticClass: "nf-message__content",
200
+ domProps: {
201
+ "innerHTML": _vm._s(_vm.message)
202
+ }
203
+ })];
204
+ }), _vm.showClose ? _c("i", {
205
+ staticClass: "nf-message__closeBtn el-icon-close",
206
+ on: {
207
+ "click": _vm.close
208
+ }
209
+ }) : _vm._e()], 2)]);
210
+ };
211
+ var _sfc_staticRenderFns$2 = [];
212
+ var __component__$2 = /* @__PURE__ */ normalizeComponent(_sfc_main$2, _sfc_render$2, _sfc_staticRenderFns$2, false, null, null, null, null);
213
+ const Main$2 = __component__$2.exports;
214
+ function merge(target) {
215
+ for (let i = 1, j = arguments.length; i < j; i++) {
216
+ let source = arguments[i] || {};
217
+ for (let prop in source) {
218
+ if (source.hasOwnProperty(prop)) {
219
+ let value = source[prop];
220
+ if (value !== void 0) {
221
+ target[prop] = value;
222
+ }
223
+ }
224
+ }
225
+ }
226
+ return target;
227
+ }
228
+ Vue.prototype.$isServer;
229
+ const trim = function(string) {
230
+ return (string || "").replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
231
+ };
232
+ function hasClass(el, cls) {
233
+ if (!el || !cls)
234
+ return false;
235
+ if (cls.indexOf(" ") !== -1)
236
+ throw new Error("className should not contain space.");
237
+ if (el.classList) {
238
+ return el.classList.contains(cls);
239
+ } else {
240
+ return (" " + el.className + " ").indexOf(" " + cls + " ") > -1;
241
+ }
242
+ }
243
+ function addClass(el, cls) {
244
+ if (!el)
245
+ return;
246
+ var curClass = el.className;
247
+ var classes = (cls || "").split(" ");
248
+ for (var i = 0, j = classes.length; i < j; i++) {
249
+ var clsName = classes[i];
250
+ if (!clsName)
251
+ continue;
252
+ if (el.classList) {
253
+ el.classList.add(clsName);
254
+ } else if (!hasClass(el, clsName)) {
255
+ curClass += " " + clsName;
256
+ }
257
+ }
258
+ if (!el.classList) {
259
+ el.className = curClass;
260
+ }
261
+ }
262
+ function removeClass(el, cls) {
263
+ if (!el || !cls)
264
+ return;
265
+ var classes = cls.split(" ");
266
+ var curClass = " " + el.className + " ";
267
+ for (var i = 0, j = classes.length; i < j; i++) {
268
+ var clsName = classes[i];
269
+ if (!clsName)
270
+ continue;
271
+ if (el.classList) {
272
+ el.classList.remove(clsName);
273
+ } else if (hasClass(el, clsName)) {
274
+ curClass = curClass.replace(" " + clsName + " ", " ");
275
+ }
276
+ }
277
+ if (!el.classList) {
278
+ el.className = trim(curClass);
279
+ }
280
+ }
281
+ let hasModal = false;
282
+ let hasInitZIndex = false;
283
+ let zIndex;
284
+ const getModal = function() {
285
+ if (Vue.prototype.$isServer)
286
+ return;
287
+ let modalDom = PopupManager.modalDom;
288
+ if (modalDom) {
289
+ hasModal = true;
290
+ } else {
291
+ hasModal = false;
292
+ modalDom = document.createElement("div");
293
+ PopupManager.modalDom = modalDom;
294
+ modalDom.addEventListener("touchmove", function(event) {
295
+ event.preventDefault();
296
+ event.stopPropagation();
297
+ });
298
+ modalDom.addEventListener("click", function() {
299
+ PopupManager.doOnModalClick && PopupManager.doOnModalClick();
300
+ });
301
+ }
302
+ return modalDom;
303
+ };
304
+ const instances$2 = {};
305
+ const PopupManager = {
306
+ modalFade: true,
307
+ getInstance: function(id) {
308
+ return instances$2[id];
309
+ },
310
+ register: function(id, instance2) {
311
+ if (id && instance2) {
312
+ instances$2[id] = instance2;
313
+ }
314
+ },
315
+ deregister: function(id) {
316
+ if (id) {
317
+ instances$2[id] = null;
318
+ delete instances$2[id];
319
+ }
320
+ },
321
+ nextZIndex: function() {
322
+ return PopupManager.zIndex++;
323
+ },
324
+ modalStack: [],
325
+ doOnModalClick: function() {
326
+ const topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
327
+ if (!topItem)
328
+ return;
329
+ const instance2 = PopupManager.getInstance(topItem.id);
330
+ if (instance2 && instance2.closeOnClickModal) {
331
+ instance2.close();
332
+ }
333
+ },
334
+ openModal: function(id, zIndex2, dom, modalClass, modalFade) {
335
+ if (Vue.prototype.$isServer)
336
+ return;
337
+ if (!id || zIndex2 === void 0)
338
+ return;
339
+ this.modalFade = modalFade;
340
+ const modalStack = this.modalStack;
341
+ for (let i = 0, j = modalStack.length; i < j; i++) {
342
+ const item = modalStack[i];
343
+ if (item.id === id) {
344
+ return;
345
+ }
346
+ }
347
+ const modalDom = getModal();
348
+ addClass(modalDom, "v-modal");
349
+ if (this.modalFade && !hasModal) {
350
+ addClass(modalDom, "v-modal-enter");
351
+ }
352
+ if (modalClass) {
353
+ let classArr = modalClass.trim().split(/\s+/);
354
+ classArr.forEach((item) => addClass(modalDom, item));
355
+ }
356
+ setTimeout(() => {
357
+ removeClass(modalDom, "v-modal-enter");
358
+ }, 200);
359
+ if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
360
+ dom.parentNode.appendChild(modalDom);
361
+ } else {
362
+ document.body.appendChild(modalDom);
363
+ }
364
+ if (zIndex2) {
365
+ modalDom.style.zIndex = zIndex2;
366
+ }
367
+ modalDom.tabIndex = 0;
368
+ modalDom.style.display = "";
369
+ this.modalStack.push({
370
+ id,
371
+ zIndex: zIndex2,
372
+ modalClass
373
+ });
374
+ },
375
+ closeModal: function(id) {
376
+ const modalStack = this.modalStack;
377
+ const modalDom = getModal();
378
+ if (modalStack.length > 0) {
379
+ const topItem = modalStack[modalStack.length - 1];
380
+ if (topItem.id === id) {
381
+ if (topItem.modalClass) {
382
+ let classArr = topItem.modalClass.trim().split(/\s+/);
383
+ classArr.forEach((item) => removeClass(modalDom, item));
384
+ }
385
+ modalStack.pop();
386
+ if (modalStack.length > 0) {
387
+ modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
388
+ }
389
+ } else {
390
+ for (let i = modalStack.length - 1; i >= 0; i--) {
391
+ if (modalStack[i].id === id) {
392
+ modalStack.splice(i, 1);
393
+ break;
394
+ }
395
+ }
396
+ }
397
+ }
398
+ if (modalStack.length === 0) {
399
+ if (this.modalFade) {
400
+ addClass(modalDom, "v-modal-leave");
401
+ }
402
+ setTimeout(() => {
403
+ if (modalStack.length === 0) {
404
+ if (modalDom.parentNode)
405
+ modalDom.parentNode.removeChild(modalDom);
406
+ modalDom.style.display = "none";
407
+ PopupManager.modalDom = void 0;
408
+ }
409
+ removeClass(modalDom, "v-modal-leave");
410
+ }, 200);
411
+ }
412
+ }
413
+ };
414
+ Object.defineProperty(PopupManager, "zIndex", {
415
+ configurable: true,
416
+ get() {
417
+ if (!hasInitZIndex) {
418
+ zIndex = zIndex || (Vue.prototype.$ELEMENT || {}).zIndex || 2e3;
419
+ hasInitZIndex = true;
420
+ }
421
+ return zIndex;
422
+ },
423
+ set(value) {
424
+ zIndex = value;
425
+ }
426
+ });
427
+ const getTopPopup = function() {
428
+ if (Vue.prototype.$isServer)
429
+ return;
430
+ if (PopupManager.modalStack.length > 0) {
431
+ const topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1];
432
+ if (!topPopup)
433
+ return;
434
+ const instance2 = PopupManager.getInstance(topPopup.id);
435
+ return instance2;
436
+ }
437
+ };
438
+ if (!Vue.prototype.$isServer) {
439
+ window.addEventListener("keydown", function(event) {
440
+ if (event.keyCode === 27) {
441
+ const topPopup = getTopPopup();
442
+ if (topPopup && topPopup.closeOnPressEscape) {
443
+ topPopup.handleClose ? topPopup.handleClose() : topPopup.handleAction ? topPopup.handleAction("cancel") : topPopup.close();
444
+ }
445
+ }
446
+ });
447
+ }
448
+ function isObject(obj) {
449
+ return Object.prototype.toString.call(obj) === "[object Object]";
450
+ }
451
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
452
+ function hasOwn(obj, key) {
453
+ return hasOwnProperty.call(obj, key);
454
+ }
455
+ function isVNode(node) {
456
+ return node !== null && typeof node === "object" && hasOwn(node, "componentOptions");
457
+ }
458
+ let MessageConstructor = Vue2.extend(Main$2);
459
+ let instance$1;
460
+ let instances$1 = [];
461
+ let seed$1 = 1;
462
+ const Message = function(options) {
463
+ var _a;
464
+ if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
465
+ return;
466
+ options = options || {};
467
+ if (typeof options === "string") {
468
+ options = {
469
+ message: options
470
+ };
471
+ }
472
+ let userOnClose = options.onClose;
473
+ let id = "message_" + seed$1++;
474
+ options.onClose = function() {
475
+ Message.close(id, userOnClose);
476
+ };
477
+ instance$1 = new MessageConstructor({
478
+ data: options
479
+ });
480
+ instance$1.id = id;
481
+ if (isVNode(instance$1.message)) {
482
+ instance$1.$slots.default = [instance$1.message];
483
+ instance$1.message = null;
484
+ }
485
+ instance$1.$mount();
486
+ document.body.appendChild(instance$1.$el);
487
+ let verticalOffset = options.offset || 100;
488
+ instances$1.forEach((item) => {
489
+ verticalOffset += item.$el.offsetHeight + 16;
490
+ });
491
+ instance$1.verticalOffset = verticalOffset;
492
+ instance$1.visible = true;
493
+ instance$1.$el.style.zIndex = PopupManager.nextZIndex() + 1e3;
494
+ instances$1.push(instance$1);
495
+ return instance$1;
496
+ };
497
+ ["success", "warning", "info", "error"].forEach((type) => {
498
+ Message[type] = (options) => {
499
+ if (isObject(options) && !isVNode(options)) {
500
+ return Message({
501
+ ...options,
502
+ type
503
+ });
504
+ }
505
+ return Message({
506
+ type,
507
+ message: options
508
+ });
509
+ };
510
+ });
511
+ Message.close = function(id, userOnClose) {
512
+ let len = instances$1.length;
513
+ let index = -1;
514
+ let removedHeight;
515
+ for (let i = 0; i < len; i++) {
516
+ if (id === instances$1[i].id) {
517
+ removedHeight = instances$1[i].$el.offsetHeight;
518
+ index = i;
519
+ if (typeof userOnClose === "function") {
520
+ userOnClose(instances$1[i]);
521
+ }
522
+ instances$1.splice(i, 1);
523
+ break;
524
+ }
525
+ }
526
+ if (len <= 1 || index === -1 || index > instances$1.length - 1)
527
+ return;
528
+ for (let i = index; i < len - 1; i++) {
529
+ let dom = instances$1[i].$el;
530
+ dom.style["top"] = parseInt(dom.style["top"], 10) - removedHeight - 16 + "px";
531
+ }
532
+ };
533
+ Message.closeAll = function() {
534
+ for (let i = instances$1.length - 1; i >= 0; i--) {
535
+ instances$1[i].close();
536
+ }
537
+ };
538
+ const typeMap$1 = {
539
+ success: "success",
540
+ info: "info",
541
+ warning: "warning",
542
+ error: "error"
543
+ };
544
+ const _sfc_main$1 = defineComponent({
545
+ name: "nf-notification",
546
+ data() {
547
+ return {
548
+ visible: false,
549
+ title: "",
550
+ message: "",
551
+ duration: 4500,
552
+ type: "",
553
+ showClose: true,
554
+ customClass: "",
555
+ iconClass: "",
556
+ onClose: null,
557
+ onClick: null,
558
+ onCancel: null,
559
+ onConfirm: null,
560
+ closed: false,
561
+ verticalOffset: 0,
562
+ timer: null,
563
+ dangerouslyUseHTMLString: false,
564
+ position: "top-right",
565
+ cancelButtonText: "",
566
+ confirmButtonText: ""
567
+ };
568
+ },
569
+ computed: {
570
+ typeClass() {
571
+ return this.type && typeMap$1[this.type] ? `el-icon-${typeMap$1[this.type]}` : "";
572
+ },
573
+ horizontalClass() {
574
+ return this.position.indexOf("right") > -1 ? "right" : "left";
575
+ },
576
+ verticalProperty() {
577
+ return /^top-/.test(this.position) ? "top" : "bottom";
578
+ },
579
+ positionStyle() {
580
+ return {
581
+ [this.verticalProperty]: `${this.verticalOffset}px`
582
+ };
583
+ }
584
+ },
585
+ watch: {
586
+ closed(newVal) {
587
+ if (newVal) {
588
+ this.visible = false;
589
+ this.$el.addEventListener("transitionend", this.destroyElement);
590
+ }
591
+ }
592
+ },
593
+ methods: {
594
+ destroyElement() {
595
+ this.$el.removeEventListener("transitionend", this.destroyElement);
596
+ this.$destroy(true);
597
+ this.$el.parentNode.removeChild(this.$el);
598
+ },
599
+ click() {
600
+ if (typeof this.onClick === "function") {
601
+ this.onClick();
602
+ }
603
+ },
604
+ handleCancel() {
605
+ if (typeof this.onCancel === "function") {
606
+ this.onCancel();
607
+ }
608
+ },
609
+ handleConfirm() {
610
+ if (typeof this.onConfirm === "function") {
611
+ this.onConfirm();
612
+ }
613
+ },
614
+ close() {
615
+ this.closed = true;
616
+ if (typeof this.onClose === "function") {
617
+ this.onClose();
618
+ }
619
+ },
620
+ clearTimer() {
621
+ clearTimeout(this.timer);
622
+ },
623
+ startTimer() {
624
+ if (this.duration > 0) {
625
+ this.timer = setTimeout(() => {
626
+ if (!this.closed) {
627
+ this.close();
628
+ }
629
+ }, this.duration);
630
+ }
631
+ },
632
+ keydown(e) {
633
+ if (e.keyCode === 46 || e.keyCode === 8) {
634
+ this.clearTimer();
635
+ } else if (e.keyCode === 27) {
636
+ if (!this.closed) {
637
+ this.close();
638
+ }
639
+ } else {
640
+ this.startTimer();
641
+ }
642
+ }
643
+ },
644
+ mounted() {
645
+ if (this.duration > 0) {
646
+ this.timer = setTimeout(() => {
647
+ if (!this.closed) {
648
+ this.close();
649
+ }
650
+ }, this.duration);
651
+ }
652
+ document.addEventListener("keydown", this.keydown);
653
+ },
654
+ beforeDestroy() {
655
+ document.removeEventListener("keydown", this.keydown);
656
+ }
657
+ });
658
+ var _sfc_render$1 = function render2() {
659
+ var _vm = this, _c = _vm._self._c;
660
+ _vm._self._setupProxy;
661
+ return _c("transition", {
662
+ attrs: {
663
+ "name": "el-notification-fade"
664
+ }
665
+ }, [_c("div", {
666
+ directives: [{
667
+ name: "show",
668
+ rawName: "v-show",
669
+ value: _vm.visible,
670
+ expression: "visible"
671
+ }],
672
+ class: ["nf-notification", _vm.customClass, _vm.horizontalClass],
673
+ style: _vm.positionStyle,
674
+ attrs: {
675
+ "role": "alert"
676
+ },
677
+ on: {
678
+ "mouseenter": function($event) {
679
+ return _vm.clearTimer();
680
+ },
681
+ "mouseleave": function($event) {
682
+ return _vm.startTimer();
683
+ },
684
+ "click": _vm.click
685
+ }
686
+ }, [_vm.type || _vm.iconClass ? _c("i", {
687
+ staticClass: "nf-notification__icon",
688
+ class: [_vm.typeClass, _vm.iconClass]
689
+ }) : _vm._e(), _c("div", {
690
+ staticClass: "nf-notification__group",
691
+ class: {
692
+ "is-with-icon": _vm.typeClass || _vm.iconClass
693
+ }
694
+ }, [_c("h2", {
695
+ staticClass: "nf-notification__title",
696
+ domProps: {
697
+ "textContent": _vm._s(_vm.title)
698
+ }
699
+ }), _c("div", {
700
+ directives: [{
701
+ name: "show",
702
+ rawName: "v-show",
703
+ value: _vm.message,
704
+ expression: "message"
705
+ }],
706
+ staticClass: "nf-notification__content"
707
+ }, [_vm._t("default", function() {
708
+ return [!_vm.dangerouslyUseHTMLString ? _c("p", [_vm._v(_vm._s(_vm.message))]) : _c("p", {
709
+ domProps: {
710
+ "innerHTML": _vm._s(_vm.message)
711
+ }
712
+ })];
713
+ })], 2), _vm.cancelButtonText || _vm.confirmButtonText ? _c("div", {
714
+ staticClass: "nf-notification__btns"
715
+ }, [_vm.cancelButtonText ? _c("nf-button", {
716
+ on: {
717
+ "click": function($event) {
718
+ $event.stopPropagation();
719
+ return _vm.handleCancel.apply(null, arguments);
720
+ }
721
+ }
722
+ }, [_vm._v(_vm._s(_vm.cancelButtonText))]) : _vm._e(), _vm.confirmButtonText ? _c("nf-button", {
723
+ attrs: {
724
+ "type": "primary"
725
+ },
726
+ on: {
727
+ "click": function($event) {
728
+ $event.stopPropagation();
729
+ return _vm.handleConfirm.apply(null, arguments);
730
+ }
731
+ }
732
+ }, [_vm._v(_vm._s(_vm.confirmButtonText))]) : _vm._e()], 1) : _vm._e(), _vm.showClose ? _c("div", {
733
+ staticClass: "nf-notification__closeBtn el-icon-close",
734
+ on: {
735
+ "click": function($event) {
736
+ $event.stopPropagation();
737
+ return _vm.close.apply(null, arguments);
738
+ }
739
+ }
740
+ }) : _vm._e()])])]);
741
+ };
742
+ var _sfc_staticRenderFns$1 = [];
743
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, null, null, null);
744
+ const Main$1 = __component__$1.exports;
745
+ const NotificationConstructor = Vue2.extend(Main$1);
746
+ let instance;
747
+ let instances = [];
748
+ let seed = 1;
749
+ const Notification = function(options) {
750
+ var _a;
751
+ if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
752
+ return;
753
+ options = merge({}, options);
754
+ const userOnClose = options.onClose;
755
+ const id = "notification_" + seed++;
756
+ const position = options.position || "top-right";
757
+ options.onClose = function() {
758
+ Notification.close(id, userOnClose);
759
+ };
760
+ instance = new NotificationConstructor({
761
+ data: options
762
+ });
763
+ if (isVNode(options.message)) {
764
+ instance.$slots.default = [options.message];
765
+ options.message = "REPLACED_BY_VNODE";
766
+ }
767
+ instance.id = id;
768
+ instance.$mount();
769
+ document.body.appendChild(instance.$el);
770
+ instance.visible = true;
771
+ instance.dom = instance.$el;
772
+ instance.dom.style.zIndex = PopupManager.nextZIndex() + 1e3;
773
+ let verticalOffset = options.offset || 0;
774
+ instances.filter((item) => item.position === position).forEach((item) => {
775
+ verticalOffset += item.$el.offsetHeight + 16;
776
+ });
777
+ verticalOffset += 16;
778
+ instance.verticalOffset = verticalOffset;
779
+ instances.push(instance);
780
+ return instance;
781
+ };
782
+ ["success", "warning", "info", "error"].forEach((type) => {
783
+ Notification[type] = (options) => {
784
+ if (typeof options === "string" || isVNode(options)) {
785
+ options = {
786
+ message: options
787
+ };
788
+ }
789
+ options.type = type;
790
+ return Notification(options);
791
+ };
792
+ });
793
+ Notification.close = function(id, userOnClose) {
794
+ let index = -1;
795
+ const len = instances.length;
796
+ const instance2 = instances.filter((instance3, i) => {
797
+ if (instance3.id === id) {
798
+ index = i;
799
+ return true;
800
+ }
801
+ return false;
802
+ })[0];
803
+ if (!instance2)
804
+ return;
805
+ if (typeof userOnClose === "function") {
806
+ userOnClose(instance2);
807
+ }
808
+ instances.splice(index, 1);
809
+ if (len <= 1)
810
+ return;
811
+ const position = instance2.position;
812
+ const removedHeight = instance2.dom.offsetHeight;
813
+ for (let i = index; i < len - 1; i++) {
814
+ if (instances[i].position === position) {
815
+ instances[i].dom.style[instance2.verticalProperty] = parseInt(instances[i].dom.style[instance2.verticalProperty], 10) - removedHeight - 16 + "px";
816
+ }
817
+ }
818
+ };
819
+ Notification.closeAll = function() {
820
+ for (let i = instances.length - 1; i >= 0; i--) {
821
+ instances[i].close();
822
+ }
823
+ };
824
+ const typeMap = {
825
+ success: "success",
826
+ info: "info",
827
+ warning: "warning",
828
+ error: "error"
829
+ };
830
+ const _sfc_main = defineComponent({
831
+ name: "nf-confirm",
832
+ data() {
833
+ return {
834
+ visible: false,
835
+ width: 400,
836
+ title: "",
837
+ message: "",
838
+ type: "",
839
+ customClass: "",
840
+ iconClass: "",
841
+ cancelButtonText: "取消",
842
+ confirmButtonText: "确定",
843
+ loading: false,
844
+ onCancel: null,
845
+ onConfirm: null,
846
+ callback: null,
847
+ dangerouslyUseHTMLString: false
848
+ };
849
+ },
850
+ computed: {
851
+ typeClass() {
852
+ return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
853
+ }
854
+ },
855
+ methods: {
856
+ close() {
857
+ this.loading = false;
858
+ this.visible = false;
859
+ this.$nextTick(() => {
860
+ this.$destroy(true);
861
+ this.$el.parentNode.removeChild(this.$el);
862
+ });
863
+ },
864
+ handleCancel() {
865
+ if (typeof this.onCancel === "function") {
866
+ this.onCancel(this.close);
867
+ } else {
868
+ this.close();
869
+ this.callback && this.callback("cancel");
870
+ }
871
+ },
872
+ handleConfirm() {
873
+ if (typeof this.onConfirm === "function") {
874
+ this.loading = true;
875
+ this.onConfirm(this.close);
876
+ } else {
877
+ this.loading = true;
878
+ this.callback && this.callback("confirm", this.close);
879
+ }
880
+ }
881
+ }
882
+ });
883
+ var _sfc_render = function render3() {
884
+ var _vm = this, _c = _vm._self._c;
885
+ _vm._self._setupProxy;
886
+ return _c("div", {
887
+ class: ["nf-confirm", _vm.customClass]
888
+ }, [_c("el-dialog", {
889
+ attrs: {
890
+ "visible": _vm.visible,
891
+ "showClose": false,
892
+ "width": `${_vm.width}px`,
893
+ "close-on-click-modal": false
894
+ },
895
+ on: {
896
+ "update:visible": function($event) {
897
+ _vm.visible = $event;
898
+ }
899
+ }
900
+ }, [_c("div", {
901
+ staticClass: "nf-confirm__wrapper"
902
+ }, [_vm.type || _vm.iconClass ? _c("i", {
903
+ staticClass: "nf-confirm__icon",
904
+ class: [_vm.typeClass, _vm.iconClass]
905
+ }) : _vm._e(), _c("div", {
906
+ staticClass: "nf-confirm__inner"
907
+ }, [_c("h2", {
908
+ staticClass: "nf-confirm__title"
909
+ }, [_vm._v(_vm._s(_vm.title))]), !_vm.dangerouslyUseHTMLString ? _c("p", {
910
+ staticClass: "nf-confirm__content"
911
+ }, [_vm._v(_vm._s(_vm.message))]) : _c("p", {
912
+ staticClass: "nf-confirm__content",
913
+ domProps: {
914
+ "innerHTML": _vm._s(_vm.message)
915
+ }
916
+ }), _c("div", {
917
+ staticClass: "nf-confirm__btns"
918
+ }, [_c("nf-button", {
919
+ on: {
920
+ "click": _vm.handleCancel
921
+ }
922
+ }, [_vm._v(_vm._s(_vm.cancelButtonText))]), _c("nf-button", {
923
+ attrs: {
924
+ "type": "primary",
925
+ "loading": _vm.loading
926
+ },
927
+ on: {
928
+ "click": _vm.handleConfirm
929
+ }
930
+ }, [_vm._v(_vm._s(_vm.confirmButtonText))])], 1)])])])], 1);
931
+ };
932
+ var _sfc_staticRenderFns = [];
933
+ var __component__ = /* @__PURE__ */ normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
934
+ const Main = __component__.exports;
935
+ const ConfirmConstructor = Vue2.extend(Main);
936
+ let currentMsg = null;
937
+ const Confirm = function(options) {
938
+ var _a;
939
+ if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
940
+ return;
941
+ options = merge({}, options);
942
+ const instance2 = new ConfirmConstructor({
943
+ data: options
944
+ });
945
+ instance2.callback = defaultCallBack;
946
+ instance2.$mount();
947
+ document.body.appendChild(instance2.$el);
948
+ instance2.visible = true;
949
+ return new Promise((resolve, reject) => {
950
+ currentMsg = { resolve, reject };
951
+ });
952
+ };
953
+ const defaultCallBack = (action, done) => {
954
+ if (action === "confirm") {
955
+ currentMsg.resolve(done);
956
+ } else {
957
+ currentMsg.reject();
958
+ }
959
+ };
82
960
  const CommonUI = defineComponent({
83
961
  name: "common-ui",
84
962
  install(app) {
@@ -129,6 +1007,8 @@ const CommonUI = defineComponent({
129
1007
  }
130
1008
  });
131
1009
  export {
1010
+ Confirm,
1011
+ Message,
132
1012
  default11 as NfAction,
133
1013
  default41 as NfAddressSelect,
134
1014
  default8 as NfAlert,
@@ -169,5 +1049,6 @@ export {
169
1049
  default40 as NfTransferSelect,
170
1050
  default36 as NfVariableSelect,
171
1051
  default9 as NfVirtualSelect,
1052
+ Notification,
172
1053
  CommonUI as default
173
1054
  };