@v-c/notification 1.0.0 → 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
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { VueNode } from '@v-c/util/dist/type';
|
|
2
|
+
import { Component, CSSProperties, PropType } from 'vue';
|
|
3
|
+
import { ClosableType } from './hooks/useClosable';
|
|
4
|
+
import { NotificationProgressProps } from './Progress';
|
|
5
|
+
export interface NotificationClassNames {
|
|
6
|
+
wrapper?: string;
|
|
7
|
+
root?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
section?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
actions?: string;
|
|
13
|
+
close?: string;
|
|
14
|
+
progress?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface NotificationStyles {
|
|
17
|
+
wrapper?: CSSProperties;
|
|
18
|
+
root?: CSSProperties;
|
|
19
|
+
icon?: CSSProperties;
|
|
20
|
+
section?: CSSProperties;
|
|
21
|
+
title?: CSSProperties;
|
|
22
|
+
description?: CSSProperties;
|
|
23
|
+
actions?: CSSProperties;
|
|
24
|
+
close?: CSSProperties;
|
|
25
|
+
progress?: CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
export interface ComponentsType {
|
|
28
|
+
progress?: Component<NotificationProgressProps>;
|
|
29
|
+
}
|
|
30
|
+
export interface NotificationProps {
|
|
31
|
+
prefixCls: string;
|
|
32
|
+
class?: string;
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
classNames?: NotificationClassNames;
|
|
35
|
+
styles?: NotificationStyles;
|
|
36
|
+
components?: ComponentsType;
|
|
37
|
+
title?: VueNode;
|
|
38
|
+
description?: VueNode;
|
|
39
|
+
icon?: VueNode;
|
|
40
|
+
actions?: VueNode;
|
|
41
|
+
role?: string;
|
|
42
|
+
closable?: ClosableType;
|
|
43
|
+
offset?: number;
|
|
44
|
+
notificationIndex?: number;
|
|
45
|
+
stackInThreshold?: boolean;
|
|
46
|
+
props?: Record<string, any>;
|
|
47
|
+
duration?: number | false | null;
|
|
48
|
+
showProgress?: boolean;
|
|
49
|
+
times?: number;
|
|
50
|
+
hovering?: boolean;
|
|
51
|
+
pauseOnHover?: boolean;
|
|
52
|
+
onClick?: (event: MouseEvent) => void;
|
|
53
|
+
onMouseEnter?: (event: MouseEvent) => void;
|
|
54
|
+
onMouseLeave?: (event: MouseEvent) => void;
|
|
55
|
+
/** @deprecated Please use `closable.onClose` instead. */
|
|
56
|
+
onClose?: () => void;
|
|
57
|
+
}
|
|
58
|
+
declare const Notification: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
59
|
+
prefixCls: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
required: true;
|
|
62
|
+
};
|
|
63
|
+
class: {
|
|
64
|
+
type: StringConstructor;
|
|
65
|
+
default: undefined;
|
|
66
|
+
};
|
|
67
|
+
style: {
|
|
68
|
+
type: PropType<CSSProperties>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
classNames: {
|
|
72
|
+
type: PropType<NotificationClassNames>;
|
|
73
|
+
default: undefined;
|
|
74
|
+
};
|
|
75
|
+
styles: {
|
|
76
|
+
type: PropType<NotificationStyles>;
|
|
77
|
+
default: undefined;
|
|
78
|
+
};
|
|
79
|
+
components: {
|
|
80
|
+
type: PropType<ComponentsType>;
|
|
81
|
+
default: undefined;
|
|
82
|
+
};
|
|
83
|
+
title: {
|
|
84
|
+
type: any;
|
|
85
|
+
default: undefined;
|
|
86
|
+
};
|
|
87
|
+
description: {
|
|
88
|
+
type: any;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
91
|
+
icon: {
|
|
92
|
+
type: any;
|
|
93
|
+
default: undefined;
|
|
94
|
+
};
|
|
95
|
+
actions: {
|
|
96
|
+
type: any;
|
|
97
|
+
default: undefined;
|
|
98
|
+
};
|
|
99
|
+
role: {
|
|
100
|
+
type: StringConstructor;
|
|
101
|
+
default: undefined;
|
|
102
|
+
};
|
|
103
|
+
closable: {
|
|
104
|
+
type: PropType<ClosableType>;
|
|
105
|
+
default: undefined;
|
|
106
|
+
};
|
|
107
|
+
offset: {
|
|
108
|
+
type: NumberConstructor;
|
|
109
|
+
default: undefined;
|
|
110
|
+
};
|
|
111
|
+
notificationIndex: {
|
|
112
|
+
type: NumberConstructor;
|
|
113
|
+
default: undefined;
|
|
114
|
+
};
|
|
115
|
+
stackInThreshold: {
|
|
116
|
+
type: BooleanConstructor;
|
|
117
|
+
default: boolean;
|
|
118
|
+
};
|
|
119
|
+
props: {
|
|
120
|
+
type: PropType<Record<string, any>>;
|
|
121
|
+
default: undefined;
|
|
122
|
+
};
|
|
123
|
+
duration: {
|
|
124
|
+
type: PropType<number | false | null>;
|
|
125
|
+
default: number;
|
|
126
|
+
};
|
|
127
|
+
showProgress: {
|
|
128
|
+
type: BooleanConstructor;
|
|
129
|
+
default: boolean;
|
|
130
|
+
};
|
|
131
|
+
times: {
|
|
132
|
+
type: NumberConstructor;
|
|
133
|
+
default: undefined;
|
|
134
|
+
};
|
|
135
|
+
hovering: {
|
|
136
|
+
type: BooleanConstructor;
|
|
137
|
+
default: boolean;
|
|
138
|
+
};
|
|
139
|
+
pauseOnHover: {
|
|
140
|
+
type: BooleanConstructor;
|
|
141
|
+
default: boolean;
|
|
142
|
+
};
|
|
143
|
+
onClick: {
|
|
144
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
145
|
+
default: undefined;
|
|
146
|
+
};
|
|
147
|
+
onMouseEnter: {
|
|
148
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
149
|
+
default: undefined;
|
|
150
|
+
};
|
|
151
|
+
onMouseLeave: {
|
|
152
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
153
|
+
default: undefined;
|
|
154
|
+
};
|
|
155
|
+
onClose: {
|
|
156
|
+
type: PropType<() => void>;
|
|
157
|
+
default: undefined;
|
|
158
|
+
};
|
|
159
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
160
|
+
prefixCls: {
|
|
161
|
+
type: StringConstructor;
|
|
162
|
+
required: true;
|
|
163
|
+
};
|
|
164
|
+
class: {
|
|
165
|
+
type: StringConstructor;
|
|
166
|
+
default: undefined;
|
|
167
|
+
};
|
|
168
|
+
style: {
|
|
169
|
+
type: PropType<CSSProperties>;
|
|
170
|
+
default: undefined;
|
|
171
|
+
};
|
|
172
|
+
classNames: {
|
|
173
|
+
type: PropType<NotificationClassNames>;
|
|
174
|
+
default: undefined;
|
|
175
|
+
};
|
|
176
|
+
styles: {
|
|
177
|
+
type: PropType<NotificationStyles>;
|
|
178
|
+
default: undefined;
|
|
179
|
+
};
|
|
180
|
+
components: {
|
|
181
|
+
type: PropType<ComponentsType>;
|
|
182
|
+
default: undefined;
|
|
183
|
+
};
|
|
184
|
+
title: {
|
|
185
|
+
type: any;
|
|
186
|
+
default: undefined;
|
|
187
|
+
};
|
|
188
|
+
description: {
|
|
189
|
+
type: any;
|
|
190
|
+
default: undefined;
|
|
191
|
+
};
|
|
192
|
+
icon: {
|
|
193
|
+
type: any;
|
|
194
|
+
default: undefined;
|
|
195
|
+
};
|
|
196
|
+
actions: {
|
|
197
|
+
type: any;
|
|
198
|
+
default: undefined;
|
|
199
|
+
};
|
|
200
|
+
role: {
|
|
201
|
+
type: StringConstructor;
|
|
202
|
+
default: undefined;
|
|
203
|
+
};
|
|
204
|
+
closable: {
|
|
205
|
+
type: PropType<ClosableType>;
|
|
206
|
+
default: undefined;
|
|
207
|
+
};
|
|
208
|
+
offset: {
|
|
209
|
+
type: NumberConstructor;
|
|
210
|
+
default: undefined;
|
|
211
|
+
};
|
|
212
|
+
notificationIndex: {
|
|
213
|
+
type: NumberConstructor;
|
|
214
|
+
default: undefined;
|
|
215
|
+
};
|
|
216
|
+
stackInThreshold: {
|
|
217
|
+
type: BooleanConstructor;
|
|
218
|
+
default: boolean;
|
|
219
|
+
};
|
|
220
|
+
props: {
|
|
221
|
+
type: PropType<Record<string, any>>;
|
|
222
|
+
default: undefined;
|
|
223
|
+
};
|
|
224
|
+
duration: {
|
|
225
|
+
type: PropType<number | false | null>;
|
|
226
|
+
default: number;
|
|
227
|
+
};
|
|
228
|
+
showProgress: {
|
|
229
|
+
type: BooleanConstructor;
|
|
230
|
+
default: boolean;
|
|
231
|
+
};
|
|
232
|
+
times: {
|
|
233
|
+
type: NumberConstructor;
|
|
234
|
+
default: undefined;
|
|
235
|
+
};
|
|
236
|
+
hovering: {
|
|
237
|
+
type: BooleanConstructor;
|
|
238
|
+
default: boolean;
|
|
239
|
+
};
|
|
240
|
+
pauseOnHover: {
|
|
241
|
+
type: BooleanConstructor;
|
|
242
|
+
default: boolean;
|
|
243
|
+
};
|
|
244
|
+
onClick: {
|
|
245
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
246
|
+
default: undefined;
|
|
247
|
+
};
|
|
248
|
+
onMouseEnter: {
|
|
249
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
250
|
+
default: undefined;
|
|
251
|
+
};
|
|
252
|
+
onMouseLeave: {
|
|
253
|
+
type: PropType<(event: MouseEvent) => void>;
|
|
254
|
+
default: undefined;
|
|
255
|
+
};
|
|
256
|
+
onClose: {
|
|
257
|
+
type: PropType<() => void>;
|
|
258
|
+
default: undefined;
|
|
259
|
+
};
|
|
260
|
+
}>> & Readonly<{}>, {
|
|
261
|
+
onClose: () => void;
|
|
262
|
+
class: string;
|
|
263
|
+
style: CSSProperties;
|
|
264
|
+
title: any;
|
|
265
|
+
onClick: (event: MouseEvent) => void;
|
|
266
|
+
props: Record<string, any>;
|
|
267
|
+
classNames: NotificationClassNames;
|
|
268
|
+
styles: NotificationStyles;
|
|
269
|
+
components: ComponentsType;
|
|
270
|
+
description: any;
|
|
271
|
+
icon: any;
|
|
272
|
+
actions: any;
|
|
273
|
+
role: string;
|
|
274
|
+
closable: ClosableType;
|
|
275
|
+
offset: number;
|
|
276
|
+
notificationIndex: number;
|
|
277
|
+
stackInThreshold: boolean;
|
|
278
|
+
duration: number | false | null;
|
|
279
|
+
showProgress: boolean;
|
|
280
|
+
times: number;
|
|
281
|
+
hovering: boolean;
|
|
282
|
+
pauseOnHover: boolean;
|
|
283
|
+
onMouseEnter: (event: MouseEvent) => void;
|
|
284
|
+
onMouseLeave: (event: MouseEvent) => void;
|
|
285
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
286
|
+
export default Notification;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import useClosable from "./hooks/useClosable.js";
|
|
2
|
+
import useNoticeTimer from "./hooks/useNoticeTimer.js";
|
|
3
|
+
import Progress from "./Progress.js";
|
|
4
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef, toRef, watch } from "vue";
|
|
5
|
+
import { classNames } from "@v-c/util";
|
|
6
|
+
//#region src/Notification.tsx
|
|
7
|
+
var Notification = /* @__PURE__ */ defineComponent({
|
|
8
|
+
name: "Notification",
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
prefixCls: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
class: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
style: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: void 0
|
|
22
|
+
},
|
|
23
|
+
classNames: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
styles: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
components: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
title: {
|
|
36
|
+
type: null,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
description: {
|
|
40
|
+
type: null,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
icon: {
|
|
44
|
+
type: null,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
actions: {
|
|
48
|
+
type: null,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
role: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: void 0
|
|
54
|
+
},
|
|
55
|
+
closable: {
|
|
56
|
+
type: [
|
|
57
|
+
Boolean,
|
|
58
|
+
Object,
|
|
59
|
+
null
|
|
60
|
+
],
|
|
61
|
+
default: void 0
|
|
62
|
+
},
|
|
63
|
+
offset: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: void 0
|
|
66
|
+
},
|
|
67
|
+
notificationIndex: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
stackInThreshold: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
props: {
|
|
76
|
+
type: Object,
|
|
77
|
+
default: void 0
|
|
78
|
+
},
|
|
79
|
+
duration: {
|
|
80
|
+
type: [Number, Boolean],
|
|
81
|
+
default: 4.5
|
|
82
|
+
},
|
|
83
|
+
showProgress: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: false
|
|
86
|
+
},
|
|
87
|
+
times: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: void 0
|
|
90
|
+
},
|
|
91
|
+
hovering: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
pauseOnHover: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: true
|
|
98
|
+
},
|
|
99
|
+
onClick: {
|
|
100
|
+
type: Function,
|
|
101
|
+
default: void 0
|
|
102
|
+
},
|
|
103
|
+
onMouseEnter: {
|
|
104
|
+
type: Function,
|
|
105
|
+
default: void 0
|
|
106
|
+
},
|
|
107
|
+
onMouseLeave: {
|
|
108
|
+
type: Function,
|
|
109
|
+
default: void 0
|
|
110
|
+
},
|
|
111
|
+
onClose: {
|
|
112
|
+
type: Function,
|
|
113
|
+
default: void 0
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
setup(props, { attrs, expose }) {
|
|
117
|
+
const noticeRef = shallowRef(null);
|
|
118
|
+
expose({ get nativeElement() {
|
|
119
|
+
return noticeRef.value;
|
|
120
|
+
} });
|
|
121
|
+
const noticePrefixCls = computed(() => `${props.prefixCls}-notice`);
|
|
122
|
+
const localHovering = shallowRef(false);
|
|
123
|
+
const percent = shallowRef(0);
|
|
124
|
+
const [mergedClosable, closableConfig, closeBtnAriaProps] = useClosable(toRef(props, "closable"));
|
|
125
|
+
const onInternalClose = () => {
|
|
126
|
+
closableConfig.value.onClose?.();
|
|
127
|
+
props.onClose?.();
|
|
128
|
+
};
|
|
129
|
+
const [onResume, onPause] = useNoticeTimer(toRef(props, "duration"), onInternalClose, (ptg) => {
|
|
130
|
+
percent.value = ptg;
|
|
131
|
+
});
|
|
132
|
+
watch([
|
|
133
|
+
() => props.pauseOnHover,
|
|
134
|
+
() => props.hovering,
|
|
135
|
+
localHovering
|
|
136
|
+
], ([pauseOnHover, forcedHovering, hovering]) => {
|
|
137
|
+
if (!pauseOnHover) return;
|
|
138
|
+
if (forcedHovering) onPause();
|
|
139
|
+
else if (!hovering) onResume();
|
|
140
|
+
}, { immediate: true });
|
|
141
|
+
function onInternalMouseEnter(event) {
|
|
142
|
+
localHovering.value = true;
|
|
143
|
+
if (props.pauseOnHover) onPause();
|
|
144
|
+
props.onMouseEnter?.(event);
|
|
145
|
+
}
|
|
146
|
+
function onInternalMouseLeave(event) {
|
|
147
|
+
localHovering.value = false;
|
|
148
|
+
if (props.pauseOnHover && !props.hovering) onResume();
|
|
149
|
+
props.onMouseLeave?.(event);
|
|
150
|
+
}
|
|
151
|
+
function onInternalCloseClick(event) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
event.stopPropagation();
|
|
154
|
+
onInternalClose();
|
|
155
|
+
}
|
|
156
|
+
let lastOffset = props.offset;
|
|
157
|
+
let lastIndex = props.notificationIndex;
|
|
158
|
+
watch(() => props.offset, (val) => {
|
|
159
|
+
if (val !== void 0) lastOffset = val;
|
|
160
|
+
}, { immediate: true });
|
|
161
|
+
watch(() => props.notificationIndex, (val) => {
|
|
162
|
+
if (val !== void 0) lastIndex = val;
|
|
163
|
+
}, { immediate: true });
|
|
164
|
+
return () => {
|
|
165
|
+
const { title, description, icon, actions, role, showProgress, duration, classNames: classNames$1, styles, components, class: className, style, props: rootProps, onClick } = props;
|
|
166
|
+
const validPercent = 100 - Math.min(Math.max(percent.value * 100, 0), 100);
|
|
167
|
+
const ProgressComponent = components?.progress || Progress;
|
|
168
|
+
const titleNode = title !== void 0 && title !== null ? createVNode("div", {
|
|
169
|
+
"class": classNames(`${noticePrefixCls.value}-title`, classNames$1?.title),
|
|
170
|
+
"style": styles?.title
|
|
171
|
+
}, [title]) : null;
|
|
172
|
+
const descNode = description !== void 0 && description !== null ? createVNode("div", {
|
|
173
|
+
"class": classNames(`${noticePrefixCls.value}-description`, classNames$1?.description),
|
|
174
|
+
"style": styles?.description
|
|
175
|
+
}, [description]) : null;
|
|
176
|
+
const hasTitle = titleNode !== null;
|
|
177
|
+
const hasDescription = descNode !== null;
|
|
178
|
+
let contentNode = null;
|
|
179
|
+
if (hasTitle && hasDescription) contentNode = createVNode("div", {
|
|
180
|
+
"class": classNames(`${noticePrefixCls.value}-section`, classNames$1?.section),
|
|
181
|
+
"style": styles?.section
|
|
182
|
+
}, [titleNode, descNode]);
|
|
183
|
+
else contentNode = titleNode || descNode;
|
|
184
|
+
if (icon !== void 0 && icon !== null) contentNode = createVNode("div", {
|
|
185
|
+
"class": classNames(`${noticePrefixCls.value}-wrapper`, classNames$1?.wrapper),
|
|
186
|
+
"style": styles?.wrapper
|
|
187
|
+
}, [createVNode("div", {
|
|
188
|
+
"class": classNames(`${noticePrefixCls.value}-icon`, classNames$1?.icon),
|
|
189
|
+
"style": styles?.icon
|
|
190
|
+
}, [icon]), contentNode]);
|
|
191
|
+
const actionsNode = actions ? createVNode("div", {
|
|
192
|
+
"class": classNames(`${noticePrefixCls.value}-actions`, classNames$1?.actions),
|
|
193
|
+
"style": styles?.actions
|
|
194
|
+
}, [actions]) : null;
|
|
195
|
+
const mergedOffset = props.offset ?? lastOffset;
|
|
196
|
+
const mergedIndex = props.notificationIndex ?? lastIndex ?? 0;
|
|
197
|
+
const mergedStyle = {
|
|
198
|
+
"--notification-index": mergedIndex,
|
|
199
|
+
...styles?.root,
|
|
200
|
+
...style
|
|
201
|
+
};
|
|
202
|
+
if (mergedOffset !== void 0) mergedStyle["--notification-y"] = `${mergedOffset}px`;
|
|
203
|
+
const mergedRole = role ?? rootProps?.role ?? "alert";
|
|
204
|
+
return createVNode("div", mergeProps(rootProps, {
|
|
205
|
+
"ref": noticeRef,
|
|
206
|
+
"role": mergedRole,
|
|
207
|
+
"data-notification-index": mergedIndex,
|
|
208
|
+
"class": classNames(noticePrefixCls.value, className, attrs.class, classNames$1?.root, {
|
|
209
|
+
[`${noticePrefixCls.value}-closable`]: mergedClosable.value,
|
|
210
|
+
[`${noticePrefixCls.value}-stack-in-threshold`]: props.stackInThreshold
|
|
211
|
+
}),
|
|
212
|
+
"style": mergedStyle,
|
|
213
|
+
"onClick": onClick,
|
|
214
|
+
"onMouseenter": onInternalMouseEnter,
|
|
215
|
+
"onMouseleave": onInternalMouseLeave
|
|
216
|
+
}), [
|
|
217
|
+
contentNode,
|
|
218
|
+
actionsNode,
|
|
219
|
+
mergedClosable.value && createVNode("button", mergeProps({
|
|
220
|
+
"type": "button",
|
|
221
|
+
"class": classNames(`${noticePrefixCls.value}-close`, classNames$1?.close),
|
|
222
|
+
"aria-label": "Close"
|
|
223
|
+
}, closeBtnAriaProps.value, {
|
|
224
|
+
"style": styles?.close,
|
|
225
|
+
"onClick": onInternalCloseClick
|
|
226
|
+
}), [closableConfig.value.closeIcon]),
|
|
227
|
+
showProgress && typeof duration === "number" && duration > 0 && createVNode(ProgressComponent, {
|
|
228
|
+
"class": classNames(`${noticePrefixCls.value}-progress`, classNames$1?.progress),
|
|
229
|
+
"percent": validPercent,
|
|
230
|
+
"style": styles?.progress
|
|
231
|
+
}, null)
|
|
232
|
+
]);
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
//#endregion
|
|
237
|
+
export { Notification as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CSSProperties, PropType, TransitionGroupProps } from 'vue';
|
|
2
|
+
export interface ContentProps {
|
|
3
|
+
listPrefixCls: string;
|
|
4
|
+
height: number;
|
|
5
|
+
topNoticeHeight?: number;
|
|
6
|
+
topNoticeWidth?: number;
|
|
7
|
+
class?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
motionProps?: TransitionGroupProps;
|
|
10
|
+
onAfterLeave?: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Content: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
13
|
+
listPrefixCls: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
height: {
|
|
18
|
+
type: NumberConstructor;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
topNoticeHeight: {
|
|
22
|
+
type: NumberConstructor;
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
25
|
+
topNoticeWidth: {
|
|
26
|
+
type: NumberConstructor;
|
|
27
|
+
default: number;
|
|
28
|
+
};
|
|
29
|
+
class: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
style: {
|
|
34
|
+
type: PropType<CSSProperties>;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
motionProps: {
|
|
38
|
+
type: PropType<TransitionGroupProps>;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
onAfterLeave: {
|
|
42
|
+
type: PropType<() => void>;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
48
|
+
listPrefixCls: {
|
|
49
|
+
type: StringConstructor;
|
|
50
|
+
required: true;
|
|
51
|
+
};
|
|
52
|
+
height: {
|
|
53
|
+
type: NumberConstructor;
|
|
54
|
+
required: true;
|
|
55
|
+
};
|
|
56
|
+
topNoticeHeight: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
60
|
+
topNoticeWidth: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: number;
|
|
63
|
+
};
|
|
64
|
+
class: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
style: {
|
|
69
|
+
type: PropType<CSSProperties>;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
motionProps: {
|
|
73
|
+
type: PropType<TransitionGroupProps>;
|
|
74
|
+
default: undefined;
|
|
75
|
+
};
|
|
76
|
+
onAfterLeave: {
|
|
77
|
+
type: PropType<() => void>;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
}>> & Readonly<{}>, {
|
|
81
|
+
class: string;
|
|
82
|
+
style: CSSProperties;
|
|
83
|
+
onAfterLeave: () => void;
|
|
84
|
+
topNoticeHeight: number;
|
|
85
|
+
topNoticeWidth: number;
|
|
86
|
+
motionProps: TransitionGroupProps;
|
|
87
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
88
|
+
export default Content;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TransitionGroup, defineComponent, h, shallowRef } from "vue";
|
|
2
|
+
import { classNames } from "@v-c/util";
|
|
3
|
+
//#region src/NotificationList/Content.tsx
|
|
4
|
+
var Content = /* @__PURE__ */ defineComponent({
|
|
5
|
+
name: "NotificationListContent",
|
|
6
|
+
inheritAttrs: false,
|
|
7
|
+
props: {
|
|
8
|
+
listPrefixCls: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
height: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
topNoticeHeight: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 0
|
|
19
|
+
},
|
|
20
|
+
topNoticeWidth: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 0
|
|
23
|
+
},
|
|
24
|
+
class: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: void 0
|
|
27
|
+
},
|
|
28
|
+
style: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: void 0
|
|
31
|
+
},
|
|
32
|
+
motionProps: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: void 0
|
|
35
|
+
},
|
|
36
|
+
onAfterLeave: {
|
|
37
|
+
type: Function,
|
|
38
|
+
default: void 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setup(props, { slots, expose }) {
|
|
42
|
+
let prevHeight = props.height;
|
|
43
|
+
const innerRef = shallowRef(null);
|
|
44
|
+
expose({ get nativeElement() {
|
|
45
|
+
return innerRef.value;
|
|
46
|
+
} });
|
|
47
|
+
return () => {
|
|
48
|
+
const { listPrefixCls, height, topNoticeHeight, topNoticeWidth, class: className, style, motionProps, onAfterLeave } = props;
|
|
49
|
+
const heightStatus = height < prevHeight ? "decrease" : "increase";
|
|
50
|
+
prevHeight = height;
|
|
51
|
+
const contentPrefixCls = `${listPrefixCls}-content`;
|
|
52
|
+
const contentStyle = {
|
|
53
|
+
...style,
|
|
54
|
+
"height": `${height}px`,
|
|
55
|
+
"--top-notificiation-height": `${topNoticeHeight ?? 0}px`,
|
|
56
|
+
"--top-notificiation-width": `${topNoticeWidth ?? 0}px`
|
|
57
|
+
};
|
|
58
|
+
const contentClass = classNames(contentPrefixCls, `${contentPrefixCls}-${heightStatus}`, className);
|
|
59
|
+
return h(TransitionGroup, {
|
|
60
|
+
tag: "div",
|
|
61
|
+
appear: true,
|
|
62
|
+
...motionProps,
|
|
63
|
+
ref: (el) => {
|
|
64
|
+
innerRef.value = el?.$el ?? el;
|
|
65
|
+
},
|
|
66
|
+
class: contentClass,
|
|
67
|
+
style: contentStyle,
|
|
68
|
+
onAfterLeave
|
|
69
|
+
}, () => slots.default?.());
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
//#endregion
|
|
74
|
+
export { Content as default };
|