Skip to content

@serenity-is/corelib / Select2Options

Interface: Select2Options

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

Options for the Select2 widget.

Properties

adaptContainerCssClass()?

optional adaptContainerCssClass: (cls) => string

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

Callback that adapts the container CSS class.

Parameters

cls

string

Returns

string


adaptDropdownCssClass()?

optional adaptDropdownCssClass: (cls) => string

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

Callback that adapts the dropdown CSS class.

Parameters

cls

string

Returns

string


ajax?

optional ajax: Select2AjaxOptions

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

Ajax options.


allowClear?

optional allowClear: boolean

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

Whether the selection can be cleared.


blurOnChange?

optional blurOnChange: boolean

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

Whether to blur on change.


checkList?

optional checkList: boolean

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

Makes a multiple select a checklist: the results that are selected stay in the list, marked as selected, see the aria-selected attribute of the results, e.g. for a check box that the styles or formatResult draw, and a click on one of them unselects it, instead of selecting it again. It is usually used with selectionSummary, as the choices of the selection would repeat the list, and selectAll.


closeOnSelect?

optional closeOnSelect: boolean

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

Whether to close the dropdown on select.


containerCss?

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

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

Container CSS.


containerCssClass?

optional containerCssClass: string | () => string

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

Container CSS class.


createSearchChoice()?

optional createSearchChoice: (term) => Select2Item

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

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:213

Position of the create-search-choice item.


data?

optional data: any

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

Static data.


optional dropdownAutoWidth: boolean

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

Whether the dropdown is as wide as its widest result, instead of as wide as the control, though never narrower than the control, nor wider than the max-width that the styles give the select2-drop-auto-width class. It keeps the widest width it took while it is open, so that it does not shrink as what is typed filters the results.


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

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

Dropdown CSS.


optional dropdownCssClass: string | () => string

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

Dropdown CSS class.


optional dropdownParent: (input) => HTMLElement

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

Callback that returns the dropdown parent.

Parameters

input

HTMLElement

Returns

HTMLElement


element?

optional element: Select2Element

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

The element to attach Select2 to.


escapeMarkup()?

optional escapeMarkup: (markup) => string

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

Callback that escapes markup.

Parameters

markup

string

Returns

string


formatAjaxError()?

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

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

Formatter for ajax errors.

Parameters

data

Select2Result

info?

any

Returns

Select2FormatResult


formatInputTooLong()?

optional formatInputTooLong: (input, max) => Select2FormatResult

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

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:181

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:175

Formatter for load-more text.

Parameters

pageNumber

number

Returns

Select2FormatResult


formatMatches()?

optional formatMatches: (matches) => Select2FormatResult

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

Formatter for the matches count.

Parameters

matches

number

Returns

Select2FormatResult


formatNoMatches()?

optional formatNoMatches: (input) => Select2FormatResult

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

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:162

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:169

Formatter for result CSS classes.

Parameters

data

Select2Item

Returns

string


formatSearching()?

optional formatSearching: () => Select2FormatResult

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

Formatter for searching text.

Returns

Select2FormatResult


formatSelectAll()?

optional formatSelectAll: (item, container, query) => Select2FormatResult

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

Formatter for the item that selects all the results of a checklist, or clears them when they are all selected, see selectAll. It defaults to formatResult.

Parameters

item

Select2Item

container

HTMLElement

query

Select2QueryOptions

Returns

Select2FormatResult


formatSelection()?

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

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

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:171

Formatter for selection CSS classes.

Parameters

item

Select2Item

container

HTMLElement

Returns

string


formatSelectionTooBig()?

optional formatSelectionTooBig: (limit) => Select2FormatResult

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

Formatter for selection-too-big text.

Parameters

limit

number

Returns

Select2FormatResult


id()?

optional id: (item) => string

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

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:215

Callback that initializes the selection.

Parameters

element

HTMLElement

callback

(data) => void

Returns

void


loadMorePadding?

optional loadMorePadding: number

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

Padding for load-more.


matcher()?

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

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

Custom matcher function.

Parameters

term

string

text

string

data?

any

Returns

boolean


maximumInputLength?

optional maximumInputLength: number

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

Maximum input length.


maximumSelectionSize?

optional maximumSelectionSize: number | () => number

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

Maximum number of selectable items.


minimumInputLength?

optional minimumInputLength: number

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

Minimum input length before searching.


minimumResultsForSearch?

optional minimumResultsForSearch: number

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

Minimum results required to show the search box.


multiple?

optional multiple: boolean

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

Whether multiple items can be selected.


nextSearchTerm()?

optional nextSearchTerm: (selectedObject, currentSearchTerm) => string

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

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:148

Whether to open the dropdown on enter.


placeholder?

optional placeholder: string

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

Placeholder text.


placeholderIcon?

optional placeholderIcon: IconClassName

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

Icon of the placeholder, e.g. the icon of the field or of the filter of an editor, which the control shows before the placeholder text when nothing is selected.


placeholderOption?

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

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

Placeholder option.


populateResults()?

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

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

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:221

Query callback.

Parameters

query

Select2QueryOptions

Returns

void


searchInputPlaceholder?

optional searchInputPlaceholder: string

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

Placeholder for the search input.


selectAll?

optional selectAll: boolean | SelectAllOptions

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

Adds an item at the top of the results of a multiple select, which selects them all, or clears the ones it shows when they are all selected. The select adds the item itself, to the first page of results, when there is a result it can select, and tells it apart by its identity, not by its id. It is rendered with formatSelectAll.

It acts on the results that are loaded, which a search term filters, and its text tells which, see SelectAllOptions: "Select all" when nothing is typed, "Select all matching" when something is, and "Select shown" when the source pages its results, see Select2Result.more, and the pages that are not loaded yet are not selected. The texts default to the ones of SelectEditorTexts.


selectionSummary()?

optional selectionSummary: (items, container) => void

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

Renders the selection of a multiple select as one element, e.g. a summary of the selected items, instead of a choice for each item, which keeps the search field of the control after it. The items are kept for AbstractSelect2.data. It does not change how the results behave, see checkList.

Parameters

items

Select2Item[]

The selected items.

container

HTMLElement

The element to render the selection in.

Returns

void


selectOnBlur?

optional selectOnBlur: boolean

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

Whether to select on blur.


separator?

optional separator: string

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

Separator for multiple values.


shouldFocusInput()?

optional shouldFocusInput: (instance) => boolean

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

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:154

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:227

Tags for tag mode.


tokenizer()?

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

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

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:219

Token separators.


width?

optional width: string | () => string

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

Width of the widget.