UNPKG

@studiocms/ui

Version:

The UI library for StudioCMS. Includes the layouts & components we use to build StudioCMS.

49 lines (48 loc) 1.6 kB
declare class ModalHelper { private element; private cancelButton; private confirmButton; private isForm; private modalForm; /** * A helper to manage modals. * @param id The ID of the modal. * @param triggerID The ID of the element that should trigger the modal. */ constructor(id: string, triggerID?: string); /** * A helper function which adds event listeners to the modal buttons to close the modal when clicked. * @param id The ID of the modal. * @param dismissable Whether the modal is dismissable. */ private addButtonListeners; /** * A helper function to close the modal when the user clicks outside of it. */ private addDismissiveClickListener; /** * A function to show the modal. */ show: () => void; /** * A function to hide the modal. */ hide: () => void; /** * A function to add another trigger to show the modal with. * @param elementID The ID of the element that should trigger the modal when clicked. */ bindTrigger: (elementID: string) => void; /** * Registers a callback for the cancel button. * @param func The callback function. */ registerCancelCallback: (func: () => void) => void; /** * Registers a callback for the confirm button. * @param func The callback function. If the modal is a form, the function will be called with * the form data as the first argument. */ registerConfirmCallback: (func: (data?: FormData | undefined) => void) => void; } export { ModalHelper };