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
|
|
|
|
*
|
|
|
|
*/
|
2023-08-02 14:07:22 +00:00
|
|
|
import { ButtonHTMLAttributes, TransitionProps, VNode } from 'vue';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2023-08-17 23:51:01 +00:00
|
|
|
import { ClassComponent, GlobalComponentConstructor, PTOptions } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-07-11 22:42:43 +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 {
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-04-28 13:39:19 +00:00
|
|
|
props: ToastProps;
|
|
|
|
state: ToastState;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the container's DOM element.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
container?: ToastPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the content's DOM element.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
content?: ToastPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the icon's DOM element.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
icon?: ToastPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the text's DOM element.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
text?: ToastPassThroughOptionType;
|
|
|
|
/**
|
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.
|
2023-07-19 11:34:12 +00:00
|
|
|
* @deprecated since v3.30.2. Use 'closeButton' option.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
button?: ToastPassThroughOptionType;
|
2023-07-19 11:34:12 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the button's DOM element.
|
2023-07-19 11:34:12 +00:00
|
|
|
*/
|
|
|
|
closeButton?: ToastPassThroughOptionType;
|
2023-04-28 13:39:19 +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
|
|
|
* @deprecated since v3.30.2. Use 'closeIcon' option.
|
2023-04-28 13:39:19 +00:00
|
|
|
*/
|
|
|
|
buttonIcon?: 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-08-01 14:01:12 +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
|
|
|
*/
|
2023-04-14 12:03:58 +00:00
|
|
|
severity?: 'success' | 'info' | 'warn' | 'error' | 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.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'closeicon' slot.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
|
|
|
closeIcon?: string | undefined;
|
|
|
|
/**
|
2023-04-14 12:03:58 +00:00
|
|
|
* Icon to display in the toast with info severity.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'icon' slot.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
2023-04-14 12:03:58 +00:00
|
|
|
infoIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon to display in the toast with warn severity.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'icon' slot.
|
2023-04-14 12:03:58 +00:00
|
|
|
*/
|
|
|
|
warnIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon to display in the toast with error severity.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'icon' slot.
|
2023-04-14 12:03:58 +00:00
|
|
|
*/
|
|
|
|
errorIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Icon to display in the toast with success severity.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'icon' slot.
|
2023-04-14 12:03:58 +00:00
|
|
|
*/
|
|
|
|
successIcon?: string | undefined;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass all properties of the HTMLButtonElement to the close button.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.26.0. Use 'pt' property.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
|
|
|
closeButtonProps?: ButtonHTMLAttributes | undefined;
|
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}
|
|
|
|
*/
|
2023-08-17 23:51:01 +00:00
|
|
|
pt?: PTOptions<ToastPassThroughOptions>;
|
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[];
|
2023-04-11 21:25:24 +00:00
|
|
|
/**
|
|
|
|
* Custom icon template.
|
|
|
|
*/
|
|
|
|
icon(): VNode[];
|
|
|
|
/**
|
|
|
|
* Custom close icon template.
|
|
|
|
*/
|
|
|
|
closeicon(): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-07 08:00:47 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in Toast component.
|
|
|
|
*/
|
2023-03-07 12:36:38 +00:00
|
|
|
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/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Toast: GlobalComponentConstructor<Toast>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Toast;
|