diff --git a/api-generator/components/menubar.js b/api-generator/components/menubar.js index a1cc25bfd..885730a1f 100644 --- a/api-generator/components/menubar.js +++ b/api-generator/components/menubar.js @@ -10,6 +10,12 @@ const MenubarProps = [ 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/menubar/Menubar.d.ts b/components/lib/menubar/Menubar.d.ts index bd1e688c3..e8377cce6 100755 --- a/components/lib/menubar/Menubar.d.ts +++ b/components/lib/menubar/Menubar.d.ts @@ -11,6 +11,130 @@ import { ButtonHTMLAttributes, VNode } from 'vue'; import { MenuItem } from '../menuitem'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type MenubarPassThroughOptionType = MenubarPassThroughAttributes | ((options: MenubarPassThroughMethodOptions) => MenubarPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface MenubarPassThroughMethodOptions { + props: MenubarProps; + state: MenubarState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link MenubarProps.pt} + */ +export interface MenubarPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the list's DOM element. + */ + menu?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the list item's DOM element. + */ + menuitem?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the content's DOM element. + */ + content?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the action's DOM element. + */ + action?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the submenu icon's DOM element. + */ + submenuicon?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the separator's DOM element. + */ + separator?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the mobile popup menu button's DOM element. + */ + button?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the mobile popup menu button icon's DOM element. + */ + popupIcon?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the start of the component. + */ + start?: MenubarPassThroughOptionType; + /** + * Uses to pass attributes to the end of the component. + */ + end?: MenubarPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface MenubarPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines focused item info + */ +export interface MenubarFocusedItemInfo { + /** + * Active item index + */ + index: number; + /** + * Active item level + */ + level: number; + /** + * Parent key info + */ + parentKey: string; +} + +/** + * Defines current inline state in Menubar component. + */ +export interface MenubarState { + /** + * Current id state as a string. + */ + id: string; + /** + * Current mobile menu active state as a boolean. + * @defaultValue false + */ + mobileActive: boolean; + /** + * Current focus state as a boolean. + * @defaultValue false + */ + focused: boolean; + /** + * Current focused item info. + * @type {MenubarFocusedItemInfo} + */ + focusedItemInfo: MenubarFocusedItemInfo; + /** + * Active item path. + * @type {MenubarFocusedItemInfo} + */ + activeItemPath: MenubarFocusedItemInfo[]; +} + /** * Defines valid properties in Menubar component. */ @@ -36,6 +160,11 @@ export interface MenubarProps { * Identifier of the underlying input element. */ 'aria-labelledby'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {MenubarPassThroughOptions} + */ + pt?: MenubarPassThroughOptions; } /** diff --git a/components/lib/menubar/Menubar.vue b/components/lib/menubar/Menubar.vue index e3507774d..7f8193129 100755 --- a/components/lib/menubar/Menubar.vue +++ b/components/lib/menubar/Menubar.vue @@ -1,6 +1,6 @@