@v-c/notification 0.0.3 → 2.0.0-beta.1
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/Notification.d.ts +286 -0
- package/dist/Notification.js +237 -0
- package/dist/NotificationList/Content.d.ts +88 -0
- package/dist/NotificationList/Content.js +74 -0
- package/dist/NotificationList/index.d.ts +156 -0
- package/dist/NotificationList/index.js +204 -0
- package/dist/NotificationProvider.d.ts +20 -1
- package/dist/NotificationProvider.js +16 -3
- package/dist/Notifications.d.ts +136 -8
- package/dist/Notifications.js +118 -109
- package/dist/Progress.d.ts +8 -0
- package/dist/Progress.js +18 -0
- package/dist/hooks/useClosable.d.ts +22 -0
- package/dist/hooks/useClosable.js +33 -0
- package/dist/hooks/useListPosition/index.d.ts +17 -0
- package/dist/hooks/useListPosition/index.js +48 -0
- package/dist/hooks/useListPosition/useSizes.d.ts +13 -0
- package/dist/hooks/useListPosition/useSizes.js +29 -0
- package/dist/hooks/useNoticeTimer.d.ts +6 -0
- package/dist/hooks/useNoticeTimer.js +71 -0
- package/dist/hooks/useNotification.d.ts +8 -24
- package/dist/hooks/useNotification.js +33 -22
- package/dist/hooks/useStack.d.ts +8 -4
- package/dist/hooks/useStack.js +15 -18
- package/dist/index.d.ts +7 -5
- package/dist/index.js +5 -3
- package/docs/context.vue +1 -1
- package/docs/hooks.vue +4 -4
- package/docs/index.less +62 -143
- package/docs/maxCount.vue +1 -1
- package/docs/showProgress.vue +2 -2
- package/docs/stack.vue +1 -1
- package/package.json +5 -4
- package/src/Notification.tsx +363 -0
- package/src/NotificationList/Content.tsx +84 -0
- package/src/NotificationList/index.tsx +298 -0
- package/src/NotificationProvider.tsx +23 -3
- package/src/Notifications.tsx +103 -87
- package/src/Progress.tsx +23 -0
- package/src/hooks/useClosable.ts +54 -0
- package/src/hooks/useListPosition/index.ts +85 -0
- package/src/hooks/useListPosition/useSizes.ts +42 -0
- package/src/hooks/useNoticeTimer.ts +96 -0
- package/src/hooks/useNotification.tsx +54 -80
- package/src/hooks/useStack.ts +26 -18
- package/src/index.ts +31 -5
- package/tests/index.spec.tsx +200 -0
- package/vite.config.ts +4 -3
- package/vitest.config.ts +3 -1
- package/dist/Notice.cjs +0 -235
- package/dist/Notice.d.ts +0 -15
- package/dist/Notice.js +0 -227
- package/dist/NoticeList.cjs +0 -170
- package/dist/NoticeList.d.ts +0 -13
- package/dist/NoticeList.js +0 -164
- package/dist/NotificationProvider.cjs +0 -14
- package/dist/Notifications.cjs +0 -146
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/hooks/useNotification.cjs +0 -93
- package/dist/hooks/useStack.cjs +0 -27
- package/dist/index.cjs +0 -7
- package/dist/interface.cjs +0 -1
- package/dist/interface.d.ts +0 -55
- package/dist/interface.js +0 -0
- package/src/Notice.tsx +0 -212
- package/src/NoticeList.tsx +0 -219
- package/src/interface.ts +0 -61
package/dist/hooks/useStack.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { ComputedRef, MaybeRef
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ComputedRef, MaybeRef } from 'vue';
|
|
2
|
+
export interface StackConfig {
|
|
3
|
+
threshold?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
}
|
|
6
|
+
type StackParams = Required<StackConfig>;
|
|
7
|
+
export type StackInput = boolean | StackConfig;
|
|
8
|
+
type UseStack = (config?: MaybeRef<StackInput | undefined>) => [ComputedRef<boolean>, ComputedRef<StackParams>];
|
|
5
9
|
declare const useStack: UseStack;
|
|
6
10
|
export default useStack;
|
package/dist/hooks/useStack.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { computed,
|
|
1
|
+
import { computed, unref } from "vue";
|
|
2
|
+
//#region src/hooks/useStack.ts
|
|
2
3
|
var DEFAULT_OFFSET = 8;
|
|
3
4
|
var DEFAULT_THRESHOLD = 3;
|
|
4
|
-
var DEFAULT_GAP = 16;
|
|
5
5
|
var useStack = (config) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return [computed(() => !!unref(config)), toRefs(result)];
|
|
6
|
+
return [computed(() => !!unref(config)), computed(() => {
|
|
7
|
+
const value = unref(config);
|
|
8
|
+
if (value && typeof value === "object") return {
|
|
9
|
+
offset: value.offset ?? DEFAULT_OFFSET,
|
|
10
|
+
threshold: value.threshold ?? DEFAULT_THRESHOLD
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
offset: DEFAULT_OFFSET,
|
|
14
|
+
threshold: DEFAULT_THRESHOLD
|
|
15
|
+
};
|
|
16
|
+
})];
|
|
20
17
|
};
|
|
21
|
-
|
|
22
|
-
export {
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useStack as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NotificationAPI, NotificationConfig, default as useNotification } from './hooks/useNotification';
|
|
2
|
-
import { default as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
2
|
+
import { ComponentsType, NotificationProps, default as Notification } from './Notification';
|
|
3
|
+
import { NotificationProgressProps, default as Progress } from './Progress';
|
|
4
|
+
import { default as NotificationList } from './NotificationList';
|
|
5
|
+
import { default as NotificationProvider, useNotificationProvider } from './NotificationProvider';
|
|
6
|
+
export { Notification, NotificationList, NotificationProvider, Progress, useNotification, useNotificationProvider, };
|
|
7
|
+
export type { ComponentsType, NotificationAPI, NotificationConfig, NotificationProgressProps, NotificationProps, };
|
|
8
|
+
export type { NotificationClassNames, NotificationListConfig, NotificationListProps, NotificationStyles, Placement, StackConfig, StackInput, } from './NotificationList';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import Progress from "./Progress.js";
|
|
2
|
+
import Notification from "./Notification.js";
|
|
3
|
+
import NotificationProvider, { useNotificationProvider } from "./NotificationProvider.js";
|
|
4
|
+
import NotificationList from "./NotificationList/index.js";
|
|
3
5
|
import useNotification from "./hooks/useNotification.js";
|
|
4
|
-
export {
|
|
6
|
+
export { Notification, NotificationList, NotificationProvider, Progress, useNotification, useNotificationProvider };
|
package/docs/context.vue
CHANGED
package/docs/hooks.vue
CHANGED
|
@@ -11,7 +11,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
|
|
|
11
11
|
<button
|
|
12
12
|
@click="() => {
|
|
13
13
|
notice.open({
|
|
14
|
-
|
|
14
|
+
description: `${new Date().toISOString()}`,
|
|
15
15
|
})
|
|
16
16
|
}"
|
|
17
17
|
>
|
|
@@ -20,7 +20,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
|
|
|
20
20
|
<button
|
|
21
21
|
@click="() => {
|
|
22
22
|
notice.open({
|
|
23
|
-
|
|
23
|
+
description: `${Array(Math.round(Math.random() * 5) + 1)
|
|
24
24
|
.fill(1)
|
|
25
25
|
.map(() => new Date().toISOString())
|
|
26
26
|
.join('\n')}`,
|
|
@@ -34,7 +34,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
|
|
|
34
34
|
<button
|
|
35
35
|
@click="() => {
|
|
36
36
|
notice.open({
|
|
37
|
-
|
|
37
|
+
description: `${Array(5)
|
|
38
38
|
.fill(1)
|
|
39
39
|
.map(() => new Date().toISOString())
|
|
40
40
|
.join('\n')}`,
|
|
@@ -50,7 +50,7 @@ const [notice, contextHolder] = useNotification({ motion, closable: true })
|
|
|
50
50
|
<button
|
|
51
51
|
@click="() => {
|
|
52
52
|
notice.open({
|
|
53
|
-
|
|
53
|
+
description: `No Close! ${new Date().toISOString()}`,
|
|
54
54
|
duration: null,
|
|
55
55
|
closable: false,
|
|
56
56
|
key: 'No Close',
|
package/docs/index.less
CHANGED
|
@@ -5,16 +5,11 @@
|
|
|
5
5
|
position: fixed;
|
|
6
6
|
z-index: 1000;
|
|
7
7
|
display: flex;
|
|
8
|
-
max-height: 100vh;
|
|
9
|
-
padding: 10px;
|
|
10
|
-
align-items: flex-end;
|
|
11
8
|
width: 340px;
|
|
12
|
-
overflow-x: hidden;
|
|
13
|
-
overflow-y: auto;
|
|
14
|
-
height: 100vh;
|
|
15
9
|
box-sizing: border-box;
|
|
16
10
|
pointer-events: none;
|
|
17
11
|
flex-direction: column;
|
|
12
|
+
padding: 10px;
|
|
18
13
|
|
|
19
14
|
// Position
|
|
20
15
|
&-top,
|
|
@@ -34,37 +29,68 @@
|
|
|
34
29
|
right: 0;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
//
|
|
38
|
-
&-
|
|
32
|
+
// ===================== List Content =======================
|
|
33
|
+
&-list-content {
|
|
39
34
|
position: relative;
|
|
40
35
|
display: block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
transition: height 0.3s;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ========================= Notice =========================
|
|
41
|
+
&-notice {
|
|
42
|
+
pointer-events: auto;
|
|
43
|
+
position: absolute;
|
|
44
|
+
inset-inline: 0;
|
|
41
45
|
box-sizing: border-box;
|
|
42
46
|
line-height: 1.5;
|
|
43
|
-
width:
|
|
47
|
+
width: 300px;
|
|
48
|
+
border-radius: 3px;
|
|
49
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
|
|
50
|
+
background: #fff;
|
|
51
|
+
border: 0px solid rgba(0, 0, 0, 0);
|
|
52
|
+
transform: translateY(var(--notification-y, 0));
|
|
53
|
+
transition: transform 0.3s, opacity 0.3s;
|
|
54
|
+
|
|
55
|
+
// Title
|
|
56
|
+
&-title {
|
|
57
|
+
padding: 7px 30px 0 10px;
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
}
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
// Description
|
|
62
|
+
&-description {
|
|
63
|
+
padding: 7px 30px 7px 10px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Section (title + description)
|
|
67
|
+
&-section {
|
|
48
68
|
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
69
|
}
|
|
58
70
|
|
|
59
|
-
//
|
|
60
|
-
&-
|
|
61
|
-
|
|
71
|
+
// Wrapper (icon + section)
|
|
72
|
+
&-wrapper {
|
|
73
|
+
display: flex;
|
|
74
|
+
gap: 8px;
|
|
75
|
+
padding: 7px 30px 7px 10px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&-wrapper > &-section,
|
|
79
|
+
&-wrapper > &-title,
|
|
80
|
+
&-wrapper > &-description {
|
|
81
|
+
padding: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&-icon {
|
|
85
|
+
flex: none;
|
|
62
86
|
}
|
|
63
87
|
|
|
64
|
-
|
|
65
|
-
|
|
88
|
+
// Actions
|
|
89
|
+
&-actions {
|
|
90
|
+
padding: 0 10px 7px;
|
|
66
91
|
}
|
|
67
92
|
|
|
93
|
+
// Close
|
|
68
94
|
&-close {
|
|
69
95
|
position: absolute;
|
|
70
96
|
top: 3px;
|
|
@@ -78,18 +104,12 @@
|
|
|
78
104
|
outline: none;
|
|
79
105
|
cursor: pointer;
|
|
80
106
|
opacity: 0.2;
|
|
81
|
-
filter: alpha(opacity=20);
|
|
82
107
|
border: 0;
|
|
83
|
-
background-color:
|
|
84
|
-
|
|
85
|
-
&-x:after {
|
|
86
|
-
content: '×';
|
|
87
|
-
}
|
|
108
|
+
background-color: transparent;
|
|
88
109
|
|
|
89
110
|
&:hover {
|
|
90
111
|
text-decoration: none;
|
|
91
112
|
opacity: 1;
|
|
92
|
-
filter: alpha(opacity=100);
|
|
93
113
|
}
|
|
94
114
|
}
|
|
95
115
|
|
|
@@ -98,12 +118,13 @@
|
|
|
98
118
|
position: absolute;
|
|
99
119
|
left: 3px;
|
|
100
120
|
right: 3px;
|
|
121
|
+
bottom: 0;
|
|
101
122
|
border-radius: 1px;
|
|
102
123
|
overflow: hidden;
|
|
103
124
|
appearance: none;
|
|
104
125
|
-webkit-appearance: none;
|
|
105
126
|
display: block;
|
|
106
|
-
inline-size: 100
|
|
127
|
+
inline-size: calc(100% - 6px);
|
|
107
128
|
block-size: 2px;
|
|
108
129
|
border: 0;
|
|
109
130
|
|
|
@@ -142,123 +163,21 @@
|
|
|
142
163
|
opacity: 1;
|
|
143
164
|
}
|
|
144
165
|
|
|
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
166
|
// ========================= Stack =========================
|
|
193
167
|
&-stack {
|
|
194
|
-
& > .@{notificationPrefixCls}-notice {
|
|
195
|
-
|
|
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
|
-
}
|
|
168
|
+
& > .@{notificationPrefixCls}-list-content > .@{notificationPrefixCls}-notice {
|
|
169
|
+
transition: transform 0.3s, opacity 0.3s;
|
|
213
170
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
}
|
|
171
|
+
&:not(.@{notificationPrefixCls}-notice-stack-in-threshold) {
|
|
172
|
+
opacity: 0;
|
|
173
|
+
pointer-events: none;
|
|
227
174
|
}
|
|
228
175
|
}
|
|
229
176
|
|
|
230
177
|
&&-expanded {
|
|
231
|
-
& > .@{notificationPrefixCls}-notice {
|
|
232
|
-
|
|
233
|
-
|
|
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;
|
|
178
|
+
& > .@{notificationPrefixCls}-list-content > .@{notificationPrefixCls}-notice {
|
|
179
|
+
opacity: 1;
|
|
180
|
+
pointer-events: auto;
|
|
262
181
|
}
|
|
263
182
|
}
|
|
264
183
|
}
|
package/docs/maxCount.vue
CHANGED
package/docs/showProgress.vue
CHANGED
|
@@ -10,7 +10,7 @@ const [notice, contextHolder] = useNotification({ showProgress: true, motion })
|
|
|
10
10
|
<button
|
|
11
11
|
@click="() => {
|
|
12
12
|
notice.open({
|
|
13
|
-
|
|
13
|
+
description: `${new Date().toISOString()}`,
|
|
14
14
|
});
|
|
15
15
|
}"
|
|
16
16
|
>
|
|
@@ -19,7 +19,7 @@ const [notice, contextHolder] = useNotification({ showProgress: true, motion })
|
|
|
19
19
|
<button
|
|
20
20
|
@click="() => {
|
|
21
21
|
notice.open({
|
|
22
|
-
|
|
22
|
+
description: `${new Date().toISOString()}`,
|
|
23
23
|
pauseOnHover: false,
|
|
24
24
|
});
|
|
25
25
|
}"
|
package/docs/stack.vue
CHANGED
|
@@ -7,7 +7,7 @@ const [{ open }, contextHolder] = useNotification({ motion, stack: true })
|
|
|
7
7
|
|
|
8
8
|
function getConfig() {
|
|
9
9
|
return {
|
|
10
|
-
|
|
10
|
+
description: `${Array.from({ length: Math.round(Math.random() * 5) + 1 })
|
|
11
11
|
.fill(1)
|
|
12
12
|
.map(() => new Date().toISOString())
|
|
13
13
|
.join('\n')}`,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/notification",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
-
"
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./dist/*": "./dist/*",
|
|
15
15
|
"./package.json": "./package.json"
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"vue": "^3.0.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@v-c/util": "^1.0.
|
|
22
|
+
"@v-c/util": "^1.0.19"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "vite build",
|
|
26
26
|
"test": "vitest run",
|
|
27
27
|
"prepublish": "pnpm build",
|
|
28
|
-
"bump": "bumpp
|
|
28
|
+
"bump": "bumpp",
|
|
29
|
+
"patch": "bumpp --release patch"
|
|
29
30
|
}
|
|
30
31
|
}
|