UNPKG

@smallstack/svelte-ui

Version:

Tiny library for Svelte 5 and DaisyUI, published as multi entry ESM module and as web components.

42 lines (41 loc) 1.54 kB
import type { Component, Snippet } from "svelte"; export interface ModalButton { text: string; color: "primary" | "secondary" | "error" | "default"; onClick: (options: { closeModal: () => void; }) => Promise<void>; } export declare const ModalOkBtn: ModalButton; export declare const ModalCancelBtn: ModalButton; export interface SimpleModalOptions { title: string; message: string; buttons?: ModalButton[]; } export interface ModalOptions<RETURN_TYPE = any> { /** will be used for navigation and as title */ title: string; /** will be passed as props to the component shown in the modal */ data?: any; closeDialog?: (data?: RETURN_TYPE) => void | Promise<void>; /** if set, the given prop will automatically passed to the component as the closing function */ closingPropName?: string; buttons?: ModalButton[]; modalClass?: string; } export interface ModalComponent { showModal: (component: Component | Snippet, options?: ModalOptions) => Promise<void>; closeModal: (data?: any) => void; } declare class ModalService { private modalComponent; private storedModals; registerModalContainer(modalComponent: ModalComponent): void; openSimpleModal(options: SimpleModalOptions): Promise<void>; openModal<RETURN_TYPE = any>(component: Component | Snippet, options?: ModalOptions<RETURN_TYPE>): Promise<void>; /** closes the currently opened modal */ closeModal(data?: any): void; } export declare const modalService: ModalService; export {};