Refactor #3907 - For ContextMenu

This commit is contained in:
Tuğçe Küçükoğlu 2023-04-26 12:57:43 +03:00
parent a04d4a470b
commit 9e1903bbbe
4 changed files with 149 additions and 11 deletions

View file

@ -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;
}
/**