UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

333 lines (303 loc) • 9.86 kB
/** * DevExtreme (ui/menu.d.ts) * Version: 25.2.3 * Build date: Fri Dec 12 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { DataSourceLike } from '../data/data_source'; import { DxElement, } from '../core/element'; import { Cancelable, EventInfo, NativeEventInfo, InitializedEventInfo, ChangedOptionInfo, ItemInfo, PointerInteractionEvent, } from '../events'; import { CollectionWidgetItem, SelectionChangeInfo, } from './collection/ui.collection_widget.base'; import dxMenuBase, { dxMenuBaseOptions, } from './context_menu/ui.menu_base'; import { Orientation, SubmenuShowMode, } from '../common'; export { Orientation, SubmenuShowMode, }; type ItemLike = Item | any; export type SubmenuDirection = 'auto' | 'leftOrTop' | 'rightOrBottom'; /** * The type of the contentReady event handler&apos;s argument. */ export type ContentReadyEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>>; /** * The type of the disposing event handler&apos;s argument. */ export type DisposingEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>>; /** * The type of the initialized event handler&apos;s argument. */ export type InitializedEvent<TItem extends ItemLike = any, TKey = any> = InitializedEventInfo<dxMenu<TItem, TKey>>; /** * The type of the itemClick event handler&apos;s argument. */ export type ItemClickEvent<TItem extends ItemLike = any, TKey = any> = NativeEventInfo<dxMenu<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<dxMenu<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<dxMenu<TItem, TKey>> & ItemInfo<TItem>; /** * The type of the optionChanged event handler&apos;s argument. */ export type OptionChangedEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>> & ChangedOptionInfo; /** * The type of the selectionChanged event handler&apos;s argument. */ export type SelectionChangedEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>> & SelectionChangeInfo<TItem>; /** * The type of the submenuHidden event handler&apos;s argument. */ export type SubmenuHiddenEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>> & { /** * */ readonly itemData?: TItem; /** * */ readonly rootItem?: DxElement; /** * */ readonly submenuContainer?: DxElement; }; /** * The type of the submenuHiding event handler&apos;s argument. */ export type SubmenuHidingEvent<TItem extends ItemLike = any, TKey = any> = Cancelable & EventInfo<dxMenu<TItem, TKey>> & { /** * */ readonly itemData?: TItem; /** * */ readonly rootItem?: DxElement; /** * */ readonly submenuContainer?: DxElement; }; /** * The type of the submenuShowing event handler&apos;s argument. */ export type SubmenuShowingEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>> & { /** * */ readonly itemData?: TItem; /** * */ readonly rootItem?: DxElement; /** * */ readonly submenuContainer?: DxElement; }; /** * The type of the submenuShown event handler&apos;s argument. */ export type SubmenuShownEvent<TItem extends ItemLike = any, TKey = any> = EventInfo<dxMenu<TItem, TKey>> & { /** * */ readonly itemData?: TItem; /** * */ readonly rootItem?: DxElement; /** * */ readonly submenuContainer?: DxElement; }; /** * * @deprecated */ export interface dxMenuOptions< TItem extends ItemLike = any, TKey = any, > extends dxMenuBaseOptions<dxMenu<TItem, TKey>, TItem, TKey> { /** * Specifies whether adaptive rendering is enabled. This property is in effect only if the orientation is &apos;horizontal&apos;. */ adaptivityEnabled?: boolean; /** * Binds the UI component to data. */ dataSource?: DataSourceLike<TItem, TKey> | null; /** * Specifies whether or not the submenu is hidden when the mouse pointer leaves it. */ hideSubmenuOnMouseLeave?: boolean; /** * Holds an array of menu items. */ items?: Array<TItem>; /** * A function that is executed after a submenu is hidden. */ onSubmenuHidden?: ((e: SubmenuHiddenEvent<TItem, TKey>) => void); /** * A function that is executed before a submenu is hidden. */ onSubmenuHiding?: ((e: SubmenuHidingEvent<TItem, TKey>) => void); /** * A function that is executed before a submenu is displayed. */ onSubmenuShowing?: ((e: SubmenuShowingEvent<TItem, TKey>) => void); /** * A function that is executed after a submenu is displayed. */ onSubmenuShown?: ((e: SubmenuShownEvent<TItem, TKey>) => void); /** * Specifies whether the menu has horizontal or vertical orientation. */ orientation?: Orientation; /** * Specifies properties for showing and hiding the first level submenu. */ showFirstSubmenuMode?: { /** * Specifies the delay in submenu showing and hiding. */ delay?: { /** * The time span after which the submenu is hidden. */ hide?: number; /** * The time span after which the submenu is shown. */ show?: number; } | number; /** * Specifies the mode name. */ name?: SubmenuShowMode; } | SubmenuShowMode; /** * Specifies the direction at which the submenus are displayed. */ submenuDirection?: SubmenuDirection; } /** * The Menu UI component is a panel with clickable items. A click on an item opens a drop-down menu, which can contain several submenus. */ export default class dxMenu< TItem extends ItemLike = any, TKey = any, > extends dxMenuBase<dxMenuOptions<TItem, TKey>, TItem, TKey> { } /** * @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 MenuBasePlainItem extends CollectionWidgetItem { /** * Specifies whether a group separator is displayed over the item. */ beginGroup?: boolean; /** * Specifies if a menu is closed when a user clicks the item. Does not apply to the root items. */ closeMenuOnClick?: boolean; /** * Specifies whether the menu item responds to user interaction. */ disabled?: boolean; /** * Specifies the menu item&apos;s icon. */ icon?: string; /** * Specifies whether or not a user can select a menu item. */ selectable?: boolean; /** * Specifies whether or not the item is selected. */ selected?: boolean; /** * Specifies the text inserted into the item element. */ text?: string; /** * Specifies whether or not the menu item is visible. */ visible?: boolean; } /** * * @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 dxMenuBaseItem extends MenuBasePlainItem { /** * Specifies nested menu items. */ items?: Array<dxMenuBaseItem>; } export type Item = dxMenuItem; /** * @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 dxMenuItem extends dxMenuBaseItem { /** * Specifies nested menu items. */ items?: Array<Item>; /** * Specifies a web address to be opened when a user clicks on an item. */ url?: string; /** * Specifies link attributes for the url option. */ linkAttr?: { [key: string]: any }; } export type ExplicitTypes<TItem extends ItemLike = any, TKey = any> = { Properties: Properties<TItem, TKey>; ContentReadyEvent: ContentReadyEvent<TItem, TKey>; DisposingEvent: DisposingEvent<TItem, TKey>; InitializedEvent: InitializedEvent<TItem, TKey>; ItemClickEvent: ItemClickEvent<TItem, TKey>; ItemContextMenuEvent: ItemContextMenuEvent<TItem, TKey>; ItemRenderedEvent: ItemRenderedEvent<TItem, TKey>; OptionChangedEvent: OptionChangedEvent<TItem, TKey>; SelectionChangedEvent: SelectionChangedEvent<TItem, TKey>; SubmenuHiddenEvent: SubmenuHiddenEvent<TItem, TKey>; SubmenuHidingEvent: SubmenuHidingEvent<TItem, TKey>; SubmenuShowingEvent: SubmenuShowingEvent<TItem, TKey>; SubmenuShownEvent: SubmenuShownEvent<TItem, TKey>; }; export type Properties<TItem extends ItemLike = any, TKey = any> = dxMenuOptions<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>;