import { FormResultValue, InputForm, InputFormConfig } from "./form"; import { Vue } from './../lib/libs'; interface ActionInterface { name: string; description?: string; icon: string; color?: string; click(event: Event): void; condition?: ConditionResolvable; } type DialogLineOptions = (HTMLElement | { label?: string; widget?: Widget | (() => Widget); nocolon?: boolean; node?: HTMLElement; } | string); export interface DialogSidebarOptions { pages?: { [key: string]: string | { label: string; icon: IconString; color?: string; } | MenuSeparator; }; page?: string; actions?: (Action | ActionInterface | string)[]; onPageSwitch?(page: string): void; } export declare class DialogSidebar { open: boolean; pages: { [key: string]: string | { label: string; icon: IconString; color?: string; } | MenuSeparator; }; page: string; actions: (Action | ActionInterface | string)[]; dialog: Dialog; node: HTMLDivElement; page_menu: Record; onPageSwitch?(page: string): void; constructor(options: DialogSidebarOptions, dialog: Dialog); build(): HTMLDivElement; toggle(state?: boolean): void; setPage(page: string): void; } export interface DialogOptions { title: string; id?: string; icon?: IconString; width?: number; /** * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog. */ cancel_on_click_outside?: boolean; /** * Default button to press to confirm the dialog. Defaults to the first button. */ confirmIndex?: number; /** * Default button to press to cancel the dialog. Defaults to the last button. */ cancelIndex?: number; /** * Function to execute when the dialog is opened */ onOpen?(): void; /** * Function to execute when the user confirms the dialog */ onConfirm?(formResult: any, event: Event): void | boolean; /** * Function to execute when the user cancels the dialog */ onCancel?(event: Event): void | boolean; /** * Triggered when the user presses a specific button */ onButton?(button_index: number, event?: Event): void | boolean; /** * Triggered when the user attemps to close the dialog */ onClose?(button_index: number, event?: Event): void | boolean; /** * Runs when the dialog is resized */ onResize?(): void; /** * Runs when the dialog is built */ onBuild?(): void; /** * Function to run when anything in the form is changed */ onFormChange?(form_result: { [key: string]: FormResultValue; }): void; /** * Array of HTML any strings for each line of content in the dialog. */ lines?: DialogLineOptions[]; /** * Creates a form in the dialog */ form?: InputFormConfig; /** * Vue component */ component?: Vue.Component; /** * Order that the different interface types appear in the dialog. Default is 'form', 'lines', 'component'. */ part_order?: string[]; form_first?: boolean; /** * Creates a dialog sidebar */ sidebar?: DialogSidebarOptions; toolbars?: Record; /** * Menu in the handle bar */ title_menu?: Menu; /** * Display a progress bar in the dialog */ progress_bar?: { /** * A progress value between 0 and 1 */ progress?: number; }; /** * If true, the dialog will only have one button to close it */ singleButton?: boolean; /** * List of buttons */ buttons?: string[]; /** * A list of keyboard shortcuts that only work inside the dialog */ keyboard_actions?: { [id: string]: { keybind: Keybind; run: (event: KeyboardEvent) => void; condition?: ConditionResolvable; }; }; /** * Select on which axes the dialog can be resized. None by default */ resizable?: 'x' | 'y' | 'xy' | boolean; /** * Set to false to stop the dialog from being dragged around */ draggable?: false; /** * Create a dark backdrop behind the dialog */ darken?: boolean; } export declare class Dialog { id: string; title: string; object: HTMLElement; content_vue: Vue | null; progress_bar?: { /** * The current progress */ progress?: number; /** * Set the progress displayed in the progress bar * @param value A progress value between 0 and 1 */ setProgress(value: number): void; /** * The progress bar HTML node */ node?: HTMLDivElement; }; confirmIndex: number; cancelIndex: number; lines?: DialogLineOptions[]; form?: InputForm; component?: Vue.Component; part_order?: string[]; form_first?: boolean; sidebar?: DialogSidebar; title_menu?: Menu; singleButton?: boolean; buttons?: string[]; keyboard_actions?: { [id: string]: { keybind: Keybind; run: (event: KeyboardEvent) => void; condition?: ConditionResolvable; }; }; resizable?: 'x' | 'y' | 'xy' | false; configuration: DialogOptions; toolbars: Record; form_config: InputFormConfig; width: number; default_width?: number; draggable: boolean; darken: boolean; cancel_on_click_outside: boolean; max_label_width?: number; uses_wide_inputs?: boolean; onConfirm?(formResult: any, event: Event): void | boolean; onCancel?(event: Event): void | boolean; onButton?(button_index: number, event?: Event): void | boolean; onFormChange?(form_result: { [key: string]: FormResultValue; }): void; onOpen: () => void; onBuild: (object: HTMLElement) => void; onResize: () => void; constructor(options: DialogOptions); constructor(id: string, options: DialogOptions); /** * Triggers the confirm event of the dialog. */ confirm(event?: Event): void; /** * Triggers the cancel event of the dialog. */ cancel(event?: Event): void; updateFormValues(initial?: boolean): { [x: string]: FormResultValue; }; /** * Set the values of the dialog form inputs * @param values The values to set, by form input key * @param update Whether to update the dialog (call onFormChange) after setting the values. Default is true. Set to false when called from onFormChange */ setFormValues(values: Record, update?: boolean): void; /** * Set whether the dialog form inputs are toggled on or off. See "toggle_enabled" * @param values * @param update Whether to update the dialog (call onFormChange) after setting the values. Default is true. Set to false when called from onFormChange */ setFormToggles(values: Record, update?: boolean): void; getFormResult(): { [x: string]: FormResultValue; }; close(button?: number, event?: Event): void; build(): this; private resize_observer; show(anchor?: HTMLElement): this; focus(): void; hide(): this; delete(): void; getFormBar(form_id: string): JQuery; /** * Currently opened dialog */ static open: Dialog | null; /** * Stack of currently open dialogs, ordered by depth */ static stack: Dialog[]; } interface ShapelessDialogOptions { title: string; /** * Default button to press to confirm the dialog. Defaults to the first button. */ confirmIndex?: number; /** * Default button to press to cancel the dialog. Defaults to the last button. */ cancelIndex?: number; /** * Function to execute when the user confirms the dialog */ onConfirm?(formResult: any): void; /** * Function to execute when the user cancels the dialog */ onCancel?(): void; /** * Triggered when the user presses a specific button */ onClose?(button_index: number, event?: Event): void; /** * Vue component */ component?: Vue.Component; /** * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog. */ cancel_on_click_outside?: boolean; } export declare class ShapelessDialog extends Dialog { onClose?: (event: Event) => void | boolean; onConfirm?: (event: Event) => void | boolean; constructor(id: string, options: ShapelessDialogOptions); close(button: number, event: Event): void; show(): this; build(): this; delete(): void; } type MessageBoxCommandOptions = string | { text: string; icon?: IconString; condition?: ConditionResolvable; description?: string; category?: string; }; type MessageBoxCheckbox = string | { value?: boolean; condition?: ConditionResolvable; text: string; }; export interface MessageBoxOptions { /** * Index of the confirm button within the buttons array */ confirm?: number; /** * Index of the cancel button within the buttons array */ cancel?: number; buttons?: string[]; /** * Unless set to false, clicking on the darkened area outside of the dialog will cancel the dialog. */ cancel_on_click_outside?: boolean; translateKey?: string; title?: string; message?: string; icon?: IconString; width?: number; cancelIndex?: number; confirmIndex?: number; /** * Display a list of actions to do in the dialog. When clicked, the message box closes with the string ID of the command as first argument. */ commands?: Record; /** * Adds checkboxes to the bottom of the message box */ checkboxes?: Record; } export declare class MessageBox extends Dialog { configuration: MessageBoxOptions; callback?: (button: number | string, result?: Record, event?: Event) => void | boolean; constructor(options: MessageBoxOptions, callback?: (button: number | string, result?: Record, event?: Event) => void | boolean); close(button: number | string, result: Record, event: Event): void; build(): this; delete(): void; } interface ConfigDialogOptions extends DialogOptions { } export declare class ConfigDialog extends Dialog { constructor(id: string, options: ConfigDialogOptions); anchor_tool?: HTMLElement; show(anchor?: HTMLElement): this; hide(): this; build(): this; delete(): void; } export declare class ToolConfig extends ConfigDialog { options: { [key: string]: FormResultValue; }; constructor(id: string, options: ConfigDialogOptions); /** * Open the config menu * @param anchor Optional element to anchor the menu to */ show(anchor?: HTMLElement): this; /** * Save any changes in local storage */ save(): this; /** * Change and save a number of options in the config * @param options Options to set */ changeOptions(options: Record): this; close(): void; } declare const global: { DialogSidebar: typeof import("./dialog").DialogSidebar; Dialog: typeof import("./dialog").Dialog; ShapelessDialog: typeof import("./dialog").ShapelessDialog; MessageBox: typeof import("./dialog").MessageBox; ConfigDialog: typeof import("./dialog").ConfigDialog; ToolConfig: typeof import("./dialog").ToolConfig; }; declare global { const Dialog: typeof global.Dialog; type Dialog = import('./dialog').Dialog; const ConfigDialog: typeof global.ConfigDialog; type ConfigDialog = import('./dialog').ConfigDialog; const DialogSidebar: typeof global.DialogSidebar; type DialogSidebar = import('./dialog').DialogSidebar; const MessageBox: typeof global.MessageBox; type MessageBox = import('./dialog').MessageBox; const ShapelessDialog: typeof global.ShapelessDialog; type ShapelessDialog = import('./dialog').ShapelessDialog; const ToolConfig: typeof global.ToolConfig; type ToolConfig = import('./dialog').ToolConfig; } export {};