@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,156 @@
|
|
|
1
|
+
import { CSSProperties, PropType, TransitionGroupProps } from 'vue';
|
|
2
|
+
import { StackInput } from '../hooks/useStack';
|
|
3
|
+
import { ComponentsType, NotificationClassNames as NoticeClassNames, NotificationStyles as NoticeStyles, NotificationProps } from '../Notification';
|
|
4
|
+
type Key = string | number | symbol;
|
|
5
|
+
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
|
|
6
|
+
export type { StackConfig, StackInput } from '../hooks/useStack';
|
|
7
|
+
export type { ComponentsType } from '../Notification';
|
|
8
|
+
export interface NotificationListConfig extends Omit<NotificationProps, 'prefixCls'> {
|
|
9
|
+
key: Key;
|
|
10
|
+
placement?: Placement;
|
|
11
|
+
times?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface NotificationClassNames extends NoticeClassNames {
|
|
14
|
+
list?: string;
|
|
15
|
+
listContent?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NotificationStyles extends NoticeStyles {
|
|
18
|
+
list?: CSSProperties;
|
|
19
|
+
listContent?: CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export interface NotificationListProps {
|
|
22
|
+
configList?: NotificationListConfig[];
|
|
23
|
+
prefixCls?: string;
|
|
24
|
+
placement: Placement;
|
|
25
|
+
pauseOnHover?: boolean;
|
|
26
|
+
classNames?: NotificationClassNames;
|
|
27
|
+
styles?: NotificationStyles;
|
|
28
|
+
components?: ComponentsType;
|
|
29
|
+
stack?: StackInput;
|
|
30
|
+
motion?: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps);
|
|
31
|
+
class?: string;
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
onNoticeClose?: (key: Key) => void;
|
|
34
|
+
onAllRemoved?: (placement: Placement) => void;
|
|
35
|
+
}
|
|
36
|
+
declare const NotificationList: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
37
|
+
configList: {
|
|
38
|
+
type: PropType<NotificationListConfig[]>;
|
|
39
|
+
default: () => never[];
|
|
40
|
+
};
|
|
41
|
+
prefixCls: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
placement: {
|
|
46
|
+
type: PropType<Placement>;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
pauseOnHover: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
classNames: {
|
|
54
|
+
type: PropType<NotificationClassNames>;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
styles: {
|
|
58
|
+
type: PropType<NotificationStyles>;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
61
|
+
components: {
|
|
62
|
+
type: PropType<ComponentsType>;
|
|
63
|
+
default: undefined;
|
|
64
|
+
};
|
|
65
|
+
stack: {
|
|
66
|
+
type: PropType<StackInput>;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
motion: {
|
|
70
|
+
type: PropType<NotificationListProps["motion"]>;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
class: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: undefined;
|
|
76
|
+
};
|
|
77
|
+
style: {
|
|
78
|
+
type: PropType<CSSProperties>;
|
|
79
|
+
default: undefined;
|
|
80
|
+
};
|
|
81
|
+
onNoticeClose: {
|
|
82
|
+
type: PropType<(key: Key) => void>;
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
onAllRemoved: {
|
|
86
|
+
type: PropType<(placement: Placement) => void>;
|
|
87
|
+
default: undefined;
|
|
88
|
+
};
|
|
89
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
90
|
+
configList: {
|
|
91
|
+
type: PropType<NotificationListConfig[]>;
|
|
92
|
+
default: () => never[];
|
|
93
|
+
};
|
|
94
|
+
prefixCls: {
|
|
95
|
+
type: StringConstructor;
|
|
96
|
+
default: string;
|
|
97
|
+
};
|
|
98
|
+
placement: {
|
|
99
|
+
type: PropType<Placement>;
|
|
100
|
+
required: true;
|
|
101
|
+
};
|
|
102
|
+
pauseOnHover: {
|
|
103
|
+
type: BooleanConstructor;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
classNames: {
|
|
107
|
+
type: PropType<NotificationClassNames>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
styles: {
|
|
111
|
+
type: PropType<NotificationStyles>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
components: {
|
|
115
|
+
type: PropType<ComponentsType>;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
stack: {
|
|
119
|
+
type: PropType<StackInput>;
|
|
120
|
+
default: undefined;
|
|
121
|
+
};
|
|
122
|
+
motion: {
|
|
123
|
+
type: PropType<NotificationListProps["motion"]>;
|
|
124
|
+
default: undefined;
|
|
125
|
+
};
|
|
126
|
+
class: {
|
|
127
|
+
type: StringConstructor;
|
|
128
|
+
default: undefined;
|
|
129
|
+
};
|
|
130
|
+
style: {
|
|
131
|
+
type: PropType<CSSProperties>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
onNoticeClose: {
|
|
135
|
+
type: PropType<(key: Key) => void>;
|
|
136
|
+
default: undefined;
|
|
137
|
+
};
|
|
138
|
+
onAllRemoved: {
|
|
139
|
+
type: PropType<(placement: Placement) => void>;
|
|
140
|
+
default: undefined;
|
|
141
|
+
};
|
|
142
|
+
}>> & Readonly<{}>, {
|
|
143
|
+
class: string;
|
|
144
|
+
style: CSSProperties;
|
|
145
|
+
prefixCls: string;
|
|
146
|
+
classNames: NotificationClassNames;
|
|
147
|
+
styles: NotificationStyles;
|
|
148
|
+
components: ComponentsType;
|
|
149
|
+
pauseOnHover: boolean;
|
|
150
|
+
motion: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps) | undefined;
|
|
151
|
+
configList: NotificationListConfig[];
|
|
152
|
+
stack: StackInput;
|
|
153
|
+
onNoticeClose: (key: Key) => void;
|
|
154
|
+
onAllRemoved: (placement: Placement) => void;
|
|
155
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
156
|
+
export default NotificationList;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import Notification from "../Notification.js";
|
|
2
|
+
import { NotificationContext } from "../NotificationProvider.js";
|
|
3
|
+
import useListPosition from "../hooks/useListPosition/index.js";
|
|
4
|
+
import useStack from "../hooks/useStack.js";
|
|
5
|
+
import Content from "./Content.js";
|
|
6
|
+
import { computed, createVNode, defineComponent, inject, isVNode, mergeProps, nextTick, onMounted, ref, shallowRef, toRef, watch } from "vue";
|
|
7
|
+
import { classNames } from "@v-c/util";
|
|
8
|
+
import { getTransitionGroupProps } from "@v-c/util/dist/utils/transition";
|
|
9
|
+
//#region src/NotificationList/index.tsx
|
|
10
|
+
function _isSlot(s) {
|
|
11
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
12
|
+
}
|
|
13
|
+
var noticeSlotKeys = [
|
|
14
|
+
"wrapper",
|
|
15
|
+
"root",
|
|
16
|
+
"icon",
|
|
17
|
+
"section",
|
|
18
|
+
"title",
|
|
19
|
+
"description",
|
|
20
|
+
"actions",
|
|
21
|
+
"close",
|
|
22
|
+
"progress"
|
|
23
|
+
];
|
|
24
|
+
function fillClassNames(classNamesList) {
|
|
25
|
+
return noticeSlotKeys.reduce((merged, key) => {
|
|
26
|
+
merged[key] = classNames(...classNamesList.map((cn) => cn?.[key]));
|
|
27
|
+
return merged;
|
|
28
|
+
}, {});
|
|
29
|
+
}
|
|
30
|
+
function fillStyles(stylesList) {
|
|
31
|
+
return noticeSlotKeys.reduce((merged, key) => {
|
|
32
|
+
merged[key] = Object.assign({}, ...stylesList.map((s) => s?.[key]));
|
|
33
|
+
return merged;
|
|
34
|
+
}, {});
|
|
35
|
+
}
|
|
36
|
+
var NotificationList = /* @__PURE__ */ defineComponent({
|
|
37
|
+
name: "NotificationList",
|
|
38
|
+
inheritAttrs: false,
|
|
39
|
+
props: {
|
|
40
|
+
configList: {
|
|
41
|
+
type: Array,
|
|
42
|
+
default: () => []
|
|
43
|
+
},
|
|
44
|
+
prefixCls: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "vc-notification"
|
|
47
|
+
},
|
|
48
|
+
placement: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: true
|
|
51
|
+
},
|
|
52
|
+
pauseOnHover: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: void 0
|
|
55
|
+
},
|
|
56
|
+
classNames: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default: void 0
|
|
59
|
+
},
|
|
60
|
+
styles: {
|
|
61
|
+
type: Object,
|
|
62
|
+
default: void 0
|
|
63
|
+
},
|
|
64
|
+
components: {
|
|
65
|
+
type: Object,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
stack: {
|
|
69
|
+
type: [Boolean, Object],
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
motion: {
|
|
73
|
+
type: [Object, Function],
|
|
74
|
+
default: void 0
|
|
75
|
+
},
|
|
76
|
+
class: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
style: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
84
|
+
onNoticeClose: {
|
|
85
|
+
type: Function,
|
|
86
|
+
default: void 0
|
|
87
|
+
},
|
|
88
|
+
onAllRemoved: {
|
|
89
|
+
type: Function,
|
|
90
|
+
default: void 0
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
setup(props, { attrs }) {
|
|
94
|
+
const ctx = inject(NotificationContext, ref({}));
|
|
95
|
+
const keys = computed(() => props.configList.map((config) => ({
|
|
96
|
+
config,
|
|
97
|
+
key: String(config.key)
|
|
98
|
+
})));
|
|
99
|
+
const placementMotion = computed(() => {
|
|
100
|
+
if (typeof props.motion === "function") return props.motion(props.placement);
|
|
101
|
+
return props.motion;
|
|
102
|
+
});
|
|
103
|
+
const motionGroupProps = computed(() => {
|
|
104
|
+
const motionVal = placementMotion.value;
|
|
105
|
+
if (!motionVal) return {};
|
|
106
|
+
if (motionVal.name) return getTransitionGroupProps(motionVal.name, motionVal);
|
|
107
|
+
return { ...motionVal };
|
|
108
|
+
});
|
|
109
|
+
const [stackEnabled, stackParams] = useStack(toRef(props, "stack"));
|
|
110
|
+
const listHovering = shallowRef(false);
|
|
111
|
+
const expanded = computed(() => stackEnabled.value && (listHovering.value || keys.value.length <= stackParams.value.threshold));
|
|
112
|
+
const stackPosition = computed(() => {
|
|
113
|
+
if (!stackEnabled.value || expanded.value) return;
|
|
114
|
+
return {
|
|
115
|
+
offset: stackParams.value.offset,
|
|
116
|
+
threshold: stackParams.value.threshold
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const gap = shallowRef(0);
|
|
120
|
+
const contentRef = shallowRef(null);
|
|
121
|
+
const [notificationPosition, setNodeSize, totalHeight, topNoticeHeight, topNoticeWidth] = useListPosition(computed(() => props.configList), stackPosition, gap);
|
|
122
|
+
const hasConfigList = computed(() => keys.value.length > 0);
|
|
123
|
+
function syncGap() {
|
|
124
|
+
const node = contentRef.value?.nativeElement;
|
|
125
|
+
if (!node) return;
|
|
126
|
+
const { gap: cssGap, rowGap } = window.getComputedStyle(node);
|
|
127
|
+
const next = Number.parseFloat(rowGap || cssGap) || 0;
|
|
128
|
+
if (next !== gap.value) gap.value = next;
|
|
129
|
+
}
|
|
130
|
+
onMounted(syncGap);
|
|
131
|
+
watch(hasConfigList, () => {
|
|
132
|
+
nextTick(syncGap);
|
|
133
|
+
});
|
|
134
|
+
function checkAllClosed() {
|
|
135
|
+
if (!props.placement) return;
|
|
136
|
+
if (keys.value.length === 0) props.onAllRemoved?.(props.placement);
|
|
137
|
+
}
|
|
138
|
+
return () => {
|
|
139
|
+
let _slot;
|
|
140
|
+
const { prefixCls = "vc-notification", placement, classNames: classNames$1, styles, components, pauseOnHover, class: className, style, onNoticeClose } = props;
|
|
141
|
+
const listPrefixCls = `${prefixCls}-list`;
|
|
142
|
+
const ctxClassNames = ctx.value?.classNames;
|
|
143
|
+
const renderItems = () => keys.value.map(({ config }) => {
|
|
144
|
+
const { key, placement: itemPlacement, onClose: configOnClose, ...notificationConfig } = config;
|
|
145
|
+
const strKey = String(key);
|
|
146
|
+
const dataIndex = keys.value.findIndex((item) => item.key === strKey);
|
|
147
|
+
const notificationIndex = dataIndex === -1 ? void 0 : keys.value.length - dataIndex - 1;
|
|
148
|
+
const stackInThreshold = stackEnabled.value && notificationIndex !== void 0 && notificationIndex < stackParams.value.threshold;
|
|
149
|
+
return createVNode(Notification, mergeProps(notificationConfig, {
|
|
150
|
+
"key": strKey,
|
|
151
|
+
"ref": (el) => {
|
|
152
|
+
setNodeSize(strKey, el?.nativeElement ?? null);
|
|
153
|
+
},
|
|
154
|
+
"prefixCls": prefixCls,
|
|
155
|
+
"class": classNames(ctxClassNames?.notice, config.class),
|
|
156
|
+
"classNames": fillClassNames([classNames$1, config.classNames]),
|
|
157
|
+
"styles": fillStyles([styles, config.styles]),
|
|
158
|
+
"components": {
|
|
159
|
+
...components,
|
|
160
|
+
...config.components
|
|
161
|
+
},
|
|
162
|
+
"hovering": stackEnabled.value && listHovering.value,
|
|
163
|
+
"pauseOnHover": config.pauseOnHover ?? pauseOnHover,
|
|
164
|
+
"offset": notificationPosition.value.get(strKey),
|
|
165
|
+
"notificationIndex": notificationIndex,
|
|
166
|
+
"stackInThreshold": !!stackInThreshold,
|
|
167
|
+
"onClose": () => {
|
|
168
|
+
configOnClose?.();
|
|
169
|
+
onNoticeClose?.(key);
|
|
170
|
+
}
|
|
171
|
+
}), null);
|
|
172
|
+
});
|
|
173
|
+
return createVNode("div", {
|
|
174
|
+
"class": classNames(prefixCls, listPrefixCls, `${prefixCls}-${placement}`, ctxClassNames?.list, className, attrs.class, classNames$1?.list, {
|
|
175
|
+
[`${prefixCls}-stack`]: stackEnabled.value,
|
|
176
|
+
[`${prefixCls}-stack-expanded`]: expanded.value,
|
|
177
|
+
[`${listPrefixCls}-hovered`]: listHovering.value
|
|
178
|
+
}),
|
|
179
|
+
"onMouseenter": () => {
|
|
180
|
+
listHovering.value = true;
|
|
181
|
+
},
|
|
182
|
+
"onMouseleave": () => {
|
|
183
|
+
listHovering.value = false;
|
|
184
|
+
},
|
|
185
|
+
"style": {
|
|
186
|
+
...styles?.list,
|
|
187
|
+
...style
|
|
188
|
+
}
|
|
189
|
+
}, [createVNode(Content, {
|
|
190
|
+
"ref": contentRef,
|
|
191
|
+
"listPrefixCls": listPrefixCls,
|
|
192
|
+
"height": totalHeight.value,
|
|
193
|
+
"topNoticeHeight": topNoticeHeight.value,
|
|
194
|
+
"topNoticeWidth": topNoticeWidth.value,
|
|
195
|
+
"class": classNames$1?.listContent,
|
|
196
|
+
"style": styles?.listContent,
|
|
197
|
+
"motionProps": motionGroupProps.value,
|
|
198
|
+
"onAfterLeave": checkAllClosed
|
|
199
|
+
}, _isSlot(_slot = renderItems()) ? _slot : { default: () => [_slot] })]);
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
//#endregion
|
|
204
|
+
export { NotificationList as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionKey, Ref } from 'vue';
|
|
1
|
+
import { InjectionKey, PropType, Ref } from 'vue';
|
|
2
2
|
export interface NotificationContextProps {
|
|
3
3
|
classNames?: {
|
|
4
4
|
notice?: string;
|
|
@@ -8,3 +8,22 @@ export interface NotificationContextProps {
|
|
|
8
8
|
export declare const NotificationContext: InjectionKey<Ref<NotificationContextProps>>;
|
|
9
9
|
export declare function useNotificationProvider(props: Ref<NotificationContextProps>): Ref<NotificationContextProps, NotificationContextProps>;
|
|
10
10
|
export declare function useNotificationContext(): Ref<{}, {}>;
|
|
11
|
+
declare const NotificationProvider: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
12
|
+
classNames: {
|
|
13
|
+
type: PropType<NotificationContextProps["classNames"]>;
|
|
14
|
+
default: undefined;
|
|
15
|
+
};
|
|
16
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>[] | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
19
|
+
classNames: {
|
|
20
|
+
type: PropType<NotificationContextProps["classNames"]>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
|
+
classNames: {
|
|
25
|
+
notice?: string;
|
|
26
|
+
list?: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
export default NotificationProvider;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { inject, provide, ref } from "vue";
|
|
2
|
-
|
|
1
|
+
import { computed, defineComponent, inject, provide, ref } from "vue";
|
|
2
|
+
//#region src/NotificationProvider.tsx
|
|
3
|
+
var NotificationContext = Symbol("NotificationContext");
|
|
3
4
|
function useNotificationProvider(props) {
|
|
4
5
|
provide(NotificationContext, props);
|
|
5
6
|
return props;
|
|
@@ -7,4 +8,16 @@ function useNotificationProvider(props) {
|
|
|
7
8
|
function useNotificationContext() {
|
|
8
9
|
return inject(NotificationContext, ref({}));
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
var NotificationProvider = /* @__PURE__ */ defineComponent({
|
|
12
|
+
name: "NotificationProvider",
|
|
13
|
+
props: { classNames: {
|
|
14
|
+
type: Object,
|
|
15
|
+
default: void 0
|
|
16
|
+
} },
|
|
17
|
+
setup(props, { slots }) {
|
|
18
|
+
provide(NotificationContext, computed(() => ({ classNames: props.classNames })));
|
|
19
|
+
return () => slots.default?.();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { NotificationContext, NotificationProvider as default, useNotificationContext, useNotificationProvider };
|
package/dist/Notifications.d.ts
CHANGED
|
@@ -1,24 +1,152 @@
|
|
|
1
1
|
import { VueNode } from '@v-c/util/dist/type';
|
|
2
|
-
import { CSSProperties, TransitionGroupProps } from 'vue';
|
|
3
|
-
import {
|
|
2
|
+
import { CSSProperties, PropType, TransitionGroupProps } from 'vue';
|
|
3
|
+
import { ComponentsType, NotificationClassNames, NotificationListConfig, NotificationStyles, Placement, StackInput } from './NotificationList';
|
|
4
|
+
type Key = string | number | symbol;
|
|
4
5
|
export interface NotificationsProps {
|
|
5
6
|
prefixCls?: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
classNames?: NotificationClassNames;
|
|
8
|
+
styles?: NotificationStyles;
|
|
9
|
+
components?: ComponentsType;
|
|
9
10
|
className?: (placement: Placement) => string;
|
|
10
11
|
style?: (placement: Placement) => CSSProperties;
|
|
12
|
+
container?: HTMLElement | ShadowRoot;
|
|
13
|
+
motion?: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps);
|
|
14
|
+
maxCount?: number;
|
|
15
|
+
pauseOnHover?: boolean;
|
|
16
|
+
stack?: StackInput;
|
|
11
17
|
onAllRemoved?: VoidFunction;
|
|
12
|
-
stack?: StackConfig;
|
|
13
18
|
renderNotifications?: (node: VueNode, info: {
|
|
14
19
|
prefixCls: string;
|
|
15
20
|
key: Key;
|
|
16
21
|
}) => VueNode;
|
|
17
22
|
}
|
|
18
23
|
export interface NotificationsRef {
|
|
19
|
-
open: (config:
|
|
24
|
+
open: (config: NotificationListConfig) => void;
|
|
20
25
|
close: (key: Key) => void;
|
|
21
26
|
destroy: () => void;
|
|
22
27
|
}
|
|
23
|
-
declare const Notifications: import('vue').
|
|
28
|
+
declare const Notifications: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
29
|
+
prefixCls: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
classNames: {
|
|
34
|
+
type: PropType<NotificationClassNames>;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
styles: {
|
|
38
|
+
type: PropType<NotificationStyles>;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
components: {
|
|
42
|
+
type: PropType<ComponentsType>;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
className: {
|
|
46
|
+
type: PropType<(p: Placement) => string>;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
style: {
|
|
50
|
+
type: PropType<(p: Placement) => CSSProperties>;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
container: {
|
|
54
|
+
type: PropType<HTMLElement | ShadowRoot>;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
motion: {
|
|
58
|
+
type: PropType<NotificationsProps["motion"]>;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
61
|
+
maxCount: {
|
|
62
|
+
type: NumberConstructor;
|
|
63
|
+
default: undefined;
|
|
64
|
+
};
|
|
65
|
+
pauseOnHover: {
|
|
66
|
+
type: BooleanConstructor;
|
|
67
|
+
default: undefined;
|
|
68
|
+
};
|
|
69
|
+
stack: {
|
|
70
|
+
type: PropType<StackInput>;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
onAllRemoved: {
|
|
74
|
+
type: PropType<VoidFunction>;
|
|
75
|
+
default: undefined;
|
|
76
|
+
};
|
|
77
|
+
renderNotifications: {
|
|
78
|
+
type: PropType<NotificationsProps["renderNotifications"]>;
|
|
79
|
+
default: undefined;
|
|
80
|
+
};
|
|
81
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
82
|
+
prefixCls: {
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
classNames: {
|
|
87
|
+
type: PropType<NotificationClassNames>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
styles: {
|
|
91
|
+
type: PropType<NotificationStyles>;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
components: {
|
|
95
|
+
type: PropType<ComponentsType>;
|
|
96
|
+
default: undefined;
|
|
97
|
+
};
|
|
98
|
+
className: {
|
|
99
|
+
type: PropType<(p: Placement) => string>;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
style: {
|
|
103
|
+
type: PropType<(p: Placement) => CSSProperties>;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
container: {
|
|
107
|
+
type: PropType<HTMLElement | ShadowRoot>;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
motion: {
|
|
111
|
+
type: PropType<NotificationsProps["motion"]>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
maxCount: {
|
|
115
|
+
type: NumberConstructor;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
pauseOnHover: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
default: undefined;
|
|
121
|
+
};
|
|
122
|
+
stack: {
|
|
123
|
+
type: PropType<StackInput>;
|
|
124
|
+
default: undefined;
|
|
125
|
+
};
|
|
126
|
+
onAllRemoved: {
|
|
127
|
+
type: PropType<VoidFunction>;
|
|
128
|
+
default: undefined;
|
|
129
|
+
};
|
|
130
|
+
renderNotifications: {
|
|
131
|
+
type: PropType<NotificationsProps["renderNotifications"]>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
}>> & Readonly<{}>, {
|
|
135
|
+
style: (p: Placement) => CSSProperties;
|
|
136
|
+
prefixCls: string;
|
|
137
|
+
classNames: NotificationClassNames;
|
|
138
|
+
styles: NotificationStyles;
|
|
139
|
+
components: ComponentsType;
|
|
140
|
+
pauseOnHover: boolean;
|
|
141
|
+
container: HTMLElement | ShadowRoot;
|
|
142
|
+
motion: TransitionGroupProps | ((placement: Placement) => TransitionGroupProps) | undefined;
|
|
143
|
+
stack: StackInput;
|
|
144
|
+
onAllRemoved: VoidFunction;
|
|
145
|
+
renderNotifications: ((node: VueNode, info: {
|
|
146
|
+
prefixCls: string;
|
|
147
|
+
key: Key;
|
|
148
|
+
}) => VueNode) | undefined;
|
|
149
|
+
className: (p: Placement) => string;
|
|
150
|
+
maxCount: number;
|
|
151
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
24
152
|
export default Notifications;
|