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
105 lines
2.1 KiB
TypeScript
105 lines
2.1 KiB
TypeScript
import { buildProps, definePropType, iconPropType } from '@element-plus/utils'
|
|
import type { VNode, ExtractPropTypes } from 'vue'
|
|
|
|
export const messageTypes = ['success', 'info', 'warning', 'error'] as const
|
|
|
|
export interface MessageConfigContext {
|
|
max?: number
|
|
}
|
|
|
|
export const messageProps = buildProps({
|
|
customClass: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
center: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
dangerouslyUseHTMLString: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
duration: {
|
|
type: Number,
|
|
default: 3000,
|
|
},
|
|
icon: {
|
|
type: iconPropType,
|
|
default: '',
|
|
},
|
|
id: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
message: {
|
|
type: definePropType<string | VNode>([String, Object]),
|
|
default: '',
|
|
},
|
|
onClose: {
|
|
type: definePropType<() => void>(Function),
|
|
required: false,
|
|
},
|
|
showClose: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
type: {
|
|
type: String,
|
|
values: messageTypes,
|
|
default: 'info',
|
|
},
|
|
offset: {
|
|
type: Number,
|
|
default: 20,
|
|
},
|
|
zIndex: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
grouping: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
repeatNum: {
|
|
type: Number,
|
|
default: 1,
|
|
},
|
|
} as const)
|
|
export type MessageProps = ExtractPropTypes<typeof messageProps>
|
|
|
|
export const messageEmits = {
|
|
destroy: () => true,
|
|
}
|
|
export type MessageEmits = typeof messageEmits
|
|
|
|
export type MessageOptions = Omit<MessageProps, 'id'> & {
|
|
appendTo?: HTMLElement | string
|
|
}
|
|
export type MessageOptionsTyped = Omit<MessageOptions, 'type'>
|
|
|
|
export interface MessageHandle {
|
|
close: () => void
|
|
}
|
|
|
|
export type MessageParams = Partial<MessageOptions> | string | VNode
|
|
export type MessageParamsTyped = Partial<MessageOptionsTyped> | string | VNode
|
|
|
|
export type MessageFn = ((options?: MessageParams) => MessageHandle) & {
|
|
closeAll(): void
|
|
}
|
|
export type MessageTypedFn = (options?: MessageParamsTyped) => MessageHandle
|
|
|
|
export interface Message extends MessageFn {
|
|
success: MessageTypedFn
|
|
warning: MessageTypedFn
|
|
info: MessageTypedFn
|
|
error: MessageTypedFn
|
|
}
|
|
|
|
type MessageQueueItem = {
|
|
vm: VNode
|
|
}
|
|
|
|
export type MessageQueue = MessageQueueItem[]
|