message-next
v0.1.5
Published
Readme
Message-next
message-next is a TypeScript library that provides convenient methods for displaying alert messages using SweetAlert2.
Installation
You can install message-next via npm:
npm install message-nextUsage
Import message-next in your TypeScript file:
import {
confirmationDeleteReturn,
success,
error,
info,
confirmationReturn,
} from 'message-next';
confirmationDeleteReturn Displays a confirmation dialog for delete actions.
const deleteConfirmed = await confirmationDeleteReturn('Exclusão', 'Deseja excluir este registro?');
if (!deleteConfirmed) {
return false;
} success Displays a success message.
success('Operação realizada com sucesso');error Displays an error message.
error('Ocorreu um erro ao realizar a operação');info Displays an information message.
info('Este é um aviso informativo');confirmationReturn Displays a generic confirmation dialog.
const confirmed = await confirmationReturn('Confirmação', 'Tem certeza?');
if (confirmed) {
// Proceed with the action
} else {
// Cancelled action
}
API
confirmationDeleteReturn(title?: string, msg?: string): Promise
title (optional): Title for the confirmation dialog (default: 'Exclusão').
msg (optional): Message for the confirmation dialog (default: 'Deseja excluir este registro?').
Returns a promise that resolves to true if the user confirms, false if cancelled.
success(msg: string, title?: string): void
msg: Success message to display.
title (optional): Title for the success alert (default: 'Sucesso').
error(msg: string, title?: string): void
msg: Error message to display.
title (optional): Title for the error alert (default: 'Erro').
info(msg: string, title?: string): void
msg: Information message to display.
title (optional): Title for the info alert (default: 'Aviso').
confirmationReturn(title?: string, msg?: string): Promise
title (optional): Title for the confirmation dialog (default: '').
msg (optional): Message for the confirmation dialog (default: '').
Returns a promise that resolves to true if the user confirms, false if cancelled.
Dependencies
SweetAlert2 is used for displaying the alert dialogs.
