@v-c/notification 2.0.0-beta.1 → 2.0.0-rc.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.
Files changed (51) hide show
  1. package/dist/Notification.d.ts +7 -234
  2. package/dist/Notification.js +199 -135
  3. package/dist/NotificationList/Content.d.ts +3 -80
  4. package/dist/NotificationList/Content.js +33 -47
  5. package/dist/NotificationList/index.d.ts +7 -128
  6. package/dist/NotificationList/index.js +139 -122
  7. package/dist/NotificationProvider.d.ts +1 -20
  8. package/dist/NotificationProvider.js +2 -13
  9. package/dist/Notifications.d.ts +10 -132
  10. package/dist/Notifications.js +123 -108
  11. package/dist/Progress.d.ts +3 -3
  12. package/dist/Progress.js +24 -11
  13. package/dist/hooks/useClosable.d.ts +6 -11
  14. package/dist/hooks/useClosable.js +7 -6
  15. package/dist/hooks/useListPosition/index.d.ts +14 -13
  16. package/dist/hooks/useListPosition/index.js +16 -23
  17. package/dist/hooks/useListPosition/useSizes.d.ts +3 -6
  18. package/dist/hooks/useListPosition/useSizes.js +12 -10
  19. package/dist/hooks/useNoticeTimer.d.ts +5 -4
  20. package/dist/hooks/useNoticeTimer.js +33 -41
  21. package/dist/hooks/useNotification.d.ts +25 -7
  22. package/dist/hooks/useNotification.js +20 -25
  23. package/dist/hooks/useStack.d.ts +9 -8
  24. package/dist/hooks/useStack.js +17 -11
  25. package/dist/index.d.ts +9 -8
  26. package/dist/index.js +2 -2
  27. package/dist/interface.d.ts +30 -0
  28. package/dist/interface.js +0 -0
  29. package/docs/context.vue +1 -1
  30. package/docs/hooks.vue +4 -4
  31. package/docs/index.less +143 -62
  32. package/docs/maxCount.vue +1 -1
  33. package/docs/showProgress.vue +2 -2
  34. package/docs/stack.vue +1 -1
  35. package/package.json +2 -3
  36. package/src/Notification.tsx +128 -165
  37. package/src/NotificationList/Content.tsx +36 -54
  38. package/src/NotificationList/index.tsx +131 -135
  39. package/src/NotificationProvider.tsx +3 -23
  40. package/src/Notifications.tsx +62 -84
  41. package/src/Progress.tsx +19 -15
  42. package/src/hooks/useClosable.ts +15 -16
  43. package/src/hooks/useListPosition/index.ts +24 -40
  44. package/src/hooks/useListPosition/useSizes.ts +16 -15
  45. package/src/hooks/useNoticeTimer.ts +34 -45
  46. package/src/hooks/useNotification.tsx +71 -43
  47. package/src/hooks/useStack.ts +20 -24
  48. package/src/index.ts +28 -13
  49. package/src/interface.ts +45 -0
  50. package/vitest.config.ts +1 -3
  51. package/tests/index.spec.tsx +0 -200
package/docs/index.less CHANGED
@@ -5,11 +5,16 @@
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;
8
11
  width: 340px;
12
+ overflow-x: hidden;
13
+ overflow-y: auto;
14
+ height: 100vh;
9
15
  box-sizing: border-box;
10
16
  pointer-events: none;
11
17
  flex-direction: column;
12
- padding: 10px;
13
18
 
14
19
  // Position
15
20
  &-top,
@@ -29,68 +34,37 @@
29
34
  right: 0;
30
35
  }
31
36
 
32
- // ===================== List Content =======================
33
- &-list-content {
34
- position: relative;
35
- display: block;
36
- width: 100%;
37
- transition: height 0.3s;
38
- }
39
-
40
37
  // ========================= Notice =========================
41
38
  &-notice {
42
- pointer-events: auto;
43
- position: absolute;
44
- inset-inline: 0;
39
+ position: relative;
40
+ display: block;
45
41
  box-sizing: border-box;
46
42
  line-height: 1.5;
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
- }
60
-
61
- // Description
62
- &-description {
63
- padding: 7px 30px 7px 10px;
64
- }
65
-
66
- // Section (title + description)
67
- &-section {
68
- display: block;
69
- }
43
+ width: 100%;
70
44
 
71
- // Wrapper (icon + section)
72
45
  &-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;
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;
82
57
  }
83
58
 
84
- &-icon {
85
- flex: none;
59
+ // Content
60
+ &-content {
61
+ padding: 7px 20px 7px 10px;
86
62
  }
87
63
 
88
- // Actions
89
- &-actions {
90
- padding: 0 10px 7px;
64
+ &-closable &-content {
65
+ padding-right: 20px;
91
66
  }
92
67
 
93
- // Close
94
68
  &-close {
95
69
  position: absolute;
96
70
  top: 3px;
@@ -104,12 +78,18 @@
104
78
  outline: none;
105
79
  cursor: pointer;
106
80
  opacity: 0.2;
81
+ filter: alpha(opacity=20);
107
82
  border: 0;
108
- background-color: transparent;
83
+ background-color: #fff;
84
+
85
+ &-x:after {
86
+ content: '×';
87
+ }
109
88
 
110
89
  &:hover {
111
90
  text-decoration: none;
112
91
  opacity: 1;
92
+ filter: alpha(opacity=100);
113
93
  }
114
94
  }
115
95
 
@@ -118,13 +98,12 @@
118
98
  position: absolute;
119
99
  left: 3px;
120
100
  right: 3px;
121
- bottom: 0;
122
101
  border-radius: 1px;
123
102
  overflow: hidden;
124
103
  appearance: none;
125
104
  -webkit-appearance: none;
126
105
  display: block;
127
- inline-size: calc(100% - 6px);
106
+ inline-size: 100%;
128
107
  block-size: 2px;
129
108
  border: 0;
130
109
 
@@ -163,21 +142,123 @@
163
142
  opacity: 1;
164
143
  }
165
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
+
166
192
  // ========================= Stack =========================
167
193
  &-stack {
168
- & > .@{notificationPrefixCls}-list-content > .@{notificationPrefixCls}-notice {
169
- transition: transform 0.3s, opacity 0.3s;
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
+ }
170
213
 
171
- &:not(.@{notificationPrefixCls}-notice-stack-in-threshold) {
172
- opacity: 0;
173
- pointer-events: none;
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
+ }
174
227
  }
175
228
  }
176
229
 
177
230
  &&-expanded {
178
- & > .@{notificationPrefixCls}-list-content > .@{notificationPrefixCls}-notice {
179
- opacity: 1;
180
- pointer-events: auto;
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;
181
262
  }
182
263
  }
183
264
  }
package/docs/maxCount.vue CHANGED
@@ -10,7 +10,7 @@ const [notice, contextHolder] = useNotification({ maxCount: 3, motion })
10
10
  <button
11
11
  @click="() => {
12
12
  notice.open({
13
- description: `${new Date().toISOString()}`,
13
+ content: `${new Date().toISOString()}`,
14
14
  });
15
15
  }"
16
16
  >
@@ -10,7 +10,7 @@ const [notice, contextHolder] = useNotification({ showProgress: true, motion })
10
10
  <button
11
11
  @click="() => {
12
12
  notice.open({
13
- description: `${new Date().toISOString()}`,
13
+ content: `${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
- description: `${new Date().toISOString()}`,
22
+ content: `${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
- description: `${Array.from({ length: Math.round(Math.random() * 5) + 1 })
10
+ content: `${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": "2.0.0-beta.1",
4
+ "version": "2.0.0-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,7 +25,6 @@
25
25
  "build": "vite build",
26
26
  "test": "vitest run",
27
27
  "prepublish": "pnpm build",
28
- "bump": "bumpp",
29
- "patch": "bumpp --release patch"
28
+ "bump": "bumpp --release patch"
30
29
  }
31
30
  }