diff --git a/components/ModalStack.vue b/components/ModalStack.vue index 3d64d93..d42d747 100644 --- a/components/ModalStack.vue +++ b/components/ModalStack.vue @@ -5,7 +5,7 @@ :z-height="(modalIdx + 1) * 50" :loading="modal.loading" :data="modal.data" - @event="(event: string) => handleCallback(modalIdx, event)" + @event="(event: string, ...args: any[]) => handleCallback(modalIdx, event, args)" />
@@ -13,7 +13,7 @@ diff --git a/composables/modal-stack.ts b/composables/modal-stack.ts index 7ba0c73..f68665d 100644 --- a/composables/modal-stack.ts +++ b/composables/modal-stack.ts @@ -1,10 +1,12 @@ import type { Component } from "vue"; import ConfirmationModal from "../components/ConfirmationModal.vue"; import NotificationModal from "../components/NotificationModal.vue"; +import TextInputModal from "../components/TextInputModal.vue"; export type ModalCallbackType = ( event: ModalEvents[T], - close: () => void + close: () => void, + ...args: any[] ) => Promise | void; export interface ModalStackElement { @@ -18,11 +20,13 @@ export interface ModalStackElement { export enum ModalType { Confirmation, Notification, + TextInput } export type ModalEvents = { [ModalType.Confirmation]: "confirm" | "cancel"; [ModalType.Notification]: "close"; + [ModalType.TextInput]: "cancel" | "submit" }; export type ModalDatas = { @@ -36,11 +40,19 @@ export type ModalDatas = { description: string; buttonText?: string; }; + [ModalType.TextInput]: { + title: string, + description: string, + buttonText?: string, + dft?: string, + placeholder?: string, + } }; const modalComponents: { [key in ModalType]: Component } = { [ModalType.Confirmation]: ConfirmationModal, [ModalType.Notification]: NotificationModal, + [ModalType.TextInput]: TextInputModal, }; export function createModal(