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