@94ai/nf-notification 3.1.13
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/.eslintrc.cjs +49 -0
- package/README.md +15 -0
- package/components.d.ts +8 -0
- package/lib/index.d.ts +79 -0
- package/lib/main.d.ts +6 -0
- package/lib/nf-notification.cjs.js +537 -0
- package/lib/nf-notification.esm-bundler.js +537 -0
- package/lib/nf-notification.vue.d.ts +29 -0
- package/lib/style/css.d.ts +1 -0
- package/lib/style/css.js +1 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +1 -0
- package/package/index.ts +10 -0
- package/package/main.ts +94 -0
- package/package/nf-notification.vue +174 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package.json +34 -0
- package/postcss.config.js +8 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"plugin:vue/essential"
|
|
8
|
+
],
|
|
9
|
+
"parser": "vue-eslint-parser",
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"ecmaVersion": 2020,
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"rules": {
|
|
16
|
+
"@typescript-eslint/ban-ts-ignore": "off",
|
|
17
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
20
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
21
|
+
"vue/custom-event-name-casing": "off",
|
|
22
|
+
"no-use-before-define": "off",
|
|
23
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
24
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
25
|
+
"@typescript-eslint/ban-types": "off",
|
|
26
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
27
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
28
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
29
|
+
"vue/multi-word-component-names": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
"ignores": [
|
|
33
|
+
"index"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"no-console": "warn",
|
|
38
|
+
"no-debugger": "warn",
|
|
39
|
+
"prettier/prettier": [
|
|
40
|
+
"error",
|
|
41
|
+
{
|
|
42
|
+
"tabWidth": 2,
|
|
43
|
+
"singleQuote": true,
|
|
44
|
+
"semi": false,
|
|
45
|
+
"endOfLine": "auto"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@94ai/nf-notification`
|
|
2
|
+
|
|
3
|
+
通知提示组件
|
|
4
|
+
|
|
5
|
+
## HomePage
|
|
6
|
+
|
|
7
|
+
官网地址: https://oss.xccjh.top/common-ui/#/ai-index
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
const NfNotification = import('@94ai/nf-notification'); // or const NfMessage = require('@94ai/nf-notification');
|
|
13
|
+
|
|
14
|
+
Vue.use(NfNotification)
|
|
15
|
+
```
|
package/components.d.ts
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { PluginObject } from 'vue-demi';
|
|
2
|
+
declare const _default: import("vue/types/v3-component-public-instance").ComponentPublicInstanceConstructor<import("vue/types/v3-component-public-instance").Vue3Instance<{
|
|
3
|
+
visible: boolean;
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
duration: number;
|
|
7
|
+
type: string;
|
|
8
|
+
showClose: boolean;
|
|
9
|
+
customClass: string;
|
|
10
|
+
iconClass: string;
|
|
11
|
+
onClose: null;
|
|
12
|
+
onClick: null;
|
|
13
|
+
onCancel: null;
|
|
14
|
+
onConfirm: null;
|
|
15
|
+
closed: boolean;
|
|
16
|
+
verticalOffset: number;
|
|
17
|
+
timer: null;
|
|
18
|
+
dangerouslyUseHTMLString: boolean;
|
|
19
|
+
position: string;
|
|
20
|
+
cancelButtonText: string;
|
|
21
|
+
confirmButtonText: string;
|
|
22
|
+
}, Readonly<import("vue-demi").ExtractPropTypes<{}>>, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}, {}, true, import("vue/types/v3-component-options").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any>> & Readonly<Readonly<import("vue-demi").ExtractPropTypes<{}>>> & import("vue-demi").ShallowUnwrapRef<any> & {
|
|
23
|
+
visible: boolean;
|
|
24
|
+
title: string;
|
|
25
|
+
message: string;
|
|
26
|
+
duration: number;
|
|
27
|
+
type: string;
|
|
28
|
+
showClose: boolean;
|
|
29
|
+
customClass: string;
|
|
30
|
+
iconClass: string;
|
|
31
|
+
onClose: null;
|
|
32
|
+
onClick: null;
|
|
33
|
+
onCancel: null;
|
|
34
|
+
onConfirm: null;
|
|
35
|
+
closed: boolean;
|
|
36
|
+
verticalOffset: number;
|
|
37
|
+
timer: null;
|
|
38
|
+
dangerouslyUseHTMLString: boolean;
|
|
39
|
+
position: string;
|
|
40
|
+
cancelButtonText: string;
|
|
41
|
+
confirmButtonText: string;
|
|
42
|
+
} & import("vue/types/v3-component-options").ExtractComputedReturns<{
|
|
43
|
+
typeClass(): string;
|
|
44
|
+
horizontalClass(): "right" | "left";
|
|
45
|
+
verticalProperty(): "top" | "bottom";
|
|
46
|
+
positionStyle(): {
|
|
47
|
+
[x: string]: string;
|
|
48
|
+
};
|
|
49
|
+
}> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, {
|
|
50
|
+
visible: boolean;
|
|
51
|
+
title: string;
|
|
52
|
+
message: string;
|
|
53
|
+
duration: number;
|
|
54
|
+
type: string;
|
|
55
|
+
showClose: boolean;
|
|
56
|
+
customClass: string;
|
|
57
|
+
iconClass: string;
|
|
58
|
+
onClose: null;
|
|
59
|
+
onClick: null;
|
|
60
|
+
onCancel: null;
|
|
61
|
+
onConfirm: null;
|
|
62
|
+
closed: boolean;
|
|
63
|
+
verticalOffset: number;
|
|
64
|
+
timer: null;
|
|
65
|
+
dangerouslyUseHTMLString: boolean;
|
|
66
|
+
position: string;
|
|
67
|
+
cancelButtonText: string;
|
|
68
|
+
confirmButtonText: string;
|
|
69
|
+
}, {
|
|
70
|
+
typeClass(): string;
|
|
71
|
+
horizontalClass(): "right" | "left";
|
|
72
|
+
verticalProperty(): "top" | "bottom";
|
|
73
|
+
positionStyle(): {
|
|
74
|
+
[x: string]: string;
|
|
75
|
+
};
|
|
76
|
+
}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {}> & {
|
|
77
|
+
props: {};
|
|
78
|
+
} & PluginObject<undefined>;
|
|
79
|
+
export default _default;
|
package/lib/main.d.ts
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vueDemi = require("vue-demi");
|
|
4
|
+
const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
|
|
5
|
+
const Vue = require("vue");
|
|
6
|
+
const typeMap = {
|
|
7
|
+
success: "success",
|
|
8
|
+
info: "info",
|
|
9
|
+
warning: "warning",
|
|
10
|
+
error: "error"
|
|
11
|
+
};
|
|
12
|
+
const _sfc_main = vueDemi.defineComponent({
|
|
13
|
+
name: "nf-notification",
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
visible: false,
|
|
17
|
+
title: "",
|
|
18
|
+
message: "",
|
|
19
|
+
duration: 4500,
|
|
20
|
+
type: "",
|
|
21
|
+
showClose: true,
|
|
22
|
+
customClass: "",
|
|
23
|
+
iconClass: "",
|
|
24
|
+
onClose: null,
|
|
25
|
+
onClick: null,
|
|
26
|
+
onCancel: null,
|
|
27
|
+
onConfirm: null,
|
|
28
|
+
closed: false,
|
|
29
|
+
verticalOffset: 0,
|
|
30
|
+
timer: null,
|
|
31
|
+
dangerouslyUseHTMLString: false,
|
|
32
|
+
position: "top-right",
|
|
33
|
+
cancelButtonText: "",
|
|
34
|
+
confirmButtonText: ""
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
typeClass() {
|
|
39
|
+
return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
|
|
40
|
+
},
|
|
41
|
+
horizontalClass() {
|
|
42
|
+
return this.position.indexOf("right") > -1 ? "right" : "left";
|
|
43
|
+
},
|
|
44
|
+
verticalProperty() {
|
|
45
|
+
return /^top-/.test(this.position) ? "top" : "bottom";
|
|
46
|
+
},
|
|
47
|
+
positionStyle() {
|
|
48
|
+
return {
|
|
49
|
+
[this.verticalProperty]: `${this.verticalOffset}px`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
watch: {
|
|
54
|
+
closed(newVal) {
|
|
55
|
+
if (newVal) {
|
|
56
|
+
this.visible = false;
|
|
57
|
+
this.$el.addEventListener("transitionend", this.destroyElement);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
destroyElement() {
|
|
63
|
+
this.$el.removeEventListener("transitionend", this.destroyElement);
|
|
64
|
+
this.$destroy(true);
|
|
65
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
66
|
+
},
|
|
67
|
+
click() {
|
|
68
|
+
if (typeof this.onClick === "function") {
|
|
69
|
+
this.onClick();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
handleCancel() {
|
|
73
|
+
if (typeof this.onCancel === "function") {
|
|
74
|
+
this.onCancel();
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
handleConfirm() {
|
|
78
|
+
if (typeof this.onConfirm === "function") {
|
|
79
|
+
this.onConfirm();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
close() {
|
|
83
|
+
this.closed = true;
|
|
84
|
+
if (typeof this.onClose === "function") {
|
|
85
|
+
this.onClose();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
clearTimer() {
|
|
89
|
+
clearTimeout(this.timer);
|
|
90
|
+
},
|
|
91
|
+
startTimer() {
|
|
92
|
+
if (this.duration > 0) {
|
|
93
|
+
this.timer = setTimeout(() => {
|
|
94
|
+
if (!this.closed) {
|
|
95
|
+
this.close();
|
|
96
|
+
}
|
|
97
|
+
}, this.duration);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
keydown(e) {
|
|
101
|
+
if (e.keyCode === 46 || e.keyCode === 8) {
|
|
102
|
+
this.clearTimer();
|
|
103
|
+
} else if (e.keyCode === 27) {
|
|
104
|
+
if (!this.closed) {
|
|
105
|
+
this.close();
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
this.startTimer();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
mounted() {
|
|
113
|
+
if (this.duration > 0) {
|
|
114
|
+
this.timer = setTimeout(() => {
|
|
115
|
+
if (!this.closed) {
|
|
116
|
+
this.close();
|
|
117
|
+
}
|
|
118
|
+
}, this.duration);
|
|
119
|
+
}
|
|
120
|
+
document.addEventListener("keydown", this.keydown);
|
|
121
|
+
},
|
|
122
|
+
beforeDestroy() {
|
|
123
|
+
document.removeEventListener("keydown", this.keydown);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
var _sfc_render = function render() {
|
|
127
|
+
var _vm = this, _c = _vm._self._c;
|
|
128
|
+
_vm._self._setupProxy;
|
|
129
|
+
return _c("transition", {
|
|
130
|
+
attrs: {
|
|
131
|
+
"name": "el-notification-fade"
|
|
132
|
+
}
|
|
133
|
+
}, [_c("div", {
|
|
134
|
+
directives: [{
|
|
135
|
+
name: "show",
|
|
136
|
+
rawName: "v-show",
|
|
137
|
+
value: _vm.visible,
|
|
138
|
+
expression: "visible"
|
|
139
|
+
}],
|
|
140
|
+
class: ["nf-notification", _vm.customClass, _vm.horizontalClass],
|
|
141
|
+
style: _vm.positionStyle,
|
|
142
|
+
attrs: {
|
|
143
|
+
"role": "alert"
|
|
144
|
+
},
|
|
145
|
+
on: {
|
|
146
|
+
"mouseenter": function($event) {
|
|
147
|
+
return _vm.clearTimer();
|
|
148
|
+
},
|
|
149
|
+
"mouseleave": function($event) {
|
|
150
|
+
return _vm.startTimer();
|
|
151
|
+
},
|
|
152
|
+
"click": _vm.click
|
|
153
|
+
}
|
|
154
|
+
}, [_vm.type || _vm.iconClass ? _c("i", {
|
|
155
|
+
staticClass: "nf-notification__icon",
|
|
156
|
+
class: [_vm.typeClass, _vm.iconClass]
|
|
157
|
+
}) : _vm._e(), _c("div", {
|
|
158
|
+
staticClass: "nf-notification__group",
|
|
159
|
+
class: {
|
|
160
|
+
"is-with-icon": _vm.typeClass || _vm.iconClass
|
|
161
|
+
}
|
|
162
|
+
}, [_c("h2", {
|
|
163
|
+
staticClass: "nf-notification__title",
|
|
164
|
+
domProps: {
|
|
165
|
+
"textContent": _vm._s(_vm.title)
|
|
166
|
+
}
|
|
167
|
+
}), _c("div", {
|
|
168
|
+
directives: [{
|
|
169
|
+
name: "show",
|
|
170
|
+
rawName: "v-show",
|
|
171
|
+
value: _vm.message,
|
|
172
|
+
expression: "message"
|
|
173
|
+
}],
|
|
174
|
+
staticClass: "nf-notification__content"
|
|
175
|
+
}, [_vm._t("default", function() {
|
|
176
|
+
return [!_vm.dangerouslyUseHTMLString ? _c("p", [_vm._v(_vm._s(_vm.message))]) : _c("p", {
|
|
177
|
+
domProps: {
|
|
178
|
+
"innerHTML": _vm._s(_vm.message)
|
|
179
|
+
}
|
|
180
|
+
})];
|
|
181
|
+
})], 2), _vm.cancelButtonText || _vm.confirmButtonText ? _c("div", {
|
|
182
|
+
staticClass: "nf-notification__btns"
|
|
183
|
+
}, [_vm.cancelButtonText ? _c("nf-button", {
|
|
184
|
+
on: {
|
|
185
|
+
"click": function($event) {
|
|
186
|
+
$event.stopPropagation();
|
|
187
|
+
return _vm.handleCancel.apply(null, arguments);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, [_vm._v(_vm._s(_vm.cancelButtonText))]) : _vm._e(), _vm.confirmButtonText ? _c("nf-button", {
|
|
191
|
+
attrs: {
|
|
192
|
+
"type": "primary"
|
|
193
|
+
},
|
|
194
|
+
on: {
|
|
195
|
+
"click": function($event) {
|
|
196
|
+
$event.stopPropagation();
|
|
197
|
+
return _vm.handleConfirm.apply(null, arguments);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, [_vm._v(_vm._s(_vm.confirmButtonText))]) : _vm._e()], 1) : _vm._e(), _vm.showClose ? _c("div", {
|
|
201
|
+
staticClass: "nf-notification__closeBtn el-icon-close",
|
|
202
|
+
on: {
|
|
203
|
+
"click": function($event) {
|
|
204
|
+
$event.stopPropagation();
|
|
205
|
+
return _vm.close.apply(null, arguments);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}) : _vm._e()])])]);
|
|
209
|
+
};
|
|
210
|
+
var _sfc_staticRenderFns = [];
|
|
211
|
+
var __component__ = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
212
|
+
const NfNotification = __component__.exports;
|
|
213
|
+
function merge(target) {
|
|
214
|
+
for (let i = 1, j = arguments.length; i < j; i++) {
|
|
215
|
+
let source = arguments[i] || {};
|
|
216
|
+
for (let prop in source) {
|
|
217
|
+
if (source.hasOwnProperty(prop)) {
|
|
218
|
+
let value = source[prop];
|
|
219
|
+
if (value !== void 0) {
|
|
220
|
+
target[prop] = value;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return target;
|
|
226
|
+
}
|
|
227
|
+
Vue.prototype.$isServer;
|
|
228
|
+
const trim = function(string) {
|
|
229
|
+
return (string || "").replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
|
|
230
|
+
};
|
|
231
|
+
function hasClass(el, cls) {
|
|
232
|
+
if (!el || !cls)
|
|
233
|
+
return false;
|
|
234
|
+
if (cls.indexOf(" ") !== -1)
|
|
235
|
+
throw new Error("className should not contain space.");
|
|
236
|
+
if (el.classList) {
|
|
237
|
+
return el.classList.contains(cls);
|
|
238
|
+
} else {
|
|
239
|
+
return (" " + el.className + " ").indexOf(" " + cls + " ") > -1;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function addClass(el, cls) {
|
|
243
|
+
if (!el)
|
|
244
|
+
return;
|
|
245
|
+
var curClass = el.className;
|
|
246
|
+
var classes = (cls || "").split(" ");
|
|
247
|
+
for (var i = 0, j = classes.length; i < j; i++) {
|
|
248
|
+
var clsName = classes[i];
|
|
249
|
+
if (!clsName)
|
|
250
|
+
continue;
|
|
251
|
+
if (el.classList) {
|
|
252
|
+
el.classList.add(clsName);
|
|
253
|
+
} else if (!hasClass(el, clsName)) {
|
|
254
|
+
curClass += " " + clsName;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (!el.classList) {
|
|
258
|
+
el.className = curClass;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function removeClass(el, cls) {
|
|
262
|
+
if (!el || !cls)
|
|
263
|
+
return;
|
|
264
|
+
var classes = cls.split(" ");
|
|
265
|
+
var curClass = " " + el.className + " ";
|
|
266
|
+
for (var i = 0, j = classes.length; i < j; i++) {
|
|
267
|
+
var clsName = classes[i];
|
|
268
|
+
if (!clsName)
|
|
269
|
+
continue;
|
|
270
|
+
if (el.classList) {
|
|
271
|
+
el.classList.remove(clsName);
|
|
272
|
+
} else if (hasClass(el, clsName)) {
|
|
273
|
+
curClass = curClass.replace(" " + clsName + " ", " ");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (!el.classList) {
|
|
277
|
+
el.className = trim(curClass);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
let hasModal = false;
|
|
281
|
+
let hasInitZIndex = false;
|
|
282
|
+
let zIndex;
|
|
283
|
+
const getModal = function() {
|
|
284
|
+
if (Vue.prototype.$isServer)
|
|
285
|
+
return;
|
|
286
|
+
let modalDom = PopupManager.modalDom;
|
|
287
|
+
if (modalDom) {
|
|
288
|
+
hasModal = true;
|
|
289
|
+
} else {
|
|
290
|
+
hasModal = false;
|
|
291
|
+
modalDom = document.createElement("div");
|
|
292
|
+
PopupManager.modalDom = modalDom;
|
|
293
|
+
modalDom.addEventListener("touchmove", function(event) {
|
|
294
|
+
event.preventDefault();
|
|
295
|
+
event.stopPropagation();
|
|
296
|
+
});
|
|
297
|
+
modalDom.addEventListener("click", function() {
|
|
298
|
+
PopupManager.doOnModalClick && PopupManager.doOnModalClick();
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return modalDom;
|
|
302
|
+
};
|
|
303
|
+
const instances$1 = {};
|
|
304
|
+
const PopupManager = {
|
|
305
|
+
modalFade: true,
|
|
306
|
+
getInstance: function(id) {
|
|
307
|
+
return instances$1[id];
|
|
308
|
+
},
|
|
309
|
+
register: function(id, instance2) {
|
|
310
|
+
if (id && instance2) {
|
|
311
|
+
instances$1[id] = instance2;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
deregister: function(id) {
|
|
315
|
+
if (id) {
|
|
316
|
+
instances$1[id] = null;
|
|
317
|
+
delete instances$1[id];
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
nextZIndex: function() {
|
|
321
|
+
return PopupManager.zIndex++;
|
|
322
|
+
},
|
|
323
|
+
modalStack: [],
|
|
324
|
+
doOnModalClick: function() {
|
|
325
|
+
const topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1];
|
|
326
|
+
if (!topItem)
|
|
327
|
+
return;
|
|
328
|
+
const instance2 = PopupManager.getInstance(topItem.id);
|
|
329
|
+
if (instance2 && instance2.closeOnClickModal) {
|
|
330
|
+
instance2.close();
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
openModal: function(id, zIndex2, dom, modalClass, modalFade) {
|
|
334
|
+
if (Vue.prototype.$isServer)
|
|
335
|
+
return;
|
|
336
|
+
if (!id || zIndex2 === void 0)
|
|
337
|
+
return;
|
|
338
|
+
this.modalFade = modalFade;
|
|
339
|
+
const modalStack = this.modalStack;
|
|
340
|
+
for (let i = 0, j = modalStack.length; i < j; i++) {
|
|
341
|
+
const item = modalStack[i];
|
|
342
|
+
if (item.id === id) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const modalDom = getModal();
|
|
347
|
+
addClass(modalDom, "v-modal");
|
|
348
|
+
if (this.modalFade && !hasModal) {
|
|
349
|
+
addClass(modalDom, "v-modal-enter");
|
|
350
|
+
}
|
|
351
|
+
if (modalClass) {
|
|
352
|
+
let classArr = modalClass.trim().split(/\s+/);
|
|
353
|
+
classArr.forEach((item) => addClass(modalDom, item));
|
|
354
|
+
}
|
|
355
|
+
setTimeout(() => {
|
|
356
|
+
removeClass(modalDom, "v-modal-enter");
|
|
357
|
+
}, 200);
|
|
358
|
+
if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
|
|
359
|
+
dom.parentNode.appendChild(modalDom);
|
|
360
|
+
} else {
|
|
361
|
+
document.body.appendChild(modalDom);
|
|
362
|
+
}
|
|
363
|
+
if (zIndex2) {
|
|
364
|
+
modalDom.style.zIndex = zIndex2;
|
|
365
|
+
}
|
|
366
|
+
modalDom.tabIndex = 0;
|
|
367
|
+
modalDom.style.display = "";
|
|
368
|
+
this.modalStack.push({
|
|
369
|
+
id,
|
|
370
|
+
zIndex: zIndex2,
|
|
371
|
+
modalClass
|
|
372
|
+
});
|
|
373
|
+
},
|
|
374
|
+
closeModal: function(id) {
|
|
375
|
+
const modalStack = this.modalStack;
|
|
376
|
+
const modalDom = getModal();
|
|
377
|
+
if (modalStack.length > 0) {
|
|
378
|
+
const topItem = modalStack[modalStack.length - 1];
|
|
379
|
+
if (topItem.id === id) {
|
|
380
|
+
if (topItem.modalClass) {
|
|
381
|
+
let classArr = topItem.modalClass.trim().split(/\s+/);
|
|
382
|
+
classArr.forEach((item) => removeClass(modalDom, item));
|
|
383
|
+
}
|
|
384
|
+
modalStack.pop();
|
|
385
|
+
if (modalStack.length > 0) {
|
|
386
|
+
modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex;
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
for (let i = modalStack.length - 1; i >= 0; i--) {
|
|
390
|
+
if (modalStack[i].id === id) {
|
|
391
|
+
modalStack.splice(i, 1);
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (modalStack.length === 0) {
|
|
398
|
+
if (this.modalFade) {
|
|
399
|
+
addClass(modalDom, "v-modal-leave");
|
|
400
|
+
}
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
if (modalStack.length === 0) {
|
|
403
|
+
if (modalDom.parentNode)
|
|
404
|
+
modalDom.parentNode.removeChild(modalDom);
|
|
405
|
+
modalDom.style.display = "none";
|
|
406
|
+
PopupManager.modalDom = void 0;
|
|
407
|
+
}
|
|
408
|
+
removeClass(modalDom, "v-modal-leave");
|
|
409
|
+
}, 200);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
Object.defineProperty(PopupManager, "zIndex", {
|
|
414
|
+
configurable: true,
|
|
415
|
+
get() {
|
|
416
|
+
if (!hasInitZIndex) {
|
|
417
|
+
zIndex = zIndex || (Vue.prototype.$ELEMENT || {}).zIndex || 2e3;
|
|
418
|
+
hasInitZIndex = true;
|
|
419
|
+
}
|
|
420
|
+
return zIndex;
|
|
421
|
+
},
|
|
422
|
+
set(value) {
|
|
423
|
+
zIndex = value;
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
const getTopPopup = function() {
|
|
427
|
+
if (Vue.prototype.$isServer)
|
|
428
|
+
return;
|
|
429
|
+
if (PopupManager.modalStack.length > 0) {
|
|
430
|
+
const topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1];
|
|
431
|
+
if (!topPopup)
|
|
432
|
+
return;
|
|
433
|
+
const instance2 = PopupManager.getInstance(topPopup.id);
|
|
434
|
+
return instance2;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
if (!Vue.prototype.$isServer) {
|
|
438
|
+
window.addEventListener("keydown", function(event) {
|
|
439
|
+
if (event.keyCode === 27) {
|
|
440
|
+
const topPopup = getTopPopup();
|
|
441
|
+
if (topPopup && topPopup.closeOnPressEscape) {
|
|
442
|
+
topPopup.handleClose ? topPopup.handleClose() : topPopup.handleAction ? topPopup.handleAction("cancel") : topPopup.close();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
448
|
+
function hasOwn(obj, key) {
|
|
449
|
+
return hasOwnProperty.call(obj, key);
|
|
450
|
+
}
|
|
451
|
+
function isVNode(node) {
|
|
452
|
+
return node !== null && typeof node === "object" && hasOwn(node, "componentOptions");
|
|
453
|
+
}
|
|
454
|
+
const NotificationConstructor = vueDemi.Vue2.extend(NfNotification);
|
|
455
|
+
let instance;
|
|
456
|
+
let instances = [];
|
|
457
|
+
let seed = 1;
|
|
458
|
+
const Notification = function(options) {
|
|
459
|
+
var _a;
|
|
460
|
+
if ((_a = vueDemi.Vue2.prototype) == null ? void 0 : _a.$isServer)
|
|
461
|
+
return;
|
|
462
|
+
options = merge({}, options);
|
|
463
|
+
const userOnClose = options.onClose;
|
|
464
|
+
const id = "notification_" + seed++;
|
|
465
|
+
const position = options.position || "top-right";
|
|
466
|
+
options.onClose = function() {
|
|
467
|
+
Notification.close(id, userOnClose);
|
|
468
|
+
};
|
|
469
|
+
instance = new NotificationConstructor({
|
|
470
|
+
data: options
|
|
471
|
+
});
|
|
472
|
+
if (isVNode(options.message)) {
|
|
473
|
+
instance.$slots.default = [options.message];
|
|
474
|
+
options.message = "REPLACED_BY_VNODE";
|
|
475
|
+
}
|
|
476
|
+
instance.id = id;
|
|
477
|
+
instance.$mount();
|
|
478
|
+
document.body.appendChild(instance.$el);
|
|
479
|
+
instance.visible = true;
|
|
480
|
+
instance.dom = instance.$el;
|
|
481
|
+
instance.dom.style.zIndex = PopupManager.nextZIndex() + 1e3;
|
|
482
|
+
let verticalOffset = options.offset || 0;
|
|
483
|
+
instances.filter((item) => item.position === position).forEach((item) => {
|
|
484
|
+
verticalOffset += item.$el.offsetHeight + 16;
|
|
485
|
+
});
|
|
486
|
+
verticalOffset += 16;
|
|
487
|
+
instance.verticalOffset = verticalOffset;
|
|
488
|
+
instances.push(instance);
|
|
489
|
+
return instance;
|
|
490
|
+
};
|
|
491
|
+
["success", "warning", "info", "error"].forEach((type) => {
|
|
492
|
+
Notification[type] = (options) => {
|
|
493
|
+
if (typeof options === "string" || isVNode(options)) {
|
|
494
|
+
options = {
|
|
495
|
+
message: options
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
options.type = type;
|
|
499
|
+
return Notification(options);
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
Notification.close = function(id, userOnClose) {
|
|
503
|
+
let index = -1;
|
|
504
|
+
const len = instances.length;
|
|
505
|
+
const instance2 = instances.filter((instance3, i) => {
|
|
506
|
+
if (instance3.id === id) {
|
|
507
|
+
index = i;
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
return false;
|
|
511
|
+
})[0];
|
|
512
|
+
if (!instance2)
|
|
513
|
+
return;
|
|
514
|
+
if (typeof userOnClose === "function") {
|
|
515
|
+
userOnClose(instance2);
|
|
516
|
+
}
|
|
517
|
+
instances.splice(index, 1);
|
|
518
|
+
if (len <= 1)
|
|
519
|
+
return;
|
|
520
|
+
const position = instance2.position;
|
|
521
|
+
const removedHeight = instance2.dom.offsetHeight;
|
|
522
|
+
for (let i = index; i < len - 1; i++) {
|
|
523
|
+
if (instances[i].position === position) {
|
|
524
|
+
instances[i].dom.style[instance2.verticalProperty] = parseInt(instances[i].dom.style[instance2.verticalProperty], 10) - removedHeight - 16 + "px";
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
Notification.closeAll = function() {
|
|
529
|
+
for (let i = instances.length - 1; i >= 0; i--) {
|
|
530
|
+
instances[i].close();
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
NfNotification.install = (app) => {
|
|
534
|
+
app.component("nf-notification", NfNotification);
|
|
535
|
+
app.prototype.$openNotify = Notification;
|
|
536
|
+
};
|
|
537
|
+
exports.default = NfNotification;
|