Skip to content

@serenity-is/corelib / Select2Options

Interface: Select2Options

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

Options for the Select2 widget.

Properties

adaptContainerCssClass()?

optional adaptContainerCssClass: (cls) => string

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

Callback that adapts the container CSS class.

Parameters

cls

string

Returns

string


adaptDropdownCssClass()?

optional adaptDropdownCssClass: (cls) => string

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

Callback that adapts the dropdown CSS class.

Parameters

cls

string

Returns

string


ajax?

optional ajax: Select2AjaxOptions

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

Ajax options.


allowClear?

optional allowClear: boolean

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

Whether the selection can be cleared.


blurOnChange?

optional blurOnChange: boolean

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

Whether to blur on change.


closeOnSelect?

optional closeOnSelect: boolean

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

Whether to close the dropdown on select.


containerCss?

optional containerCss: Record<string, string> | () => Record<string, string>

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

Container CSS.


containerCssClass?

optional containerCssClass: string | () => string

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

Container CSS class.


createSearchChoice()?

optional createSearchChoice: (term) => Select2Item

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

Callback that creates a search choice.

Parameters

term

string

Returns

Select2Item


createSearchChoicePosition?

optional createSearchChoicePosition: string | (list, item) => void

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

Position of the create-search-choice item.


data?

optional data: any

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

Static data.


optional dropdownAutoWidth: boolean

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

Whether the dropdown auto-widths.


optional dropdownCss: Record<string, string> | () => Record<string, string>

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

Dropdown CSS.


optional dropdownCssClass: string | () => string

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

Dropdown CSS class.


optional dropdownParent: (input) => HTMLElement

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

Callback that returns the dropdown parent.

Parameters

input

HTMLElement

Returns

HTMLElement


element?

optional element: Select2Element

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

The element to attach Select2 to.


escapeMarkup()?

optional escapeMarkup: (markup) => string

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

Callback that escapes markup.

Parameters

markup

string

Returns

string


formatAjaxError()?

optional formatAjaxError: (data, info?) => Select2FormatResult

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

Formatter for ajax errors.

Parameters

data

Select2Result

info?

any

Returns

Select2FormatResult


formatInputTooLong()?

optional formatInputTooLong: (input, max) => Select2FormatResult

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

Formatter for input-too-long text.

Parameters

input

string

max

number

Returns

Select2FormatResult


formatInputTooShort()?

optional formatInputTooShort: (input, min) => Select2FormatResult

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

Formatter for input-too-short text.

Parameters

input

string

min

number

Returns

Select2FormatResult


formatLoadMore()?

optional formatLoadMore: (pageNumber) => Select2FormatResult

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

Formatter for load-more text.

Parameters

pageNumber

number

Returns

Select2FormatResult


formatMatches()?

optional formatMatches: (matches) => Select2FormatResult

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

Formatter for the matches count.

Parameters

matches

number

Returns

Select2FormatResult


formatNoMatches()?

optional formatNoMatches: (input) => Select2FormatResult

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

Formatter for no-matches text.

Parameters

input

string

Returns

Select2FormatResult


formatResult()?

optional formatResult: (result, container, query, escapeMarkup) => Select2FormatResult

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

Formatter for result items.

Parameters

result

Select2Item

container

HTMLElement

query

Select2QueryOptions

escapeMarkup

(markup) => string

Returns

Select2FormatResult


formatResultCssClass()?

optional formatResultCssClass: (data) => string

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

Formatter for result CSS classes.

Parameters

data

Select2Item

Returns

string


formatSearching()?

optional formatSearching: () => Select2FormatResult

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

Formatter for searching text.

Returns

Select2FormatResult


formatSelection()?

optional formatSelection: (data, container, escapeMarkup) => Select2FormatResult

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

Formatter for selected items.

Parameters

data

Select2Item

container

HTMLElement

escapeMarkup

(markup) => string

Returns

Select2FormatResult


formatSelectionCssClass()?

optional formatSelectionCssClass: (item, container) => string

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

Formatter for selection CSS classes.

Parameters

item

Select2Item

container

HTMLElement

Returns

string


formatSelectionTooBig()?

optional formatSelectionTooBig: (limit) => Select2FormatResult

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

Formatter for selection-too-big text.

Parameters

limit

number

Returns

Select2FormatResult


id()?

optional id: (item) => string

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

Callback that returns the id of an item.

Parameters

item

any

Returns

string


initSelection()?

optional initSelection: (element, callback) => void

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

Callback that initializes the selection.

Parameters

element

HTMLElement

callback

(data) => void

Returns

void


loadMorePadding?

optional loadMorePadding: number

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

Padding for load-more.


matcher()?

optional matcher: (term, text, data?) => boolean

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

Custom matcher function.

Parameters

term

string

text

string

data?

any

Returns

boolean


maximumInputLength?

optional maximumInputLength: number

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

Maximum input length.


maximumSelectionSize?

optional maximumSelectionSize: number | () => number

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

Maximum number of selectable items.


minimumInputLength?

optional minimumInputLength: number

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

Minimum input length before searching.


minimumResultsForSearch?

optional minimumResultsForSearch: number

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

Minimum results required to show the search box.


multiple?

optional multiple: boolean

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

Whether multiple items can be selected.


nextSearchTerm()?

optional nextSearchTerm: (selectedObject, currentSearchTerm) => string

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

Callback that returns the next search term.

Parameters

selectedObject

Select2Item

currentSearchTerm

string

Returns

string


openOnEnter?

optional openOnEnter: boolean

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

Whether to open the dropdown on enter.


placeholder?

optional placeholder: string

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

Placeholder text.


placeholderOption?

optional placeholderOption: "first" | (select) => HTMLOptionElement

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

Placeholder option.


populateResults()?

optional populateResults: (container, results, query) => void

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

Callback that populates results.

Parameters

container

HTMLElement

results

Select2Item[]

query

Select2QueryOptions

Returns

void


query()?

optional query: (query) => void

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

Query callback.

Parameters

query

Select2QueryOptions

Returns

void


searchInputPlaceholder?

optional searchInputPlaceholder: string

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

Placeholder for the search input.


selectOnBlur?

optional selectOnBlur: boolean

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

Whether to select on blur.


separator?

optional separator: string

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

Separator for multiple values.


shouldFocusInput()?

optional shouldFocusInput: (instance) => boolean

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

Callback that determines whether to focus the input. Defaults to not focusing the input on touch devices, so that the virtual keyboard does not cover the dropdown. Hardware keyboard input is still routed to the widget.

Parameters

instance

AbstractSelect2

Returns

boolean


sortResults()?

optional sortResults: (results, container, query) => Select2Item[]

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

Callback that sorts results.

Parameters

results

Select2Item[]

container

HTMLElement

query

Select2QueryOptions

Returns

Select2Item[]


tags?

optional tags: (string | Select2Item)[] | () => (string | Select2Item)[]

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

Tags for tag mode.


tokenizer()?

optional tokenizer: (input, selection, selectCallback, opts) => string

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

Tokenizer function.

Parameters

input

string

selection

Select2Item[]

selectCallback

(data) => void

opts

Select2Options

Returns

string


tokenSeparators?

optional tokenSeparators: string[]

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

Token separators.


width?

optional width: string | () => string

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

Width of the widget.