@serenity-is/corelib / Select2
Class: Select2
Defined in: src/ui/editors/select2.tsx:568
A searchable select widget ported from Select2.
Constructors
Constructor
new Select2(
opts?):Select2
Defined in: src/ui/editors/select2.tsx:576
Creates a Select2 widget.
Parameters
opts?
Select2 options.
Returns
Select2
Properties
ajaxDefaults
readonlystaticajaxDefaults:Select2AjaxOptions
Defined in: src/ui/editors/select2.tsx:756
Default ajax options.
defaults
readonlystaticdefaults:Select2Options
Defined in: src/ui/editors/select2.tsx:765
Default options for the Select2 widget.
Accessors
container
Get Signature
get container():
HTMLElement
Defined in: src/ui/editors/select2.tsx:620
Returns the container element.
Returns
HTMLElement
The container element.
data
Get Signature
get data():
Select2Item|Select2Item[]
Defined in: src/ui/editors/select2.tsx:643
Returns the current data.
Returns
The selected item(s).
Set Signature
set data(
value):void
Defined in: src/ui/editors/select2.tsx:649
Sets the current data.
Parameters
value
The data to set.
Returns
void
dropdown
Get Signature
get dropdown():
HTMLElement
Defined in: src/ui/editors/select2.tsx:628
Returns the dropdown element.
Returns
HTMLElement
The dropdown element.
isFocused
Get Signature
get isFocused():
boolean
Defined in: src/ui/editors/select2.tsx:679
Whether the widget is focused.
Returns
boolean
True when focused.
isMultiple
Get Signature
get isMultiple():
boolean
Defined in: src/ui/editors/select2.tsx:687
Whether the widget allows multiple selection.
Returns
boolean
True when multiple.
opened
Get Signature
get opened():
boolean
Defined in: src/ui/editors/select2.tsx:695
Whether the dropdown is open.
Returns
boolean
True when open.
search
Get Signature
get search():
HTMLInputElement
Defined in: src/ui/editors/select2.tsx:726
Returns the search input element.
Returns
HTMLInputElement
The search input.
val
Get Signature
get val():
string|string[]
Defined in: src/ui/editors/select2.tsx:734
Returns the current value.
Returns
string | string[]
The value.
Set Signature
set val(
value):void
Defined in: src/ui/editors/select2.tsx:740
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:612
Closes the dropdown.
Returns
void
destroy()
destroy():
void
Defined in: src/ui/editors/select2.tsx:635
Destroys the Select2 instance.
Returns
void
disable()
disable():
void
Defined in: src/ui/editors/select2.tsx:656
Disables the Select2 widget.
Returns
void
enable()
enable(
enabled?):void
Defined in: src/ui/editors/select2.tsx:664
Enables or disables the Select2 widget.
Parameters
enabled?
boolean
Whether to enable.
Returns
void
focus()
focus():
void
Defined in: src/ui/editors/select2.tsx:671
Focuses the search input.
Returns
void
open()
open():
boolean
Defined in: src/ui/editors/select2.tsx:703
Opens the dropdown.
Returns
boolean
True when opened.
positionDropdown()
positionDropdown():
void
Defined in: src/ui/editors/select2.tsx:710
Repositions the dropdown.
Returns
void
readonly()
readonly(
value?):void
Defined in: src/ui/editors/select2.tsx:718
Sets the read-only state.
Parameters
value?
boolean
Whether to enable read-only mode.
Returns
void
getInstance()
staticgetInstance(el):Select2
Defined in: src/ui/editors/select2.tsx:749
Returns the Select2 instance attached to an element, or null.
Parameters
el
The element.
Returns
Select2
The Select2 instance, or null.
highlightMatch()
statichighlightMatch(text,term):Select2FormatResult
Defined in: src/ui/editors/select2.tsx:831
Highlights the matching portion of text for a search term.
Parameters
text
string
The text to highlight.
term
string
The search term.
Returns
The highlighted result.
stripDiacritics()
staticstripDiacritics(str):string
Defined in: src/ui/editors/select2.tsx:849
Strips diacritics from a string for accent-insensitive matching.
Parameters
str
string
The string to process.
Returns
string
The string with diacritics removed.