Skip to content

utils/dropdown

Classes

Defined in: utils/dropdown.ts:21

Type Parameters

T

T

Constructors

Constructor
new Dropdown<T>(opts): Dropdown<T>;

Defined in: utils/dropdown.ts:26

Parameters
opts

DropdownOptions\<T>

Returns

Dropdown\<T>

Methods

setItems()
setItems(items): void;

Defined in: utils/dropdown.ts:34

Replace the visible item list. Passing [] hides the dropdown.

Parameters
items

T[]

Returns

void

isOpen()
isOpen(): boolean;

Defined in: utils/dropdown.ts:47

True if the dropdown is currently visible.

Returns

boolean

hide()
hide(): void;

Defined in: utils/dropdown.ts:51

Returns

void

getItems()
getItems(): readonly T[];

Defined in: utils/dropdown.ts:57

Returns

readonly T[]

getSelectedIndex()
getSelectedIndex(): number;

Defined in: utils/dropdown.ts:61

Returns

number

handleKey()
handleKey(key): boolean;

Defined in: utils/dropdown.ts:69

Consume a keyboard event. Returns true if the dropdown handled it. The caller is responsible for calling preventDefault / stopPropagation.

Parameters
key

string

Returns

boolean

Interfaces

Defined in: utils/dropdown.ts:8

Generic keyboard-navigable autocomplete dropdown.

Console.ts historically carried two near-identical implementations for ACID and aircraft-type suggestions; this class captures the shared structure while leaving rendering and selection behaviour to the caller.

Type Parameters

T

T

Properties

container
container: HTMLElement;

Defined in: utils/dropdown.ts:10

Parent the dropdown element is appended to.

rootClass
rootClass: string;

Defined in: utils/dropdown.ts:12

CSS class on the dropdown root element (e.g. "acid-autocomplete-dropdown").

itemClass
itemClass: string;

Defined in: utils/dropdown.ts:14

CSS class on each item (e.g. "acid-dropdown-item").

renderItem
renderItem: (value, index) => string | HTMLElement;

Defined in: utils/dropdown.ts:16

Renders an item's text/innerHTML. Return a string or an HTMLElement.

Parameters
value

T

index

number

Returns

string | HTMLElement

onSelect
onSelect: (value, index) => void;

Defined in: utils/dropdown.ts:18

Called when an item is chosen (click, Tab, or Enter).

Parameters
value

T

index

number

Returns

void