Skip to content

@serenity-is/corelib / Combobox

Class: Combobox<TItem>

Defined in: src/ui/editors/combobox.ts:130

A combobox widget that provides searchable selection over a set of items.

Type Parameters

TItem

TItem = any

The item type.

Constructors

Constructor

new Combobox<TItem>(opt): Combobox<TItem>

Defined in: src/ui/editors/combobox.ts:143

Creates a combobox.

Parameters

opt

ComboboxOptions

Combobox options.

Returns

Combobox<TItem>

Properties

defaults

static defaults: ComboboxOptions

Defined in: src/ui/editors/combobox.ts:134

Default combobox options.

Accessors

container

Get Signature

get container(): HTMLElement

Defined in: src/ui/editors/combobox.ts:484

Returns the combobox container element.

Returns

HTMLElement

The container element.


isMultiple

Get Signature

get isMultiple(): boolean

Defined in: src/ui/editors/combobox.ts:508

Whether the combobox allows multiple selection.

Returns

boolean

True when multiple.


selectionLoadState

Get Signature

get selectionLoadState(): "error" | "loading" | "idle"

Defined in: src/ui/editors/combobox.ts:170

Returns the current state of the initial selection load. "idle" means there is no pending or failed load. It does not guarantee that an item is currently selected.

Returns

"error" | "loading" | "idle"


type

Get Signature

get type(): "select2"

Defined in: src/ui/editors/combobox.ts:494

Returns the combobox provider type.

Returns

"select2"

The provider type, or null.

Methods

abortInitSelection()

abortInitSelection(): void

Defined in: src/ui/editors/combobox.ts:445

Aborts any pending initial selection query.

Returns

void


abortPendingQuery()

abortPendingQuery(): void

Defined in: src/ui/editors/combobox.ts:419

Aborts any pending search query.

Returns

void


closeDropdown()

closeDropdown(): void

Defined in: src/ui/editors/combobox.ts:657

Closes the dropdown.

Returns

void


dispose()

dispose(): void

Defined in: src/ui/editors/combobox.ts:470

Disposes the combobox and cleans up its resources.

Returns

void


ensureSelectionLoaded()

ensureSelectionLoaded(): Promise<void>

Defined in: src/ui/editors/combobox.ts:186

Waits for the initial selection to load, if necessary.

Returns

Promise<void>

A promise that resolves when the selection is loaded or rejects if loading fails or is aborted. It resolves immediately when there is no pending load.


getSelectedItem()

getSelectedItem(): ComboboxItem

Defined in: src/ui/editors/combobox.ts:523

Returns the first selected item.

Returns

ComboboxItem

The selected item.


getSelectedItems()

getSelectedItems(): ComboboxItem<any>[]

Defined in: src/ui/editors/combobox.ts:537

Returns all selected items.

Returns

ComboboxItem<any>[]

The selected items.


getValue()

getValue(): string

Defined in: src/ui/editors/combobox.ts:557

Returns the current value as a comma-separated string.

Returns

string

The value.


getValues()

getValues(): string[]

Defined in: src/ui/editors/combobox.ts:577

Returns the current values as an array.

Returns

string[]

The values.


openDropdown()

openDropdown(): void

Defined in: src/ui/editors/combobox.ts:664

Opens the dropdown.

Returns

void


setValue()

setValue(value, triggerChange): void

Defined in: src/ui/editors/combobox.ts:602

Sets the current value.

Parameters

value

string

The value to set.

triggerChange

boolean = false

When true, triggers a change event.

Returns

void


setValues()

setValues(value, triggerChange): void

Defined in: src/ui/editors/combobox.ts:645

Sets the current values.

Parameters

value

string[]

The values to set.

triggerChange

boolean = false

When true, triggers a change event.

Returns

void


getInstance()

static getInstance(el): Combobox

Defined in: src/ui/editors/combobox.ts:673

Returns the combobox instance attached to an element, or null.

Parameters

el

The element or collection.

Element | ArrayLike<Element>

Returns

Combobox

The combobox instance, or null.