/**
* DevExtreme (ui/context_menu.d.ts)
* Version: 25.2.7
* Build date: Tue May 05 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import { DataSourceLike } from '../data/data_source';
import {
    PositionConfig,
} from '../common/core/animation';

import {
    UserDefinedElement,
} from '../core/element';

import {
    DxPromise,
} from '../core/utils/deferred';

import {
    Cancelable,
    EventInfo,
    NativeEventInfo,
    InitializedEventInfo,
    ChangedOptionInfo,
    ItemInfo,
    DxEvent,
    PointerInteractionEvent,
} from '../events';

import dxMenuBase, {
    dxMenuBaseOptions,
} from './context_menu/ui.menu_base';

import {
    dxMenuBaseItem,
} from './menu';

import {
    SelectionChangeInfo,
} from './collection/ui.collection_widget.base';

/**
 * @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
 */
type ItemLike = Item | any;

export type ContextSubmenuDirection = 'auto' | 'left' | 'right';

/**
 * The type of the contentReady event handler&apos;s argument.
 */
export type ContentReadyEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the disposing event handler&apos;s argument.
 */
export type DisposingEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the hidden event handler&apos;s argument.
 */
export type HiddenEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the hiding event handler&apos;s argument.
 */
export type HidingEvent<TItem extends ItemLike = any, TKey = any> = Cancelable & EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the initialized event handler&apos;s argument.
 */
export type InitializedEvent<TItem extends ItemLike = any, TKey = any> = InitializedEventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the itemClick event handler&apos;s argument.
 */
export type ItemClickEvent<TItem extends ItemLike = any, TKey = any> = NativeEventInfo<dxContextMenu<TItem, TKey>, KeyboardEvent | MouseEvent | PointerEvent> & ItemInfo<TItem>;

/**
 * The type of the itemContextMenu event handler&apos;s argument.
 */
export type ItemContextMenuEvent<TItem extends ItemLike = any, TKey = any> = NativeEventInfo<dxContextMenu<TItem, TKey>, PointerInteractionEvent> & ItemInfo<TItem>;

/**
 * The type of the itemRendered event handler&apos;s argument.
 */
export type ItemRenderedEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>> & ItemInfo<TItem>;

/**
 * The type of the optionChanged event handler&apos;s argument.
 */
export type OptionChangedEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>> & ChangedOptionInfo;

/**
 * The type of the positioning event handler&apos;s argument.
 */
export type PositioningEvent<TItem extends ItemLike = any, TKey = any> = NativeEventInfo<dxContextMenu<TItem, TKey>, PointerInteractionEvent> & {
    /**
     * 
     */
    readonly position: PositionConfig;
};

/**
 * The type of the selectionChanged event handler&apos;s argument.
 */
export type SelectionChangedEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>> & SelectionChangeInfo<TItem>;

/**
 * The type of the showing event handler&apos;s argument.
 */
export type ShowingEvent<TItem extends ItemLike = any, TKey = any> = Cancelable & EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * The type of the shown event handler&apos;s argument.
 */
export type ShownEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxContextMenu<TItem, TKey>>;

/**
 * 
 * @deprecated 
 */
export interface dxContextMenuOptions<
    TItem extends ItemLike = any,
    TKey = any,
> extends dxMenuBaseOptions<dxContextMenu<TItem, TKey>, TItem, TKey> {
    /**
     * Binds the UI component to data.
     */
    dataSource?: DataSourceLike<TItem, TKey> | null;
    /**
     * Specifies whether to hide the UI component if a user clicks outside it.
     */
    hideOnOutsideClick?: boolean | ((event: DxEvent<PointerInteractionEvent>) => boolean);
    /**
     * Holds an array of menu items.
     */
    items?: Array<TItem>;
    /**
     * A function that is executed after the ContextMenu is hidden.
     */
    onHidden?: ((e: HiddenEvent<TItem, TKey>) => void);
    /**
     * A function that is executed before the ContextMenu is hidden.
     */
    onHiding?: ((e: HidingEvent<TItem, TKey>) => void);
    /**
     * A function that is executed before the ContextMenu is positioned.
     */
    onPositioning?: ((e: PositioningEvent<TItem, TKey>) => void);
    /**
     * A function that is executed before the ContextMenu is shown.
     */
    onShowing?: ((e: ShowingEvent<TItem, TKey>) => void);
    /**
     * A function that is executed after the ContextMenu is shown.
     */
    onShown?: ((e: ShownEvent<TItem, TKey>) => void);
    /**
     * An object defining UI component positioning properties.
     */
    position?: PositionConfig;
    /**
     * Specifies properties used to display the UI component.
     */
    showEvent?: {
      /**
       * The delay in milliseconds after which the UI component is displayed.
       */
      delay?: number | undefined;
      /**
       * Specifies the event names on which the UI component is shown.
       */
      name?: string | undefined;
    } | string;
    /**
     * Specifies the direction at which submenus are displayed.
     */
    submenuDirection?: ContextSubmenuDirection;
    /**
     * The target element associated with the context menu.
     */
    target?: string | UserDefinedElement | undefined;
    /**
     * A Boolean value specifying whether or not the UI component is visible.
     */
    visible?: boolean;
}
/**
 * The ContextMenu UI component displays a single- or multi-level context menu. An end user invokes this menu by a right click or a long press.
 */
export default class dxContextMenu<
    TItem extends ItemLike = any,
    TKey = any,
> extends dxMenuBase<dxContextMenuOptions<TItem, TKey>, TItem, TKey> {
    /**
     * Hides the UI component.
     */
    hide(): DxPromise<void>;
    /**
     * Shows the UI component.
     */
    show(): DxPromise<void>;
    /**
     * Shows or hides the UI component depending on the argument.
     */
    toggle(showing: boolean): DxPromise<void>;
}

export type Item = dxContextMenuItem;

/**
 * @deprecated Use Item instead
 * @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
 */
export interface dxContextMenuItem extends dxMenuBaseItem {
    /**
     * Specifies nested menu items.
     */
    items?: Array<Item>;
}

export type ExplicitTypes<TItem extends ItemLike = any, TKey = any> = {
    Properties: Properties<TItem, TKey>;
    ContentReadyEvent: ContentReadyEvent<TItem, TKey>;
    DisposingEvent: DisposingEvent<TItem, TKey>;
    HiddenEvent: HiddenEvent<TItem, TKey>;
    HidingEvent: HidingEvent<TItem, TKey>;
    InitializedEvent: InitializedEvent<TItem, TKey>;
    ItemClickEvent: ItemClickEvent<TItem, TKey>;
    ItemContextMenuEvent: ItemContextMenuEvent<TItem, TKey>;
    ItemRenderedEvent: ItemRenderedEvent<TItem, TKey>;
    OptionChangedEvent: OptionChangedEvent<TItem, TKey>;
    PositioningEvent: PositioningEvent<TItem, TKey>;
    SelectionChangedEvent: SelectionChangedEvent<TItem, TKey>;
    ShowingEvent: ShowingEvent<TItem, TKey>;
    ShownEvent: ShownEvent<TItem, TKey>;
};

export type Properties<TItem extends ItemLike = any, TKey = any> = dxContextMenuOptions<TItem, TKey>;

/**
 * @deprecated use Properties instead
 * @deprecated Attention! This type is for internal purposes only. If you used it previously, please submit a ticket to our {@link https://supportcenter.devexpress.com/ticket/create Support Center}. We will check if there is an alternative solution.
 */
export type Options<TItem extends ItemLike = any, TKey = any> = Properties<TItem, TKey>;


