mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { TeleportProps } from 'vue';
|
|
|
|
type ToastMessage = string | number;
|
|
type ToastType = 'text' | 'loading' | 'success' | 'fail' | 'html';
|
|
type ToastPosition = 'top' | 'middle' | 'bottom';
|
|
type ToastLoadingType = 'circular' | 'spinner';
|
|
|
|
export type ToastOptions = {
|
|
icon?: string;
|
|
type?: ToastType;
|
|
mask?: boolean;
|
|
message?: ToastMessage;
|
|
onClose?: () => void;
|
|
onOpened?: () => void;
|
|
overlay?: boolean;
|
|
duration?: number;
|
|
teleport?: TeleportProps['to'];
|
|
position?: ToastPosition;
|
|
className?: any;
|
|
transition?: string;
|
|
iconPrefix?: string;
|
|
loadingType?: ToastLoadingType;
|
|
forbidClick?: boolean;
|
|
closeOnClick?: boolean;
|
|
overlayClass?: any;
|
|
overlayStyle?: Record<string, any>;
|
|
closeOnClickOverlay?: boolean;
|
|
};
|
|
|
|
export interface VanToast {
|
|
type: ToastType;
|
|
position: ToastPosition;
|
|
loadingType: ToastLoadingType;
|
|
forbidClick: boolean;
|
|
message: ToastMessage;
|
|
clear(): void;
|
|
}
|
|
|
|
export interface Toast {
|
|
(message: ToastOptions | ToastMessage, options?: ToastOptions): VanToast;
|
|
loading(options?: ToastOptions | ToastMessage): VanToast;
|
|
success(options?: ToastOptions | ToastMessage): VanToast;
|
|
fail(options?: ToastOptions | ToastMessage): VanToast;
|
|
clear(all?: boolean): void;
|
|
install(): void;
|
|
setDefaultOptions(
|
|
type: ToastType | ToastOptions,
|
|
options?: ToastOptions
|
|
): void;
|
|
resetDefaultOptions(options?: string): void;
|
|
allowMultiple(allow: boolean): void;
|
|
}
|
|
|
|
declare module '@vue/runtime-core' {
|
|
interface ComponentCustomProperties {
|
|
$toast: Toast;
|
|
}
|
|
}
|
|
|
|
export const Toast: Toast;
|