@tplc/wot
Version:
185 lines (184 loc) • 3.71 kB
TypeScript
import type { ExtractPropTypes, PropType } from 'vue'
import type { LoadingType } from '../wd-loading/types'
export type ToastIconType = 'success' | 'error' | 'warning' | 'loading' | 'info'
export type ToastPositionType = 'top' | 'middle-top' | 'middle' | 'bottom'
export type ToastDirection = 'vertical' | 'horizontal'
export type ToastLoadingType = LoadingType
export type ToastOptions = {
msg?: string
duration?: number
direction?: ToastDirection
iconName?: ToastIconType
iconSize?: number
loadingType?: ToastLoadingType
loadingColor?: string
loadingSize?: number
iconColor?: string
position?: ToastPositionType
show?: boolean
zIndex?: number
/**
* 是否存在遮罩层
*/
cover?: boolean
/**
* 图标类名
*/
iconClass?: string
/**
* 类名前缀,用于使用自定义图标
*/
classPrefix?: string
/**
* 完全展示后的回调函数
*/
opened?: () => void
/**
* 完全关闭时的回调函数
*/
closed?: () => void
}
export interface Toast {
show(toastOptions: ToastOptions | string): void
success(toastOptions: ToastOptions | string): void
error(toastOptions: ToastOptions | string): void
info(toastOptions: ToastOptions | string): void
warning(toastOptions: ToastOptions | string): void
loading(toastOptions: ToastOptions | string): void
close(): void
}
export declare const toastProps: {
/**
* 选择器
* @type {string}
* @default ''
*/
selector: {
type: PropType<string>
default: string
}
/**
* 提示信息
* @type {string}
* @default ''
*/
msg: {
type: StringConstructor
default: string
}
/**
* 排列方向
* @type {'vertical' | 'horizontal'}
* @default 'horizontal'
*/
direction: {
type: PropType<ToastDirection>
default: ToastDirection
}
/**
* 图标名称
* @type {'success' | 'error' | 'warning' | 'loading' | 'info'}
* @default ''
*/
iconName: {
type: PropType<ToastIconType>
default: string
}
/**
* 图标大小
* @type {number}
*/
iconSize: NumberConstructor
/**
* 加载类型
* @type {'outline' | 'ring'}
* @default 'outline'
*/
loadingType: {
type: PropType<LoadingType>
default: LoadingType
}
/**
* 加载颜色
* @type {string}
* @default '#4D80F0'
*/
loadingColor: {
type: StringConstructor
default: string
}
/**
* 加载大小
* @type {number}
*/
loadingSize: NumberConstructor
/**
* 图标颜色
* @type {string}
*/
iconColor: StringConstructor
/**
* 位置
* @type {'top' | 'middle-top' | 'middle' | 'bottom'}
* @default 'middle-top'
*/
position: {
type: PropType<ToastPositionType>
default: ToastPositionType
}
/**
* 层级
* @type {number}
* @default 100
*/
zIndex: {
type: NumberConstructor
default: number
}
/**
* 是否存在遮罩层
* @type {boolean}
* @default false
*/
cover: {
type: BooleanConstructor
default: boolean
}
/**
* 图标类名
* @type {string}
* @default ''
*/
iconClass: {
type: StringConstructor
default: string
}
/**
* 类名前缀
* @type {string}
* @default 'wd-icon'
*/
classPrefix: {
type: StringConstructor
default: string
}
/**
* 完全展示后的回调函数
* @type {Function}
*/
opened: PropType<() => void>
/**
* 完全关闭时的回调函数
* @type {Function}
*/
closed: PropType<() => void>
customStyle: {
type: PropType<string>
default: string
}
customClass: {
type: PropType<string>
default: string
}
}
export type ToastProps = ExtractPropTypes<typeof toastProps>