2023-03-01 13:04:19 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Menu is a navigation / command component that supports dynamic and static positioning.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/menu/)
|
|
|
|
*
|
|
|
|
* @module menu
|
|
|
|
*
|
|
|
|
*/
|
2023-08-02 14:07:22 +00:00
|
|
|
import { TransitionProps, VNode } from 'vue';
|
2023-07-06 11:17:08 +00:00
|
|
|
import { ComponentHooks } from '../basecomponent';
|
2022-09-06 12:03:37 +00:00
|
|
|
import { MenuItem } from '../menuitem';
|
2023-08-17 23:51:01 +00:00
|
|
|
import { ClassComponent, GlobalComponentConstructor, PTOptions } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-07-11 22:42:43 +00:00
|
|
|
export declare type MenuPassThroughOptionType = MenuPassThroughAttributes | ((options: MenuPassThroughMethodOptions) => MenuPassThroughAttributes | string) | string | null | undefined;
|
2023-04-26 09:58:05 +00:00
|
|
|
|
2023-08-02 14:07:22 +00:00
|
|
|
export declare type MenuPassThroughTransitionType = TransitionProps | ((options: MenuPassThroughMethodOptions) => TransitionProps) | undefined;
|
|
|
|
|
2023-04-26 09:58:05 +00:00
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface MenuPassThroughMethodOptions {
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines instance.
|
|
|
|
*/
|
2023-07-06 12:01:33 +00:00
|
|
|
instance: any;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties.
|
|
|
|
*/
|
2023-04-26 09:58:05 +00:00
|
|
|
props: MenuProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-04-26 09:58:05 +00:00
|
|
|
state: MenuState;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current options.
|
|
|
|
*/
|
2023-04-28 10:15:44 +00:00
|
|
|
context: MenuContext;
|
2023-04-26 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link MenuProps.pt}
|
|
|
|
*/
|
|
|
|
export interface MenuPassThroughOptions {
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
root?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the list's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
menu?: MenuPassThroughOptionType;
|
2023-05-03 12:53:24 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the submenu header's DOM element.
|
2023-05-03 12:53:24 +00:00
|
|
|
*/
|
|
|
|
submenuHeader?: MenuPassThroughOptionType;
|
2023-04-26 09:58:05 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the list item's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
menuitem?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the content's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
content?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the action's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
action?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the icon's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
icon?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the label's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
label?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the separator's DOM element.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
separator?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the start of the component.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
start?: MenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the end of the component.
|
2023-04-26 09:58:05 +00:00
|
|
|
*/
|
|
|
|
end?: MenuPassThroughOptionType;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to manage all lifecycle hooks
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-08-02 12:01:18 +00:00
|
|
|
/**
|
|
|
|
* Used to control Vue Transition API.
|
|
|
|
*/
|
2023-08-02 14:07:22 +00:00
|
|
|
transition?: MenuPassThroughTransitionType;
|
2023-04-26 09:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface MenuPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in Menu component.
|
|
|
|
*/
|
|
|
|
export interface MenuState {
|
|
|
|
/**
|
|
|
|
* Current id state as a string.
|
|
|
|
*/
|
|
|
|
id: string;
|
|
|
|
/**
|
|
|
|
* Current visible state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
overlayVisible: boolean;
|
|
|
|
/**
|
|
|
|
* Current focus state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
/**
|
|
|
|
* Focused option index.
|
|
|
|
*/
|
|
|
|
focusedOptionIndex: number;
|
|
|
|
/**
|
|
|
|
* Selected option index.
|
|
|
|
*/
|
|
|
|
selectedOptionIndex: number;
|
|
|
|
}
|
|
|
|
|
2023-04-28 10:15:44 +00:00
|
|
|
/**
|
|
|
|
* Defines current options in Menu component.
|
|
|
|
*/
|
|
|
|
export interface MenuContext {
|
2023-07-25 09:11:23 +00:00
|
|
|
/**
|
|
|
|
* Current menuitem
|
|
|
|
*/
|
|
|
|
item: any;
|
|
|
|
/**
|
|
|
|
* Current index of the menuitem.
|
|
|
|
*/
|
|
|
|
index: number;
|
2023-04-28 10:15:44 +00:00
|
|
|
/**
|
|
|
|
* Current focused state of menuitem as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
}
|
|
|
|
|
2023-09-04 09:16:03 +00:00
|
|
|
/**
|
|
|
|
* Defines valid router binding props in Menu component.
|
|
|
|
*/
|
|
|
|
export interface MenuRouterBindProps {
|
|
|
|
/**
|
|
|
|
* Action element binding
|
|
|
|
*/
|
|
|
|
action: object;
|
|
|
|
/**
|
|
|
|
* Icon element binding
|
|
|
|
*/
|
|
|
|
icon: object;
|
|
|
|
/**
|
|
|
|
* Label element binding
|
|
|
|
*/
|
|
|
|
label: object;
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:04:19 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Menu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface MenuProps {
|
|
|
|
/**
|
|
|
|
* An array of menuitems.
|
|
|
|
*/
|
|
|
|
model?: MenuItem[] | undefined;
|
|
|
|
/**
|
|
|
|
* Defines if menu would displayed as a popup.
|
2023-03-01 13:04:19 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
popup?: boolean | 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:04:19 +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:04:19 +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:04:19 +00:00
|
|
|
* @defaultValue 0
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
baseZIndex?: number | undefined;
|
|
|
|
/**
|
|
|
|
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
|
2023-03-01 13:04:19 +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 input element.
|
|
|
|
*/
|
|
|
|
'aria-labelledby'?: string | undefined;
|
2023-04-26 09:58:05 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-04-26 09:58:05 +00:00
|
|
|
* @type {MenuPassThroughOptions}
|
|
|
|
*/
|
2023-08-17 23:51:01 +00:00
|
|
|
pt?: PTOptions<MenuPassThroughOptions>;
|
2023-05-29 09:09:48 +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:04:19 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Menu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface MenuSlots {
|
2023-01-27 13:25:28 +00:00
|
|
|
/**
|
|
|
|
* Custom start template.
|
|
|
|
*/
|
2023-03-01 13:04:19 +00:00
|
|
|
start(): VNode[];
|
2023-01-27 13:25:28 +00:00
|
|
|
/**
|
|
|
|
* Custom end template.
|
|
|
|
*/
|
2023-03-01 13:04:19 +00:00
|
|
|
end(): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Custom item template.
|
|
|
|
* @param {Object} scope - item slot's params.
|
|
|
|
*/
|
2023-03-01 13:04:19 +00:00
|
|
|
item(scope: {
|
|
|
|
/**
|
|
|
|
* Menuitem instance
|
|
|
|
*/
|
|
|
|
item: MenuItem;
|
2023-08-30 13:28:00 +00:00
|
|
|
/**
|
|
|
|
* Label property of the menuitem
|
|
|
|
*/
|
|
|
|
label: string | ((...args: any) => string) | undefined;
|
|
|
|
/**
|
|
|
|
* Binding properties of the menuitem
|
|
|
|
*/
|
2023-09-04 09:16:03 +00:00
|
|
|
props: MenuRouterBindProps;
|
2023-03-01 13:04:19 +00:00
|
|
|
}): VNode[];
|
2023-04-17 06:05:55 +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-08-29 14:44:18 +00:00
|
|
|
/**
|
|
|
|
* Custom item template.
|
|
|
|
* @param {Object} scope - submenuheader slot's params.
|
|
|
|
*/
|
|
|
|
submenuheader(scope: {
|
|
|
|
/**
|
|
|
|
* Menuitem instance
|
|
|
|
*/
|
|
|
|
submenuheader: MenuItem;
|
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:04:19 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in Menu component.
|
|
|
|
*/
|
|
|
|
export interface MenuEmits {
|
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:04:19 +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:04:19 +00:00
|
|
|
blur(event: Event): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 13:04:19 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Menu**
|
|
|
|
*
|
|
|
|
* _Menu is a navigation / command component that supports dynamic and static positioning._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/menu/)
|
|
|
|
* --- ---
|
2023-03-03 10:55:20 +00:00
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
2023-03-01 13:04:19 +00:00
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
declare class Menu extends ClassComponent<MenuProps, MenuSlots, MenuEmits> {
|
|
|
|
/**
|
|
|
|
* Toggles the visibility of the overlay.
|
|
|
|
* @param {Event} event - Browser event.
|
|
|
|
*
|
|
|
|
* @memberof Menu
|
|
|
|
*/
|
2023-03-01 13:04:19 +00:00
|
|
|
toggle(event: Event): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Shows the overlay.
|
|
|
|
* @param {Event} event - Browser event.
|
2023-03-01 13:04:19 +00:00
|
|
|
* @param {*} [target] - Target element
|
2022-09-06 12:03:37 +00:00
|
|
|
*
|
|
|
|
* @memberof Menu
|
|
|
|
*/
|
2023-03-01 13:04:19 +00:00
|
|
|
show(event: Event, target?: any): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Hides the overlay.
|
|
|
|
*
|
|
|
|
* @memberof Menu
|
|
|
|
*/
|
|
|
|
hide(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module '@vue/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Menu: GlobalComponentConstructor<Menu>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Menu;
|