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