2023-03-01 13:03:58 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* ContextMenu displays an overlay menu on right click of its target. Note that components like DataTable has special integration with ContextMenu.
|
|
|
|
* Refer to documentation of the individual documentation of the with context menu support.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/contextmenu/)
|
|
|
|
*
|
|
|
|
* @module contextmenu
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
import { VNode } from 'vue';
|
|
|
|
import { MenuItem } from '../menuitem';
|
2022-12-08 11:04:25 +00:00
|
|
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-04-26 09:57:43 +00:00
|
|
|
export declare type ContextMenuPassThroughOptionType = ContextMenuPassThroughAttributes | ((options: ContextMenuPassThroughMethodOptions) => ContextMenuPassThroughAttributes) | null | undefined;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface ContextMenuPassThroughMethodOptions {
|
|
|
|
props: ContextMenuProps;
|
|
|
|
state: ContextMenuState;
|
2023-04-28 10:15:44 +00:00
|
|
|
context: ContextMenuContext;
|
2023-04-26 09:57:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link ContextMenuProps.pt}
|
|
|
|
*/
|
|
|
|
export interface ContextMenuPassThroughOptions {
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the root's DOM element.
|
|
|
|
*/
|
|
|
|
root?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the list's DOM element.
|
|
|
|
*/
|
|
|
|
menu?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the list item's DOM element.
|
|
|
|
*/
|
|
|
|
menuitem?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the content's DOM element.
|
|
|
|
*/
|
|
|
|
content?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the action's DOM element.
|
|
|
|
*/
|
|
|
|
action?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the icon's DOM element.
|
|
|
|
*/
|
|
|
|
icon?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the label's DOM element.
|
|
|
|
*/
|
|
|
|
label?: ContextMenuPassThroughOptionType;
|
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the submenu icon's DOM element.
|
|
|
|
*/
|
2023-05-03 12:53:24 +00:00
|
|
|
submenuIcon?: ContextMenuPassThroughOptionType;
|
2023-05-29 11:12:29 +00:00
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the submenu's DOM element.
|
|
|
|
*/
|
|
|
|
submenu?: ContextMenuPassThroughOptionType;
|
2023-04-26 09:57:43 +00:00
|
|
|
/**
|
|
|
|
* Uses to pass attributes to the separator's DOM element.
|
|
|
|
*/
|
|
|
|
separator?: ContextMenuPassThroughOptionType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface ContextMenuPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines focused item info
|
|
|
|
*/
|
|
|
|
export interface ContextMenuFocusedItemInfo {
|
|
|
|
/**
|
|
|
|
* Active item index
|
|
|
|
*/
|
|
|
|
index: number;
|
|
|
|
/**
|
|
|
|
* Active item level
|
|
|
|
*/
|
|
|
|
level: number;
|
|
|
|
/**
|
|
|
|
* Parent key info
|
|
|
|
*/
|
|
|
|
parentKey: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in ContextMenu component.
|
|
|
|
*/
|
|
|
|
export interface ContextMenuState {
|
|
|
|
/**
|
|
|
|
* Current id state as a string.
|
|
|
|
*/
|
|
|
|
id: string;
|
|
|
|
/**
|
|
|
|
* Current focus state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
/**
|
|
|
|
* Current focused item info.
|
|
|
|
* @type {ContextMenuFocusedItemInfo}
|
|
|
|
*/
|
|
|
|
focusedItemInfo: ContextMenuFocusedItemInfo;
|
|
|
|
/**
|
|
|
|
* Active item path.
|
|
|
|
* @type {ContextMenuFocusedItemInfo}
|
|
|
|
*/
|
|
|
|
activeItemPath: ContextMenuFocusedItemInfo[];
|
|
|
|
/**
|
|
|
|
* Current visible state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
visible: boolean;
|
|
|
|
/**
|
|
|
|
* Current submenu visible state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
submenuVisible: boolean;
|
|
|
|
}
|
|
|
|
|
2023-04-27 14:16:09 +00:00
|
|
|
/**
|
|
|
|
* Defines current options in ContextMenu component.
|
|
|
|
*/
|
2023-04-28 10:15:44 +00:00
|
|
|
export interface ContextMenuContext {
|
2023-04-27 14:16:09 +00:00
|
|
|
/**
|
|
|
|
* Current active state of menuitem as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
active: boolean;
|
|
|
|
/**
|
|
|
|
* Current focused state of menuitem as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:03:58 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in ContextMenu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ContextMenuProps {
|
|
|
|
/**
|
|
|
|
* An array of menuitems.
|
|
|
|
*/
|
|
|
|
model?: MenuItem[] | undefined;
|
|
|
|
/**
|
|
|
|
* A valid query selector or an HTMLElement to specify where the overlay gets attached.
|
2023-03-08 10:51:52 +00:00
|
|
|
* @defaultValue body
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Whether to automatically manage layering.
|
2023-03-01 13:03:58 +00:00
|
|
|
* @defaultValue true
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
autoZIndex?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Base zIndex value to use in layering.
|
2023-03-01 13:03:58 +00:00
|
|
|
* @defaultValue 0
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
baseZIndex?: number | undefined;
|
|
|
|
/**
|
|
|
|
* Attaches the menu to document instead of a particular item.
|
2023-03-01 13:03:58 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
global?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
|
2023-03-01 13:03:58 +00:00
|
|
|
* @defaultValue true
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
exact?: boolean | undefined;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Index of the element in tabbing order.
|
|
|
|
*/
|
|
|
|
tabindex?: number | string | undefined;
|
|
|
|
/**
|
|
|
|
* Defines a string value that labels an interactive element.
|
|
|
|
*/
|
|
|
|
'aria-label'?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Identifier of the underlying menu element.
|
|
|
|
*/
|
|
|
|
'aria-labelledby'?: string | undefined;
|
2023-04-26 09:57:43 +00:00
|
|
|
/**
|
|
|
|
* Uses to pass attributes to DOM elements inside the component.
|
|
|
|
* @type {ContextMenuPassThroughOptions}
|
|
|
|
*/
|
|
|
|
pt?: ContextMenuPassThroughOptions;
|
2023-05-29 11:12:29 +00:00
|
|
|
/**
|
|
|
|
* When enabled, it removes component related styles in the core.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
unstyled?: boolean;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:03:58 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in ContextMenu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ContextMenuSlots {
|
|
|
|
/**
|
|
|
|
* Custom item template.
|
|
|
|
* @param {Object} scope - item slot's params.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
item(scope: {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Menuitem instance
|
|
|
|
*/
|
|
|
|
item: MenuItem;
|
2023-03-01 13:03:58 +00:00
|
|
|
}): VNode[];
|
2023-04-17 05:59:08 +00:00
|
|
|
/**
|
|
|
|
* Custom item icon template.
|
|
|
|
* @param {Object} scope - item icon slot's params.
|
|
|
|
*/
|
|
|
|
itemicon(scope: {
|
|
|
|
/**
|
|
|
|
* Menuitem instance
|
|
|
|
*/
|
|
|
|
item: MenuItem;
|
|
|
|
/**
|
|
|
|
* Style class of the item icon element.
|
|
|
|
*/
|
|
|
|
class: any;
|
|
|
|
}): VNode[];
|
2023-04-05 11:56:05 +00:00
|
|
|
/**
|
|
|
|
* Custom submenu icon template.
|
|
|
|
*/
|
|
|
|
submenuicon(scope: {
|
|
|
|
/**
|
|
|
|
* Whether item is active
|
|
|
|
*/
|
|
|
|
active: boolean;
|
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:03:58 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in ContextMenu component.
|
|
|
|
*/
|
|
|
|
export interface ContextMenuEmits {
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the component receives focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
focus(event: Event): void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the component loses focus.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
blur(event: Event): void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke before the popup is shown.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
'before-show'(): void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke before the popup is hidden.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
'before-hide'(): void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the popup is shown.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
show(): void;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the popup is hidden.
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
hide(): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 13:03:58 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - ContextMenu**
|
|
|
|
*
|
|
|
|
* _ContextMenu displays an overlay menu on right click of its target. Note that components like DataTable has special integration with ContextMenu.
|
|
|
|
* Refer to documentation of the individual documentation of the with context menu support._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/contextmenu/)
|
|
|
|
* --- ---
|
2023-03-03 10:55:20 +00:00
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
2023-03-01 13:03:58 +00:00
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
declare class ContextMenu extends ClassComponent<ContextMenuProps, ContextMenuSlots, ContextMenuEmits> {
|
|
|
|
/**
|
|
|
|
* Toggles the visibility of the menu.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*
|
|
|
|
* @memberof ContextMenu
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
toggle(event: Event): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Shows the menu.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*
|
|
|
|
* @memberof ContextMenu
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
show(event: Event): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Hides the menu.
|
|
|
|
*
|
|
|
|
* @memberof ContextMenu
|
|
|
|
*/
|
2023-03-01 13:03:58 +00:00
|
|
|
hide(): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare module '@vue/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
ContextMenu: GlobalComponentConstructor<ContextMenu>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ContextMenu;
|