Skip to content

@serenity-is/corelib / Select2

Class: Select2

Defined in: src/ui/editors/select2.tsx:647

A searchable select widget ported from Select2.

Constructors

Constructor

new Select2(opts?): Select2

Defined in: src/ui/editors/select2.tsx:655

Creates a Select2 widget.

Parameters

opts?

Select2Options

Select2 options.

Returns

Select2

Properties

ajaxDefaults

readonly static ajaxDefaults: Select2AjaxOptions

Defined in: src/ui/editors/select2.tsx:835

Default ajax options.


defaults

readonly static defaults: Select2Options

Defined in: src/ui/editors/select2.tsx:844

Default options for the Select2 widget.

Accessors

container

Get Signature

get container(): HTMLElement

Defined in: src/ui/editors/select2.tsx:699

Returns the container element.

Returns

HTMLElement

The container element.


data

Get Signature

get data(): Select2Item | Select2Item[]

Defined in: src/ui/editors/select2.tsx:722

Returns the current data.

Returns

Select2Item | Select2Item[]

The selected item(s).

Set Signature

set data(value): void

Defined in: src/ui/editors/select2.tsx:728

Sets the current data.

Parameters
value

The data to set.

Select2Item | Select2Item[]

Returns

void


Get Signature

get dropdown(): HTMLElement

Defined in: src/ui/editors/select2.tsx:707

Returns the dropdown element.

Returns

HTMLElement

The dropdown element.


isFocused

Get Signature

get isFocused(): boolean

Defined in: src/ui/editors/select2.tsx:758

Whether the widget is focused.

Returns

boolean

True when focused.


isMultiple

Get Signature

get isMultiple(): boolean

Defined in: src/ui/editors/select2.tsx:766

Whether the widget allows multiple selection.

Returns

boolean

True when multiple.


opened

Get Signature

get opened(): boolean

Defined in: src/ui/editors/select2.tsx:774

Whether the dropdown is open.

Returns

boolean

True when open.


Get Signature

get search(): HTMLInputElement

Defined in: src/ui/editors/select2.tsx:805

Returns the search input element.

Returns

HTMLInputElement

The search input.


val

Get Signature

get val(): string | string[]

Defined in: src/ui/editors/select2.tsx:813

Returns the current value.

Returns

string | string[]

The value.

Set Signature

set val(value): void

Defined in: src/ui/editors/select2.tsx:819

Sets the current value.

Parameters
value

The value to set.

string | string[]

Returns

void

Methods

close()

close(): void

Defined in: src/ui/editors/select2.tsx:691

Closes the dropdown.

Returns

void


destroy()

destroy(): void

Defined in: src/ui/editors/select2.tsx:714

Destroys the Select2 instance.

Returns

void


disable()

disable(): void

Defined in: src/ui/editors/select2.tsx:735

Disables the Select2 widget.

Returns

void


enable()

enable(enabled?): void

Defined in: src/ui/editors/select2.tsx:743

Enables or disables the Select2 widget.

Parameters

enabled?

boolean

Whether to enable.

Returns

void


focus()

focus(): void

Defined in: src/ui/editors/select2.tsx:750

Focuses the search input.

Returns

void


open()

open(): boolean

Defined in: src/ui/editors/select2.tsx:782

Opens the dropdown.

Returns

boolean

True when opened.


positionDropdown()

positionDropdown(): void

Defined in: src/ui/editors/select2.tsx:789

Repositions the dropdown.

Returns

void


readonly()

readonly(value?): void

Defined in: src/ui/editors/select2.tsx:797

Sets the read-only state.

Parameters

value?

boolean

Whether to enable read-only mode.

Returns

void


getInstance()

static getInstance(el): Select2

Defined in: src/ui/editors/select2.tsx:828

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

Parameters

el

Select2Element

The element.

Returns

Select2

The Select2 instance, or null.


highlightMatch()

static highlightMatch(text, term): Select2FormatResult

Defined in: src/ui/editors/select2.tsx:911

Highlights the matching portion of text for a search term.

Parameters

text

string

The text to highlight.

term

string

The search term.

Returns

Select2FormatResult

The highlighted result.


stripDiacritics()

static stripDiacritics(str): string

Defined in: src/ui/editors/select2.tsx:929

Strips diacritics from a string for accent-insensitive matching.

Parameters

str

string

The string to process.

Returns

string

The string with diacritics removed.