2023-03-01 13:04:12 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* MegaMenu is navigation component that displays submenus together.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/megamenu/)
|
|
|
|
*
|
|
|
|
* @module megamenu
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
import { 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-09-05 08:50:46 +00:00
|
|
|
import { PassThroughOptions } from '../passthrough';
|
2024-04-02 08:24:31 +00:00
|
|
|
import { ClassComponent, DesignToken, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-07-11 22:42:43 +00:00
|
|
|
export declare type MegaMenuPassThroughOptionType = MegaMenuPassThroughAttributes | ((options: MegaMenuPassThroughMethodOptions) => MegaMenuPassThroughAttributes | string) | string | null | undefined;
|
2023-04-26 09:57:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) option method.
|
|
|
|
*/
|
|
|
|
export interface MegaMenuPassThroughMethodOptions {
|
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:57:55 +00:00
|
|
|
props: MegaMenuProps;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current inline state.
|
|
|
|
*/
|
2023-04-26 09:57:55 +00:00
|
|
|
state: MegaMenuState;
|
2023-09-05 06:50:04 +00:00
|
|
|
/**
|
|
|
|
* Defines current options.
|
|
|
|
*/
|
2023-04-28 10:15:44 +00:00
|
|
|
context: MegaMenuContext;
|
2023-12-10 21:41:17 +00:00
|
|
|
/**
|
|
|
|
* Defines valid attributes.
|
|
|
|
*/
|
|
|
|
attrs: any;
|
2023-12-05 11:06:32 +00:00
|
|
|
/**
|
|
|
|
* Defines parent options.
|
|
|
|
*/
|
|
|
|
parent: any;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Defines passthrough(pt) options in global config.
|
|
|
|
*/
|
|
|
|
global: object | undefined;
|
2023-04-26 09:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough(pt) options.
|
|
|
|
* @see {@link MegaMenuProps.pt}
|
|
|
|
*/
|
|
|
|
export interface MegaMenuPassThroughOptions {
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the root's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
root?: MegaMenuPassThroughOptionType;
|
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the root list's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
rootList?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the item's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
item?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the item content's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
itemContent?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the item link's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
itemLink?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the item icon's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
itemIcon?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-05-06 13:10:13 +00:00
|
|
|
* Used to pass attributes to the item label's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-05-06 13:10:13 +00:00
|
|
|
itemLabel?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the submenu icon's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2023-05-03 12:53:24 +00:00
|
|
|
submenuIcon?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2024-05-11 08:33:40 +00:00
|
|
|
* Used to pass attributes to the overlay DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
2024-05-11 08:33:40 +00:00
|
|
|
overlay?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the grid's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
grid?: MegaMenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the column's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
column?: MegaMenuPassThroughOptionType;
|
2023-05-03 12:53:24 +00:00
|
|
|
/**
|
2024-04-30 13:02:03 +00:00
|
|
|
* Used to pass attributes to the submenu item's DOM element.
|
2023-05-03 12:53:24 +00:00
|
|
|
*/
|
2024-05-11 08:33:40 +00:00
|
|
|
submenuLabel?: MegaMenuPassThroughOptionType;
|
2023-05-30 06:56:47 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the submenu's DOM element.
|
2023-05-30 06:56:47 +00:00
|
|
|
*/
|
|
|
|
submenu?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the separator's DOM element.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
separator?: MegaMenuPassThroughOptionType;
|
2023-11-15 11:30:23 +00:00
|
|
|
/**
|
|
|
|
* Used to pass attributes to the mobile popup menu button's DOM element.
|
|
|
|
*/
|
2024-04-30 13:02:03 +00:00
|
|
|
button?: MegaMenuPassThroughOptionType;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the start of the component.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
start?: MegaMenuPassThroughOptionType;
|
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to the end of the component.
|
2023-04-26 09:57:55 +00:00
|
|
|
*/
|
|
|
|
end?: MegaMenuPassThroughOptionType;
|
2023-07-06 11:09:01 +00:00
|
|
|
/**
|
2023-11-07 06:16:39 +00:00
|
|
|
* Used to manage all lifecycle hooks.
|
2023-07-06 11:09:01 +00:00
|
|
|
* @see {@link BaseComponent.ComponentHooks}
|
|
|
|
*/
|
|
|
|
hooks?: ComponentHooks;
|
2023-04-26 09:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom passthrough attributes for each DOM elements
|
|
|
|
*/
|
|
|
|
export interface MegaMenuPassThroughAttributes {
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines focused item info
|
|
|
|
*/
|
|
|
|
export interface MegaMenuFocusedItemInfo {
|
|
|
|
/**
|
|
|
|
* Active item index
|
|
|
|
*/
|
|
|
|
index: number;
|
|
|
|
/**
|
|
|
|
* Active item level
|
|
|
|
*/
|
|
|
|
level: number;
|
|
|
|
/**
|
|
|
|
* Parent key info
|
|
|
|
*/
|
|
|
|
parentKey: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines current inline state in MegaMenu component.
|
|
|
|
*/
|
|
|
|
export interface MegaMenuState {
|
|
|
|
/**
|
|
|
|
* Current id state as a string.
|
|
|
|
*/
|
|
|
|
id: string;
|
|
|
|
/**
|
|
|
|
* Current focus state as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
focused: boolean;
|
|
|
|
/**
|
|
|
|
* Current focused item info.
|
|
|
|
* @type {MegaMenuFocusedItemInfo}
|
|
|
|
*/
|
|
|
|
focusedItemInfo: MegaMenuFocusedItemInfo;
|
|
|
|
/**
|
|
|
|
* Active item path.
|
|
|
|
* @type {MenuItem}
|
|
|
|
*/
|
|
|
|
activeItem: MenuItem;
|
|
|
|
}
|
|
|
|
|
2023-04-27 14:16:09 +00:00
|
|
|
/**
|
|
|
|
* Defines current options in MegaMenu component.
|
|
|
|
*/
|
2023-04-28 10:15:44 +00:00
|
|
|
export interface MegaMenuContext {
|
2023-07-25 09:11:12 +00:00
|
|
|
/**
|
|
|
|
* Current menuitem
|
|
|
|
*/
|
|
|
|
item: any;
|
|
|
|
/**
|
|
|
|
* Current index of the menuitem.
|
|
|
|
*/
|
|
|
|
index: number;
|
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-10-17 10:06:59 +00:00
|
|
|
/**
|
|
|
|
* Current disabled state of menuitem as a boolean.
|
|
|
|
* @defaultValue false
|
|
|
|
*/
|
|
|
|
disabled: boolean;
|
2023-04-27 14:16:09 +00:00
|
|
|
}
|
|
|
|
|
2023-09-04 09:16:03 +00:00
|
|
|
/**
|
|
|
|
* Defines valid router binding props in MegaMenu component.
|
|
|
|
*/
|
|
|
|
export interface MegaMenuRouterBindProps {
|
|
|
|
/**
|
|
|
|
* Action element binding
|
|
|
|
*/
|
|
|
|
action: object;
|
|
|
|
/**
|
|
|
|
* Icon element binding
|
|
|
|
*/
|
|
|
|
icon: object;
|
|
|
|
/**
|
|
|
|
* Label element binding
|
|
|
|
*/
|
|
|
|
label: object;
|
|
|
|
/**
|
|
|
|
* Submenuicon elemnt binding
|
|
|
|
*/
|
|
|
|
submenuicon: object;
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:04:12 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in MegaMenu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface MegaMenuProps {
|
|
|
|
/**
|
|
|
|
* An array of menuitems.
|
|
|
|
*/
|
|
|
|
model?: MenuItem[] | undefined;
|
|
|
|
/**
|
|
|
|
* Defines the orientation.
|
2023-03-08 10:51:52 +00:00
|
|
|
* @defaultValue horizontal
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
2023-03-01 13:04:12 +00:00
|
|
|
orientation?: 'horizontal' | 'vertical' | undefined;
|
2023-11-15 10:45:42 +00:00
|
|
|
/**
|
|
|
|
* The breakpoint to define the maximum width boundary.
|
|
|
|
* @defaultValue 960px
|
|
|
|
*/
|
|
|
|
breakpoint?: string | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Whether to apply 'router-link-active-exact' class if route exactly matches the item path.
|
2023-11-08 12:48:37 +00:00
|
|
|
* @deprecated since v3.40.0.
|
2023-03-01 13:04:12 +00:00
|
|
|
* @defaultValue true
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
exact?: boolean | undefined;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* When present, it specifies that the component should be disabled.
|
2023-03-01 13:04:12 +00:00
|
|
|
* @defaultValue false
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
|
|
|
disabled?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Index of the element in tabbing order.
|
|
|
|
*/
|
|
|
|
tabindex?: number | string | undefined;
|
|
|
|
/**
|
|
|
|
* Defines a string value that labels an interactive element.
|
|
|
|
*/
|
2023-11-24 12:21:54 +00:00
|
|
|
ariaLabel?: string | undefined;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Identifier of the underlying menu element.
|
|
|
|
*/
|
2023-11-24 12:21:54 +00:00
|
|
|
ariaLabelledby?: string | undefined;
|
2024-04-02 08:24:31 +00:00
|
|
|
/**
|
|
|
|
* It generates scoped CSS variables using design tokens for the component.
|
|
|
|
*/
|
|
|
|
dt?: DesignToken<any>;
|
2023-04-26 09:57:55 +00:00
|
|
|
/**
|
2023-08-01 14:01:12 +00:00
|
|
|
* Used to pass attributes to DOM elements inside the component.
|
2023-04-26 09:57:55 +00:00
|
|
|
* @type {MegaMenuPassThroughOptions}
|
|
|
|
*/
|
2023-09-05 11:28:04 +00:00
|
|
|
pt?: PassThrough<MegaMenuPassThroughOptions>;
|
2023-09-05 08:50:46 +00:00
|
|
|
/**
|
|
|
|
* Used to configure passthrough(pt) options of the component.
|
|
|
|
* @type {PassThroughOptions}
|
|
|
|
*/
|
|
|
|
ptOptions?: PassThroughOptions;
|
2023-05-30 06:56:47 +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:12 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in MegaMenu component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface MegaMenuSlots {
|
|
|
|
/**
|
|
|
|
* Custom start template.
|
|
|
|
*/
|
2023-03-01 13:04:12 +00:00
|
|
|
start(): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Custom end template.
|
|
|
|
*/
|
2023-03-01 13:04:12 +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:12 +00:00
|
|
|
item(scope: {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* 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: MegaMenuRouterBindProps;
|
2023-08-30 13:28:00 +00:00
|
|
|
/**
|
|
|
|
* Whether or not there is a submenu
|
|
|
|
*/
|
|
|
|
hasSubmenu: boolean;
|
2023-03-01 13:04:12 +00:00
|
|
|
}): VNode[];
|
2023-11-22 10:36:31 +00:00
|
|
|
/**
|
|
|
|
* Custom menu button template on responsive mode.
|
|
|
|
* @param {Object} scope - menu button slot's params.
|
|
|
|
*/
|
|
|
|
menubutton(scope: {
|
|
|
|
/**
|
|
|
|
* Current id state as a string
|
|
|
|
*/
|
|
|
|
id: string;
|
|
|
|
/**
|
|
|
|
* Style class of component
|
|
|
|
*/
|
|
|
|
class: string;
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Toggle event
|
|
|
|
*/
|
|
|
|
toggleCallback: () => void;
|
|
|
|
}): VNode[];
|
|
|
|
/**
|
|
|
|
* Custom menu button icon template on responsive mode.
|
|
|
|
*/
|
|
|
|
menubuttonicon(): VNode[];
|
2023-04-05 11:56:29 +00:00
|
|
|
/**
|
|
|
|
* Custom submenu icon template.
|
2023-08-17 07:16:25 +00:00
|
|
|
* @param {Object} scope - submenuicon slot's params.
|
2023-04-05 11:56:29 +00:00
|
|
|
*/
|
|
|
|
submenuicon(scope: {
|
|
|
|
/**
|
|
|
|
* Whether item is active
|
|
|
|
*/
|
|
|
|
active: boolean;
|
|
|
|
}): VNode[];
|
2023-04-17 06:14:45 +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[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 13:04:12 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in MegaMenu component.
|
|
|
|
*/
|
|
|
|
export interface MegaMenuEmits {
|
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:12 +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:12 +00:00
|
|
|
blur(event: Event): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 13:04:12 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - MegaMenu**
|
|
|
|
*
|
|
|
|
* _MegaMenu is navigation component that displays submenus together._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/megamenu/)
|
|
|
|
* --- ---
|
2023-03-03 10:55:20 +00:00
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
2023-03-01 13:04:12 +00:00
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2022-09-14 11:26:01 +00:00
|
|
|
declare class MegaMenu extends ClassComponent<MegaMenuProps, MegaMenuSlots, MegaMenuEmits> {}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2024-03-14 22:58:11 +00:00
|
|
|
declare module 'vue' {
|
|
|
|
export interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
MegaMenu: GlobalComponentConstructor<MegaMenu>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MegaMenu;
|