-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlert.props.ts
50 lines (38 loc) · 1.06 KB
/
Alert.props.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Component, VNode } from 'vue';
export type AlertProps<T = unknown> = {
type?: 'success' | 'error' | 'telegram' | string;
// The "content" property can be a string or another component, and it will receive the "context" prop.
content?: string | Component;
// The "closable" property determines whether the alert can be closed or not.
closable?: boolean;
// You can pass data to the "content" as a component through the "data" property.
data?: T;
};
// helper type to get correct context inside your component in alert
/*
Usage:
CustomAlert.vue:
<template>
{{ context.data.sayHello ? 'Hello' : 'Bye' }}
<button @click="context.close">close</button>
</template>
type Data = {
sayHello?: boolean;
};
defineProps<AlertContextProps<Date>>();
*/
export type AlertContextProps<T = unknown> = {
context: {
close: () => void;
data: T;
};
};
export type AlertSlots = {
default?: (props: {}) => ReadonlyArray<VNode>;
};
export type AlertEmits = {
(e: 'close'): void;
};
export const AlertDefaultProps = {
type: 'success',
} as const;