primevue-mirror/components/lib/toast/Toast.d.ts

369 lines
9.4 KiB
TypeScript
Raw Normal View History

2023-03-01 13:06:17 +00:00
/**
*
* Toast is used to display messages in an overlay.
*
* [Live Demo](https://www.primevue.org/toast/)
*
* @module toast
*
*/
2024-05-02 10:35:32 +00:00
import { ButtonHTMLAttributes, TransitionProps, VNode } from 'vue';
2024-05-02 13:15:26 +00:00
import { ComponentHooks } from '../basecomponent';
2023-09-05 08:50:46 +00:00
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, DesignToken, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
2022-09-06 12:03:37 +00:00
export declare type ToastPassThroughOptionType = ToastPassThroughAttributes | ((options: ToastPassThroughMethodOptions) => ToastPassThroughAttributes | string) | string | null | undefined;
2023-04-28 13:39:19 +00:00
2023-08-02 14:07:22 +00:00
export declare type ToastPassThroughTransitionType = TransitionProps | ((options: ToastPassThroughMethodOptions) => TransitionProps) | undefined;
2023-04-28 13:39:19 +00:00
/**
* Custom passthrough(pt) option method.
*/
export interface ToastPassThroughMethodOptions {
/**
* Defines instance.
*/
2023-07-06 12:01:33 +00:00
instance: any;
/**
* Defines valid properties.
*/
2023-04-28 13:39:19 +00:00
props: ToastProps;
/**
* Defines current inline state.
*/
2023-04-28 13:39:19 +00:00
state: ToastState;
/**
* Defines valid attributes.
*/
attrs: any;
2023-09-05 08:50:46 +00:00
/**
* Defines parent options.
*/
parent: any;
/**
2023-09-05 08:50:46 +00:00
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
2023-04-28 13:39:19 +00:00
}
/**
* Custom passthrough(pt) options.
* @see {@link ToastProps.pt}
*/
export interface ToastPassThroughOptions {
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the root's DOM element.
2023-04-28 13:39:19 +00:00
*/
root?: ToastPassThroughOptionType;
2023-05-03 14:14:24 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the message's DOM element.
2023-05-03 14:14:24 +00:00
*/
message?: ToastPassThroughOptionType;
2023-04-28 13:39:19 +00:00
/**
2024-04-30 08:15:34 +00:00
* Used to pass attributes to the message content's DOM element.
2023-04-28 13:39:19 +00:00
*/
2024-04-30 08:15:34 +00:00
messageContent?: ToastPassThroughOptionType;
2023-04-28 13:39:19 +00:00
/**
2024-04-30 08:15:34 +00:00
* Used to pass attributes to the message icon's DOM element.
2023-04-28 13:39:19 +00:00
*/
2024-04-30 08:15:34 +00:00
messageIcon?: ToastPassThroughOptionType;
2023-04-28 13:39:19 +00:00
/**
2024-04-30 08:15:34 +00:00
* Used to pass attributes to the message text's DOM element.
2023-04-28 13:39:19 +00:00
*/
2024-04-30 08:15:34 +00:00
messageText?: ToastPassThroughOptionType;
2023-04-28 13:39:19 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the summary's DOM element.
2023-04-28 13:39:19 +00:00
*/
summary?: ToastPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the detail's DOM element.
2023-04-28 13:39:19 +00:00
*/
detail?: ToastPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the button container's DOM element.
2023-04-28 13:39:19 +00:00
*/
buttonContainer?: ToastPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the button's DOM element.
2024-05-02 10:35:32 +00:00
* @deprecated since v3.30.2. Use 'closeButton' option.
2023-04-28 13:39:19 +00:00
*/
2024-05-02 10:35:32 +00:00
button?: ToastPassThroughOptionType;
2023-07-19 11:34:12 +00:00
/**
2024-05-02 10:35:32 +00:00
* Used to pass attributes to the button's DOM element.
2023-04-28 13:39:19 +00:00
*/
2024-05-02 10:35:32 +00:00
closeButton?: ToastPassThroughOptionType;
2023-07-19 11:34:12 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the button icon's DOM element.
2023-07-19 11:34:12 +00:00
*/
closeIcon?: ToastPassThroughOptionType;
2023-07-06 11:09:01 +00:00
/**
2023-11-07 06:16:39 +00:00
* Used to manage all lifecycle hooks.
2023-07-06 11:09:01 +00:00
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
2023-08-02 12:02:57 +00:00
/**
* Used to control Vue Transition API.
*/
2023-08-02 14:07:22 +00:00
transition?: ToastPassThroughTransitionType;
2023-04-28 13:39:19 +00:00
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ToastPassThroughAttributes {
[key: string]: any;
}
2023-03-07 08:00:47 +00:00
/**
* Defines message options in Toast component.
*/
2022-09-06 12:03:37 +00:00
export interface ToastMessageOptions {
/**
* Severity level of the message.
2023-03-08 10:51:52 +00:00
* @defaultValue info
2022-09-06 12:03:37 +00:00
*/
severity?: 'success' | 'info' | 'warn' | 'error' | 'secondary' | 'contrast' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Summary content of the message.
*/
summary?: string | undefined;
/**
* Detail content of the message.
*/
detail?: any | undefined;
/**
* Whether the message can be closed manually using the close icon.
2023-03-03 08:18:55 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
closable?: boolean | undefined;
/**
* Delay in milliseconds to close the message automatically.
*/
life?: number | undefined;
/**
* Key of the Toast to display the message.
*/
group?: string | undefined;
/**
* Style class of the message.
*/
styleClass?: any;
/**
* Style class of the content.
*/
contentStyleClass?: any;
}
2023-03-07 08:00:47 +00:00
/**
* Defines breakpoints type in Toast component.
*/
2022-09-06 12:03:37 +00:00
export interface ToastBreakpointsType {
/**
* Breakpoint for responsive mode.
*
* Example:
*
* <Toast :breakpoints="{'960px': { width: '75vw', ... }" ... />
*
*/
[key: string]: any;
}
2023-04-28 13:39:19 +00:00
/**
* Defines current inline state in Toast component.
*/
export interface ToastState {
/**
* Current messages.
*/
messages: any[];
}
2023-03-01 13:06:17 +00:00
/**
* Defines valid properties in Toast component.
*/
2022-09-06 12:03:37 +00:00
export interface ToastProps {
/**
* Unique identifier of a message group.
*/
group?: string | undefined;
/**
* Position of the toast in viewport.
2023-03-01 13:06:17 +00:00
* @defaultValue top-right
2022-09-06 12:03:37 +00:00
*/
2023-03-01 13:06:17 +00:00
position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Whether to automatically manage layering.
2023-03-01 13:06:17 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
autoZIndex?: boolean | undefined;
/**
* Base zIndex value to use in layering.
2023-03-01 13:06:17 +00:00
* @defaultValue 0
2022-09-06 12:03:37 +00:00
*/
baseZIndex?: number | undefined;
/**
* Object literal to define styles per screen size.
* @see ToastBreakpointsType
*/
breakpoints?: ToastBreakpointsType;
2022-12-08 11:04:25 +00:00
/**
* Icon to display in the toast close button.
* @deprecated since v3.27.0. Use 'closeicon' slot.
2022-12-08 11:04:25 +00:00
*/
closeIcon?: string | undefined;
/**
* Icon to display in the toast with info severity.
* @deprecated since v3.27.0. Use 'icon' slot.
2022-12-08 11:04:25 +00:00
*/
infoIcon?: string | undefined;
/**
* Icon to display in the toast with warn severity.
* @deprecated since v3.27.0. Use 'icon' slot.
*/
warnIcon?: string | undefined;
/**
* Icon to display in the toast with error severity.
* @deprecated since v3.27.0. Use 'icon' slot.
*/
errorIcon?: string | undefined;
/**
* Icon to display in the toast with success severity.
* @deprecated since v3.27.0. Use 'icon' slot.
*/
successIcon?: string | undefined;
2022-12-08 11:04:25 +00:00
/**
2024-05-02 10:35:32 +00:00
* Used to pass all properties of the HTMLButtonElement to the close button.
* @deprecated since v3.26.0. Use 'pt' property.
2022-12-08 11:04:25 +00:00
*/
2024-05-02 10:35:32 +00:00
closeButtonProps?: ButtonHTMLAttributes | undefined;
/**
* Used to access message options.
* @type {ToastMessageOptions}
*/
message?: ToastMessageOptions;
/**
* It generates scoped CSS variables using design tokens for the component.
*/
dt?: DesignToken<any>;
2023-04-28 13:39:19 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to DOM elements inside the component.
2023-04-28 13:39:19 +00:00
* @type {ToastPassThroughOptions}
*/
pt?: PassThrough<ToastPassThroughOptions>;
2023-09-05 08:50:46 +00:00
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
2023-05-25 21:53:07 +00:00
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
2022-09-06 12:03:37 +00:00
}
2023-03-07 08:00:47 +00:00
/**
* Defines valid slot in Toast component.
*/
2022-09-06 12:03:37 +00:00
export interface ToastSlots {
/**
* Custom message template.
* @param {Object} scope - message slot's params.
*/
2023-03-01 13:06:17 +00:00
message(scope: {
2022-09-14 11:26:01 +00:00
/**
* Message of the component
*/
message: any;
2023-03-01 13:06:17 +00:00
}): VNode[];
/**
2024-05-06 11:07:53 +00:00
* @deprecated since v4.0. Use 'messageicon' slot instead.
* Custom message icon template.
* @param {Object} scope - message icon slot's params.
*/
icon(scope: {
2024-05-06 11:07:53 +00:00
/**
* Style class of the message icon
*/
class: any;
}): VNode[];
/**
* Custom message icon template.
* @param {Object} scope - message icon slot's params.
*/
messageicon(scope: {
/**
* Style class of the icon
*/
class: any;
}): VNode[];
/**
* Custom close icon template.
* @param {Object} scope - close icon slot's params.
*/
closeicon(scope: {
/**
* Style class of the close icon
*/
class: any;
}): VNode[];
/**
* Custom container slot.
* @param {Object} scope - container slot's params.
*/
container(scope: {
/**
* Message of the component
*/
message: any;
/**
* Close toast function
* @deprecated since v3.39.0. Use 'closeCallback' property instead.
*/
onClose: () => void;
/**
* Close sidebar function.
*/
closeCallback: () => void;
}): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-07 08:00:47 +00:00
/**
* Defines valid emits in Toast component.
*/
export interface ToastEmits {
/**
* Callback to invoke when the toast is closed.
* @param {ToastMessageOptions} message - Toast message.
*/
close(message: ToastMessageOptions): void;
/**
* Callback to invoke when the toast's timeout is over.
* @param {ToastMessageOptions} message - Toast message.
*/
'life-end'(message: ToastMessageOptions): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 13:06:17 +00:00
/**
* **PrimeVue - Toast**
*
* _Toast is used to display messages in an overlay._
*
* [Live Demo](https://www.primevue.org/toast/)
* --- ---
2023-03-03 10:55:20 +00:00
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
2023-03-01 13:06:17 +00:00
*
* @group Component
*
*/
2022-09-14 11:26:01 +00:00
declare class Toast extends ClassComponent<ToastProps, ToastSlots, ToastEmits> {}
2022-09-06 12:03:37 +00:00
declare module 'vue' {
export interface GlobalComponents {
2022-09-14 11:26:01 +00:00
Toast: GlobalComponentConstructor<Toast>;
2022-09-06 12:03:37 +00:00
}
}
export default Toast;