diff --git a/api-generator/components/contextmenu.js b/api-generator/components/contextmenu.js index 71a201365..d0f7cffe6 100644 --- a/api-generator/components/contextmenu.js +++ b/api-generator/components/contextmenu.js @@ -34,6 +34,12 @@ const ContextMenuProps = [ type: 'boolean', default: 'true', description: "Whether to apply 'router-link-active-exact' class if route exactly matches the item path." + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/contextmenu/ContextMenu.d.ts b/components/lib/contextmenu/ContextMenu.d.ts index e44f7d71c..c262e1347 100755 --- a/components/lib/contextmenu/ContextMenu.d.ts +++ b/components/lib/contextmenu/ContextMenu.d.ts @@ -12,6 +12,119 @@ import { VNode } from 'vue'; import { MenuItem } from '../menuitem'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ContextMenuPassThroughOptionType = ContextMenuPassThroughAttributes | ((options: ContextMenuPassThroughMethodOptions) => ContextMenuPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ContextMenuPassThroughMethodOptions { + props: ContextMenuProps; + state: ContextMenuState; +} + +/** + * 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. + */ + submenuicon?: ContextMenuPassThroughOptionType; + /** + * 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; +} + /** * Defines valid properties in ContextMenu component. */ @@ -57,6 +170,11 @@ export interface ContextMenuProps { * Identifier of the underlying menu element. */ 'aria-labelledby'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ContextMenuPassThroughOptions} + */ + pt?: ContextMenuPassThroughOptions; } /** diff --git a/components/lib/contextmenu/ContextMenu.vue b/components/lib/contextmenu/ContextMenu.vue index d4f78d4e6..2ffa1b54a 100755 --- a/components/lib/contextmenu/ContextMenu.vue +++ b/components/lib/contextmenu/ContextMenu.vue @@ -1,7 +1,7 @@