import type { SVGTemplateResult } from 'lit';
import type { MenuItem } from './MenuItem.js';
export type MenuItemType = 'normal' | 'separator' | 'label' | 'radio';
export interface MenuOptions {
    /**
     * By default the `contextmenu` event is always cancelled by the library
     * whether the command is actually handled or not.
     * When this is set the event is cancelled only when the context menu can be rendered
     * in the current context.
     *
     * Note, this may cause a disjoint experience to the user as in one situation the right click
     * would render this context menu and in another system's & browser context menu.
     */
    cancelNativeWhenHandled?: boolean;
    /**
     * Called before the menu is rendered.
     * Specifically, it is called right before the internal `render()` method is called.
     * It doesn't allow you to modify the menu items, but you can perform any setup
     * before the menu is rendered.
     */
    beforeRender?: (ctx: MenuContext) => void;
    /**
     * Called after the menu is closed.
     */
    afterClose?: (ctx: MenuContext) => void;
}
export interface MenuPoint {
    x: number;
    y: number;
}
export interface MenuContext<S = unknown> {
    /**
     * The object store to be used to store menu item data.
     */
    store: S;
    /**
     * An instance of the element that triggered the command.
     */
    target: HTMLElement | SVGElement;
    /**
     * The element with which this context menu was initialized with.
     */
    root: HTMLElement;
    /**
     * Any data passed to the command through a custom event.
     */
    customData?: unknown;
}
interface LifecycleContext<S = unknown> extends MenuContext<S> {
    /**
     * The id of the command.
     */
    id: string;
}
export interface EnabledMenuOptions<S = unknown> extends LifecycleContext<S> {
}
export interface CheckedMenuOptions<S = unknown> extends LifecycleContext<S> {
}
/**
 * Options passed to the `visible()` callback function.
 */
export type VisibleOptions<S = unknown> = EnabledMenuOptions<S>;
export interface CommandExecuteOptions<S = unknown> extends LifecycleContext<S> {
    /**
     * The point of the original click.
     */
    clickPoint: MenuPoint;
    /**
     * This is only passed to the execute function when a sub-menu has triggered a menu item
     * that has no `execute` function defined. This is the index of the command.
     * Note, the index includes separators.
     */
    selectedSubcommand?: number;
    /**
     * The menu item that triggered the selection.
     */
    item: MenuItem<S>;
}
export interface BeforeRenderOptions<S = unknown> extends LifecycleContext<S> {
    /**
     * The menu item that triggered the selection. Changing this item will affects the rendering of it.
     */
    menu: MenuItem<S>;
}
export interface CommandBase<S = unknown> {
    /**
     * The identifier of the command. Can be used to ids manually. The command is passed
     * to the lifecycle callbacks so you can use it to identify a command.
     * When not set the Menu generates a random value.
     */
    id?: string;
    /**
     * The type of the command. By default the command is `normal`. `separator` draws a line between menu items.
     * The `label` renders a title over other list items.
     *
     * The radio type renders a "check" mark on the right of the label instead of image (it is ignored when set).
     * To mark the checkbox as checked use the `checked` property. Use the lifecycle methods to set the checked state.
     */
    type?: MenuItemType;
    /**
     * The target object that activates this item.
     * The `ContextMenu` class uses `findTarget(mouseEvent)` to find the event target and `elementToTarget(targetElement)`
     * to find the target. By default the "elementTarget" is the event's target, and the target is the elementTarget's
     * `localName` with list of class names (period separated).
     * When the target is the same as the `workspace` then the target is `root`.
     * Override this two methods to customize this behavior and support custom use cases.
     *
     * By default the constructed target from an element is something like this: `div.item.target-item`.
     *
     * This must be provided for the top level menu items only. This is ignored in sub-menus.
     */
    target?: string | string[] | 'all' | 'root';
    /**
     * Determines whether the menu item is visible in the rendered menu.
     * The item is always inserted into the DOM but when this value is false or the result of calling the function
     * is false then the item is hidden. You can still access the menu item via DOM apis.
     */
    visible?: boolean | ((args: VisibleOptions<S>) => boolean);
}
export interface ContextMenuCommand<S = unknown> extends CommandBase<S> {
    /**
     * The label to render.
     */
    label?: string;
    /**
     * Optional title of the element. Do not use it for elements that represent a sub-menu.
     */
    title?: string;
    /**
     * The icon to render. It should be full definition of an SVG image wrapped into
     * the svg`...` template, from the `lit-html` library.
     */
    icon?: SVGTemplateResult;
    /**
     * A children of this command. When set and not empty then it renders a nested sub-menu
     * for this entry. In this case the `execute()` lifecycle method won't be executed and a new menu is rendered
     * positioned relative to this entry.
     *
     * Note, sub entries of the menu are not rendered until the user hover over the menu. When the user hover over
     * another menu entry the child menu is destroyed.
     */
    children?: (ContextMenuCommand<S> | CommandBase<S>)[];
    /**
     * Whether the command is enabled or not.
     * When set to a boolean value, this value is used to determine whether the item should be rendered.
     * When set to a function, it must return a value indicating whether the command is enabled.
     */
    enabled?: boolean | ((args: EnabledMenuOptions<S>) => boolean);
    /**
     * Only used when the `type` is set to `radio` and indicated that the element is in the checked state.
     * When this is true then the UI renders the check mark in the image are.
     * Note, you cannot use the `image` with this property as the image is ignored and the selection state
     * is indicated in this place.
     */
    checked?: boolean | ((args: CheckedMenuOptions<S>) => boolean);
    /**
     * The action to be executed when this command is activated.
     * This is ignored when the command has children. When the command has no children then
     * when this is set to a function, this function is called when a menu item is triggered.
     * You may not set this value and use the `activate` event to listen for command activation.
     */
    execute?: (args: CommandExecuteOptions<S>) => void;
    /**
     * A function that is executed before the item is rendered.
     * This way you can customize the rendered values like the icon, label, or title.
     */
    beforeRender?: (ctx: BeforeRenderOptions<S>) => void;
}
export interface MenuTriggerInfo {
    /**
     * The element that triggered the context menu.
     */
    target: HTMLElement | SVGElement;
    /**
     * The location where the click relative position is.
     * This can be customized by overriding the `readTargetClickPosition()`.
     */
    point: MenuPoint;
    /**
     * A custom data to be passed to the lifecycle methods.
     */
    customData?: unknown;
}
export interface CustomMenuEventDetail {
    /**
     * The name of the command target. It is used to render commands group. It corresponds to ContextMenuCommand.target.
     */
    name: string;
    /**
     * The x coordinate of the click. Default to 0.
     */
    x?: number;
    /**
     * The y coordinate of the click. Default to 0.
     */
    y?: number;
    /**
     * The click target passed back to the command execute function. Default to the workspace.
     */
    actionTarget?: HTMLElement | SVGElement;
    /**
     * The original click event associated with the action. Optional.
     */
    clickEvent?: PointerEvent;
    /**
     * Any data to be passed to the enabled and execute function.
     */
    customData?: unknown;
}
export interface ContextMenuExecuteDetail<S = unknown> {
    /**
     * The id of the executed command.
     * When not set by the command definition this is auto generated
     * when registering a command.
     */
    id: string;
    /**
     * The object store to be used to store menu item data.
     */
    store: S;
    /**
     * An instance of the element that triggered the command.
     */
    target: HTMLElement | SVGElement;
    /**
     * The element with which this context menu was initialized with.
     */
    root: HTMLElement;
    /**
     * Any data passed to the command through a custom event.
     */
    customData?: unknown;
    /**
     * The point of the original click.
     */
    clickPoint: MenuPoint;
    /**
     * The index of the clicked subcommand
     */
    selectedSubcommand?: number;
    /**
     * The selected me nu item.
     */
    item: MenuItem<S>;
}
export {};
//# sourceMappingURL=types.d.ts.map