@v-c/notification 2.0.0 → 2.0.2
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/dist/NotificationList/index.d.ts +1 -1
- package/dist/NotificationList/index.js +7 -6
- package/dist/Notifications.js +1 -1
- package/package.json +12 -2
- package/bump.config.ts +0 -6
- package/docs/context.vue +0 -34
- package/docs/hooks.vue +0 -89
- package/docs/index.less +0 -265
- package/docs/maxCount.vue +0 -24
- package/docs/motion.ts +0 -33
- package/docs/notification.stories.vue +0 -31
- package/docs/showProgress.vue +0 -34
- package/docs/stack.vue +0 -39
- package/src/Notification.tsx +0 -326
- package/src/NotificationList/Content.tsx +0 -76
- package/src/NotificationList/index.tsx +0 -322
- package/src/NotificationProvider.tsx +0 -19
- package/src/Notifications.tsx +0 -153
- package/src/Progress.tsx +0 -27
- package/src/hooks/useClosable.ts +0 -53
- package/src/hooks/useListPosition/index.ts +0 -69
- package/src/hooks/useListPosition/useSizes.ts +0 -43
- package/src/hooks/useNoticeTimer.ts +0 -85
- package/src/hooks/useNotification.tsx +0 -181
- package/src/hooks/useStack.ts +0 -36
- package/src/index.ts +0 -50
- package/src/interface.ts +0 -45
- package/tests/notification.test.tsx +0 -70
- package/tsconfig.json +0 -7
- package/vite.config.ts +0 -19
- package/vitest.config.ts +0 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, TransitionGroupProps } from 'vue';
|
|
2
2
|
import { Key, StackConfig } from '../interface';
|
|
3
|
-
import { ComponentsType, NotificationClassNames as NoticeClassNames,
|
|
3
|
+
import { ComponentsType, NotificationClassNames as NoticeClassNames, NotificationStyles as NoticeStyles, NotificationProps } from '../Notification';
|
|
4
4
|
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
|
|
5
5
|
export type { StackConfig };
|
|
6
6
|
export interface NotificationListConfig extends Omit<NotificationProps, 'prefixCls'> {
|
|
@@ -5,6 +5,7 @@ import useStack from "../hooks/useStack.js";
|
|
|
5
5
|
import Content from "./Content.js";
|
|
6
6
|
import { TransitionGroup, computed, createVNode, defineComponent, isVNode, mergeProps, ref, shallowRef, toRef, watch, watchEffect } from "vue";
|
|
7
7
|
import { clsx } from "@v-c/util";
|
|
8
|
+
import { createElementRef } from "@v-c/util/dist/vnode";
|
|
8
9
|
import { unrefElement } from "@v-c/util/dist/vueuse/unref-element";
|
|
9
10
|
//#region src/NotificationList/index.tsx
|
|
10
11
|
/**
|
|
@@ -17,6 +18,9 @@ import { unrefElement } from "@v-c/util/dist/vueuse/unref-element";
|
|
|
17
18
|
* on leave without animating. Wire each phase to the correct rc-motion
|
|
18
19
|
* suffix so the opacity/transform transition runs.
|
|
19
20
|
*/
|
|
21
|
+
function _isSlot(s) {
|
|
22
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
23
|
+
}
|
|
20
24
|
function buildMotionGroupProps(name, override) {
|
|
21
25
|
return {
|
|
22
26
|
name,
|
|
@@ -31,9 +35,6 @@ function buildMotionGroupProps(name, override) {
|
|
|
31
35
|
...override
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
|
-
function _isSlot(s) {
|
|
35
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
36
|
-
}
|
|
37
38
|
var noticeSlotKeys = [
|
|
38
39
|
"wrapper",
|
|
39
40
|
"root",
|
|
@@ -120,9 +121,9 @@ var NotificationList = /* @__PURE__ */ defineComponent((props, { attrs }) => {
|
|
|
120
121
|
const notificationIndex = getIndex(keys.value, key);
|
|
121
122
|
const stackInThreshold = stackEnabled.value && notificationIndex !== void 0 && notificationIndex < (stackParams.threshold?.value ?? 0);
|
|
122
123
|
return createVNode(Notification, mergeProps({ "key": strKey }, notificationConfig, {
|
|
123
|
-
"ref": (
|
|
124
|
-
setNodeSize(strKey,
|
|
125
|
-
},
|
|
124
|
+
"ref": createElementRef((node) => {
|
|
125
|
+
setNodeSize(strKey, node ?? null);
|
|
126
|
+
}, (el) => unrefElement(el?.nativeElement) ?? null),
|
|
126
127
|
"prefixCls": prefixCls,
|
|
127
128
|
"class": clsx(ctx.value?.classNames?.notice, configClassName),
|
|
128
129
|
"style": configStyle,
|
package/dist/Notifications.js
CHANGED
|
@@ -89,7 +89,7 @@ var Notifications = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
89
89
|
})) ? _slot : { default: () => [_slot] });
|
|
90
90
|
};
|
|
91
91
|
}, {
|
|
92
|
-
props:
|
|
92
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
93
93
|
prefixCls: {
|
|
94
94
|
type: String,
|
|
95
95
|
required: false,
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/notification",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/antdv-next/vue-components/tree/next/packages/notification",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/antdv-next/vue-components.git"
|
|
10
|
+
},
|
|
5
11
|
"publishConfig": {
|
|
6
12
|
"access": "public"
|
|
7
13
|
},
|
|
@@ -15,11 +21,15 @@
|
|
|
15
21
|
"./package.json": "./package.json"
|
|
16
22
|
},
|
|
17
23
|
"main": "./dist/index.js",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
18
28
|
"peerDependencies": {
|
|
19
29
|
"vue": "^3.0.0"
|
|
20
30
|
},
|
|
21
31
|
"dependencies": {
|
|
22
|
-
"@v-c/util": "^1.0.
|
|
32
|
+
"@v-c/util": "^1.0.20"
|
|
23
33
|
},
|
|
24
34
|
"scripts": {
|
|
25
35
|
"build": "vite build",
|
package/bump.config.ts
DELETED
package/docs/context.vue
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { h } from 'vue'
|
|
3
|
-
import { useNotification } from '../src'
|
|
4
|
-
import motion from './motion'
|
|
5
|
-
|
|
6
|
-
const [{ open }, holder] = useNotification({ motion })
|
|
7
|
-
const NOTICE = {
|
|
8
|
-
content: h('span', ['simple show']),
|
|
9
|
-
onclose() {
|
|
10
|
-
console.log('simple close')
|
|
11
|
-
},
|
|
12
|
-
}
|
|
13
|
-
function handleClick() {
|
|
14
|
-
open({
|
|
15
|
-
...NOTICE,
|
|
16
|
-
props: {
|
|
17
|
-
'data-testid': 'my-data-testid',
|
|
18
|
-
},
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<template>
|
|
24
|
-
<div>
|
|
25
|
-
<button @click="handleClick">
|
|
26
|
-
simple show
|
|
27
|
-
</button>
|
|
28
|
-
<holder />
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<style lang="less">
|
|
33
|
-
@import "./index.less";
|
|
34
|
-
</style>
|
package/docs/hooks.vue
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useNotification } from '../src'
|
|
3
|
-
import motion from './motion'
|
|
4
|
-
|
|
5
|
-
const [notice, contextHolder] = useNotification({ motion, closable: true })
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<template>
|
|
9
|
-
<div>
|
|
10
|
-
<!-- Default -->
|
|
11
|
-
<button
|
|
12
|
-
@click="() => {
|
|
13
|
-
notice.open({
|
|
14
|
-
content: `${new Date().toISOString()}`,
|
|
15
|
-
})
|
|
16
|
-
}"
|
|
17
|
-
>
|
|
18
|
-
Basic
|
|
19
|
-
</button>
|
|
20
|
-
<button
|
|
21
|
-
@click="() => {
|
|
22
|
-
notice.open({
|
|
23
|
-
content: `${Array(Math.round(Math.random() * 5) + 1)
|
|
24
|
-
.fill(1)
|
|
25
|
-
.map(() => new Date().toISOString())
|
|
26
|
-
.join('\n')}`,
|
|
27
|
-
duration: null,
|
|
28
|
-
})
|
|
29
|
-
}"
|
|
30
|
-
>
|
|
31
|
-
Not Auto Close
|
|
32
|
-
</button>
|
|
33
|
-
|
|
34
|
-
<button
|
|
35
|
-
@click="() => {
|
|
36
|
-
notice.open({
|
|
37
|
-
content: `${Array(5)
|
|
38
|
-
.fill(1)
|
|
39
|
-
.map(() => new Date().toISOString())
|
|
40
|
-
.join('\n')}`,
|
|
41
|
-
duration: null,
|
|
42
|
-
});
|
|
43
|
-
}"
|
|
44
|
-
>
|
|
45
|
-
Not Auto Close
|
|
46
|
-
</button>
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<div>
|
|
50
|
-
<button
|
|
51
|
-
@click="() => {
|
|
52
|
-
notice.open({
|
|
53
|
-
content: `No Close! ${new Date().toISOString()}`,
|
|
54
|
-
duration: null,
|
|
55
|
-
closable: false,
|
|
56
|
-
key: 'No Close',
|
|
57
|
-
onClose: () => {
|
|
58
|
-
console.log('Close!!!');
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}"
|
|
62
|
-
>
|
|
63
|
-
No Closable
|
|
64
|
-
</button>
|
|
65
|
-
|
|
66
|
-
<button
|
|
67
|
-
@click="() => {
|
|
68
|
-
notice.close('No Close');
|
|
69
|
-
}"
|
|
70
|
-
>
|
|
71
|
-
Force Close No Closable
|
|
72
|
-
</button>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<div>
|
|
76
|
-
<button
|
|
77
|
-
@click="() => {
|
|
78
|
-
notice.destroy();
|
|
79
|
-
}"
|
|
80
|
-
>
|
|
81
|
-
Destroy All
|
|
82
|
-
</button>
|
|
83
|
-
</div>
|
|
84
|
-
<contextHolder />
|
|
85
|
-
</template>
|
|
86
|
-
|
|
87
|
-
<style scoped>
|
|
88
|
-
|
|
89
|
-
</style>
|
package/docs/index.less
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
@notificationPrefixCls: vc-notification;
|
|
2
|
-
|
|
3
|
-
.@{notificationPrefixCls} {
|
|
4
|
-
// ====================== Notification ======================
|
|
5
|
-
position: fixed;
|
|
6
|
-
z-index: 1000;
|
|
7
|
-
display: flex;
|
|
8
|
-
max-height: 100vh;
|
|
9
|
-
padding: 10px;
|
|
10
|
-
align-items: flex-end;
|
|
11
|
-
width: 340px;
|
|
12
|
-
overflow-x: hidden;
|
|
13
|
-
overflow-y: auto;
|
|
14
|
-
height: 100vh;
|
|
15
|
-
box-sizing: border-box;
|
|
16
|
-
pointer-events: none;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
|
|
19
|
-
// Position
|
|
20
|
-
&-top,
|
|
21
|
-
&-topLeft,
|
|
22
|
-
&-topRight {
|
|
23
|
-
top: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&-bottom,
|
|
27
|
-
&-bottomRight,
|
|
28
|
-
&-bottomLeft {
|
|
29
|
-
bottom: 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&-bottomRight,
|
|
33
|
-
&-topRight {
|
|
34
|
-
right: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ========================= Notice =========================
|
|
38
|
-
&-notice {
|
|
39
|
-
position: relative;
|
|
40
|
-
display: block;
|
|
41
|
-
box-sizing: border-box;
|
|
42
|
-
line-height: 1.5;
|
|
43
|
-
width: 100%;
|
|
44
|
-
|
|
45
|
-
&-wrapper {
|
|
46
|
-
pointer-events: auto;
|
|
47
|
-
position: relative;
|
|
48
|
-
display: block;
|
|
49
|
-
box-sizing: border-box;
|
|
50
|
-
border-radius: 3px 3px;
|
|
51
|
-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
|
|
52
|
-
margin: 0 0 16px;
|
|
53
|
-
border: 1px solid #999;
|
|
54
|
-
border: 0px solid rgba(0, 0, 0, 0);
|
|
55
|
-
background: #fff;
|
|
56
|
-
width: 300px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Content
|
|
60
|
-
&-content {
|
|
61
|
-
padding: 7px 20px 7px 10px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
&-closable &-content {
|
|
65
|
-
padding-right: 20px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&-close {
|
|
69
|
-
position: absolute;
|
|
70
|
-
top: 3px;
|
|
71
|
-
right: 5px;
|
|
72
|
-
color: #000;
|
|
73
|
-
font-weight: 700;
|
|
74
|
-
font-size: 16px;
|
|
75
|
-
line-height: 1;
|
|
76
|
-
text-decoration: none;
|
|
77
|
-
text-shadow: 0 1px 0 #fff;
|
|
78
|
-
outline: none;
|
|
79
|
-
cursor: pointer;
|
|
80
|
-
opacity: 0.2;
|
|
81
|
-
filter: alpha(opacity=20);
|
|
82
|
-
border: 0;
|
|
83
|
-
background-color: #fff;
|
|
84
|
-
|
|
85
|
-
&-x:after {
|
|
86
|
-
content: '×';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
&:hover {
|
|
90
|
-
text-decoration: none;
|
|
91
|
-
opacity: 1;
|
|
92
|
-
filter: alpha(opacity=100);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Progress
|
|
97
|
-
&-progress {
|
|
98
|
-
position: absolute;
|
|
99
|
-
left: 3px;
|
|
100
|
-
right: 3px;
|
|
101
|
-
border-radius: 1px;
|
|
102
|
-
overflow: hidden;
|
|
103
|
-
appearance: none;
|
|
104
|
-
-webkit-appearance: none;
|
|
105
|
-
display: block;
|
|
106
|
-
inline-size: 100%;
|
|
107
|
-
block-size: 2px;
|
|
108
|
-
border: 0;
|
|
109
|
-
|
|
110
|
-
&,
|
|
111
|
-
&::-webkit-progress-bar {
|
|
112
|
-
background-color: rgba(0, 0, 0, 0.04);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&::-moz-progress-bar {
|
|
116
|
-
background-color: #31afff;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
&::-webkit-progress-value {
|
|
120
|
-
background-color: #31afff;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
&-fade {
|
|
126
|
-
overflow: hidden;
|
|
127
|
-
transition: all 0.3s;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&-fade-appear-prepare {
|
|
131
|
-
pointer-events: none;
|
|
132
|
-
opacity: 0 !important;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
&-fade-appear-start {
|
|
136
|
-
transform: translateX(100%);
|
|
137
|
-
opacity: 0;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&-fade-appear-active {
|
|
141
|
-
transform: translateX(0);
|
|
142
|
-
opacity: 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// .fade-effect() {
|
|
146
|
-
// animation-duration: 0.3s;
|
|
147
|
-
// animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
|
|
148
|
-
// animation-fill-mode: both;
|
|
149
|
-
// }
|
|
150
|
-
|
|
151
|
-
// &-fade-appear,
|
|
152
|
-
// &-fade-enter {
|
|
153
|
-
// opacity: 0;
|
|
154
|
-
// animation-play-state: paused;
|
|
155
|
-
// .fade-effect();
|
|
156
|
-
// }
|
|
157
|
-
|
|
158
|
-
// &-fade-leave {
|
|
159
|
-
// .fade-effect();
|
|
160
|
-
// animation-play-state: paused;
|
|
161
|
-
// }
|
|
162
|
-
|
|
163
|
-
// &-fade-appear&-fade-appear-active,
|
|
164
|
-
// &-fade-enter&-fade-enter-active {
|
|
165
|
-
// animation-name: rcNotificationFadeIn;
|
|
166
|
-
// animation-play-state: running;
|
|
167
|
-
// }
|
|
168
|
-
|
|
169
|
-
// &-fade-leave&-fade-leave-active {
|
|
170
|
-
// animation-name: rcDialogFadeOut;
|
|
171
|
-
// animation-play-state: running;
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
|
-
// @keyframes rcNotificationFadeIn {
|
|
175
|
-
// 0% {
|
|
176
|
-
// opacity: 0;
|
|
177
|
-
// }
|
|
178
|
-
// 100% {
|
|
179
|
-
// opacity: 1;
|
|
180
|
-
// }
|
|
181
|
-
// }
|
|
182
|
-
|
|
183
|
-
// @keyframes rcDialogFadeOut {
|
|
184
|
-
// 0% {
|
|
185
|
-
// opacity: 1;
|
|
186
|
-
// }
|
|
187
|
-
// 100% {
|
|
188
|
-
// opacity: 0;
|
|
189
|
-
// }
|
|
190
|
-
// }
|
|
191
|
-
|
|
192
|
-
// ========================= Stack =========================
|
|
193
|
-
&-stack {
|
|
194
|
-
& > .@{notificationPrefixCls}-notice {
|
|
195
|
-
&-wrapper {
|
|
196
|
-
transition: all 0.3s;
|
|
197
|
-
position: absolute;
|
|
198
|
-
top: 12px;
|
|
199
|
-
opacity: 1;
|
|
200
|
-
|
|
201
|
-
&:not(:nth-last-child(-n + 3)) {
|
|
202
|
-
opacity: 0;
|
|
203
|
-
right: 34px;
|
|
204
|
-
width: 252px;
|
|
205
|
-
overflow: hidden;
|
|
206
|
-
color: transparent;
|
|
207
|
-
pointer-events: none;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
&:nth-last-child(1) {
|
|
211
|
-
right: 10px;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
&:nth-last-child(2) {
|
|
215
|
-
right: 18px;
|
|
216
|
-
width: 284px;
|
|
217
|
-
color: transparent;
|
|
218
|
-
overflow: hidden;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
&:nth-last-child(3) {
|
|
222
|
-
right: 26px;
|
|
223
|
-
width: 268px;
|
|
224
|
-
color: transparent;
|
|
225
|
-
overflow: hidden;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
&&-expanded {
|
|
231
|
-
& > .@{notificationPrefixCls}-notice {
|
|
232
|
-
&-wrapper {
|
|
233
|
-
&:not(:nth-last-child(-n + 1)) {
|
|
234
|
-
opacity: 1;
|
|
235
|
-
width: 300px;
|
|
236
|
-
right: 10px;
|
|
237
|
-
overflow: unset;
|
|
238
|
-
color: inherit;
|
|
239
|
-
pointer-events: auto;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
&::before {
|
|
243
|
-
content: "";
|
|
244
|
-
position: absolute;
|
|
245
|
-
left: 0;
|
|
246
|
-
right: 0;
|
|
247
|
-
top: -16px;
|
|
248
|
-
width: 100%;
|
|
249
|
-
height: calc(100% + 32px);
|
|
250
|
-
background: transparent;
|
|
251
|
-
pointer-events: auto;
|
|
252
|
-
color: rgb(0,0,0);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
&.@{notificationPrefixCls}-bottomRight {
|
|
259
|
-
& > .@{notificationPrefixCls}-notice-wrapper {
|
|
260
|
-
top: unset;
|
|
261
|
-
bottom: 12px;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
package/docs/maxCount.vue
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useNotification } from '../src'
|
|
3
|
-
import motion from './motion.ts'
|
|
4
|
-
import './index.less'
|
|
5
|
-
|
|
6
|
-
const [notice, contextHolder] = useNotification({ maxCount: 3, motion })
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<button
|
|
11
|
-
@click="() => {
|
|
12
|
-
notice.open({
|
|
13
|
-
content: `${new Date().toISOString()}`,
|
|
14
|
-
});
|
|
15
|
-
}"
|
|
16
|
-
>
|
|
17
|
-
Max Count
|
|
18
|
-
</button>
|
|
19
|
-
<contextHolder />
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<style scoped>
|
|
23
|
-
|
|
24
|
-
</style>
|
package/docs/motion.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { TransitionGroupProps } from 'vue'
|
|
2
|
-
|
|
3
|
-
const motion: TransitionGroupProps = {
|
|
4
|
-
appear: true,
|
|
5
|
-
name: 'vc-notification-fade',
|
|
6
|
-
// enterFromClass: 'vc-notification-fade-appear-start vc-notification-fade-appear-prepare',
|
|
7
|
-
// enterActiveClass: 'vc-notification-fade',
|
|
8
|
-
// enterToClass: 'vc-notification-fade-appear-active',
|
|
9
|
-
// leaveFromClass: 'vc-notification-fade-appear-active',
|
|
10
|
-
// leaveToClass: 'vc-notification-fade-appear-start vc-notification-fade-appear-prepare',
|
|
11
|
-
// leaveActiveClass: 'vc-notification-fade vc-notification-fade-appear-leave',
|
|
12
|
-
// moveClass: 'vc-notification-fade',
|
|
13
|
-
onBeforeLeave: (el) => {
|
|
14
|
-
const _el = el as HTMLDivElement
|
|
15
|
-
_el.style.height = `${_el.offsetHeight}px`
|
|
16
|
-
},
|
|
17
|
-
onLeave(el) {
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
const _el = el as HTMLDivElement
|
|
20
|
-
_el.style.height = '0px'
|
|
21
|
-
_el.style.opacity = '1'
|
|
22
|
-
_el.style.margin = '0px'
|
|
23
|
-
})
|
|
24
|
-
},
|
|
25
|
-
onAfterLeave(el) {
|
|
26
|
-
const _el = el as HTMLDivElement
|
|
27
|
-
_el.style.height = ''
|
|
28
|
-
_el.style.opacity = ''
|
|
29
|
-
_el.style.margin = ''
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default motion
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import Context from './context.vue'
|
|
3
|
-
import Hooks from './hooks.vue'
|
|
4
|
-
import MaxCount from './maxCount.vue'
|
|
5
|
-
import ShowProgress from './showProgress.vue'
|
|
6
|
-
import Stack from './stack.vue'
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<Story title="Notification">
|
|
11
|
-
<Variant title="Context">
|
|
12
|
-
<Context />
|
|
13
|
-
</Variant>
|
|
14
|
-
|
|
15
|
-
<Variant title="Hooks">
|
|
16
|
-
<Hooks />
|
|
17
|
-
</Variant>
|
|
18
|
-
|
|
19
|
-
<Variant title="MaxCount">
|
|
20
|
-
<MaxCount />
|
|
21
|
-
</Variant>
|
|
22
|
-
|
|
23
|
-
<Variant title="ShowProgress">
|
|
24
|
-
<ShowProgress />
|
|
25
|
-
</Variant>
|
|
26
|
-
|
|
27
|
-
<Variant title="Stack">
|
|
28
|
-
<Stack />
|
|
29
|
-
</Variant>
|
|
30
|
-
</Story>
|
|
31
|
-
</template>
|
package/docs/showProgress.vue
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useNotification } from '../src'
|
|
3
|
-
import motion from './motion.ts'
|
|
4
|
-
import './index.less'
|
|
5
|
-
|
|
6
|
-
const [notice, contextHolder] = useNotification({ showProgress: true, motion })
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<button
|
|
11
|
-
@click="() => {
|
|
12
|
-
notice.open({
|
|
13
|
-
content: `${new Date().toISOString()}`,
|
|
14
|
-
});
|
|
15
|
-
}"
|
|
16
|
-
>
|
|
17
|
-
Show With Progress
|
|
18
|
-
</button>
|
|
19
|
-
<button
|
|
20
|
-
@click="() => {
|
|
21
|
-
notice.open({
|
|
22
|
-
content: `${new Date().toISOString()}`,
|
|
23
|
-
pauseOnHover: false,
|
|
24
|
-
});
|
|
25
|
-
}"
|
|
26
|
-
>
|
|
27
|
-
Not Pause On Hover
|
|
28
|
-
</button>
|
|
29
|
-
<contextHolder />
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<style scoped>
|
|
33
|
-
|
|
34
|
-
</style>
|
package/docs/stack.vue
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useNotification } from '../src'
|
|
3
|
-
import motion from './motion.ts'
|
|
4
|
-
import './index.less'
|
|
5
|
-
|
|
6
|
-
const [{ open }, contextHolder] = useNotification({ motion, stack: true })
|
|
7
|
-
|
|
8
|
-
function getConfig() {
|
|
9
|
-
return {
|
|
10
|
-
content: `${Array.from({ length: Math.round(Math.random() * 5) + 1 })
|
|
11
|
-
.fill(1)
|
|
12
|
-
.map(() => new Date().toISOString())
|
|
13
|
-
.join('\n')}`,
|
|
14
|
-
duration: null,
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
<button
|
|
21
|
-
@click="() => {
|
|
22
|
-
open(getConfig());
|
|
23
|
-
}"
|
|
24
|
-
>
|
|
25
|
-
Top Right
|
|
26
|
-
</button>
|
|
27
|
-
<button
|
|
28
|
-
@click="() => {
|
|
29
|
-
open({ ...getConfig(), placement: 'bottomRight' });
|
|
30
|
-
}"
|
|
31
|
-
>
|
|
32
|
-
Bottom Right
|
|
33
|
-
</button>
|
|
34
|
-
<contextHolder />
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<style scoped>
|
|
38
|
-
|
|
39
|
-
</style>
|