@ebay/ebayui-core
Version:
Collection of core eBay components; considered to be the building blocks for all composite structures, pages & apps.
38 lines (37 loc) • 1.25 kB
TypeScript
import { type MenuItem, type BaseMenuInput, type MenuState, MenuUtils } from "../../common/menu-utils";
import type { WithNormalizedProps } from "../../global";
export interface MenuEvent {
el?: HTMLElement;
originalEvent?: Event;
index?: number;
}
export interface Item extends MenuItem {
disabled?: boolean;
itemMatchesUrl?: boolean;
current?: boolean;
badgeNumber?: number;
}
export interface Separator {
}
interface FakeMenuInput extends BaseMenuInput, Omit<Marko.HTML.Span, `on${string}`> {
item?: Marko.AttrTag<Item>;
"class-prefix"?: string;
reverse?: boolean;
"fix-width"?: boolean;
fixed?: boolean;
"on-keydown"?: (event: MenuEvent) => void;
"on-select"?: (event: MenuEvent) => void;
}
export interface Input extends WithNormalizedProps<FakeMenuInput> {
}
export default class extends MenuUtils<Input, MenuState> {
items: Item[];
onCreate(): void;
handleItemClick(index: number, originalEvent: MouseEvent, el: HTMLElement): void;
handleItemKeydown(index: number, originalEvent: KeyboardEvent, el: HTMLElement): void;
emitComponentEvent({ eventType, ...eventObj }: MenuEvent & {
eventType: string;
}): void;
onInput(input: Input): void;
}
export {};