import { BasePlugin } from '../base';
export declare const PLUGIN_KEY = "dialog";
export declare const PLUGIN_PRIORITY = 360;
/**
* @plugin Dialog
* @class Dialog
*
* @description
* The dialog plugin provides a modal dialog system for Handsontable. It allows you to display custom content in modal dialogs
* that overlay the table, providing a way to show notifications, error messages, loading indicators, or any other interactive content.
*
* In order to enable the dialog mechanism, {@link Options#dialog} option must be set to `true`.
*
* The plugin provides several configuration options to customize the dialog behavior and appearance:
* - `template`: The template to use for the dialog (default: `null`). The error will be thrown when
* the template is provided together with the `content` option.
* - `type`: The type of the template ('confirm')
* - `title`: The title of the dialog
* - `description`: The description of the dialog (default: '')
* - `buttons`: The buttons to display in the dialog (default: [])
* - `text`: The text of the button
* - `type`: The type of the button ('primary' | 'secondary')
* - `callback`: The callback to trigger when the button is clicked
* - `content`: The string or HTMLElement content to display in the dialog (default: '')
* - `customClassName`: Custom class name to apply to the dialog (default: '')
* - `background`: Dialog background variant 'solid' | 'semi-transparent' (default: 'solid')
* - `contentBackground`: Whether to show content background (default: false)
* - `animation`: Whether to enable animations (default: true)
* - `closable`: Whether the dialog can be closed (default: false)
* - `a11y`: Object with accessibility options (default object below)
* - `role`: The role of the dialog ('dialog' | 'alertdialog') (default: 'dialog')
* - `ariaLabel`: The label of the dialog (default: 'Dialog')
* - `ariaLabelledby`: The ID of the element that labels the dialog (default: '')
* - `ariaDescribedby`: The ID of the element that describes the dialog (default: ''),
*
* @example
*
* ::: only-for javascript
* ```js
* // Enable dialog plugin with default options
* dialog: true,
*
* // Enable dialog plugin with custom configuration
* dialog: {
* content: 'Dialog content',
* customClassName: 'custom-dialog',
* background: 'semi-transparent',
* contentBackground: false,
* animation: false,
* closable: true,
* a11y: {
* role: 'dialog',
* ariaLabel: 'Dialog',
* ariaLabelledby: 'titleID',
* ariaDescribedby: 'descriptionID',
* }
* }
*
* // Enable dialog plugin using prebuild templates
* dialog: {
* template: {
* type: 'confirm',
* title: 'Confirm',
* description: 'This is a confirm',
* buttons: [
* {
* text: 'Ok',
* type: 'primary',
* callback: () => {
* console.log('Ok');
* }
* },
* {
* text: 'Cancel',
* type: 'secondary',
* callback: () => {
* console.log('Cancel');
* }
* },
* ],
* },
* }
*
* // Access to dialog plugin instance:
* const dialogPlugin = hot.getPlugin('dialog');
*
* // Show a dialog programmatically:
* dialogPlugin.show({
* content: '
Custom Dialog
This is a custom dialog content.
',
* closable: true,
* });
*
* // Hide the dialog programmatically:
* dialogPlugin.hide();
*
* // Check if dialog is visible:
* const isVisible = dialogPlugin.isVisible();
* ```
* :::
*
* ::: only-for react
* ```jsx
* const MyComponent = () => {
* const hotRef = useRef(null);
*
* useEffect(() => {
* const hot = hotRef.current.hotInstance;
* const dialogPlugin = hot.getPlugin('dialog');
*
* dialogPlugin.show({
* content:
*
React Dialog
*
Dialog content rendered with React
*
,
* closable: true
* });
* }, []);
*
* return (
*
* );
* }
* ```
* :::
*
* ::: only-for angular
* ```ts
* hotSettings: Handsontable.GridSettings = {
* data: data,
* dialog: {
* customClassName: 'angular-dialog',
* closable: true
* }
* }
* ```
*
* ```html
*
*
* ```
* :::
*/
export declare class Dialog extends BasePlugin {
#private;
/**
* Returns the plugin key used to identify this plugin in Handsontable settings.
*/
static get PLUGIN_KEY(): string;
/**
* Returns the priority order used to determine the order in which plugins are initialized.
*/
static get PLUGIN_PRIORITY(): number;
/**
* Returns the default settings applied when the plugin is enabled without explicit configuration.
*/
static get DEFAULT_SETTINGS(): {
template: object | null;
content: string;
customClassName: string;
background: string;
contentBackground: boolean;
animation: boolean;
closable: boolean;
a11y: {
role: string;
ariaLabel: string;
ariaLabelledby: string;
ariaDescribedby: string;
};
};
/**
* Returns validator functions for each plugin setting to verify their values are valid before applying them.
*/
static get SETTINGS_VALIDATORS(): {
template: (value: unknown) => boolean;
content: (value: unknown) => boolean;
customClassName: (value: unknown) => value is string;
background: (value: unknown) => boolean;
contentBackground: (value: unknown) => value is boolean;
animation: (value: unknown) => value is boolean;
closable: (value: unknown) => value is boolean;
a11y: (value: unknown) => boolean;
};
/**
* Check if the plugin is enabled in the handsontable settings.
*
* @returns {boolean}
*/
isEnabled(): boolean;
/**
* Enable plugin for this Handsontable instance.
*/
enablePlugin(): void;
/**
* Update plugin state after Handsontable settings update.
*/
updatePlugin(): void;
/**
* Disable plugin for this Handsontable instance.
*/
disablePlugin(): void;
/**
* Check if the dialog is currently visible.
*
* @returns {boolean} True if the dialog is visible, false otherwise.
*/
isVisible(): boolean;
/**
* Show dialog with given configuration.
* Displays the dialog with the specified content and options.
*
* @param {object} options Dialog configuration object containing content and display options.
* @param {object} options.template The template to use for the dialog (default: `null`). The error will be thrown when
* the template is provided together with the `content` option.
* @param {'confirm'} options.template.type The type of the template ('confirm').
* @param {string} options.template.title The title of the dialog.
* @param {string} options.template.description The description of the dialog. Default: ''.
* @param {object[]} options.template.buttons The buttons to display in the dialog. Default: [].
* @param {string} options.template.buttons.text The text of the button.
* @param {'primary' | 'secondary'} options.template.buttons.type The type of the button.
* @param {function(MouseEvent)} options.template.buttons.callback The callback to trigger when the button is clicked.
* @param {string|HTMLElement|DocumentFragment} options.content The content to display in the dialog. Can be a string, HTMLElement, or DocumentFragment. Default: ''
* @param {string} options.customClassName Custom CSS class name to apply to the dialog container. Default: ''
* @param {'solid'|'semi-transparent'} options.background Dialog background variant. Default: 'solid'.
* @param {boolean} options.contentBackground Whether to show content background. Default: false.
* @param {boolean} options.animation Whether to enable animations when showing/hiding the dialog. Default: true.
* @param {boolean} options.closable Whether the dialog can be closed by user interaction. Default: false.
* @param {object} options.a11y Object with accessibility options.
* @param {string} options.a11y.role The role of the dialog. Default: 'dialog'.
* @param {string} options.a11y.ariaLabel The label of the dialog. Default: 'Dialog'.
* @param {string} options.a11y.ariaLabelledby The ID of the element that labels the dialog. Default: ''.
* @param {string} options.a11y.ariaDescribedby The ID of the element that describes the dialog. Default: ''.
*/
show(options?: Record): void;
/**
* Hide the currently open dialog.
* Closes the dialog and restores the focus to the table.
*/
hide(): void;
/**
* Update the dialog configuration.
*
* @param {object} options Dialog configuration object containing content and display options.
* @param {object} options.template The template to use for the dialog (default: `null`). The error will be thrown when
* the template is provided together with the `content` option.
* @param {'confirm'} options.template.type The type of the template ('confirm').
* @param {string} options.template.title The title of the dialog.
* @param {string} options.template.description The description of the dialog. Default: ''.
* @param {object[]} options.template.buttons The buttons to display in the dialog. Default: [].
* @param {string} options.template.buttons.text The text of the button.
* @param {'primary' | 'secondary'} options.template.buttons.type The type of the button.
* @param {function(MouseEvent)} options.template.buttons.callback The callback to trigger when the button is clicked.
* @param {string|HTMLElement|DocumentFragment} options.content The content to display in the dialog. Can be a string, HTMLElement, or DocumentFragment. Default: ''
* @param {string} options.customClassName Custom CSS class name to apply to the dialog container. Default: ''
* @param {'solid'|'semi-transparent'} options.background Dialog background variant. Default: 'solid'.
* @param {boolean} options.contentBackground Whether to show content background. Default: false.
* @param {boolean} options.animation Whether to enable animations when showing/hiding the dialog. Default: true.
* @param {boolean} options.closable Whether the dialog can be closed by user interaction. Default: false.
* @param {object} options.a11y Object with accessibility options.
* @param {string} options.a11y.role The role of the dialog. Default: 'dialog'.
* @param {string} options.a11y.ariaLabel The label of the dialog. Default: 'Dialog'.
* @param {string} options.a11y.ariaLabelledby The ID of the element that labels the dialog. Default: ''.
* @param {string} options.a11y.ariaDescribedby The ID of the element that describes the dialog. Default: ''.
*/
update(options: Record): void;
/**
* Displays the alert dialog with the specified content.
*
* @param {string | { title: string, description: string }} message The message to display in the dialog.
* Can be a string or an object with `title` and `description` properties.
* @param {function(MouseEvent): void} [callback] The callback to trigger when the button is clicked.
*/
showAlert(message?: string | Record, callback?: (...args: unknown[]) => void): void;
/**
* Displays the confirm dialog with the specified content and options.
*
* @param {string | { title: string, description: string }} message The message to display in the dialog.
* Can be a string or an object with `title` and `description` properties.
* @param {function(MouseEvent): void} [onOk] The callback to trigger when the OK button is clicked.
* @param {function(MouseEvent): void} [onCancel] The callback to trigger when the Cancel button is clicked.
*/
showConfirm(message?: string | Record, onOk?: (...args: unknown[]) => void, onCancel?: (...args: unknown[]) => void): void;
/**
* Focus the dialog.
*/
focus(): void;
/**
* Destroy dialog and reset plugin state.
*/
destroy(): void;
}