@serenity-is/corelib / Select2Options
Interface: Select2Options
Defined in: src/ui/editors/select2.tsx:117
Options for the Select2 widget.
Properties
adaptContainerCssClass()?
optionaladaptContainerCssClass: (cls) =>string
Defined in: src/ui/editors/select2.tsx:245
Callback that adapts the container CSS class.
Parameters
cls
string
Returns
string
adaptDropdownCssClass()?
optionaladaptDropdownCssClass: (cls) =>string
Defined in: src/ui/editors/select2.tsx:247
Callback that adapts the dropdown CSS class.
Parameters
cls
string
Returns
string
ajax?
optionalajax:Select2AjaxOptions
Defined in: src/ui/editors/select2.tsx:223
Ajax options.
allowClear?
optionalallowClear:boolean
Defined in: src/ui/editors/select2.tsx:142
Whether the selection can be cleared.
blurOnChange?
optionalblurOnChange:boolean
Defined in: src/ui/editors/select2.tsx:255
Whether to blur on change.
checkList?
optionalcheckList: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?
optionalcloseOnSelect:boolean
Defined in: src/ui/editors/select2.tsx:146
Whether to close the dropdown on select.
containerCss?
optionalcontainerCss:Record<string,string> | () =>Record<string,string>
Defined in: src/ui/editors/select2.tsx:229
Container CSS.
containerCssClass?
optionalcontainerCssClass:string| () =>string
Defined in: src/ui/editors/select2.tsx:231
Container CSS class.
createSearchChoice()?
optionalcreateSearchChoice: (term) =>Select2Item
Defined in: src/ui/editors/select2.tsx:185
Callback that creates a search choice.
Parameters
term
string
Returns
createSearchChoicePosition?
optionalcreateSearchChoicePosition:string| (list,item) =>void
Defined in: src/ui/editors/select2.tsx:213
Position of the create-search-choice item.
data?
optionaldata:any
Defined in: src/ui/editors/select2.tsx:225
Static data.
dropdownAutoWidth?
optionaldropdownAutoWidth: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.
dropdownCss?
optionaldropdownCss:Record<string,string> | () =>Record<string,string>
Defined in: src/ui/editors/select2.tsx:233
Dropdown CSS.
dropdownCssClass?
optionaldropdownCssClass:string| () =>string
Defined in: src/ui/editors/select2.tsx:235
Dropdown CSS class.
dropdownParent()?
optionaldropdownParent: (input) =>HTMLElement
Defined in: src/ui/editors/select2.tsx:243
Callback that returns the dropdown parent.
Parameters
input
HTMLElement
Returns
HTMLElement
element?
optionalelement:Select2Element
Defined in: src/ui/editors/select2.tsx:119
The element to attach Select2 to.
escapeMarkup()?
optionalescapeMarkup: (markup) =>string
Defined in: src/ui/editors/select2.tsx:249
Callback that escapes markup.
Parameters
markup
string
Returns
string
formatAjaxError()?
optionalformatAjaxError: (data,info?) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:156
Formatter for ajax errors.
Parameters
data
info?
any
Returns
formatInputTooLong()?
optionalformatInputTooLong: (input,max) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:179
Formatter for input-too-long text.
Parameters
input
string
max
number
Returns
formatInputTooShort()?
optionalformatInputTooShort: (input,min) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:181
Formatter for input-too-short text.
Parameters
input
string
min
number
Returns
formatLoadMore()?
optionalformatLoadMore: (pageNumber) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:175
Formatter for load-more text.
Parameters
pageNumber
number
Returns
formatMatches()?
optionalformatMatches: (matches) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:158
Formatter for the matches count.
Parameters
matches
number
Returns
formatNoMatches()?
optionalformatNoMatches: (input) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:173
Formatter for no-matches text.
Parameters
input
string
Returns
formatResult()?
optionalformatResult: (result,container,query,escapeMarkup) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:162
Formatter for result items.
Parameters
result
container
HTMLElement
query
escapeMarkup
(markup) => string
Returns
formatResultCssClass()?
optionalformatResultCssClass: (data) =>string
Defined in: src/ui/editors/select2.tsx:169
Formatter for result CSS classes.
Parameters
data
Returns
string
formatSearching()?
optionalformatSearching: () =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:177
Formatter for searching text.
Returns
formatSelectAll()?
optionalformatSelectAll: (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
container
HTMLElement
query
Returns
formatSelection()?
optionalformatSelection: (data,container,escapeMarkup) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:160
Formatter for selected items.
Parameters
data
container
HTMLElement
escapeMarkup
(markup) => string
Returns
formatSelectionCssClass()?
optionalformatSelectionCssClass: (item,container) =>string
Defined in: src/ui/editors/select2.tsx:171
Formatter for selection CSS classes.
Parameters
item
container
HTMLElement
Returns
string
formatSelectionTooBig()?
optionalformatSelectionTooBig: (limit) =>Select2FormatResult
Defined in: src/ui/editors/select2.tsx:183
Formatter for selection-too-big text.
Parameters
limit
number
Returns
id()?
optionalid: (item) =>string
Defined in: src/ui/editors/select2.tsx:150
Callback that returns the id of an item.
Parameters
item
any
Returns
string
initSelection()?
optionalinitSelection: (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?
optionalloadMorePadding:number
Defined in: src/ui/editors/select2.tsx:257
Padding for load-more.
matcher()?
optionalmatcher: (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?
optionalmaximumInputLength:number
Defined in: src/ui/editors/select2.tsx:125
Maximum input length.
maximumSelectionSize?
optionalmaximumSelectionSize:number| () =>number
Defined in: src/ui/editors/select2.tsx:129
Maximum number of selectable items.
minimumInputLength?
optionalminimumInputLength:number
Defined in: src/ui/editors/select2.tsx:123
Minimum input length before searching.
minimumResultsForSearch?
optionalminimumResultsForSearch:number
Defined in: src/ui/editors/select2.tsx:127
Minimum results required to show the search box.
multiple?
optionalmultiple:boolean
Defined in: src/ui/editors/select2.tsx:144
Whether multiple items can be selected.
nextSearchTerm()?
optionalnextSearchTerm: (selectedObject,currentSearchTerm) =>string
Defined in: src/ui/editors/select2.tsx:259
Callback that returns the next search term.
Parameters
selectedObject
currentSearchTerm
string
Returns
string
openOnEnter?
optionalopenOnEnter:boolean
Defined in: src/ui/editors/select2.tsx:148
Whether to open the dropdown on enter.
placeholder?
optionalplaceholder:string
Defined in: src/ui/editors/select2.tsx:131
Placeholder text.
placeholderIcon?
optionalplaceholderIcon: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?
optionalplaceholderOption:"first"| (select) =>HTMLOptionElement
Defined in: src/ui/editors/select2.tsx:138
Placeholder option.
populateResults()?
optionalpopulateResults: (container,results,query) =>void
Defined in: src/ui/editors/select2.tsx:261
Callback that populates results.
Parameters
container
HTMLElement
results
query
Returns
void
query()?
optionalquery: (query) =>void
Defined in: src/ui/editors/select2.tsx:221
Query callback.
Parameters
query
Returns
void
searchInputPlaceholder?
optionalsearchInputPlaceholder:string
Defined in: src/ui/editors/select2.tsx:251
Placeholder for the search input.
selectAll?
optionalselectAll: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()?
optionalselectionSummary: (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
The selected items.
container
HTMLElement
The element to render the selection in.
Returns
void
selectOnBlur?
optionalselectOnBlur:boolean
Defined in: src/ui/editors/select2.tsx:253
Whether to select on blur.
separator?
optionalseparator:string
Defined in: src/ui/editors/select2.tsx:140
Separator for multiple values.
shouldFocusInput()?
optionalshouldFocusInput: (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
Returns
boolean
sortResults()?
optionalsortResults: (results,container,query) =>Select2Item[]
Defined in: src/ui/editors/select2.tsx:154
Callback that sorts results.
Parameters
results
container
HTMLElement
query
Returns
tags?
optionaltags: (string|Select2Item)[] | () => (string|Select2Item)[]
Defined in: src/ui/editors/select2.tsx:227
Tags for tag mode.
tokenizer()?
optionaltokenizer: (input,selection,selectCallback,opts) =>string
Defined in: src/ui/editors/select2.tsx:217
Tokenizer function.
Parameters
input
string
selection
selectCallback
(data) => void
opts
Select2Options
Returns
string
tokenSeparators?
optionaltokenSeparators:string[]
Defined in: src/ui/editors/select2.tsx:219
Token separators.
width?
optionalwidth:string| () =>string
Defined in: src/ui/editors/select2.tsx:121
Width of the widget.