mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* refactor(utils-v2): migrate utils * refactor(utils-v2): migrate utils * refactor(utils-v2): migrate utils * refactor(utils): remove * refactor(utils): rename * refactor(utils): move EVENT_CODE to constants * refactor: remove generic
114 lines
2.3 KiB
TypeScript
114 lines
2.3 KiB
TypeScript
import { buildProps, definePropType } from '@element-plus/utils'
|
|
|
|
import type { VNode, ExtractPropTypes } from 'vue'
|
|
|
|
export const notificationTypes = [
|
|
'success',
|
|
'info',
|
|
'warning',
|
|
'error',
|
|
] as const
|
|
|
|
export const notificationProps = buildProps({
|
|
customClass: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
dangerouslyUseHTMLString: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
duration: {
|
|
type: Number,
|
|
default: 4500,
|
|
},
|
|
icon: {
|
|
type: definePropType<string | Comment>([String, Object]),
|
|
default: '',
|
|
},
|
|
id: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
message: {
|
|
type: definePropType<string | VNode>([String, Object]),
|
|
default: '',
|
|
},
|
|
offset: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
onClick: {
|
|
type: definePropType<() => void>(Function),
|
|
default: () => undefined,
|
|
},
|
|
onClose: {
|
|
type: definePropType<() => void>(Function),
|
|
required: true,
|
|
},
|
|
position: {
|
|
type: String,
|
|
values: ['top-right', 'top-left', 'bottom-right', 'bottom-left'],
|
|
default: 'top-right',
|
|
},
|
|
showClose: {
|
|
type: Boolean,
|
|
default: true,
|
|
},
|
|
title: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
type: {
|
|
type: String,
|
|
values: [...notificationTypes, ''],
|
|
default: '',
|
|
},
|
|
zIndex: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
} as const)
|
|
export type NotificationProps = ExtractPropTypes<typeof notificationProps>
|
|
|
|
export const notificationEmits = {
|
|
destroy: () => true,
|
|
}
|
|
export type NotificationEmits = typeof notificationEmits
|
|
|
|
export type NotificationOptions = Omit<NotificationProps, 'id'> & {
|
|
appendTo?: HTMLElement | string
|
|
}
|
|
export type NotificationOptionsTyped = Omit<NotificationOptions, 'type'>
|
|
|
|
export interface NotificationHandle {
|
|
close: () => void
|
|
}
|
|
|
|
export type NotificationParams = Partial<NotificationOptions> | string | VNode
|
|
export type NotificationParamsTyped =
|
|
| Partial<NotificationOptionsTyped>
|
|
| string
|
|
| VNode
|
|
|
|
export type NotifyFn = ((
|
|
options?: NotificationParams
|
|
) => NotificationHandle) & { closeAll: () => void }
|
|
|
|
export type NotifyTypedFn = (
|
|
options?: NotificationParamsTyped
|
|
) => NotificationHandle
|
|
|
|
export interface Notify extends NotifyFn {
|
|
success: NotifyTypedFn
|
|
warning: NotifyTypedFn
|
|
error: NotifyTypedFn
|
|
info: NotifyTypedFn
|
|
}
|
|
|
|
export interface NotificationQueueItem {
|
|
vm: VNode
|
|
}
|
|
|
|
export type NotificationQueue = NotificationQueueItem[]
|