maz-ui
Version:
A standalone components library for Vue.Js 3 & Nuxt.Js 3
81 lines (80 loc) • 2.32 kB
TypeScript
import type { Ref } from 'vue';
import type { Props } from '../MazBtn.vue';
import type { Size } from './../types';
export interface DialogState {
id: string;
isActive: boolean;
resolve: (value: unknown) => void;
reject?: (reason?: unknown) => void;
}
export interface DialogButton extends Props {
text?: string;
size?: Size;
}
export interface ActionButton {
text: string;
action: () => unknown;
}
export interface PromiseButton {
text: string;
type: 'resolve' | 'reject';
response?: unknown;
}
export type DialogCustomButton = Omit<DialogButton, 'type'> & (PromiseButton | ActionButton);
export interface DialogData {
/**
* Dialog title
*/
title?: string;
/**
* Dialog message
*/
message?: string;
/**
* Dialog cancel text
* @default 'Cancel'
*/
cancelText?: string;
/**
* Dialog cancel button
* @default { text: 'Cancel', color: 'danger', outline: true }`
*/
cancelButton?: false | DialogButton;
/**
* Dialog confirm text
* @default 'Confirm'
*/
confirmText?: string;
/**
* Dialog confirm button
* @default { text: 'Confirm', color: 'success' }
*/
confirmButton?: false | DialogButton;
/**
* This is a list of custom buttons that will replace the default confirm and cancel buttons
*/
buttons?: DialogCustomButton[];
}
export declare const defaultData: {
cancelText: string;
confirmText: string;
cancelButton: {
text: string;
color: "danger";
};
confirmButton: {
text: string;
color: "success";
};
};
declare function showDialogAndWaitChoice(identifier: string, callback?: () => unknown): Promise<unknown>;
declare function removeDialogFromState(identifier: string): DialogState[];
export declare function useMazDialogPromise(): {
data: Ref<DialogData, DialogData>;
dialogState: Ref<DialogState[], DialogState[]>;
showDialogAndWaitChoice: typeof showDialogAndWaitChoice;
removeDialogFromState: typeof removeDialogFromState;
rejectDialog: (currentDialog: DialogState, response?: unknown, action?: () => unknown) => Promise<void>;
resolveDialog: (currentDialog: DialogState, response?: unknown, action?: () => unknown) => Promise<void>;
};
export {};