UNPKG

@ebay/ebayui-core

Version:

Collection of core eBay components; considered to be the building blocks for all composite structures, pages & apps.

57 lines (56 loc) 2.06 kB
import { createLinear } from "makeup-roving-tabindex"; import typeahead from "makeup-typeahead"; import { type MenuItem, type BaseMenuInput, type MenuState, MenuUtils } from "../../common/menu-utils"; import type { WithNormalizedProps } from "../../global"; export interface MenuEvent<T extends Event = Event> { el?: HTMLElement; checked?: string[]; checkedIndex?: number[]; originalEvent?: T; index?: number; currentChecked?: boolean; } export interface Item extends MenuItem { badgeNumber?: number; } interface MenuInput extends BaseMenuInput, Omit<Marko.HTML.Span, `on${string}`> { item?: Marko.AttrTag<Item>; "class-prefix"?: string; "typeahead-timeout-length"?: number; reverse?: boolean; fixed?: boolean; "fix-width"?: boolean; renderBody?: Marko.Body; "on-keydown"?: (event: MenuEvent) => void; "on-change"?: (event: MenuEvent) => void; "on-select"?: (event: MenuEvent) => void; } export interface Input extends WithNormalizedProps<MenuInput> { } export default class extends MenuUtils<Input, MenuState> { rovingTabindex: ReturnType<typeof createLinear>; tabindexPosition: number; contentEl: HTMLElement; getTypeaheadIndex: ReturnType<typeof typeahead>["getIndex"]; destroyTypeahead: ReturnType<typeof typeahead>["destroy"]; items: Item[]; onCreate(): void; toggleItemChecked(index: number, originalEvent: Event, itemEl: HTMLElement): void; handleItemClick(index: number, originalEvent: MouseEvent, itemEl: HTMLElement): void; handleItemKeydown(index: number, originalEvent: KeyboardEvent, itemEl: HTMLElement): void; handleItemKeypress({ key }: KeyboardEvent): void; emitComponentEvent({ eventType, el, originalEvent, index, }: { eventType: string; el?: HTMLElement; originalEvent: Event; index?: number; }): void; onInput(input: Input): void; onRender(): void; onMount(): void; onUpdate(): void; onDestroy(): void; _setupMakeup(): void; _cleanupMakeup(): void; } export {};