@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
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition name="el-notification-fade">
|
|
3
|
+
<div
|
|
4
|
+
:class="['nf-notification', customClass, horizontalClass]"
|
|
5
|
+
v-show="visible"
|
|
6
|
+
:style="positionStyle"
|
|
7
|
+
@mouseenter="clearTimer()"
|
|
8
|
+
@mouseleave="startTimer()"
|
|
9
|
+
@click="click"
|
|
10
|
+
role="alert"
|
|
11
|
+
>
|
|
12
|
+
<i
|
|
13
|
+
class="nf-notification__icon"
|
|
14
|
+
:class="[ typeClass, iconClass ]"
|
|
15
|
+
v-if="type || iconClass">
|
|
16
|
+
</i>
|
|
17
|
+
<div class="nf-notification__group" :class="{ 'is-with-icon': typeClass || iconClass }">
|
|
18
|
+
<h2 class="nf-notification__title" v-text="title"></h2>
|
|
19
|
+
<div class="nf-notification__content" v-show="message">
|
|
20
|
+
<slot>
|
|
21
|
+
<p v-if="!dangerouslyUseHTMLString">{{ message }}</p>
|
|
22
|
+
<p v-else v-html="message"></p>
|
|
23
|
+
</slot>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="nf-notification__btns" v-if="cancelButtonText || confirmButtonText">
|
|
26
|
+
<nf-button @click.stop="handleCancel" v-if="cancelButtonText">{{ cancelButtonText }}</nf-button>
|
|
27
|
+
<nf-button type="primary" @click.stop="handleConfirm" v-if="confirmButtonText">{{ confirmButtonText }}</nf-button>
|
|
28
|
+
</div>
|
|
29
|
+
<div
|
|
30
|
+
class="nf-notification__closeBtn el-icon-close"
|
|
31
|
+
v-if="showClose"
|
|
32
|
+
@click.stop="close"></div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</transition>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
import { defineComponent } from 'vue-demi'
|
|
40
|
+
|
|
41
|
+
const typeMap = {
|
|
42
|
+
success: 'success',
|
|
43
|
+
info: 'info',
|
|
44
|
+
warning: 'warning',
|
|
45
|
+
error: 'error'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default defineComponent({
|
|
49
|
+
name: "nf-notification",
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
visible: false,
|
|
53
|
+
title: '',
|
|
54
|
+
message: '',
|
|
55
|
+
duration: 4500,
|
|
56
|
+
type: '',
|
|
57
|
+
showClose: true,
|
|
58
|
+
customClass: '',
|
|
59
|
+
iconClass: '',
|
|
60
|
+
onClose: null,
|
|
61
|
+
onClick: null,
|
|
62
|
+
onCancel: null,
|
|
63
|
+
onConfirm: null,
|
|
64
|
+
closed: false,
|
|
65
|
+
verticalOffset: 0,
|
|
66
|
+
timer: null,
|
|
67
|
+
dangerouslyUseHTMLString: false,
|
|
68
|
+
position: 'top-right',
|
|
69
|
+
cancelButtonText: '',
|
|
70
|
+
confirmButtonText: ''
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
computed: {
|
|
75
|
+
typeClass() {
|
|
76
|
+
return this.type && typeMap[this.type] ? `el-icon-${ typeMap[this.type] }` : '';
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
horizontalClass() {
|
|
80
|
+
return this.position.indexOf('right') > -1 ? 'right' : 'left';
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
verticalProperty() {
|
|
84
|
+
return /^top-/.test(this.position) ? 'top' : 'bottom';
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
positionStyle() {
|
|
88
|
+
return {
|
|
89
|
+
[this.verticalProperty]: `${ this.verticalOffset }px`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
watch: {
|
|
95
|
+
closed(newVal) {
|
|
96
|
+
if (newVal) {
|
|
97
|
+
this.visible = false;
|
|
98
|
+
this.$el.addEventListener('transitionend', this.destroyElement);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
methods: {
|
|
104
|
+
destroyElement() {
|
|
105
|
+
this.$el.removeEventListener('transitionend', this.destroyElement);
|
|
106
|
+
this.$destroy(true);
|
|
107
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
click() {
|
|
111
|
+
if (typeof this.onClick === 'function') {
|
|
112
|
+
this.onClick();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
handleCancel() {
|
|
117
|
+
if (typeof this.onCancel === 'function') {
|
|
118
|
+
this.onCancel();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
handleConfirm() {
|
|
123
|
+
if (typeof this.onConfirm === 'function') {
|
|
124
|
+
this.onConfirm();
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
close() {
|
|
129
|
+
this.closed = true;
|
|
130
|
+
if (typeof this.onClose === 'function') {
|
|
131
|
+
this.onClose();
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
clearTimer() {
|
|
136
|
+
clearTimeout(this.timer);
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
startTimer() {
|
|
140
|
+
if (this.duration > 0) {
|
|
141
|
+
this.timer = setTimeout(() => {
|
|
142
|
+
if (!this.closed) {
|
|
143
|
+
this.close();
|
|
144
|
+
}
|
|
145
|
+
}, this.duration);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
keydown(e) {
|
|
149
|
+
if (e.keyCode === 46 || e.keyCode === 8) {
|
|
150
|
+
this.clearTimer(); // detele 取消倒计时
|
|
151
|
+
} else if (e.keyCode === 27) { // esc关闭消息
|
|
152
|
+
if (!this.closed) {
|
|
153
|
+
this.close();
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
this.startTimer(); // 恢复倒计时
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
mounted() {
|
|
161
|
+
if (this.duration > 0) {
|
|
162
|
+
this.timer = setTimeout(() => {
|
|
163
|
+
if (!this.closed) {
|
|
164
|
+
this.close();
|
|
165
|
+
}
|
|
166
|
+
}, this.duration);
|
|
167
|
+
}
|
|
168
|
+
document.addEventListener('keydown', this.keydown);
|
|
169
|
+
},
|
|
170
|
+
beforeDestroy() {
|
|
171
|
+
document.removeEventListener('keydown', this.keydown);
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-notification.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-notification.scss'
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@94ai/nf-notification",
|
|
3
|
+
"version": "3.1.13",
|
|
4
|
+
"description": "> TODO: description",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "zhongzhenjie <1476686104@qq.com>",
|
|
7
|
+
"homepage": "https://oss.xccjh.top/common-ui/#/ai-index",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@94ai/nf-theme-chalk": "^3.1.13",
|
|
18
|
+
"vue-demi": "^0.14.5"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"@vue/composition-api": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@vue/composition-api": "^1.0.0-rc.1",
|
|
27
|
+
"element-ui": ">=2.13.2",
|
|
28
|
+
"vue": "^2.0.0 || >=3.0.0"
|
|
29
|
+
},
|
|
30
|
+
"types": "lib/index.d.ts",
|
|
31
|
+
"main": "lib/nf-notification.cjs.js",
|
|
32
|
+
"module": "lib/nf-notification.esm-bundler.js",
|
|
33
|
+
"gitHead": "a8c56183ccc8e979008e2d38bfde2d7d1448654c"
|
|
34
|
+
}
|